| 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, UChar32 rangeE
nd) | 146 static void TestSpecificUChar32RangeIdeograph(UChar32 rangeStart, |
| 147 UChar32 rangeEnd, |
| 148 bool before = true) |
| 147 { | 149 { |
| 148 EXPECT_FALSE(Character::isCJKIdeograph(rangeStart - 1)); | 150 if (before) |
| 149 EXPECT_TRUE(Character::isCJKIdeograph(rangeStart)); | 151 EXPECT_FALSE(Character::isCJKIdeographOrSymbol(rangeStart - 1)); |
| 150 EXPECT_TRUE(Character::isCJKIdeograph((UChar32)((uint64_t)rangeStart + (uint
64_t)rangeEnd) / 2)); | 152 EXPECT_TRUE(Character::isCJKIdeographOrSymbol(rangeStart)); |
| 151 EXPECT_TRUE(Character::isCJKIdeograph(rangeEnd)); | 153 EXPECT_TRUE(Character::isCJKIdeographOrSymbol( |
| 152 EXPECT_FALSE(Character::isCJKIdeograph(rangeEnd + 1)); | 154 (UChar32)((uint64_t)rangeStart + (uint64_t)rangeEnd) / 2)); |
| 155 EXPECT_TRUE(Character::isCJKIdeographOrSymbol(rangeEnd)); |
| 156 EXPECT_FALSE(Character::isCJKIdeographOrSymbol(rangeEnd + 1)); |
| 153 } | 157 } |
| 154 | 158 |
| 155 TEST(CharacterTest, TestIsCJKIdeograph) | 159 TEST(CharacterTest, TestIsCJKIdeograph) |
| 156 { | 160 { |
| 157 // The basic CJK Unified Ideographs block. | 161 // The basic CJK Unified Ideographs block. |
| 158 TestSpecificUChar32RangeIdeograph(0x4E00, 0x9FFF); | 162 TestSpecificUChar32RangeIdeograph(0x4E00, 0x9FFF); |
| 159 // CJK Unified Ideographs Extension A. | 163 // CJK Unified Ideographs Extension A. |
| 160 TestSpecificUChar32RangeIdeograph(0x3400, 0x4DBF); | 164 TestSpecificUChar32RangeIdeograph(0x3400, 0x4DBF, false); |
| 161 // CJK Unified Ideographs Extension A and Kangxi Radicals. | 165 // CJK Unified Ideographs Extension A and Kangxi Radicals. |
| 162 TestSpecificUChar32RangeIdeograph(0x2E80, 0x2FDF); | 166 TestSpecificUChar32RangeIdeograph(0x2E80, 0x2FDF); |
| 163 // CJK Strokes. | 167 // CJK Strokes. |
| 164 TestSpecificUChar32RangeIdeograph(0x31C0, 0x31EF); | 168 TestSpecificUChar32RangeIdeograph(0x31C0, 0x31EF, false); |
| 165 // CJK Compatibility Ideographs. | 169 // CJK Compatibility Ideographs. |
| 166 TestSpecificUChar32RangeIdeograph(0xF900, 0xFAFF); | 170 TestSpecificUChar32RangeIdeograph(0xF900, 0xFAFF); |
| 167 // CJK Unified Ideographs Extension B. | 171 // CJK Unified Ideographs Extension B. |
| 168 TestSpecificUChar32RangeIdeograph(0x20000, 0x2A6DF); | 172 TestSpecificUChar32RangeIdeograph(0x20000, 0x2A6DF); |
| 169 // CJK Unified Ideographs Extension C. | 173 // CJK Unified Ideographs Extension C. |
| 170 // CJK Unified Ideographs Extension D. | 174 // CJK Unified Ideographs Extension D. |
| 171 TestSpecificUChar32RangeIdeograph(0x2A700, 0x2B81F); | 175 TestSpecificUChar32RangeIdeograph(0x2A700, 0x2B81F); |
| 172 // CJK Compatibility Ideographs Supplement. | 176 // CJK Compatibility Ideographs Supplement. |
| 173 TestSpecificUChar32RangeIdeograph(0x2F800, 0x2FA1F); | 177 TestSpecificUChar32RangeIdeograph(0x2F800, 0x2FA1F); |
| 174 } | 178 } |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 EXPECT_FALSE(Character::isEmojiModifierBase(0x1F47D)); | 366 EXPECT_FALSE(Character::isEmojiModifierBase(0x1F47D)); |
| 363 } | 367 } |
| 364 | 368 |
| 365 TEST(CharacterTest, LineBreakAndQuoteNotEmoji) | 369 TEST(CharacterTest, LineBreakAndQuoteNotEmoji) |
| 366 { | 370 { |
| 367 EXPECT_FALSE(Character::isEmojiTextPresentation('\n')); | 371 EXPECT_FALSE(Character::isEmojiTextPresentation('\n')); |
| 368 EXPECT_FALSE(Character::isEmojiTextPresentation('"')); | 372 EXPECT_FALSE(Character::isEmojiTextPresentation('"')); |
| 369 } | 373 } |
| 370 | 374 |
| 371 } // namespace blink | 375 } // namespace blink |
| OLD | NEW |