• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "minikin/Emoji.h"
18 
19 #include <gtest/gtest.h>
20 #include <unicode/uchar.h>
21 
22 namespace minikin {
23 
TEST(EmojiTest,isEmojiTest)24 TEST(EmojiTest, isEmojiTest) {
25     EXPECT_TRUE(isEmoji(0x0023));   // NUMBER SIGN
26     EXPECT_TRUE(isEmoji(0x0035));   // DIGIT FIVE
27     EXPECT_TRUE(isEmoji(0x2640));   // FEMALE SIGN
28     EXPECT_TRUE(isEmoji(0x2642));   // MALE SIGN
29     EXPECT_TRUE(isEmoji(0x2695));   // STAFF OF AESCULAPIUS
30     EXPECT_TRUE(isEmoji(0x1F0CF));  // PLAYING CARD BLACK JOKER
31     EXPECT_TRUE(isEmoji(0x1F1E9));  // REGIONAL INDICATOR SYMBOL LETTER D
32     EXPECT_TRUE(isEmoji(0x1F6F7));  // SLED
33     EXPECT_TRUE(isEmoji(0x1F9E6));  // SOCKS
34 
35     EXPECT_TRUE(isEmoji(0x1F6D5));  // HINDU TEMPLE
36     EXPECT_TRUE(isEmoji(0x1F7E7));  // ORANGE SQUARE
37     EXPECT_TRUE(isEmoji(0x1F9CF));  // DEAF PERSON
38     EXPECT_TRUE(isEmoji(0x1F9CE));  // PERSON KNEELING
39     EXPECT_TRUE(isEmoji(0x1F9A6));  // OTTER
40     EXPECT_TRUE(isEmoji(0x1F9A9));  // FLAMINGO
41     EXPECT_TRUE(isEmoji(0x1F9C6));  // FALAFEL
42     EXPECT_TRUE(isEmoji(0x1F9AA));  // OYSTER
43     EXPECT_TRUE(isEmoji(0x1FA82));  // PARACHUTE
44     EXPECT_TRUE(isEmoji(0x1FA80));  // YO-YO
45     EXPECT_TRUE(isEmoji(0x1FA70));  // BALLET SHOES
46     EXPECT_TRUE(isEmoji(0x1FA79));  // ADHESIVE BANDAGE
47 
48     EXPECT_FALSE(isEmoji(0x0000));   // <control>
49     EXPECT_FALSE(isEmoji(0x0061));   // LATIN SMALL LETTER A
50     EXPECT_FALSE(isEmoji(0x1F93B));  // MODERN PENTATHLON
51     EXPECT_FALSE(isEmoji(0x1F946));  // RIFLE
52     EXPECT_FALSE(isEmoji(0x29E3D));  // A han character.
53 }
54 
TEST(EmojiTest,isEmojiModifierTest)55 TEST(EmojiTest, isEmojiModifierTest) {
56     EXPECT_TRUE(isEmojiModifier(0x1F3FB));  // EMOJI MODIFIER FITZPATRICK TYPE-1-2
57     EXPECT_TRUE(isEmojiModifier(0x1F3FC));  // EMOJI MODIFIER FITZPATRICK TYPE-3
58     EXPECT_TRUE(isEmojiModifier(0x1F3FD));  // EMOJI MODIFIER FITZPATRICK TYPE-4
59     EXPECT_TRUE(isEmojiModifier(0x1F3FE));  // EMOJI MODIFIER FITZPATRICK TYPE-5
60     EXPECT_TRUE(isEmojiModifier(0x1F3FF));  // EMOJI MODIFIER FITZPATRICK TYPE-6
61 
62     EXPECT_FALSE(isEmojiModifier(0x0000));   // <control>
63     EXPECT_FALSE(isEmojiModifier(0x1F3FA));  // AMPHORA
64     EXPECT_FALSE(isEmojiModifier(0x1F400));  // RAT
65     EXPECT_FALSE(isEmojiModifier(0x29E3D));  // A han character.
66 }
67 
TEST(EmojiTest,isEmojiBaseTest)68 TEST(EmojiTest, isEmojiBaseTest) {
69     EXPECT_TRUE(isEmojiBase(0x261D));   // WHITE UP POINTING INDEX
70     EXPECT_TRUE(isEmojiBase(0x270D));   // WRITING HAND
71     EXPECT_TRUE(isEmojiBase(0x1F385));  // FATHER CHRISTMAS
72     EXPECT_TRUE(isEmojiBase(0x1F3C2));  // SNOWBOARDER
73     EXPECT_TRUE(isEmojiBase(0x1F3C7));  // HORSE RACING
74     EXPECT_TRUE(isEmojiBase(0x1F3CC));  // GOLFER
75     EXPECT_TRUE(isEmojiBase(0x1F574));  // MAN IN BUSINESS SUIT LEVITATING
76     EXPECT_TRUE(isEmojiBase(0x1F6CC));  // SLEEPING ACCOMMODATION
77     EXPECT_TRUE(isEmojiBase(0x1F91D));  // HANDSHAKE (removed from Emoji 4.0, but we need it)
78     EXPECT_TRUE(isEmojiBase(0x1F91F));  // I LOVE YOU HAND SIGN
79     EXPECT_TRUE(isEmojiBase(0x1F931));  // BREAST-FEEDING
80     EXPECT_TRUE(isEmojiBase(0x1F932));  // PALMS UP TOGETHER
81     EXPECT_TRUE(isEmojiBase(0x1F93C));  // WRESTLERS (removed from Emoji 4.0, but we need it)
82     EXPECT_TRUE(isEmojiBase(0x1F9D1));  // ADULT
83     EXPECT_TRUE(isEmojiBase(0x1F9DD));  // ELF
84 
85     EXPECT_FALSE(isEmojiBase(0x0000));   // <control>
86     EXPECT_FALSE(isEmojiBase(0x261C));   // WHITE LEFT POINTING INDEX
87     EXPECT_FALSE(isEmojiBase(0x1F384));  // CHRISTMAS TREE
88     EXPECT_FALSE(isEmojiBase(0x1F9DE));  // GENIE
89     EXPECT_FALSE(isEmojiBase(0x29E3D));  // A han character.
90 }
91 
TEST(EmojiTest,emojiBidiOverrideTest)92 TEST(EmojiTest, emojiBidiOverrideTest) {
93     EXPECT_EQ(U_RIGHT_TO_LEFT, emojiBidiOverride(nullptr, 0x05D0));  // HEBREW LETTER ALEF
94     EXPECT_EQ(U_LEFT_TO_RIGHT,
95               emojiBidiOverride(nullptr, 0x1F170));  // NEGATIVE SQUARED LATIN CAPITAL LETTER A
96     EXPECT_EQ(U_OTHER_NEUTRAL, emojiBidiOverride(nullptr, 0x1F6F7));  // SLED
97     EXPECT_EQ(U_OTHER_NEUTRAL, emojiBidiOverride(nullptr, 0x1F9E6));  // SOCKS
98 }
99 
100 }  // namespace minikin
101