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 25 matching lines...) Expand all Loading... |
36 EXPECT_EQ("lower", QuicTextUtils::ToLower("LOWER")); | 36 EXPECT_EQ("lower", QuicTextUtils::ToLower("LOWER")); |
37 EXPECT_EQ("lower", QuicTextUtils::ToLower("lower")); | 37 EXPECT_EQ("lower", QuicTextUtils::ToLower("lower")); |
38 EXPECT_EQ("lower", QuicTextUtils::ToLower("lOwEr")); | 38 EXPECT_EQ("lower", QuicTextUtils::ToLower("lOwEr")); |
39 EXPECT_EQ("123", QuicTextUtils::ToLower("123")); | 39 EXPECT_EQ("123", QuicTextUtils::ToLower("123")); |
40 EXPECT_EQ("", QuicTextUtils::ToLower("")); | 40 EXPECT_EQ("", QuicTextUtils::ToLower("")); |
41 } | 41 } |
42 | 42 |
43 TEST(QuicTextUtilsText, RemoveLeadingAndTrailingWhitespace) { | 43 TEST(QuicTextUtilsText, RemoveLeadingAndTrailingWhitespace) { |
44 string input; | 44 string input; |
45 | 45 |
46 for (auto input : {"text", " text", " text", "text ", "text ", " text ", | 46 for (auto* input : {"text", " text", " text", "text ", "text ", " text ", |
47 " text ", "\r\n\ttext", "text\n\r\t"}) { | 47 " text ", "\r\n\ttext", "text\n\r\t"}) { |
48 StringPiece piece(input); | 48 StringPiece piece(input); |
49 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&piece); | 49 QuicTextUtils::RemoveLeadingAndTrailingWhitespace(&piece); |
50 EXPECT_EQ("text", piece); | 50 EXPECT_EQ("text", piece); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 TEST(QuicTextUtilsText, StringToNumbers) { | 54 TEST(QuicTextUtilsText, StringToNumbers) { |
55 const string kMaxInt32Plus1 = "2147483648"; | 55 const string kMaxInt32Plus1 = "2147483648"; |
56 const string kMinInt32Minus1 = "-2147483649"; | 56 const string kMinInt32Minus1 = "-2147483649"; |
57 const string kMaxUint32Plus1 = "4294967296"; | 57 const string kMaxUint32Plus1 = "4294967296"; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 EXPECT_EQ(std::vector<StringPiece>({"a", "b", "c"}), | 193 EXPECT_EQ(std::vector<StringPiece>({"a", "b", "c"}), |
194 QuicTextUtils::Split("a,b,c", ',')); | 194 QuicTextUtils::Split("a,b,c", ',')); |
195 EXPECT_EQ(std::vector<StringPiece>({"a", "b", "c"}), | 195 EXPECT_EQ(std::vector<StringPiece>({"a", "b", "c"}), |
196 QuicTextUtils::Split("a:b:c", ':')); | 196 QuicTextUtils::Split("a:b:c", ':')); |
197 EXPECT_EQ(std::vector<StringPiece>({"a:b:c"}), | 197 EXPECT_EQ(std::vector<StringPiece>({"a:b:c"}), |
198 QuicTextUtils::Split("a:b:c", ',')); | 198 QuicTextUtils::Split("a:b:c", ',')); |
199 } | 199 } |
200 | 200 |
201 } // namespace test | 201 } // namespace test |
202 } // namespace net | 202 } // namespace net |
OLD | NEW |