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/text/Character.h" | 5 #include "platform/text/Character.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "wtf/text/CharacterNames.h" | 8 #include "wtf/text/CharacterNames.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 testing::AssertionResult isCJKIdeographOrSymbolWithMessage(UChar32 codepoint) { | 12 testing::AssertionResult isCJKIdeographOrSymbolWithMessage(UChar32 codepoint) { |
13 const size_t formatBufferSize = 10; | 13 const size_t formatBufferSize = 10; |
14 char formattedAsHex[formatBufferSize]; | 14 char formattedAsHex[formatBufferSize]; |
15 snprintf(formattedAsHex, formatBufferSize, "0x%x", codepoint); | 15 snprintf(formattedAsHex, formatBufferSize, "0x%x", codepoint); |
16 | 16 |
17 if (Character::isCJKIdeographOrSymbol(codepoint)) { | 17 if (Character::isCJKIdeographOrSymbol(codepoint)) { |
18 return testing::AssertionSuccess() << "Codepoint " << formattedAsHex | 18 return testing::AssertionSuccess() |
19 << " is a CJKIdeographOrSymbol."; | 19 << "Codepoint " << formattedAsHex << " is a CJKIdeographOrSymbol."; |
20 } | 20 } |
21 | 21 |
22 return testing::AssertionFailure() << "Codepoint " << formattedAsHex | 22 return testing::AssertionFailure() |
23 << " is not a CJKIdeographOrSymbol."; | 23 << "Codepoint " << formattedAsHex << " is not a CJKIdeographOrSymbol."; |
24 } | 24 } |
25 | 25 |
26 TEST(CharacterTest, HammerEmojiVsCJKIdeographOrSymbol) { | 26 TEST(CharacterTest, HammerEmojiVsCJKIdeographOrSymbol) { |
27 for (UChar32 testChar = 0; testChar < kMaxCodepoint; testChar++) { | 27 for (UChar32 testChar = 0; testChar < kMaxCodepoint; testChar++) { |
28 if (Character::isEmojiEmojiDefault(testChar)) { | 28 if (Character::isEmojiEmojiDefault(testChar)) { |
29 EXPECT_TRUE(isCJKIdeographOrSymbolWithMessage(testChar)); | 29 EXPECT_TRUE(isCJKIdeographOrSymbolWithMessage(testChar)); |
30 } | 30 } |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 testChar = base + objectReplacementCharacter; | 299 testChar = base + objectReplacementCharacter; |
300 EXPECT_FALSE(Character::treatAsZeroWidthSpaceInComplexScript(testChar)); | 300 EXPECT_FALSE(Character::treatAsZeroWidthSpaceInComplexScript(testChar)); |
301 | 301 |
302 testChar = base + 0xA; | 302 testChar = base + 0xA; |
303 EXPECT_FALSE(Character::isNormalizedCanvasSpaceCharacter(testChar)); | 303 EXPECT_FALSE(Character::isNormalizedCanvasSpaceCharacter(testChar)); |
304 testChar = base + 0x9; | 304 testChar = base + 0x9; |
305 EXPECT_FALSE(Character::isNormalizedCanvasSpaceCharacter(testChar)); | 305 EXPECT_FALSE(Character::isNormalizedCanvasSpaceCharacter(testChar)); |
306 } | 306 } |
307 | 307 |
308 } // namespace blink | 308 } // namespace blink |
OLD | NEW |