Don't preload rarely seen large images
[chromium-blink-merge.git] / base / i18n / case_conversion_unittest.cc
blob75e5ad232533fa846b946d6462876b67f00db3ce
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/i18n/case_conversion.h"
6 #include "base/i18n/rtl.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/icu/source/i18n/unicode/usearch.h"
11 namespace base {
12 namespace {
14 // Test upper and lower case string conversion.
15 TEST(CaseConversionTest, UpperLower) {
16 const string16 mixed(ASCIIToUTF16("Text with UPPer & lowER casE."));
17 const string16 expected_lower(ASCIIToUTF16("text with upper & lower case."));
18 const string16 expected_upper(ASCIIToUTF16("TEXT WITH UPPER & LOWER CASE."));
20 string16 result = base::i18n::ToLower(mixed);
21 EXPECT_EQ(expected_lower, result);
23 result = base::i18n::ToUpper(mixed);
24 EXPECT_EQ(expected_upper, result);
27 TEST(CaseConversionTest, NonASCII) {
28 const string16 mixed(WideToUTF16(
29 L"\xC4\xD6\xE4\xF6\x20\xCF\xEF\x20\xF7\x25"
30 L"\xA4\x23\x2A\x5E\x60\x40\xA3\x24\x2030\x201A\x7E\x20\x1F07\x1F0F"
31 L"\x20\x1E00\x1E01"));
32 const string16 expected_lower(WideToUTF16(
33 L"\xE4\xF6\xE4\xF6\x20\xEF\xEF"
34 L"\x20\xF7\x25\xA4\x23\x2A\x5E\x60\x40\xA3\x24\x2030\x201A\x7E\x20\x1F07"
35 L"\x1F07\x20\x1E01\x1E01"));
36 const string16 expected_upper(WideToUTF16(
37 L"\xC4\xD6\xC4\xD6\x20\xCF\xCF"
38 L"\x20\xF7\x25\xA4\x23\x2A\x5E\x60\x40\xA3\x24\x2030\x201A\x7E\x20\x1F0F"
39 L"\x1F0F\x20\x1E00\x1E00"));
41 string16 result = base::i18n::ToLower(mixed);
42 EXPECT_EQ(expected_lower, result);
44 result = base::i18n::ToUpper(mixed);
45 EXPECT_EQ(expected_upper, result);
48 TEST(CaseConversionTest, TurkishLocaleConversion) {
49 const string16 mixed(WideToUTF16(L"\x49\x131"));
50 const string16 expected_lower(WideToUTF16(L"\x69\x131"));
51 const string16 expected_upper(WideToUTF16(L"\x49\x49"));
53 std::string default_locale(uloc_getDefault());
54 i18n::SetICUDefaultLocale("en_US");
56 string16 result = base::i18n::ToLower(mixed);
57 EXPECT_EQ(expected_lower, result);
59 result = base::i18n::ToUpper(mixed);
60 EXPECT_EQ(expected_upper, result);
62 i18n::SetICUDefaultLocale("tr");
64 const string16 expected_lower_turkish(WideToUTF16(L"\x131\x131"));
65 const string16 expected_upper_turkish(WideToUTF16(L"\x49\x49"));
67 result = base::i18n::ToLower(mixed);
68 EXPECT_EQ(expected_lower_turkish, result);
70 result = base::i18n::ToUpper(mixed);
71 EXPECT_EQ(expected_upper_turkish, result);
73 base::i18n::SetICUDefaultLocale(default_locale.data());
76 } // namespace
77 } // namespace base