Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3047)

Unified Diff: base/i18n/case_conversion_unittest.cc

Issue 1104483002: added test to test case converting with nonASCII (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use hex-escape and add test to turkish locale Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/case_conversion_unittest.cc
diff --git a/base/i18n/case_conversion_unittest.cc b/base/i18n/case_conversion_unittest.cc
index 38e2c6878228de468124d80a7aabfddebf2eec0f..b51c4d13ffdec89f6c4cd76eb891467d4afc7cf5 100644
--- a/base/i18n/case_conversion_unittest.cc
+++ b/base/i18n/case_conversion_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/i18n/case_conversion.h"
+#include "base/i18n/rtl.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -11,7 +12,7 @@ namespace {
// Test upper and lower case string conversion.
TEST(CaseConversionTest, UpperLower) {
- string16 mixed(ASCIIToUTF16("Text with UPPer & lowER casE."));
+ const string16 mixed(ASCIIToUTF16("Text with UPPer & lowER casE."));
const string16 expected_lower(ASCIIToUTF16("text with upper & lower case."));
const string16 expected_upper(ASCIIToUTF16("TEXT WITH UPPER & LOWER CASE."));
@@ -22,7 +23,49 @@ TEST(CaseConversionTest, UpperLower) {
EXPECT_EQ(expected_upper, result);
}
-// TODO(jshin): More tests are needed, especially with non-ASCII characters.
+TEST(CaseConversionTest, NonASCII) {
+ const string16 mixed(WideToUTF16(L"\xC4\xD6\xE4\xF6\x20\xCF\xEF\x20\xF7\x25"
+ L"\xA4\x23\x2A\x5E\x60\x40\xA3\x24\x2030\x201A\x7E\x20\x1F07\x1F0F"
+ L"\x20\x1E00\x1E01"));
+ const string16 expected_lower(WideToUTF16(L"\xE4\xF6\xE4\xF6\x20\xEF\xEF"
+ L"\x20\xF7\x25\xA4\x23\x2A\x5E\x60\x40\xA3\x24\x2030\x201A\x7E\x20\x1F07"
+ L"\x1F07\x20\x1E01\x1E01"));
+ const string16 expected_upper(WideToUTF16(L"\xC4\xD6\xC4\xD6\x20\xCF\xCF"
+ L"\x20\xF7\x25\xA4\x23\x2A\x5E\x60\x40\xA3\x24\x2030\x201A\x7E\x20\x1F0F"
+ L"\x1F0F\x20\x1E00\x1E00"));
+
+ string16 result = base::i18n::ToLower(mixed);
+ EXPECT_EQ(expected_lower, result);
+
+ result = base::i18n::ToUpper(mixed);
+ EXPECT_EQ(expected_upper, result);
+}
+
+TEST(CaseConversionTest, TurkishLocaleConversion) {
+ const string16 mixed(WideToUTF16(L"\x49\x131"));
+ const string16 expected_lower(WideToUTF16(L"\x69\x131"));
+ const string16 expected_upper(WideToUTF16(L"\x49\x49"));
+
+ string16 result = base::i18n::ToLower(mixed);
+ EXPECT_EQ(expected_lower, result);
+
+ result = base::i18n::ToUpper(mixed);
+ EXPECT_EQ(expected_upper, result);
+
+ i18n::SetICUDefaultLocale("tr");
jungshik at Google 2015/05/12 20:30:37 You'd better save the original ICU locale and rest
+
+ const string16 expected_lower_turkish(WideToUTF16(L"\x131\x131"));
+ const string16 expected_upper_turkish(WideToUTF16(L"\x49\x49"));
+
+ result = base::i18n::ToLower(mixed);
+ EXPECT_EQ(expected_lower_turkish, result);
+
+ result = base::i18n::ToUpper(mixed);
+ EXPECT_EQ(expected_upper_turkish, result);
+}
} // namespace
} // namespace base
+
+
+
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698