generateSourceData generates a byte slice with 4.5 chunks of data
(t *testing.T, size int)
| 107 | |
| 108 | // generateSourceData generates a byte slice with 4.5 chunks of data |
| 109 | func generateSourceData(t *testing.T, size int) ([]byte, *countingReader) { |
| 110 | t.Helper() |
| 111 | |
| 112 | // We use small chunks for tests, let's check the ChunkSize just in case |
| 113 | assert.GreaterOrEqual(t, asyncbuffer.ChunkSize, 20, "ChunkSize required for tests must be greater than 10 bytes") |
| 114 | |
| 115 | // Create a byte slice with 4 chunks of ChunkSize |
| 116 | source := make([]byte, size) |
| 117 | |
| 118 | // Fill the source with random data |
| 119 | _, err := rand.Read(source) |
| 120 | require.NoError(t, err) |
| 121 | return source, newCountingReader(bytes.NewReader(source)) |
| 122 | } |
| 123 | |
| 124 | // TestAsyncBufferRead tests reading from AsyncBuffer using readAt method which is base for all other methods |
| 125 | func TestAsyncBufferReadAt(t *testing.T) { |
no test coverage detected