OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/core/quic_utils.h" | 5 #include "net/quic/core/quic_utils.h" |
6 | 6 |
7 #include "net/quic/core/crypto/crypto_protocol.h" | 7 #include "net/quic/core/crypto/crypto_protocol.h" |
8 #include "net/quic/core/quic_flags.h" | 8 #include "net/quic/core/quic_flags.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 using base::StringPiece; | 11 using base::StringPiece; |
12 using std::string; | 12 using std::string; |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 namespace test { | 15 namespace test { |
16 namespace { | 16 namespace { |
17 | 17 |
18 TEST(QuicUtilsTest, StreamErrorToString) { | |
19 EXPECT_STREQ("QUIC_BAD_APPLICATION_PAYLOAD", | |
20 QuicUtils::StreamErrorToString(QUIC_BAD_APPLICATION_PAYLOAD)); | |
21 } | |
22 | |
23 TEST(QuicUtilsTest, ErrorToString) { | |
24 EXPECT_STREQ("QUIC_NO_ERROR", QuicUtils::ErrorToString(QUIC_NO_ERROR)); | |
25 } | |
26 | |
27 TEST(QuicUtilsTest, TagToString) { | |
28 EXPECT_EQ("SCFG", QuicUtils::TagToString(kSCFG)); | |
29 EXPECT_EQ("SNO ", QuicUtils::TagToString(kServerNonceTag)); | |
30 EXPECT_EQ("CRT ", QuicUtils::TagToString(kCertificateTag)); | |
31 EXPECT_EQ("CHLO", QuicUtils::TagToString(MakeQuicTag('C', 'H', 'L', 'O'))); | |
32 // A tag that contains a non-printing character will be printed as a decimal | |
33 // number. | |
34 EXPECT_EQ("525092931", | |
35 QuicUtils::TagToString(MakeQuicTag('C', 'H', 'L', '\x1f'))); | |
36 } | |
37 | |
38 TEST(QuicUtilsTest, ParseQuicConnectionOptions) { | 18 TEST(QuicUtilsTest, ParseQuicConnectionOptions) { |
39 QuicTagVector empty_options = QuicUtils::ParseQuicConnectionOptions(""); | 19 QuicTagVector empty_options = QuicUtils::ParseQuicConnectionOptions(""); |
40 EXPECT_EQ(0ul, empty_options.size()); | 20 EXPECT_EQ(0ul, empty_options.size()); |
41 | 21 |
42 QuicTagVector parsed_options = | 22 QuicTagVector parsed_options = |
43 QuicUtils::ParseQuicConnectionOptions("TIMER,TBBR,REJ"); | 23 QuicUtils::ParseQuicConnectionOptions("TIMER,TBBR,REJ"); |
44 QuicTagVector expected_options; | 24 QuicTagVector expected_options; |
45 expected_options.push_back(kTIME); | 25 expected_options.push_back(kTIME); |
46 expected_options.push_back(kTBBR); | 26 expected_options.push_back(kTBBR); |
47 expected_options.push_back(kREJ); | 27 expected_options.push_back(kREJ); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 "0x0010: 7320 7374 7269 6e67 2073 686f 756c 6420 s.string.should.\n" | 130 "0x0010: 7320 7374 7269 6e67 2073 686f 756c 6420 s.string.should.\n" |
151 "0x0020: 6265 206c 6f6e 6720 656e 6f75 6768 2074 be.long.enough.t\n" | 131 "0x0020: 6265 206c 6f6e 6720 656e 6f75 6768 2074 be.long.enough.t\n" |
152 "0x0030: 6f20 7370 616e 206d 756c 7469 706c 6520 o.span.multiple.\n" | 132 "0x0030: 6f20 7370 616e 206d 756c 7469 706c 6520 o.span.multiple.\n" |
153 "0x0040: 6c69 6e65 7320 6f66 206f 7574 7075 742e lines.of.output.\n" | 133 "0x0040: 6c69 6e65 7320 6f66 206f 7574 7075 742e lines.of.output.\n" |
154 "0x0050: 0102 03 ...\n"); | 134 "0x0050: 0102 03 ...\n"); |
155 } | 135 } |
156 | 136 |
157 } // namespace | 137 } // namespace |
158 } // namespace test | 138 } // namespace test |
159 } // namespace net | 139 } // namespace net |
OLD | NEW |