Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: net/quic/quic_stream_sequencer_buffer_test.cc

Issue 2101863004: net: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_spdy_session.cc ('k') | net/spdy/hpack/hpack_header_table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 #include "net/quic/quic_stream_sequencer_buffer.h" 4 #include "net/quic/quic_stream_sequencer_buffer.h"
5 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <limits> 7 #include <limits>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 EXPECT_EQ(QUIC_NO_ERROR, 213 EXPECT_EQ(QUIC_NO_ERROR,
214 buffer_->OnStreamData(800, source, t, &written, &error_details_)); 214 buffer_->OnStreamData(800, source, t, &written, &error_details_));
215 BufferBlock* block_ptr = helper_->GetBlock(0); 215 BufferBlock* block_ptr = helper_->GetBlock(0);
216 for (size_t i = 0; i < source.size(); ++i) { 216 for (size_t i = 0; i < source.size(); ++i) {
217 ASSERT_EQ('a', block_ptr->buffer[helper_->GetInBlockOffset(800) + i]); 217 ASSERT_EQ('a', block_ptr->buffer[helper_->GetInBlockOffset(800) + i]);
218 } 218 }
219 EXPECT_EQ(2, helper_->GapSize()); 219 EXPECT_EQ(2, helper_->GapSize());
220 std::list<Gap> gaps = helper_->GetGaps(); 220 std::list<Gap> gaps = helper_->GetGaps();
221 EXPECT_EQ(800u, gaps.front().end_offset); 221 EXPECT_EQ(800u, gaps.front().end_offset);
222 EXPECT_EQ(1824u, gaps.back().begin_offset); 222 EXPECT_EQ(1824u, gaps.back().begin_offset);
223 auto frame_map = helper_->frame_arrival_time_map(); 223 auto* frame_map = helper_->frame_arrival_time_map();
224 EXPECT_EQ(1u, frame_map->size()); 224 EXPECT_EQ(1u, frame_map->size());
225 EXPECT_EQ(800u, frame_map->begin()->first); 225 EXPECT_EQ(800u, frame_map->begin()->first);
226 EXPECT_EQ(t, (*frame_map)[800].timestamp); 226 EXPECT_EQ(t, (*frame_map)[800].timestamp);
227 EXPECT_TRUE(helper_->CheckBufferInvariants()); 227 EXPECT_TRUE(helper_->CheckBufferInvariants());
228 } 228 }
229 229
230 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataWithOverlap) { 230 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataWithOverlap) {
231 string source(1024, 'a'); 231 string source(1024, 'a');
232 // Write something into [800, 1824) 232 // Write something into [800, 1824)
233 size_t written; 233 size_t written;
234 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 234 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
235 QuicTime t1 = clock_.ApproximateNow(); 235 QuicTime t1 = clock_.ApproximateNow();
236 EXPECT_EQ(QUIC_NO_ERROR, 236 EXPECT_EQ(QUIC_NO_ERROR,
237 buffer_->OnStreamData(800, source, t1, &written, &error_details_)); 237 buffer_->OnStreamData(800, source, t1, &written, &error_details_));
238 // Try to write to [0, 1024) and [1024, 2048). 238 // Try to write to [0, 1024) and [1024, 2048).
239 // But no byte will be written since overlap. 239 // But no byte will be written since overlap.
240 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 240 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
241 QuicTime t2 = clock_.ApproximateNow(); 241 QuicTime t2 = clock_.ApproximateNow();
242 EXPECT_EQ(QUIC_OVERLAPPING_STREAM_DATA, 242 EXPECT_EQ(QUIC_OVERLAPPING_STREAM_DATA,
243 buffer_->OnStreamData(0, source, t2, &written, &error_details_)); 243 buffer_->OnStreamData(0, source, t2, &written, &error_details_));
244 EXPECT_EQ(QUIC_OVERLAPPING_STREAM_DATA, 244 EXPECT_EQ(QUIC_OVERLAPPING_STREAM_DATA,
245 buffer_->OnStreamData(1024, source, t2, &written, &error_details_)); 245 buffer_->OnStreamData(1024, source, t2, &written, &error_details_));
246 auto frame_map = helper_->frame_arrival_time_map(); 246 auto* frame_map = helper_->frame_arrival_time_map();
247 EXPECT_EQ(1u, frame_map->size()); 247 EXPECT_EQ(1u, frame_map->size());
248 EXPECT_EQ(t1, (*frame_map)[800].timestamp); 248 EXPECT_EQ(t1, (*frame_map)[800].timestamp);
249 } 249 }
250 250
251 TEST_F(QuicStreamSequencerBufferTest, 251 TEST_F(QuicStreamSequencerBufferTest,
252 OnStreamDataOverlapAndDuplicateCornerCases) { 252 OnStreamDataOverlapAndDuplicateCornerCases) {
253 string source(1024, 'a'); 253 string source(1024, 'a');
254 // Write something into [800, 1824) 254 // Write something into [800, 1824)
255 size_t written; 255 size_t written;
256 buffer_->OnStreamData(800, source, clock_.ApproximateNow(), &written, 256 buffer_->OnStreamData(800, source, clock_.ApproximateNow(), &written,
(...skipping 10 matching lines...) Expand all
267 // Try to write one byte to [1823, 1824), but should count as duplicate 267 // Try to write one byte to [1823, 1824), but should count as duplicate
268 string one_byte = "c"; 268 string one_byte = "c";
269 EXPECT_EQ(QUIC_NO_ERROR, 269 EXPECT_EQ(QUIC_NO_ERROR,
270 buffer_->OnStreamData(1823, one_byte, clock_.ApproximateNow(), 270 buffer_->OnStreamData(1823, one_byte, clock_.ApproximateNow(),
271 &written, &error_details_)); 271 &written, &error_details_));
272 EXPECT_EQ(0u, written); 272 EXPECT_EQ(0u, written);
273 // write one byte to [1824, 1825) 273 // write one byte to [1824, 1825)
274 EXPECT_EQ(QUIC_NO_ERROR, 274 EXPECT_EQ(QUIC_NO_ERROR,
275 buffer_->OnStreamData(1824, one_byte, clock_.ApproximateNow(), 275 buffer_->OnStreamData(1824, one_byte, clock_.ApproximateNow(),
276 &written, &error_details_)); 276 &written, &error_details_));
277 auto frame_map = helper_->frame_arrival_time_map(); 277 auto* frame_map = helper_->frame_arrival_time_map();
278 EXPECT_EQ(3u, frame_map->size()); 278 EXPECT_EQ(3u, frame_map->size());
279 EXPECT_TRUE(helper_->CheckBufferInvariants()); 279 EXPECT_TRUE(helper_->CheckBufferInvariants());
280 } 280 }
281 281
282 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataWithoutOverlap) { 282 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataWithoutOverlap) {
283 string source(1024, 'a'); 283 string source(1024, 'a');
284 // Write something into [800, 1824). 284 // Write something into [800, 1824).
285 size_t written; 285 size_t written;
286 EXPECT_EQ(QUIC_NO_ERROR, 286 EXPECT_EQ(QUIC_NO_ERROR,
287 buffer_->OnStreamData(800, source, clock_.ApproximateNow(), 287 buffer_->OnStreamData(800, source, clock_.ApproximateNow(),
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " 1051 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: "
1052 << iterations; 1052 << iterations;
1053 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); 1053 EXPECT_LE(bytes_to_buffer_, total_bytes_written_);
1054 } 1054 }
1055 1055
1056 } // anonymous namespace 1056 } // anonymous namespace
1057 1057
1058 } // namespace test 1058 } // namespace test
1059 1059
1060 } // namespace net 1060 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_spdy_session.cc ('k') | net/spdy/hpack/hpack_header_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698