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

Function TestReadNumberArrayBytes_Uint16

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

Source from the content-addressed store, hash-verified

576}
577
578func TestReadNumberArrayBytes_Uint16(t *testing.T) {
579 var msg []byte
580 want := []uint16{0, 1, 255, 256, 65535}
581
582 msg = AppendArrayHeader(msg, uint32(len(want)))
583 for _, v := range want {
584 msg = AppendUint16(msg, v)
585 }
586
587 seq, tail := ReadArrayBytes(msg, ReadUint16Bytes)
588 var got []uint16
589 for v := range seq {
590 got = append(got, v)
591 }
592 remain, err := tail()
593 if err != nil {
594 t.Fatalf("tail err: %v", err)
595 }
596 if len(remain) != 0 {
597 t.Fatalf("expected no remaining bytes, got %d", len(remain))
598 }
599 if len(got) != len(want) {
600 t.Fatalf("length mismatch: got %d want %d", len(got), len(want))
601 }
602 for i := range want {
603 if got[i] != want[i] {
604 t.Fatalf("index %d: got %v want %v", i, got[i], want[i])
605 }
606 }
607}
608
609func TestReadNumberArrayBytes_ErrOnTruncated(t *testing.T) {
610 var msg []byte

Callers

nothing calls this directly

Calls 3

AppendArrayHeaderFunction · 0.85
AppendUint16Function · 0.85
ReadArrayBytesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…