commit 73e818cfa07a20afdd11e26f4abbc3795ec878e4
parent d7f8c9705bb104ba347eae7e74ae11807c2b9469
Author: francoispqt <francois@parquet.ninja>
Date: Fri, 18 May 2018 00:00:06 +0800
update tests
Diffstat:
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/decode_number_uint_test.go b/decode_number_uint_test.go
@@ -331,6 +331,13 @@ func TestDecoderUint16(t *testing.T) {
errType: InvalidJSONError(""),
},
{
+ name: "basic-overflow",
+ json: "335346564",
+ expectedResult: 0,
+ err: true,
+ errType: InvalidUnmarshalError(""),
+ },
+ {
name: "basic-negative2",
json: "-24467",
expectedResult: 24467,
@@ -347,6 +354,18 @@ func TestDecoderUint16(t *testing.T) {
err: true,
},
{
+ name: "basic-big-overflow",
+ json: " 65537",
+ expectedResult: 0,
+ err: true,
+ },
+ {
+ name: "basic-big-overflow",
+ json: " 66537",
+ expectedResult: 0,
+ err: true,
+ },
+ {
name: "basic-big-overflow2",
json: "42949672983",
expectedResult: 0,
@@ -488,6 +507,20 @@ func TestDecoderUint8(t *testing.T) {
expectedResult: 200,
},
{
+ name: "basic-overflow",
+ json: "256",
+ expectedResult: 0,
+ err: true,
+ errType: InvalidUnmarshalError(""),
+ },
+ {
+ name: "basic-overflow",
+ json: "274",
+ expectedResult: 0,
+ err: true,
+ errType: InvalidUnmarshalError(""),
+ },
+ {
name: "basic-big-overflow",
json: " 4294967298",
expectedResult: 0,
diff --git a/decode_object_test.go b/decode_object_test.go
@@ -32,7 +32,7 @@ func TestDecodeObjectComplex(t *testing.T) {
},
{
name: "complex",
- json: `{"testSubObject":{"testStr":"some string","testInt":124465,"testUint16":120, "testUint8":15,"testInt16":-135,"testInt8":-23},"testSubSliceInts":[1,2]}`,
+ json: `{"testSubObject":{"testStr":"some string","testInt":124465,"testUint16":120, "testUint8":15,"testInt16":-135,"testInt8":-23},"testSubSliceInts":[1,2],"testStr":"some \\n string"}`,
expectedResult: testObjectComplex{
testSubObject: &testObject{
testStr: "some string",
@@ -43,6 +43,7 @@ func TestDecodeObjectComplex(t *testing.T) {
testInt8: -23,
},
testSubSliceInts: &testSliceInts{1, 2},
+ testStr: "some \n string",
},
err: false,
},