MCPcopy
hub / github.com/rs/zerolog / TestAppendUints32

Function TestAppendUints32

internal/json/int_test.go:177–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175 doOne(array[:0]) // edge case of zero length
176}
177func TestAppendUints32(t *testing.T) {
178 doOne := func(vals []uint32) {
179 want := make([]byte, 0)
180 want = append(want, '[')
181 for i, val := range vals {
182 want = append(want, []byte(fmt.Sprintf("%d", uint32(val)))...)
183 if i < len(vals)-1 {
184 want = append(want, ',')
185 }
186 }
187 want = append(want, ']')
188
189 got := enc.AppendUints32([]byte{}, vals)
190 if !bytes.Equal(got, want) {
191 t.Errorf("AppendUints32(%v)\ngot: %s\nwant: %s",
192 vals,
193 string(got),
194 string(want))
195 }
196 }
197
198 array := make([]uint32, 0)
199 for _, tc := range internal.UnsignedIntegerTestCases {
200 if tc.Val > math.MaxUint32 {
201 continue
202 }
203 array = append(array, uint32(tc.Val))
204 }
205
206 doOne(array)
207 doOne(array[:1]) // single element
208 doOne(array[:0]) // edge case of zero length
209}
210
211func TestAppendInt64(t *testing.T) {
212 doOne := func(vals []int64) {

Callers

nothing calls this directly

Calls 1

AppendUints32Method · 0.65

Tested by

no test coverage detected