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/quic_utils.h" | 5 #include "net/quic/quic_utils.h" |
6 | 6 |
7 #include "net/quic/crypto/crypto_protocol.h" | 7 #include "net/quic/crypto/crypto_protocol.h" |
8 #include "net/quic/quic_flags.h" | 8 #include "net/quic/quic_flags.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 TEST(QuicUtilsHashTest, ReferenceTest) { | 178 TEST(QuicUtilsHashTest, ReferenceTest) { |
179 std::vector<uint8_t> data(32); | 179 std::vector<uint8_t> data(32); |
180 for (size_t i = 0; i < data.size(); ++i) { | 180 for (size_t i = 0; i < data.size(); ++i) { |
181 data[i] = i % 255; | 181 data[i] = i % 255; |
182 } | 182 } |
183 EXPECT_EQ(IncrementalHashReference(data.data(), data.size()), | 183 EXPECT_EQ(IncrementalHashReference(data.data(), data.size()), |
184 QuicUtils::FNV1a_128_Hash( | 184 QuicUtils::FNV1a_128_Hash( |
185 reinterpret_cast<const char*>(data.data()), data.size())); | 185 reinterpret_cast<const char*>(data.data()), data.size())); |
186 } | 186 } |
187 | 187 |
| 188 TEST(QuicUtilsTest, HexDump) { |
| 189 // Verify output of the HexDump method is as expected. |
| 190 char packet[] = { |
| 191 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x51, 0x55, 0x49, 0x43, 0x21, |
| 192 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, |
| 193 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x6c, |
| 194 0x6f, 0x6e, 0x67, 0x20, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x20, 0x74, |
| 195 0x6f, 0x20, 0x73, 0x70, 0x61, 0x6e, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, |
| 196 0x70, 0x6c, 0x65, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x6f, 0x66, |
| 197 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x01, 0x02, 0x03, 0x00, |
| 198 }; |
| 199 EXPECT_EQ( |
| 200 QuicUtils::HexDump(packet), |
| 201 "48 65 6C 6C 6F 2C 20 51 55 49 43 21 20 54 68 69 |Hello, QUIC! Thi|\n" |
| 202 "73 20 73 74 72 69 6E 67 20 73 68 6F 75 6C 64 20 |s string should |\n" |
| 203 "62 65 20 6C 6F 6E 67 20 65 6E 6F 75 67 68 20 74 |be long enough t|\n" |
| 204 "6F 20 73 70 61 6E 20 6D 75 6C 74 69 70 6C 65 20 |o span multiple |\n" |
| 205 "6C 69 6E 65 73 20 6F 66 20 6F 75 74 70 75 74 2E |lines of output.|\n" |
| 206 "01 02 03 |... |\n"); |
| 207 } |
| 208 |
188 } // namespace | 209 } // namespace |
189 } // namespace test | 210 } // namespace test |
190 } // namespace net | 211 } // namespace net |
OLD | NEW |