(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func TestDecodeArray(t *testing.T) { |
| 34 | for _, tc := range internal.IntegerArrayTestCases { |
| 35 | buf := bytes.NewBuffer([]byte{}) |
| 36 | array2Json(getReader(tc.Binary), buf) |
| 37 | if buf.String() != tc.Json { |
| 38 | t.Errorf("array2Json(0x%s)=%s, want: %s", hex.EncodeToString([]byte(tc.Binary)), buf.String(), tc.Json) |
| 39 | } |
| 40 | } |
| 41 | //Unspecified Length Array |
| 42 | var infiniteArrayTestCases = []struct { |
| 43 | in string |
| 44 | out string |
| 45 | }{ |
| 46 | {"\x9f\x20\x00\x18\xc8\x14\xff", "[-1,0,200,20]"}, |
| 47 | {"\x9f\x38\xc7\x29\x18\xc8\x19\x01\x90\xff", "[-200,-10,200,400]"}, |
| 48 | {"\x9f\x01\x02\x03\xff", "[1,2,3]"}, |
| 49 | {"\x9f\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x18\x18\x19\xff", |
| 50 | "[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]"}, |
| 51 | } |
| 52 | for _, tc := range infiniteArrayTestCases { |
| 53 | buf := bytes.NewBuffer([]byte{}) |
| 54 | array2Json(getReader(tc.in), buf) |
| 55 | if buf.String() != tc.out { |
| 56 | t.Errorf("array2Json(0x%s)=%s, want: %s", hex.EncodeToString([]byte(tc.out)), buf.String(), tc.out) |
| 57 | } |
| 58 | } |
| 59 | for _, tc := range internal.BooleanArrayTestCases { |
| 60 | buf := bytes.NewBuffer([]byte{}) |
| 61 | array2Json(getReader(tc.Binary), buf) |
| 62 | if buf.String() != tc.Json { |
| 63 | t.Errorf("array2Json(0x%s)=%s, want: %s", hex.EncodeToString([]byte(tc.Binary)), buf.String(), tc.Json) |
| 64 | } |
| 65 | } |
| 66 | //TODO add cases for arrays of other types |
| 67 | } |
| 68 | |
| 69 | var infiniteMapDecodeTestCases = []struct { |
| 70 | Bin []byte |
nothing calls this directly
no test coverage detected