both the 'str' and 'bin' types are acceptable map keys
(t *testing.T)
| 599 | |
| 600 | // both the 'str' and 'bin' types are acceptable map keys |
| 601 | func 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 | |
| 638 | func TestReadComplex64Bytes(t *testing.T) { |
| 639 | var buf bytes.Buffer |
nothing calls this directly
no test coverage detected
searching dependent graphs…