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