(t *testing.T)
| 76 | doOne(array[:0]) // edge case of zero length |
| 77 | } |
| 78 | func TestAppendInts16(t *testing.T) { |
| 79 | doOne := func(vals []int16) { |
| 80 | want := make([]byte, 0) |
| 81 | want = append(want, '[') |
| 82 | for i, val := range vals { |
| 83 | want = append(want, []byte(fmt.Sprintf("%d", int16(val)))...) |
| 84 | if i < len(vals)-1 { |
| 85 | want = append(want, ',') |
| 86 | } |
| 87 | } |
| 88 | want = append(want, ']') |
| 89 | |
| 90 | got := enc.AppendInts16([]byte{}, vals) |
| 91 | if !bytes.Equal(got, want) { |
| 92 | t.Errorf("AppendInts16(%v)\ngot: %s\nwant: %s", |
| 93 | vals, |
| 94 | string(got), |
| 95 | string(want)) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | array := make([]int16, 0) |
| 100 | for _, tc := range internal.IntegerTestCases { |
| 101 | if (tc.Val < math.MinInt16) || (tc.Val > math.MaxInt16) { |
| 102 | continue |
| 103 | } |
| 104 | array = append(array, int16(tc.Val)) |
| 105 | } |
| 106 | |
| 107 | doOne(array) |
| 108 | doOne(array[:1]) // single element |
| 109 | doOne(array[:0]) // edge case of zero length |
| 110 | } |
| 111 | func TestAppendUints16(t *testing.T) { |
| 112 | doOne := func(vals []uint16) { |
| 113 | want := make([]byte, 0) |
nothing calls this directly
no test coverage detected