Check errors
This commit is contained in:
parent
a270d1ed87
commit
63272619d9
1 changed files with 9 additions and 1 deletions
|
@ -2,6 +2,7 @@ package jsonlist
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -47,8 +48,15 @@ func TestJsonList(t *testing.T) {
|
||||||
|
|
||||||
emptySlice = reflect.New(reflect.TypeOf(test.value))
|
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())
|
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))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue