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 "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using base::StringPiece; | 10 using base::StringPiece; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 TEST(QuicUtilsHashTest, ReferenceTest) { | 92 TEST(QuicUtilsHashTest, ReferenceTest) { |
93 std::vector<uint8_t> data(32); | 93 std::vector<uint8_t> data(32); |
94 for (size_t i = 0; i < data.size(); ++i) { | 94 for (size_t i = 0; i < data.size(); ++i) { |
95 data[i] = i % 255; | 95 data[i] = i % 255; |
96 } | 96 } |
97 EXPECT_EQ(IncrementalHashReference(data.data(), data.size()), | 97 EXPECT_EQ(IncrementalHashReference(data.data(), data.size()), |
98 QuicUtils::FNV1a_128_Hash(StringPiece( | 98 QuicUtils::FNV1a_128_Hash(StringPiece( |
99 reinterpret_cast<const char*>(data.data()), data.size()))); | 99 reinterpret_cast<const char*>(data.data()), data.size()))); |
100 } | 100 } |
101 | 101 |
102 TEST(QuicUtilsTest, HexDump) { | |
103 // Verify output of the HexDump method is as expected. | |
104 char packet[] = { | |
105 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x51, 0x55, 0x49, 0x43, 0x21, | |
106 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, | |
107 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x6c, | |
108 0x6f, 0x6e, 0x67, 0x20, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x20, 0x74, | |
109 0x6f, 0x20, 0x73, 0x70, 0x61, 0x6e, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, | |
110 0x70, 0x6c, 0x65, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x6f, 0x66, | |
111 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x01, 0x02, 0x03, 0x00, | |
112 }; | |
113 EXPECT_EQ( | |
114 QuicUtils::HexDump(packet), | |
115 "0x0000: 4865 6c6c 6f2c 2051 5549 4321 2054 6869 Hello,.QUIC!.Thi\n" | |
116 "0x0010: 7320 7374 7269 6e67 2073 686f 756c 6420 s.string.should.\n" | |
117 "0x0020: 6265 206c 6f6e 6720 656e 6f75 6768 2074 be.long.enough.t\n" | |
118 "0x0030: 6f20 7370 616e 206d 756c 7469 706c 6520 o.span.multiple.\n" | |
119 "0x0040: 6c69 6e65 7320 6f66 206f 7574 7075 742e lines.of.output.\n" | |
120 "0x0050: 0102 03 ...\n"); | |
121 } | |
122 | |
123 } // namespace | 102 } // namespace |
124 } // namespace test | 103 } // namespace test |
125 } // namespace net | 104 } // namespace net |
OLD | NEW |