diff --git a/testutil/encoding_test.go b/testutil/encoding_test.go new file mode 100644 index 0000000000..d07ef1b6b4 --- /dev/null +++ b/testutil/encoding_test.go @@ -0,0 +1,33 @@ +package testutil_test + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/Finschia/finschia-sdk/testutil" +) + +func TestMustJSONMarshal(t *testing.T) { + type tc struct { + Name string `json:"myName"` + Order string `json:"myOrder"` + } + + a := tc{ + Name: "test", + Order: "first", + } + b := new(tc) + + marshaled := testutil.MustJSONMarshal(a) + err := json.Unmarshal(marshaled, b) + require.NoError(t, err) + require.Equal(t, a, *b) + require.Panics(t, func() { testutil.MustJSONMarshal(make(chan int)) }) +} + +func TestW(t *testing.T) { + require.Equal(t, []byte(`"test"`), testutil.W("test")) +}