TestPartitionAt3 tests ability to overwrite buffer previously written.
(t *testing.T)
| 891 | |
| 892 | // TestPartitionAt3 tests ability to overwrite buffer previously written. |
| 893 | func TestPartitionAt3(t *testing.T) { |
| 894 | buf := NewPartitionAt(NewMemPoolAt(5)) |
| 895 | buf.Write(make([]byte, 15, 15)) // allocates 3 membuffers |
| 896 | buf.WriteAt([]byte("hey"), 0) |
| 897 | data := make([]byte, 10) |
| 898 | data = data[:3] |
| 899 | buf.ReadAt(data, 0) |
| 900 | if string(data) != "hey" { |
| 901 | t.Error("expected hey got", string(data)) |
| 902 | } |
| 903 | buf.WriteAt([]byte("hey"), 3) |
| 904 | data = data[:5] |
| 905 | buf.ReadAt(data, 1) |
| 906 | if string(data) != "eyhey" { |
| 907 | t.Error("expected eyhey got", string(data)) |
| 908 | } |
| 909 | buf.WriteAt([]byte("hey"), 5) |
| 910 | data = data[:7] |
| 911 | buf.ReadAt(data, 1) |
| 912 | if string(data) != "eyhehey" { |
| 913 | t.Error("expected eyhehey got", string(data)) |
| 914 | } |
| 915 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…