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

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

Issue 2192633002: Switch to PacketNumberQueue interval iteration and avoid allocations in new ACK frame generation. G… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@128431128
Patch Set: Rebase Created 4 years, 4 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_protocol.cc ('k') | net/quic/quic_sent_entropy_manager.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/quic/quic_protocol.h" 5 #include "net/quic/quic_protocol.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/quic/quic_flags.h" 10 #include "net/quic/quic_flags.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 queue.Add(1); 370 queue.Add(1);
371 queue.Add(50, 100); 371 queue.Add(50, 100);
372 oss << queue; 372 oss << queue;
373 } 373 }
374 374
375 // Tests that the iterators returned from a packet queue iterate over the queue. 375 // Tests that the iterators returned from a packet queue iterate over the queue.
376 TEST(PacketNumberQueueTest, Iterators) { 376 TEST(PacketNumberQueueTest, Iterators) {
377 PacketNumberQueue queue; 377 PacketNumberQueue queue;
378 queue.Add(1, 100); 378 queue.Add(1, 100);
379 379
380 const std::vector<QuicPacketNumber> actual(queue.begin(), queue.end()); 380 const std::vector<QuicPacketNumber> actual_numbers(queue.begin(),
381 queue.end());
382 const std::vector<Interval<QuicPacketNumber>> actual_intervals(
383 queue.begin_intervals(), queue.end_intervals());
381 384
382 std::vector<QuicPacketNumber> expected; 385 std::vector<QuicPacketNumber> expected_numbers;
383 for (int i = 1; i < 100; ++i) { 386 for (int i = 1; i < 100; ++i) {
384 expected.push_back(i); 387 expected_numbers.push_back(i);
385 } 388 }
386 389
387 EXPECT_EQ(expected, actual); 390 std::vector<Interval<QuicPacketNumber>> expected_intervals;
391 expected_intervals.push_back(Interval<QuicPacketNumber>(1, 100));
392
393 EXPECT_EQ(expected_intervals, actual_intervals);
394 EXPECT_EQ(expected_numbers, actual_numbers);
388 395
389 PacketNumberQueue::const_iterator it_low = queue.lower_bound(10); 396 PacketNumberQueue::const_iterator it_low = queue.lower_bound(10);
390 EXPECT_EQ(10u, *it_low); 397 EXPECT_EQ(10u, *it_low);
391 398
392 it_low = queue.lower_bound(101); 399 it_low = queue.lower_bound(101);
393 EXPECT_TRUE(queue.end() == it_low); 400 EXPECT_TRUE(queue.end() == it_low);
394 } 401 }
395 402
396 TEST(PacketNumberQueueTest, IntervalLengthAndRemoveInterval) { 403 TEST(PacketNumberQueueTest, IntervalLengthAndRemoveInterval) {
397 PacketNumberQueue queue; 404 PacketNumberQueue queue;
(...skipping 17 matching lines...) Expand all
415 EXPECT_EQ(2u, queue.NumIntervals()); 422 EXPECT_EQ(2u, queue.NumIntervals());
416 EXPECT_TRUE(queue.Contains(10)); 423 EXPECT_TRUE(queue.Contains(10));
417 EXPECT_TRUE(queue.Contains(11)); 424 EXPECT_TRUE(queue.Contains(11));
418 EXPECT_TRUE(queue.Contains(20)); 425 EXPECT_TRUE(queue.Contains(20));
419 EXPECT_TRUE(queue.Contains(21)); 426 EXPECT_TRUE(queue.Contains(21));
420 } 427 }
421 428
422 } // namespace 429 } // namespace
423 } // namespace test 430 } // namespace test
424 } // namespace net 431 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.cc ('k') | net/quic/quic_sent_entropy_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698