MCPcopy
hub / github.com/tinylib/msgp / TestReadMapKey

Function TestReadMapKey

msgp/read_bytes_test.go:601–636  ·  view source on GitHub ↗

both the 'str' and 'bin' types are acceptable map keys

(t *testing.T)

Source from the content-addressed store, hash-verified

599
600// both the 'str' and 'bin' types are acceptable map keys
601func TestReadMapKey(t *testing.T) {
602 args := []string{
603 "a",
604 "ab",
605 "qwertyuiop",
606 }
607 var buf bytes.Buffer
608 en := NewWriter(&buf)
609
610 for i := range args {
611 en.WriteString(args[i])
612 en.WriteBytes([]byte(args[i]))
613 }
614 en.Flush()
615 b := buf.Bytes()
616
617 for i := range args {
618 var s0, s1 []byte
619 var err error
620
621 s0, b, err = ReadMapKeyZC(b)
622 if err != nil {
623 t.Fatalf("couldn't read string as map key: %q", err)
624 }
625 s1, b, err = ReadMapKeyZC(b)
626 if err != nil {
627 t.Fatalf("couldn't read bytes as map key: %q", err)
628 }
629 if !bytes.Equal(s0, s1) {
630 t.Fatalf("%q != %q", s0, s1)
631 }
632 if string(s0) != args[i] {
633 t.Fatalf("%q != %q", s0, args[i])
634 }
635 }
636}
637
638func TestReadComplex64Bytes(t *testing.T) {
639 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 6

WriteStringMethod · 0.95
WriteBytesMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
ReadMapKeyZCFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…