| 171 | } |
| 172 | |
| 173 | func BufferAtTester(t *testing.T, b BufferAt) { |
| 174 | t.Helper() |
| 175 | b.WriteAt([]byte("abc"), 0) |
| 176 | Compare(t, b, "abc") |
| 177 | |
| 178 | b.WriteAt([]byte("abc"), 1) |
| 179 | Compare(t, b, "aabc") |
| 180 | |
| 181 | b.WriteAt([]byte("abc"), 2) |
| 182 | Compare(t, b, "aaabc") |
| 183 | |
| 184 | b.WriteAt([]byte("def"), 3) |
| 185 | switch { |
| 186 | case b.Cap() > 5: |
| 187 | Compare(t, b, "aaadef") |
| 188 | default: |
| 189 | Compare(t, b, "aaade") |
| 190 | } |
| 191 | |
| 192 | b.Read(make([]byte, 2)) |
| 193 | switch { |
| 194 | case b.Cap() > 5: |
| 195 | Compare(t, b, "adef") |
| 196 | default: |
| 197 | Compare(t, b, "ade") |
| 198 | } |
| 199 | |
| 200 | b.WriteAt([]byte("ab"), 3) |
| 201 | Compare(t, b, "adeab") |
| 202 | |
| 203 | b.Reset() |
| 204 | } |
| 205 | |
| 206 | func Compare(t *testing.T, b BufferAt, s string) { |
| 207 | t.Helper() |