summaryrefslogtreecommitdiffstats
path: root/chromium/base/strings/string_util_unittest.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-28 16:14:41 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-12-13 15:19:41 +0000
commit61d9742824d54be5693191fe502325a909feca59 (patch)
treecbf28e779b11338fe52eb75b915684cd8955542c /chromium/base/strings/string_util_unittest.cc
parent45f9ded08bb7526984b24ccb5a5327aaf6821676 (diff)
BASELINE: Update Chromium to 108.0.5359.70
Change-Id: I77334ff232b819600f275bd3cfe41fbaa3619230 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/445904 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/strings/string_util_unittest.cc')
-rw-r--r--chromium/base/strings/string_util_unittest.cc61
1 files changed, 43 insertions, 18 deletions
diff --git a/chromium/base/strings/string_util_unittest.cc b/chromium/base/strings/string_util_unittest.cc
index d892bb1212b..d0926fdab36 100644
--- a/chromium/base/strings/string_util_unittest.cc
+++ b/chromium/base/strings/string_util_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -479,23 +479,26 @@ static const struct collapse_case_ascii {
const bool trim;
const char* output;
} collapse_cases_ascii[] = {
- {" Google Video ", false, "Google Video"},
- {"Google Video", false, "Google Video"},
- {"", false, ""},
- {" ", false, ""},
- {"\t\rTest String\n", false, "Test String"},
- {" Test \n \t String ", false, "Test String"},
- {" Test String", false, "Test String"},
- {"Test String ", false, "Test String"},
- {"Test String", false, "Test String"},
- {"", true, ""},
- {"\n", true, ""},
- {" \r ", true, ""},
- {"\nFoo", true, "Foo"},
- {"\r Foo ", true, "Foo"},
- {" Foo bar ", true, "Foo bar"},
- {" \tFoo bar \n", true, "Foo bar"},
- {" a \r b\n c \r\n d \t\re \t f \n ", true, "abcde f"},
+ {" Google Video ", false, "Google Video"},
+ {"Google Video", false, "Google Video"},
+ {"", false, ""},
+ {" ", false, ""},
+ {"\t\rTest String\n", false, "Test String"},
+ {" Test \n \t String ", false, "Test String"},
+ {" Test String", false, "Test String"},
+ {"Test String ", false, "Test String"},
+ {"Test String", false, "Test String"},
+ {"", true, ""},
+ {"\n", true, ""},
+ {" \r ", true, ""},
+ {"\nFoo", true, "Foo"},
+ {"\r Foo ", true, "Foo"},
+ {" Foo bar ", true, "Foo bar"},
+ // \u00A0 is whitespace, but not _ASCII_ whitespace, so it should not be
+ // collapsed by CollapseWhitespaceASCII().
+ {"Foo\u00A0bar", true, "Foo\u00A0bar"},
+ {" \tFoo bar \n", true, "Foo bar"},
+ {" a \r b\n c \r\n d \t\re \t f \n ", true, "abcde f"},
};
TEST(StringUtilTest, CollapseWhitespaceASCII) {
@@ -1324,6 +1327,28 @@ TEST(StringUtilTest, MakeBasicStringPieceTest) {
EXPECT_TRUE(MakeWStringPiece(baz.end(), baz.end()).empty());
}
+enum class StreamableTestEnum { kGreeting, kLocation };
+
+std::ostream& operator<<(std::ostream& os, const StreamableTestEnum& value) {
+ switch (value) {
+ case StreamableTestEnum::kGreeting:
+ return os << "hello";
+ case StreamableTestEnum::kLocation:
+ return os << "world";
+ }
+}
+
+TEST(StringUtilTest, StreamableToString) {
+ EXPECT_EQ(StreamableToString("foo"), "foo");
+ EXPECT_EQ(StreamableToString(123), "123");
+ EXPECT_EQ(StreamableToString(StreamableTestEnum::kGreeting), "hello");
+ EXPECT_EQ(StreamableToString(StreamableTestEnum::kGreeting, " ",
+ StreamableTestEnum::kLocation),
+ "hello world");
+ EXPECT_EQ(StreamableToString("42 in hex is ", std::hex, 42),
+ "42 in hex is 2a");
+}
+
TEST(StringUtilTest, RemoveChars) {
const char kRemoveChars[] = "-/+*";
std::string input = "A-+bc/d!*";