From 63272619d90d354c5c52f3c9160237cf7d0dd218 Mon Sep 17 00:00:00 2001 From: Fedor Korotkiy Date: Thu, 16 Apr 2020 15:14:19 +0300 Subject: [PATCH] Check errors --- jsonlist/jsonlist_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jsonlist/jsonlist_test.go b/jsonlist/jsonlist_test.go index 81418f2..e9d9a02 100644 --- a/jsonlist/jsonlist_test.go +++ b/jsonlist/jsonlist_test.go @@ -2,6 +2,7 @@ package jsonlist import ( "bytes" + "encoding/json" "reflect" "testing" @@ -47,8 +48,15 @@ func TestJsonList(t *testing.T) { emptySlice = reflect.New(reflect.TypeOf(test.value)) - require.NoError(t, Unmarshal(bytes.NewBufferString(test.js), emptySlice.Interface())) + require.NoError(t, Unmarshal(&buf, emptySlice.Interface())) require.Equal(t, test.value, emptySlice.Elem().Interface()) }) } } + +func TestErrors(t *testing.T) { + var buf bytes.Buffer + + require.Equal(t, &json.UnsupportedTypeError{Type: reflect.TypeOf([]int{})}, Unmarshal(&buf, []int{})) + require.Equal(t, &json.UnsupportedTypeError{Type: reflect.TypeOf(1)}, Marshal(&buf, 1)) +}