OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/fonts/Character.h" | 5 #include "platform/fonts/Character.h" |
6 | 6 |
7 #include "platform/Logging.h" | 7 #include "platform/Logging.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "wtf/text/CharacterNames.h" | 9 #include "wtf/text/CharacterNames.h" |
10 | 10 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 static UChar c4[] = { 0x36F, 0x330 }; | 136 static UChar c4[] = { 0x36F, 0x330 }; |
137 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c4, 2)); | 137 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c4, 2)); |
138 // Surrogate-Complex is Complex | 138 // Surrogate-Complex is Complex |
139 static UChar c5[] = { 0xD83C, 0xDDE5, 0x330 }; | 139 static UChar c5[] = { 0xD83C, 0xDDE5, 0x330 }; |
140 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c5, 3)); | 140 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c5, 3)); |
141 // Complex-Surrogate is Complex | 141 // Complex-Surrogate is Complex |
142 static UChar c6[] = { 0x330, 0xD83C, 0xDDE5 }; | 142 static UChar c6[] = { 0x330, 0xD83C, 0xDDE5 }; |
143 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c6, 3)); | 143 EXPECT_EQ(ComplexPath, Character::characterRangeCodePath(c6, 3)); |
144 } | 144 } |
145 | 145 |
146 static void TestSpecificUChar32RangeIdeograph(UChar32 rangeStart, | 146 static void TestSpecificUChar32RangeIdeograph(UChar32 rangeStart, UChar32 rangeE
nd) |
147 UChar32 rangeEnd, | |
148 bool before = true) | |
149 { | 147 { |
150 if (before) | 148 EXPECT_FALSE(Character::isCJKIdeograph(rangeStart - 1)); |
151 EXPECT_FALSE(Character::isCJKIdeographOrSymbol(rangeStart - 1)); | 149 EXPECT_TRUE(Character::isCJKIdeograph(rangeStart)); |
152 EXPECT_TRUE(Character::isCJKIdeographOrSymbol(rangeStart)); | 150 EXPECT_TRUE(Character::isCJKIdeograph((UChar32)((uint64_t)rangeStart + (uint
64_t)rangeEnd) / 2)); |
153 EXPECT_TRUE(Character::isCJKIdeographOrSymbol( | 151 EXPECT_TRUE(Character::isCJKIdeograph(rangeEnd)); |
154 (UChar32)((uint64_t)rangeStart + (uint64_t)rangeEnd) / 2)); | 152 EXPECT_FALSE(Character::isCJKIdeograph(rangeEnd + 1)); |
155 EXPECT_TRUE(Character::isCJKIdeographOrSymbol(rangeEnd)); | |
156 EXPECT_FALSE(Character::isCJKIdeographOrSymbol(rangeEnd + 1)); | |
157 } | 153 } |
158 | 154 |
159 TEST(CharacterTest, TestIsCJKIdeograph) | 155 TEST(CharacterTest, TestIsCJKIdeograph) |
160 { | 156 { |
161 // The basic CJK Unified Ideographs block. | 157 // The basic CJK Unified Ideographs block. |
162 TestSpecificUChar32RangeIdeograph(0x4E00, 0x9FFF); | 158 TestSpecificUChar32RangeIdeograph(0x4E00, 0x9FFF); |
163 // CJK Unified Ideographs Extension A. | 159 // CJK Unified Ideographs Extension A. |
164 TestSpecificUChar32RangeIdeograph(0x3400, 0x4DBF, false); | 160 TestSpecificUChar32RangeIdeograph(0x3400, 0x4DBF); |
165 // CJK Unified Ideographs Extension A and Kangxi Radicals. | 161 // CJK Unified Ideographs Extension A and Kangxi Radicals. |
166 TestSpecificUChar32RangeIdeograph(0x2E80, 0x2FDF); | 162 TestSpecificUChar32RangeIdeograph(0x2E80, 0x2FDF); |
167 // CJK Strokes. | 163 // CJK Strokes. |
168 TestSpecificUChar32RangeIdeograph(0x31C0, 0x31EF, false); | 164 TestSpecificUChar32RangeIdeograph(0x31C0, 0x31EF); |
169 // CJK Compatibility Ideographs. | 165 // CJK Compatibility Ideographs. |
170 TestSpecificUChar32RangeIdeograph(0xF900, 0xFAFF); | 166 TestSpecificUChar32RangeIdeograph(0xF900, 0xFAFF); |
171 // CJK Unified Ideographs Extension B. | 167 // CJK Unified Ideographs Extension B. |
172 TestSpecificUChar32RangeIdeograph(0x20000, 0x2A6DF); | 168 TestSpecificUChar32RangeIdeograph(0x20000, 0x2A6DF); |
173 // CJK Unified Ideographs Extension C. | 169 // CJK Unified Ideographs Extension C. |
174 // CJK Unified Ideographs Extension D. | 170 // CJK Unified Ideographs Extension D. |
175 TestSpecificUChar32RangeIdeograph(0x2A700, 0x2B81F); | 171 TestSpecificUChar32RangeIdeograph(0x2A700, 0x2B81F); |
176 // CJK Compatibility Ideographs Supplement. | 172 // CJK Compatibility Ideographs Supplement. |
177 TestSpecificUChar32RangeIdeograph(0x2F800, 0x2FA1F); | 173 TestSpecificUChar32RangeIdeograph(0x2F800, 0x2FA1F); |
178 } | 174 } |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 EXPECT_FALSE(Character::isEmojiModifierBase(0x1F47D)); | 362 EXPECT_FALSE(Character::isEmojiModifierBase(0x1F47D)); |
367 } | 363 } |
368 | 364 |
369 TEST(CharacterTest, LineBreakAndQuoteNotEmoji) | 365 TEST(CharacterTest, LineBreakAndQuoteNotEmoji) |
370 { | 366 { |
371 EXPECT_FALSE(Character::isEmojiTextPresentation('\n')); | 367 EXPECT_FALSE(Character::isEmojiTextPresentation('\n')); |
372 EXPECT_FALSE(Character::isEmojiTextPresentation('"')); | 368 EXPECT_FALSE(Character::isEmojiTextPresentation('"')); |
373 } | 369 } |
374 | 370 |
375 } // namespace blink | 371 } // namespace blink |
OLD | NEW |