(t *testing.T)
| 651 | } |
| 652 | |
| 653 | func TestRead(t *testing.T) { |
| 654 | readStrings := []string{"abcdef", "123456", "ghijkl"} |
| 655 | totalSize := len(readStrings) * len(readStrings[0]) |
| 656 | for readSz := 0; readSz < totalSize+1; readSz++ { |
| 657 | b := Buffer{} |
| 658 | for _, s := range readStrings { |
| 659 | v := NewViewWithData([]byte(s)) |
| 660 | b.appendOwned(v) |
| 661 | } |
| 662 | orig := b.Clone() |
| 663 | orig.Truncate(int64(readSz)) |
| 664 | p := make([]byte, readSz) |
| 665 | _, err := b.read(p) |
| 666 | if err != nil { |
| 667 | t.Fatalf("Read([]byte(%d)) failed: %v", readSz, err) |
| 668 | } |
| 669 | if !bytes.Equal(p, orig.Flatten()) { |
| 670 | t.Errorf("Read([]byte(%d)) failed, want p=%v, got %v", readSz, orig.Flatten(), p) |
| 671 | } |
| 672 | if int(b.Size()) != totalSize-readSz { |
| 673 | t.Errorf("Read([]byte(%d)) failed, want b.Size()=%v, got %v", readSz, totalSize-readSz, b.Size()) |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | func TestReadByte(t *testing.T) { |
| 679 | readString := "abcdef123456ghijkl" |
nothing calls this directly
no test coverage detected
searching dependent graphs…