MCPcopy Index your code
hub / github.com/tinylib/msgp / TestReadNumberArray_Int

Function TestReadNumberArray_Int

msgp/iter_test.go:316–346  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

314}
315
316func TestReadNumberArray_Int(t *testing.T) {
317 var buf bytes.Buffer
318 w := NewWriter(&buf)
319
320 want := []int{1, -2, 3, 0, 42}
321 if err := w.WriteArrayHeader(uint32(len(want))); err != nil {
322 t.Fatalf("WriteArrayHeader: %v", err)
323 }
324 for _, v := range want {
325 if err := w.WriteInt(v); err != nil {
326 t.Fatalf("WriteInt: %v", err)
327 }
328 }
329 if err := w.Flush(); err != nil {
330 t.Fatalf("Flush: %v", err)
331 }
332
333 r := NewReader(&buf)
334 got, err := collectSeq2(ReadArray(r, r.ReadInt))
335 if err != nil {
336 t.Fatalf("iteration error: %v", err)
337 }
338 if len(got) != len(want) {
339 t.Fatalf("length mismatch: got %d want %d", len(got), len(want))
340 }
341 for i := range want {
342 if got[i] != want[i] {
343 t.Fatalf("index %d: got %v want %v", i, got[i], want[i])
344 }
345 }
346}
347
348func TestReadNumberArray_Float64(t *testing.T) {
349 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 7

WriteArrayHeaderMethod · 0.95
WriteIntMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
NewReaderFunction · 0.85
collectSeq2Function · 0.85
ReadArrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…