(t *testing.T)
| 690 | } |
| 691 | |
| 692 | func TestReadIntfBytes(t *testing.T) { |
| 693 | var buf bytes.Buffer |
| 694 | en := NewWriter(&buf) |
| 695 | |
| 696 | tests := make([]any, 0, 10) |
| 697 | tests = append(tests, float64(3.5)) |
| 698 | tests = append(tests, int64(-49082)) |
| 699 | tests = append(tests, uint64(34908)) |
| 700 | tests = append(tests, string("hello!")) |
| 701 | tests = append(tests, []byte("blah.")) |
| 702 | tests = append(tests, map[string]any{ |
| 703 | "key_one": 3.5, |
| 704 | "key_two": "hi.", |
| 705 | }) |
| 706 | |
| 707 | for i, v := range tests { |
| 708 | buf.Reset() |
| 709 | if err := en.WriteIntf(v); err != nil { |
| 710 | t.Fatal(err) |
| 711 | } |
| 712 | en.Flush() |
| 713 | |
| 714 | out, left, err := ReadIntfBytes(buf.Bytes()) |
| 715 | if err != nil { |
| 716 | t.Errorf("test case %d: %s", i, err) |
| 717 | } |
| 718 | if len(left) != 0 { |
| 719 | t.Errorf("expected 0 bytes left; found %d", len(left)) |
| 720 | } |
| 721 | if !reflect.DeepEqual(v, out) { |
| 722 | t.Errorf("ReadIntf(): %v in; %v out", v, out) |
| 723 | } |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | func BenchmarkSkipBytes(b *testing.B) { |
| 728 | var buf bytes.Buffer |
nothing calls this directly
no test coverage detected
searching dependent graphs…