Add test documenting typed nil json encoding
Encoded into json null not SQL NULL.
This commit is contained in:
@@ -48,6 +48,8 @@ func TestJSONCodec(t *testing.T) {
|
|||||||
{map[string]interface{}{"foo": "bar"}, new(map[string]interface{}), isExpectedEqMap(map[string]interface{}{"foo": "bar"})},
|
{map[string]interface{}{"foo": "bar"}, new(map[string]interface{}), isExpectedEqMap(map[string]interface{}{"foo": "bar"})},
|
||||||
{jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})},
|
{jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})},
|
||||||
{nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))},
|
{nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))},
|
||||||
|
{map[string]interface{}(nil), new(string), isExpectedEq(`null`)},
|
||||||
|
{map[string]interface{}(nil), new([]byte), isExpectedEqBytes([]byte("null"))},
|
||||||
{[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
|
{[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
|
||||||
{nil, new([]byte), isExpectedEqBytes([]byte(nil))},
|
{nil, new([]byte), isExpectedEqBytes([]byte(nil))},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ func TestJSONBTranscode(t *testing.T) {
|
|||||||
{map[string]interface{}{"foo": "bar"}, new(map[string]interface{}), isExpectedEqMap(map[string]interface{}{"foo": "bar"})},
|
{map[string]interface{}{"foo": "bar"}, new(map[string]interface{}), isExpectedEqMap(map[string]interface{}{"foo": "bar"})},
|
||||||
{jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})},
|
{jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})},
|
||||||
{nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))},
|
{nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))},
|
||||||
|
{map[string]interface{}(nil), new(string), isExpectedEq(`null`)},
|
||||||
|
{map[string]interface{}(nil), new([]byte), isExpectedEqBytes([]byte("null"))},
|
||||||
{[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
|
{[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
|
||||||
{nil, new([]byte), isExpectedEqBytes([]byte(nil))},
|
{nil, new([]byte), isExpectedEqBytes([]byte(nil))},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user