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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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 #include "net/quic/quic_sent_entropy_manager.h" 5 #include "net/quic/quic_sent_entropy_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 39
40 QuicPacketEntropyHash hash = 0; 40 QuicPacketEntropyHash hash = 0;
41 for (size_t i = 0; i < entropies.size(); ++i) { 41 for (size_t i = 0; i < entropies.size(); ++i) {
42 hash ^= entropies[i].second; 42 hash ^= entropies[i].second;
43 EXPECT_EQ(hash, entropy_manager_.EntropyHash(i + 1)); 43 EXPECT_EQ(hash, entropy_manager_.EntropyHash(i + 1));
44 } 44 }
45 } 45 }
46 46
47 TEST_F(QuicSentEntropyManagerTest, IsValidEntropy) { 47 TEST_F(QuicSentEntropyManagerTest, IsValidEntropy) {
48 QuicPacketEntropyHash entropies[10] = 48 QuicPacketEntropyHash entropies[10] = {12, 1, 33, 3, 32,
49 {12, 1, 33, 3, 32, 100, 28, 42, 22, 255}; 49 100, 28, 42, 22, 255};
50 for (size_t i = 0; i < 10; ++i) { 50 for (size_t i = 0; i < 10; ++i) {
51 entropy_manager_.RecordPacketEntropyHash(i + 1, entropies[i]); 51 entropy_manager_.RecordPacketEntropyHash(i + 1, entropies[i]);
52 } 52 }
53 53
54 SequenceNumberSet missing_packets; 54 SequenceNumberSet missing_packets;
55 missing_packets.insert(1); 55 missing_packets.insert(1);
56 missing_packets.insert(4); 56 missing_packets.insert(4);
57 missing_packets.insert(7); 57 missing_packets.insert(7);
58 missing_packets.insert(8); 58 missing_packets.insert(8);
59 59
60 QuicPacketEntropyHash entropy_hash = 0; 60 QuicPacketEntropyHash entropy_hash = 0;
61 for (size_t i = 0; i < 10; ++i) { 61 for (size_t i = 0; i < 10; ++i) {
62 if (missing_packets.find(i + 1) == missing_packets.end()) { 62 if (missing_packets.find(i + 1) == missing_packets.end()) {
63 entropy_hash ^= entropies[i]; 63 entropy_hash ^= entropies[i];
64 } 64 }
65 } 65 }
66 66
67 EXPECT_TRUE(entropy_manager_.IsValidEntropy(10, missing_packets, 67 EXPECT_TRUE(
68 entropy_hash)); 68 entropy_manager_.IsValidEntropy(10, missing_packets, entropy_hash));
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 } // namespace test 72 } // namespace test
73 } // namespace net 73 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698