summaryrefslogtreecommitdiffstats
path: root/base/utf_string_conversions_unittest.cc
diff options
context:
space:
mode:
authorjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-16 16:40:38 +0000
committerjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-16 16:40:38 +0000
commit548a6c0f30c3dcf374cc06be48f02a06da5c1d19 (patch)
tree57a3406e6d51b44774b9fa37cde1810a1d76a47c /base/utf_string_conversions_unittest.cc
parentb78e6049b83a6a221b6c7b47c229b337e3abce43 (diff)
downloadchromium_src-548a6c0f30c3dcf374cc06be48f02a06da5c1d19.zip
chromium_src-548a6c0f30c3dcf374cc06be48f02a06da5c1d19.tar.gz
chromium_src-548a6c0f30c3dcf374cc06be48f02a06da5c1d19.tar.bz2
Changes are:
* base::IsValidCodepoint() now returns false on non-character code points. * base::IsStringUTF8() now uses ICU library (removed old Mozilla implementation). * Removed base::IsStringWideUTF8() (was unused and confusing) * file_util::ReplaceIllegalCharactersInPath() now treats Unicode replacement character (U+FFFD) as invalid. * Associated unit tests updated. BUG=2759 BUG=30662 TEST=base_unittests --gtest_filter=StringUtilTest.IsStringUTF8 TEST=base_unittests --gtest_filter=UTFStringConversionsTest.* TEST=base_unittests --gtest_filter=FileUtilICUTestReplaceIllegalCharactersInPathTest Review URL: http://codereview.chromium.org/548017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/utf_string_conversions_unittest.cc')
-rw-r--r--base/utf_string_conversions_unittest.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/base/utf_string_conversions_unittest.cc b/base/utf_string_conversions_unittest.cc
index 6ba0b5b..f68c593 100644
--- a/base/utf_string_conversions_unittest.cc
+++ b/base/utf_string_conversions_unittest.cc
@@ -91,8 +91,8 @@ TEST(UTFStringConversionsTest, ConvertUTF8ToWide) {
} convert_cases[] = {
// Regular UTF-8 input.
{"\xe4\xbd\xa0\xe5\xa5\xbd", L"\x4f60\x597d", true},
- // Non-character is passed through.
- {"\xef\xbf\xbfHello", L"\xffffHello", true},
+ // Non-character is rejected.
+ {"\xef\xbf\xbfHello", L"\xfffdHello", false},
// Truncated UTF-8 sequence.
{"\xe4\xa0\xe5\xa5\xbd", L"\xfffd\x597d", false},
// Truncated off the end.
@@ -105,10 +105,10 @@ TEST(UTFStringConversionsTest, ConvertUTF8ToWide) {
// The result will either be in UTF-16 or UTF-32.
#if defined(WCHAR_T_IS_UTF16)
{"A\xF0\x90\x8C\x80z", L"A\xd800\xdf00z", true},
- {"A\xF4\x8F\xBF\xBEz", L"A\xdbff\xdffez", true},
+ {"A\xF4\x8F\xBF\xBEz", L"A\xfffdz", false},
#elif defined(WCHAR_T_IS_UTF32)
{"A\xF0\x90\x8C\x80z", L"A\x10300z", true},
- {"A\xF4\x8F\xBF\xBEz", L"A\x10fffez", true},
+ {"A\xF4\x8F\xBF\xBEz", L"A\xfffdz", false},
#endif
};
@@ -148,9 +148,9 @@ TEST(UTFStringConversionsTest, ConvertUTF16ToUTF8) {
{L"\x4f60\x597d", "\xe4\xbd\xa0\xe5\xa5\xbd", true},
// Test a non-BMP character.
{L"\xd800\xdf00", "\xF0\x90\x8C\x80", true},
- // Non-characters are passed through.
- {L"\xffffHello", "\xEF\xBF\xBFHello", true},
- {L"\xdbff\xdffeHello", "\xF4\x8F\xBF\xBEHello", true},
+ // Non-characters are rejected.
+ {L"\xffffHello", "\xef\xbf\xbdHello", false},
+ {L"\xdbff\xdffeHello", "\xef\xbf\xbdHello", false},
// The first character is a truncated UTF-16 character.
{L"\xd800\x597d", "\xef\xbf\xbd\xe5\xa5\xbd", false},
// Truncated at the end.
@@ -180,9 +180,9 @@ TEST(UTFStringConversionsTest, ConvertUTF32ToUTF8) {
{L"\x4f60\x597d", "\xe4\xbd\xa0\xe5\xa5\xbd", true},
// Test a non-BMP character.
{L"A\x10300z", "A\xF0\x90\x8C\x80z", true},
- // Non-characters are passed through.
- {L"\xffffHello", "\xEF\xBF\xBFHello", true},
- {L"\x10fffeHello", "\xF4\x8F\xBF\xBEHello", true},
+ // Non-characters are rejected.
+ {L"\xffffHello", "\xEF\xBF\xBDHello", false},
+ {L"\x10fffeHello", "\xEF\xBF\xBDHello", false},
// Invalid Unicode code points.
{L"\xfffffffHello", "\xEF\xBF\xBDHello", false},
// The first character is a truncated UTF-16 character.