OLD | NEW |
| (Empty) |
1 // Copyright 2015 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. | |
4 | |
5 #include "platform/text/LocaleToScriptMapping.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 #include "wtf/text/WTFString.h" | |
9 | |
10 namespace blink { | |
11 | |
12 TEST(LocaleToScriptMappingTest, scriptCodeForHanFromLocaleTest) | |
13 { | |
14 struct { | |
15 const char* locale; | |
16 UScriptCode script; | |
17 } tests[] = { | |
18 { "ja-JP", USCRIPT_KATAKANA_OR_HIRAGANA }, | |
19 { "ko-KR", USCRIPT_HANGUL }, | |
20 { "zh-CN", USCRIPT_SIMPLIFIED_HAN }, | |
21 { "zh-TW", USCRIPT_TRADITIONAL_HAN }, | |
22 { "zh-HK", USCRIPT_TRADITIONAL_HAN }, | |
23 | |
24 // icu::Locale::getDefault() returns other combinations if, for instnace
, | |
25 // English Windows with the display language set to Japanese. | |
26 { "ja", USCRIPT_KATAKANA_OR_HIRAGANA }, | |
27 { "ja-US", USCRIPT_KATAKANA_OR_HIRAGANA }, | |
28 { "ko", USCRIPT_HANGUL }, | |
29 { "ko-US", USCRIPT_HANGUL }, | |
30 | |
31 { "zh-hant", USCRIPT_TRADITIONAL_HAN }, | |
32 | |
33 { "en-CN", USCRIPT_SIMPLIFIED_HAN }, | |
34 { "en-JP", USCRIPT_KATAKANA_OR_HIRAGANA }, | |
35 { "en-KR", USCRIPT_HANGUL }, | |
36 { "en-HK", USCRIPT_TRADITIONAL_HAN }, | |
37 { "en-TW", USCRIPT_TRADITIONAL_HAN }, | |
38 | |
39 { "en-HanS", USCRIPT_SIMPLIFIED_HAN }, | |
40 { "en-HanT", USCRIPT_TRADITIONAL_HAN }, | |
41 | |
42 { "en-HanS-JP", USCRIPT_SIMPLIFIED_HAN }, | |
43 { "en-HanT-JP", USCRIPT_TRADITIONAL_HAN }, | |
44 { "en-US-JP", USCRIPT_KATAKANA_OR_HIRAGANA }, | |
45 | |
46 { "en-US", USCRIPT_COMMON }, | |
47 }; | |
48 | |
49 for (auto test : tests) { | |
50 String str(test.locale); | |
51 EXPECT_EQ(test.script, scriptCodeForHanFromLocale(str)); | |
52 | |
53 str = str.replace('-', '_'); | |
54 EXPECT_EQ(test.script, scriptCodeForHanFromLocale(str, '_')); | |
55 } | |
56 } | |
57 | |
58 } // namespace blink | |
OLD | NEW |