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

Function TestAppendUints64

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

Source from the content-addressed store, hash-verified

239 doOne(array[:0]) // edge case of zero length
240}
241func TestAppendUints64(t *testing.T) {
242 doOne := func(vals []uint64) {
243 want := make([]byte, 0)
244 want = append(want, '[')
245 for i, val := range vals {
246 want = append(want, []byte(fmt.Sprintf("%d", uint64(val)))...)
247 if i < len(vals)-1 {
248 want = append(want, ',')
249 }
250 }
251 want = append(want, ']')
252
253 got := enc.AppendUints64([]byte{}, vals)
254 if !bytes.Equal(got, want) {
255 t.Errorf("AppendUints64(%v)\ngot: %s\nwant: %s",
256 vals,
257 string(got),
258 string(want))
259 }
260 }
261
262 array := make([]uint64, 0)
263 for _, tc := range internal.UnsignedIntegerTestCases {
264 array = append(array, uint64(tc.Val))
265 }
266
267 doOne(array)
268 doOne(array[:1]) // single element
269 doOne(array[:0]) // edge case of zero length
270}
271
272func TestAppendInt(t *testing.T) {
273 for _, tc := range internal.IntegerTestCases {

Callers

nothing calls this directly

Calls 1

AppendUints64Method · 0.65

Tested by

no test coverage detected