| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/platform/api/quic_text_utils.h" | 5 #include "net/quic/platform/api/quic_text_utils.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 TEST(QuicTextUtilsText, Uint64ToString) { | 65 TEST(QuicTextUtilsText, Uint64ToString) { |
| 66 EXPECT_EQ("123", QuicTextUtils::Uint64ToString(123)); | 66 EXPECT_EQ("123", QuicTextUtils::Uint64ToString(123)); |
| 67 EXPECT_EQ("1234", QuicTextUtils::Uint64ToString(1234)); | 67 EXPECT_EQ("1234", QuicTextUtils::Uint64ToString(1234)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 TEST(QuicTextUtilsText, HexEncode) { | 70 TEST(QuicTextUtilsText, HexEncode) { |
| 71 EXPECT_EQ("48656c6c6f", QuicTextUtils::HexEncode("Hello", 5)); | 71 EXPECT_EQ("48656c6c6f", QuicTextUtils::HexEncode("Hello", 5)); |
| 72 EXPECT_EQ("48656c6c6f", QuicTextUtils::HexEncode("Hello World", 5)); | 72 EXPECT_EQ("48656c6c6f", QuicTextUtils::HexEncode("Hello World", 5)); |
| 73 EXPECT_EQ("48656c6c6f", QuicTextUtils::HexEncode("Hello")); | 73 EXPECT_EQ("48656c6c6f", QuicTextUtils::HexEncode("Hello")); |
| 74 EXPECT_EQ("0102779cfa", QuicTextUtils::HexEncode("\x01\x02\x77\x9c\xfa")); |
| 74 } | 75 } |
| 75 | 76 |
| 76 TEST(QuicTextUtilsText, HexDecode) { | 77 TEST(QuicTextUtilsText, HexDecode) { |
| 77 EXPECT_EQ("Hello", QuicTextUtils::HexDecode("48656c6c6f")); | 78 EXPECT_EQ("Hello", QuicTextUtils::HexDecode("48656c6c6f")); |
| 78 EXPECT_EQ("", QuicTextUtils::HexDecode("")); | 79 EXPECT_EQ("", QuicTextUtils::HexDecode("")); |
| 80 EXPECT_EQ("\x01\x02\x77\x9c\xfa", QuicTextUtils::HexDecode("0102779cfa")); |
| 79 } | 81 } |
| 80 | 82 |
| 81 TEST(QuicTextUtilsText, HexDump) { | 83 TEST(QuicTextUtilsText, HexDump) { |
| 82 // Verify output of the HexDump method is as expected. | 84 // Verify output of the HexDump method is as expected. |
| 83 char packet[] = { | 85 char packet[] = { |
| 84 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x51, 0x55, 0x49, 0x43, 0x21, | 86 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x51, 0x55, 0x49, 0x43, 0x21, |
| 85 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, | 87 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, |
| 86 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x6c, | 88 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x6c, |
| 87 0x6f, 0x6e, 0x67, 0x20, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x20, 0x74, | 89 0x6f, 0x6e, 0x67, 0x20, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x20, 0x74, |
| 88 0x6f, 0x20, 0x73, 0x70, 0x61, 0x6e, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, | 90 0x6f, 0x20, 0x73, 0x70, 0x61, 0x6e, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 EXPECT_EQ(std::vector<StringPiece>({"a", "b", "c"}), | 131 EXPECT_EQ(std::vector<StringPiece>({"a", "b", "c"}), |
| 130 QuicTextUtils::Split("a,b,c", ',')); | 132 QuicTextUtils::Split("a,b,c", ',')); |
| 131 EXPECT_EQ(std::vector<StringPiece>({"a", "b", "c"}), | 133 EXPECT_EQ(std::vector<StringPiece>({"a", "b", "c"}), |
| 132 QuicTextUtils::Split("a:b:c", ':')); | 134 QuicTextUtils::Split("a:b:c", ':')); |
| 133 EXPECT_EQ(std::vector<StringPiece>({"a:b:c"}), | 135 EXPECT_EQ(std::vector<StringPiece>({"a:b:c"}), |
| 134 QuicTextUtils::Split("a:b:c", ',')); | 136 QuicTextUtils::Split("a:b:c", ',')); |
| 135 } | 137 } |
| 136 | 138 |
| 137 } // namespace test | 139 } // namespace test |
| 138 } // namespace net | 140 } // namespace net |
| OLD | NEW |