| 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 "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 9 |
| 9 using base::StringPiece; | 10 using base::StringPiece; |
| 10 using std::string; | 11 using std::string; |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 namespace test { | 14 namespace test { |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // A test string and a hex+ASCII dump of the same string. | 17 // A test string and a hex+ASCII dump of the same string. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 QuicUtils::StringToHexASCIIDump(StringPiece(tests[i].input))); | 62 QuicUtils::StringToHexASCIIDump(StringPiece(tests[i].input))); |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 65 TEST(QuicUtilsTest, StringToHexASCIIDumpSuccess) { | 66 TEST(QuicUtilsTest, StringToHexASCIIDumpSuccess) { |
| 66 EXPECT_EQ(string(reinterpret_cast<const char*>(kHexDump)), | 67 EXPECT_EQ(string(reinterpret_cast<const char*>(kHexDump)), |
| 67 QuicUtils::StringToHexASCIIDump( | 68 QuicUtils::StringToHexASCIIDump( |
| 68 string(reinterpret_cast<const char*>(kString), sizeof(kString)))); | 69 string(reinterpret_cast<const char*>(kString), sizeof(kString)))); |
| 69 } | 70 } |
| 70 | 71 |
| 72 TEST(QuicUtilsTest, TagToString) { |
| 73 EXPECT_EQ("SCFG", |
| 74 QuicUtils::TagToString(kSCFG)); |
| 75 EXPECT_EQ("SNO ", |
| 76 QuicUtils::TagToString(kServerNonceTag)); |
| 77 EXPECT_EQ("CRT ", |
| 78 QuicUtils::TagToString(kCertificateTag)); |
| 79 EXPECT_EQ("CHLO", |
| 80 QuicUtils::TagToString(MakeQuicTag('C', 'H', 'L', 'O'))); |
| 81 // A tag that contains a non-printing character will be printed as a decimal |
| 82 // number. |
| 83 EXPECT_EQ("525092931", |
| 84 QuicUtils::TagToString(MakeQuicTag('C', 'H', 'L', '\x1f'))); |
| 85 } |
| 86 |
| 71 } // namespace | 87 } // namespace |
| 72 } // namespace test | 88 } // namespace test |
| 73 } // namespace net | 89 } // namespace net |
| OLD | NEW |