1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <gtest/gtest.h>
18
19 #include <unicode/uchar.h>
20
21 #include <minikin/Emoji.h>
22
23 namespace minikin {
24
TEST(EmojiTest,isEmojiTest)25 TEST(EmojiTest, isEmojiTest) {
26 EXPECT_TRUE(isEmoji(0x0023)); // NUMBER SIGN
27 EXPECT_TRUE(isEmoji(0x0035)); // DIGIT FIVE
28 EXPECT_TRUE(isEmoji(0x2640)); // FEMALE SIGN
29 EXPECT_TRUE(isEmoji(0x2642)); // MALE SIGN
30 EXPECT_TRUE(isEmoji(0x2695)); // STAFF OF AESCULAPIUS
31 EXPECT_TRUE(isEmoji(0x1F0CF)); // PLAYING CARD BLACK JOKER
32 EXPECT_TRUE(isEmoji(0x1F1E9)); // REGIONAL INDICATOR SYMBOL LETTER D
33 EXPECT_TRUE(isEmoji(0x1F6F7)); // SLED
34 EXPECT_TRUE(isEmoji(0x1F9E6)); // SOCKS
35
36 EXPECT_FALSE(isEmoji(0x0000)); // <control>
37 EXPECT_FALSE(isEmoji(0x0061)); // LATIN SMALL LETTER A
38 EXPECT_FALSE(isEmoji(0x1F93B)); // MODERN PENTATHLON
39 EXPECT_FALSE(isEmoji(0x1F946)); // RIFLE
40 EXPECT_FALSE(isEmoji(0x29E3D)); // A han character.
41 }
42
TEST(EmojiTest,isEmojiModifierTest)43 TEST(EmojiTest, isEmojiModifierTest) {
44 EXPECT_TRUE(isEmojiModifier(0x1F3FB)); // EMOJI MODIFIER FITZPATRICK TYPE-1-2
45 EXPECT_TRUE(isEmojiModifier(0x1F3FC)); // EMOJI MODIFIER FITZPATRICK TYPE-3
46 EXPECT_TRUE(isEmojiModifier(0x1F3FD)); // EMOJI MODIFIER FITZPATRICK TYPE-4
47 EXPECT_TRUE(isEmojiModifier(0x1F3FE)); // EMOJI MODIFIER FITZPATRICK TYPE-5
48 EXPECT_TRUE(isEmojiModifier(0x1F3FF)); // EMOJI MODIFIER FITZPATRICK TYPE-6
49
50 EXPECT_FALSE(isEmojiModifier(0x0000)); // <control>
51 EXPECT_FALSE(isEmojiModifier(0x1F3FA)); // AMPHORA
52 EXPECT_FALSE(isEmojiModifier(0x1F400)); // RAT
53 EXPECT_FALSE(isEmojiModifier(0x29E3D)); // A han character.
54 }
55
TEST(EmojiTest,isEmojiBaseTest)56 TEST(EmojiTest, isEmojiBaseTest) {
57 EXPECT_TRUE(isEmojiBase(0x261D)); // WHITE UP POINTING INDEX
58 EXPECT_TRUE(isEmojiBase(0x270D)); // WRITING HAND
59 EXPECT_TRUE(isEmojiBase(0x1F385)); // FATHER CHRISTMAS
60 EXPECT_TRUE(isEmojiBase(0x1F3C2)); // SNOWBOARDER
61 EXPECT_TRUE(isEmojiBase(0x1F3C7)); // HORSE RACING
62 EXPECT_TRUE(isEmojiBase(0x1F3CC)); // GOLFER
63 EXPECT_TRUE(isEmojiBase(0x1F574)); // MAN IN BUSINESS SUIT LEVITATING
64 EXPECT_TRUE(isEmojiBase(0x1F6CC)); // SLEEPING ACCOMMODATION
65 EXPECT_TRUE(isEmojiBase(0x1F91D)); // HANDSHAKE (removed from Emoji 4.0, but we need it)
66 EXPECT_TRUE(isEmojiBase(0x1F91F)); // I LOVE YOU HAND SIGN
67 EXPECT_TRUE(isEmojiBase(0x1F931)); // BREAST-FEEDING
68 EXPECT_TRUE(isEmojiBase(0x1F932)); // PALMS UP TOGETHER
69 EXPECT_TRUE(isEmojiBase(0x1F93C)); // WRESTLERS (removed from Emoji 4.0, but we need it)
70 EXPECT_TRUE(isEmojiBase(0x1F9D1)); // ADULT
71 EXPECT_TRUE(isEmojiBase(0x1F9DD)); // ELF
72
73 EXPECT_FALSE(isEmojiBase(0x0000)); // <control>
74 EXPECT_FALSE(isEmojiBase(0x261C)); // WHITE LEFT POINTING INDEX
75 EXPECT_FALSE(isEmojiBase(0x1F384)); // CHRISTMAS TREE
76 EXPECT_FALSE(isEmojiBase(0x1F9DE)); // GENIE
77 EXPECT_FALSE(isEmojiBase(0x29E3D)); // A han character.
78 }
79
TEST(EmojiTest,emojiBidiOverrideTest)80 TEST(EmojiTest, emojiBidiOverrideTest) {
81 EXPECT_EQ(U_RIGHT_TO_LEFT, emojiBidiOverride(nullptr, 0x05D0)); // HEBREW LETTER ALEF
82 EXPECT_EQ(U_LEFT_TO_RIGHT,
83 emojiBidiOverride(nullptr, 0x1F170)); // NEGATIVE SQUARED LATIN CAPITAL LETTER A
84 EXPECT_EQ(U_OTHER_NEUTRAL, emojiBidiOverride(nullptr, 0x1F6F7)); // SLED
85 EXPECT_EQ(U_OTHER_NEUTRAL, emojiBidiOverride(nullptr, 0x1F9E6)); // SOCKS
86 }
87
88 } // namespace minikin
89