Index: base/strings/string_util_unittest.cc |
=================================================================== |
--- base/strings/string_util_unittest.cc (revision 236429) |
+++ base/strings/string_util_unittest.cc (working copy) |
@@ -7,8 +7,7 @@ |
#include <math.h> |
#include <stdarg.h> |
-#include <limits> |
-#include <sstream> |
+#include <algorithm> |
#include "base/basictypes.h" |
#include "base/strings/string16.h" |
@@ -284,7 +283,8 @@ |
TEST(StringUtilTest, CollapseWhitespace) { |
for (size_t i = 0; i < arraysize(collapse_cases); ++i) { |
const collapse_case& value = collapse_cases[i]; |
- EXPECT_EQ(value.output, CollapseWhitespace(value.input, value.trim)); |
+ EXPECT_EQ(WideToUTF16(value.output), |
+ CollapseWhitespace(WideToUTF16(value.input), value.trim)); |
} |
} |
@@ -421,13 +421,11 @@ |
std::wstring wide = ASCIIToWide(char_cases[i]); |
EXPECT_EQ(wchar_cases[i], wide); |
- EXPECT_TRUE(IsStringASCII(wchar_cases[i])); |
std::string ascii = WideToASCII(wchar_cases[i]); |
EXPECT_EQ(char_cases[i], ascii); |
} |
EXPECT_FALSE(IsStringASCII("Google \x80Video")); |
- EXPECT_FALSE(IsStringASCII(L"Google \x80Video")); |
// Convert empty strings. |
std::wstring wempty; |
@@ -476,17 +474,16 @@ |
TEST(StringUtilTest, LowerCaseEqualsASCII) { |
static const struct { |
- const wchar_t* src_w; |
const char* src_a; |
const char* dst; |
} lowercase_cases[] = { |
- { L"FoO", "FoO", "foo" }, |
- { L"foo", "foo", "foo" }, |
- { L"FOO", "FOO", "foo" }, |
+ { "FoO", "foo" }, |
+ { "foo", "foo" }, |
+ { "FOO", "foo" }, |
}; |
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(lowercase_cases); ++i) { |
- EXPECT_TRUE(LowerCaseEqualsASCII(lowercase_cases[i].src_w, |
+ EXPECT_TRUE(LowerCaseEqualsASCII(ASCIIToUTF16(lowercase_cases[i].src_a), |
lowercase_cases[i].dst)); |
EXPECT_TRUE(LowerCaseEqualsASCII(lowercase_cases[i].src_a, |
lowercase_cases[i].dst)); |
@@ -818,35 +815,48 @@ |
EXPECT_TRUE(StartsWithASCII("java", std::string(), false)); |
EXPECT_TRUE(StartsWithASCII("java", std::string(), true)); |
- EXPECT_TRUE(StartsWith(L"javascript:url", L"javascript", true)); |
- EXPECT_FALSE(StartsWith(L"JavaScript:url", L"javascript", true)); |
- EXPECT_TRUE(StartsWith(L"javascript:url", L"javascript", false)); |
- EXPECT_TRUE(StartsWith(L"JavaScript:url", L"javascript", false)); |
- EXPECT_FALSE(StartsWith(L"java", L"javascript", true)); |
- EXPECT_FALSE(StartsWith(L"java", L"javascript", false)); |
- EXPECT_FALSE(StartsWith(std::wstring(), L"javascript", false)); |
- EXPECT_FALSE(StartsWith(std::wstring(), L"javascript", true)); |
- EXPECT_TRUE(StartsWith(L"java", std::wstring(), false)); |
- EXPECT_TRUE(StartsWith(L"java", std::wstring(), true)); |
+ EXPECT_TRUE(StartsWith(ASCIIToUTF16("javascript:url"), |
+ ASCIIToUTF16("javascript"), true)); |
+ EXPECT_FALSE(StartsWith(ASCIIToUTF16("JavaScript:url"), |
+ ASCIIToUTF16("javascript"), true)); |
+ EXPECT_TRUE(StartsWith(ASCIIToUTF16("javascript:url"), |
+ ASCIIToUTF16("javascript"), false)); |
+ EXPECT_TRUE(StartsWith(ASCIIToUTF16("JavaScript:url"), |
+ ASCIIToUTF16("javascript"), false)); |
+ EXPECT_FALSE(StartsWith(ASCIIToUTF16("java"), |
+ ASCIIToUTF16("javascript"), true)); |
+ EXPECT_FALSE(StartsWith(ASCIIToUTF16("java"), |
+ ASCIIToUTF16("javascript"), false)); |
+ EXPECT_FALSE(StartsWith(string16(), ASCIIToUTF16("javascript"), false)); |
+ EXPECT_FALSE(StartsWith(string16(), ASCIIToUTF16("javascript"), true)); |
+ EXPECT_TRUE(StartsWith(ASCIIToUTF16("java"), string16(), false)); |
+ EXPECT_TRUE(StartsWith(ASCIIToUTF16("java"), string16(), true)); |
} |
TEST(StringUtilTest, EndsWith) { |
- EXPECT_TRUE(EndsWith(L"Foo.plugin", L".plugin", true)); |
- EXPECT_FALSE(EndsWith(L"Foo.Plugin", L".plugin", true)); |
- EXPECT_TRUE(EndsWith(L"Foo.plugin", L".plugin", false)); |
- EXPECT_TRUE(EndsWith(L"Foo.Plugin", L".plugin", false)); |
- EXPECT_FALSE(EndsWith(L".plug", L".plugin", true)); |
- EXPECT_FALSE(EndsWith(L".plug", L".plugin", false)); |
- EXPECT_FALSE(EndsWith(L"Foo.plugin Bar", L".plugin", true)); |
- EXPECT_FALSE(EndsWith(L"Foo.plugin Bar", L".plugin", false)); |
- EXPECT_FALSE(EndsWith(std::wstring(), L".plugin", false)); |
- EXPECT_FALSE(EndsWith(std::wstring(), L".plugin", true)); |
- EXPECT_TRUE(EndsWith(L"Foo.plugin", std::wstring(), false)); |
- EXPECT_TRUE(EndsWith(L"Foo.plugin", std::wstring(), true)); |
- EXPECT_TRUE(EndsWith(L".plugin", L".plugin", false)); |
- EXPECT_TRUE(EndsWith(L".plugin", L".plugin", true)); |
- EXPECT_TRUE(EndsWith(std::wstring(), std::wstring(), false)); |
- EXPECT_TRUE(EndsWith(std::wstring(), std::wstring(), true)); |
+ EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), |
+ ASCIIToUTF16(".plugin"), true)); |
+ EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.Plugin"), |
+ ASCIIToUTF16(".plugin"), true)); |
+ EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), |
+ ASCIIToUTF16(".plugin"), false)); |
+ EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.Plugin"), |
+ ASCIIToUTF16(".plugin"), false)); |
+ EXPECT_FALSE(EndsWith(ASCIIToUTF16(".plug"), ASCIIToUTF16(".plugin"), true)); |
+ EXPECT_FALSE(EndsWith(ASCIIToUTF16(".plug"), ASCIIToUTF16(".plugin"), false)); |
+ EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.plugin Bar"), |
+ ASCIIToUTF16(".plugin"), true)); |
+ EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.plugin Bar"), |
+ ASCIIToUTF16(".plugin"), false)); |
+ EXPECT_FALSE(EndsWith(string16(), ASCIIToUTF16(".plugin"), false)); |
+ EXPECT_FALSE(EndsWith(string16(), ASCIIToUTF16(".plugin"), true)); |
+ EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), string16(), false)); |
+ EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), string16(), true)); |
+ EXPECT_TRUE(EndsWith(ASCIIToUTF16(".plugin"), |
+ ASCIIToUTF16(".plugin"), false)); |
+ EXPECT_TRUE(EndsWith(ASCIIToUTF16(".plugin"), ASCIIToUTF16(".plugin"), true)); |
+ EXPECT_TRUE(EndsWith(string16(), string16(), false)); |
+ EXPECT_TRUE(EndsWith(string16(), string16(), true)); |
} |
TEST(StringUtilTest, GetStringFWithOffsets) { |