1*0e209d39SAndroid Build Coastguard Worker /*
2*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2020 The Android Open Source Project
3*0e209d39SAndroid Build Coastguard Worker *
4*0e209d39SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*0e209d39SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*0e209d39SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*0e209d39SAndroid Build Coastguard Worker *
8*0e209d39SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*0e209d39SAndroid Build Coastguard Worker *
10*0e209d39SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*0e209d39SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*0e209d39SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*0e209d39SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*0e209d39SAndroid Build Coastguard Worker * limitations under the License.
15*0e209d39SAndroid Build Coastguard Worker */
16*0e209d39SAndroid Build Coastguard Worker
17*0e209d39SAndroid Build Coastguard Worker #include <gtest/gtest.h>
18*0e209d39SAndroid Build Coastguard Worker
19*0e209d39SAndroid Build Coastguard Worker #include <unicode/uchar.h>
20*0e209d39SAndroid Build Coastguard Worker
TEST(Icu4cUCharTest,test_u_hasBinaryProperty)21*0e209d39SAndroid Build Coastguard Worker TEST(Icu4cUCharTest, test_u_hasBinaryProperty) {
22*0e209d39SAndroid Build Coastguard Worker ASSERT_TRUE(u_hasBinaryProperty(U' ' /* ascii space */, UCHAR_WHITE_SPACE));
23*0e209d39SAndroid Build Coastguard Worker ASSERT_TRUE(u_hasBinaryProperty(8200 /* Punctuation space U+2008 */, UCHAR_WHITE_SPACE));
24*0e209d39SAndroid Build Coastguard Worker ASSERT_TRUE(u_hasBinaryProperty(U'❤' /* Emoji heart U+2764 */, UCHAR_EMOJI));
25*0e209d39SAndroid Build Coastguard Worker ASSERT_FALSE(u_hasBinaryProperty(U'❤' /* Emoji heart U+2764 */, UCHAR_WHITE_SPACE));
26*0e209d39SAndroid Build Coastguard Worker }
27*0e209d39SAndroid Build Coastguard Worker
TEST(Icu4cUCharTest,test_u_toupper)28*0e209d39SAndroid Build Coastguard Worker TEST(Icu4cUCharTest, test_u_toupper) {
29*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(U'A', u_toupper(U'a'));
30*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(U'A', u_toupper(U'A'));
31*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(U'1', u_toupper(U'1'));
32*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(U'Ë', u_toupper(U'ë'));
33*0e209d39SAndroid Build Coastguard Worker }
34*0e209d39SAndroid Build Coastguard Worker
TEST(Icu4cUCharTest,test_u_charFromName)35*0e209d39SAndroid Build Coastguard Worker TEST(Icu4cUCharTest, test_u_charFromName) {
36*0e209d39SAndroid Build Coastguard Worker UErrorCode err;
37*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(0x0020, u_charFromName(U_UNICODE_CHAR_NAME, "SPACE", &err));
38*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(0x0061, u_charFromName(U_UNICODE_CHAR_NAME, "LATIN SMALL LETTER A", &err));
39*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(0x0042, u_charFromName(U_UNICODE_CHAR_NAME, "LATIN CAPITAL LETTER B", &err));
40*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(0x00a2, u_charFromName(U_UNICODE_CHAR_NAME, "CENT SIGN", &err));
41*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(0xffe5, u_charFromName(U_UNICODE_CHAR_NAME, "FULLWIDTH YEN SIGN", &err));
42*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(0x3401, u_charFromName(U_UNICODE_CHAR_NAME, "CJK UNIFIED IDEOGRAPH-3401", &err));
43*0e209d39SAndroid Build Coastguard Worker }
44