OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // The test buffer data is 52 bytes, wrap position is set to 20 (this is | 5 // The test buffer data is 52 bytes, wrap position is set to 20 (this is |
6 // arbitrarily chosen). The total buffer size is allocated dynamically based on | 6 // arbitrarily chosen). The total buffer size is allocated dynamically based on |
7 // the actual header size. This gives: | 7 // the actual header size. This gives: |
8 // Header of some size, non-wrapping part 20 bytes, wrapping part 32 bytes. | 8 // Header of some size, non-wrapping part 20 bytes, wrapping part 32 bytes. |
9 // As input data, a 14 byte array is used and repeatedly written. It's chosen | 9 // As input data, a 14 byte array is used and repeatedly written. It's chosen |
10 // not to be an integer factor smaller than the wrapping part. This ensures that | 10 // not to be an integer factor smaller than the wrapping part. This ensures that |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 InitReadBuffer(); | 182 InitReadBuffer(); |
183 | 183 |
184 uint8 output_data[sizeof(kInputData)] = {0}; | 184 uint8 output_data[sizeof(kInputData)] = {0}; |
185 EXPECT_EQ(sizeof(output_data), | 185 EXPECT_EQ(sizeof(output_data), |
186 pcb_read_->Read(output_data, sizeof(output_data))); | 186 pcb_read_->Read(output_data, sizeof(output_data))); |
187 | 187 |
188 EXPECT_EQ(0, memcmp(kInputData, output_data, sizeof(kInputData))); | 188 EXPECT_EQ(0, memcmp(kInputData, output_data, sizeof(kInputData))); |
189 | 189 |
190 EXPECT_EQ(0u, pcb_read_->Read(output_data, sizeof(output_data))); | 190 EXPECT_EQ(0u, pcb_read_->Read(output_data, sizeof(output_data))); |
191 } | 191 } |
192 | |
193 TEST_F(PartialCircularBufferTest, WrapTwiceWithSingleWrite) { | |
194 size_t input_size = sizeof(kInputData); | |
Nico
2015/04/07 16:42:16
const size_t kInputSize
gzobqq
2015/04/08 12:59:03
Done.
| |
195 size_t large_size = input_size * 7; | |
Nico
2015/04/07 16:42:16
const size_t kLargeSize
gzobqq
2015/04/08 12:59:03
Done.
| |
196 scoped_ptr<uint8[]> large_input(new uint8[large_size]); | |
Nico
2015/04/07 16:42:16
Shouldn't this easily fit on the stack?
gzobqq
2015/04/08 12:59:03
Done.
| |
197 for (size_t offset = 0; offset < large_size; offset += input_size) | |
198 memcpy(large_input.get() + offset, kInputData, input_size); | |
199 | |
200 InitWriteBuffer(false); | |
201 pcb_write_->Write(large_input.get(), large_size); | |
202 InitReadBuffer(); | |
203 | |
204 uint8 output_data[sizeof(kOutputRefDataWrap)] = {0}; | |
205 EXPECT_EQ(sizeof(output_data), | |
206 pcb_read_->Read(output_data, sizeof(output_data))); | |
207 | |
208 EXPECT_EQ(0, memcmp(kOutputRefDataWrap, output_data, sizeof(output_data))); | |
209 | |
210 EXPECT_EQ(0u, pcb_read_->Read(output_data, sizeof(output_data))); | |
211 } | |
212 | |
OLD | NEW |