| 693 | } |
| 694 | |
| 695 | func TestSwapAt(t *testing.T) { |
| 696 | buf := NewSwapAt(New(5), New(10)) |
| 697 | buf.WriteAt([]byte("hey"), 0) |
| 698 | data := make([]byte, 10) |
| 699 | n, _ := buf.ReadAt(data, 0) |
| 700 | if string(data[:n]) != "hey" { |
| 701 | t.Error("expected hey got", string(data[:n])) |
| 702 | } |
| 703 | buf.WriteAt([]byte("hey"), 3) |
| 704 | n, _ = buf.ReadAt(data, 1) |
| 705 | if string(data[:n]) != "eyhey" { |
| 706 | t.Error("expected eyhey got", string(data[:n])) |
| 707 | } |
| 708 | buf.WriteAt([]byte("hey"), 5) |
| 709 | n, _ = buf.ReadAt(data, 1) |
| 710 | if string(data[:n]) != "eyhehey" { |
| 711 | t.Error("expected eyhehey got", string(data[:n])) |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | func TestSwap(t *testing.T) { |
| 716 | defer func() { |