OLD | NEW |
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 "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 namespace test { | 11 namespace test { |
12 namespace { | 12 namespace { |
13 | 13 |
| 14 TEST(QuicProtocolTest, MakeQuicTag) { |
| 15 QuicTag tag = MakeQuicTag('A', 'B', 'C', 'D'); |
| 16 char bytes[4]; |
| 17 memcpy(bytes, &tag, 4); |
| 18 EXPECT_EQ('A', bytes[0]); |
| 19 EXPECT_EQ('B', bytes[1]); |
| 20 EXPECT_EQ('C', bytes[2]); |
| 21 EXPECT_EQ('D', bytes[3]); |
| 22 } |
| 23 |
14 TEST(QuicProtocolTest, IsAawaitingPacket) { | 24 TEST(QuicProtocolTest, IsAawaitingPacket) { |
15 ReceivedPacketInfo received_info; | 25 ReceivedPacketInfo received_info; |
16 received_info.largest_observed = 10u; | 26 received_info.largest_observed = 10u; |
17 EXPECT_TRUE(IsAwaitingPacket(received_info, 11u)); | 27 EXPECT_TRUE(IsAwaitingPacket(received_info, 11u)); |
18 EXPECT_FALSE(IsAwaitingPacket(received_info, 1u)); | 28 EXPECT_FALSE(IsAwaitingPacket(received_info, 1u)); |
19 | 29 |
20 received_info.missing_packets.insert(10); | 30 received_info.missing_packets.insert(10); |
21 EXPECT_TRUE(IsAwaitingPacket(received_info, 10u)); | 31 EXPECT_TRUE(IsAwaitingPacket(received_info, 10u)); |
22 } | 32 } |
23 | 33 |
24 TEST(QuicProtocolTest, InsertMissingPacketsBetween) { | 34 TEST(QuicProtocolTest, InsertMissingPacketsBetween) { |
25 ReceivedPacketInfo received_info; | 35 ReceivedPacketInfo received_info; |
26 InsertMissingPacketsBetween(&received_info, 4u, 10u); | 36 InsertMissingPacketsBetween(&received_info, 4u, 10u); |
27 EXPECT_EQ(6u, received_info.missing_packets.size()); | 37 EXPECT_EQ(6u, received_info.missing_packets.size()); |
28 | 38 |
29 QuicPacketSequenceNumber i = 4; | 39 QuicPacketSequenceNumber i = 4; |
30 for (SequenceNumberSet::iterator it = received_info.missing_packets.begin(); | 40 for (SequenceNumberSet::iterator it = received_info.missing_packets.begin(); |
31 it != received_info.missing_packets.end(); ++it, ++i) { | 41 it != received_info.missing_packets.end(); ++it, ++i) { |
32 EXPECT_EQ(i, *it); | 42 EXPECT_EQ(i, *it); |
33 } | 43 } |
34 } | 44 } |
35 | 45 |
36 } // namespace | 46 } // namespace |
37 } // namespace test | 47 } // namespace test |
38 } // namespace net | 48 } // namespace net |
OLD | NEW |