You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fx/stringify_test.go

30 lines
716 B
Go

package main
import "testing"
func Test_stringify(t *testing.T) {
t.Run("dict", func(t *testing.T) {
arg := newDict()
arg.set("a", number("1"))
arg.set("b", number("2"))
want := `{"a": 1, "b": 2}`
if got := stringify(arg); got != want {
t.Errorf("stringify() = %v, want %v", got, want)
}
})
t.Run("array", func(t *testing.T) {
arg := array{number("1"), number("2")}
want := `[1, 2]`
if got := stringify(arg); got != want {
t.Errorf("stringify() = %v, want %v", got, want)
}
})
t.Run("array_with_dict", func(t *testing.T) {
arg := array{newDict(), array{}}
want := `[{}, []]`
if got := stringify(arg); got != want {
t.Errorf("stringify() = %v, want %v", got, want)
}
})
}