15TEST(fxcrt, FXSYS_IsLowerASCII) {
16 EXPECT_TRUE(FXSYS_IsLowerASCII(
'a'));
17 EXPECT_TRUE(FXSYS_IsLowerASCII(L'a'));
18 EXPECT_TRUE(FXSYS_IsLowerASCII(
'b'));
19 EXPECT_TRUE(FXSYS_IsLowerASCII(L'b'));
20 EXPECT_TRUE(FXSYS_IsLowerASCII(
'y'));
21 EXPECT_TRUE(FXSYS_IsLowerASCII(L'y'));
22 EXPECT_TRUE(FXSYS_IsLowerASCII(
'z'));
23 EXPECT_TRUE(FXSYS_IsLowerASCII(L'z'));
24 EXPECT_FALSE(FXSYS_IsLowerASCII(
'`'));
25 EXPECT_FALSE(FXSYS_IsLowerASCII(L'`'));
26 EXPECT_FALSE(FXSYS_IsLowerASCII(
'{'));
27 EXPECT_FALSE(FXSYS_IsLowerASCII(L'{'));
28 EXPECT_FALSE(FXSYS_IsLowerASCII(
'Z'));
29 EXPECT_FALSE(FXSYS_IsLowerASCII(L'Z'));
30 EXPECT_FALSE(FXSYS_IsLowerASCII(
'7'));
31 EXPECT_FALSE(FXSYS_IsLowerASCII(L'7'));
32 EXPECT_FALSE(FXSYS_IsLowerASCII(
static_cast<
char>(-78)));
33 EXPECT_FALSE(FXSYS_IsLowerASCII(
static_cast<
wchar_t>(0xb2)));
36TEST(fxcrt, FXSYS_IsUpperASCII) {
37 EXPECT_TRUE(FXSYS_IsUpperASCII(
'A'));
38 EXPECT_TRUE(FXSYS_IsUpperASCII(L'A'));
39 EXPECT_TRUE(FXSYS_IsUpperASCII(
'B'));
40 EXPECT_TRUE(FXSYS_IsUpperASCII(L'B'));
41 EXPECT_TRUE(FXSYS_IsUpperASCII(
'Y'));
42 EXPECT_TRUE(FXSYS_IsUpperASCII(L'Y'));
43 EXPECT_TRUE(FXSYS_IsUpperASCII(
'Z'));
44 EXPECT_TRUE(FXSYS_IsUpperASCII(L'Z'));
45 EXPECT_FALSE(FXSYS_IsUpperASCII(
'@'));
46 EXPECT_FALSE(FXSYS_IsUpperASCII(L'@'));
47 EXPECT_FALSE(FXSYS_IsUpperASCII(
'['));
48 EXPECT_FALSE(FXSYS_IsUpperASCII(L'['));
49 EXPECT_FALSE(FXSYS_IsUpperASCII(
'z'));
50 EXPECT_FALSE(FXSYS_IsUpperASCII(L'z'));
51 EXPECT_FALSE(FXSYS_IsUpperASCII(
'7'));
52 EXPECT_FALSE(FXSYS_IsUpperASCII(L'7'));
53 EXPECT_FALSE(FXSYS_IsUpperASCII(
static_cast<
char>(-78)));
54 EXPECT_FALSE(FXSYS_IsUpperASCII(
static_cast<
wchar_t>(0xb2)));
57TEST(fxcrt, FXSYS_HexCharToInt) {
58 EXPECT_EQ(10, FXSYS_HexCharToInt(
'a'));
59 EXPECT_EQ(10, FXSYS_HexCharToInt(
'A'));
60 EXPECT_EQ(7, FXSYS_HexCharToInt(
'7'));
61 EXPECT_EQ(0, FXSYS_HexCharToInt(
'i'));
64TEST(fxcrt, FXSYS_DecimalCharToInt) {
65 EXPECT_EQ(7, FXSYS_DecimalCharToInt(
'7'));
66 EXPECT_EQ(0, FXSYS_DecimalCharToInt(
'a'));
67 EXPECT_EQ(7, FXSYS_DecimalCharToInt(L'7'));
68 EXPECT_EQ(0, FXSYS_DecimalCharToInt(L'a'));
69 EXPECT_EQ(0, FXSYS_DecimalCharToInt(
static_cast<
char>(-78)));
70 EXPECT_EQ(0, FXSYS_DecimalCharToInt(
static_cast<
wchar_t>(0xb2)));
73TEST(fxcrt, FXSYS_IsDecimalDigit) {
74 EXPECT_TRUE(FXSYS_IsDecimalDigit(
'7'));
75 EXPECT_TRUE(FXSYS_IsDecimalDigit(L'7'));
76 EXPECT_FALSE(FXSYS_IsDecimalDigit(
'a'));
77 EXPECT_FALSE(FXSYS_IsDecimalDigit(L'a'));
78 EXPECT_FALSE(FXSYS_IsDecimalDigit(
static_cast<
char>(-78)));
79 EXPECT_FALSE(FXSYS_IsDecimalDigit(
static_cast<
wchar_t>(0xb2)));
82TEST(fxcrt, FXSYS_IntToTwoHexChars) {
84 FXSYS_IntToTwoHexChars(0x0, buf);
85 EXPECT_STREQ(
"00", buf);
86 FXSYS_IntToTwoHexChars(0x9, buf);
87 EXPECT_STREQ(
"09", buf);
88 FXSYS_IntToTwoHexChars(0xA, buf);
89 EXPECT_STREQ(
"0A", buf);
90 FXSYS_IntToTwoHexChars(0x8C, buf);
91 EXPECT_STREQ(
"8C", buf);
92 FXSYS_IntToTwoHexChars(0xBE, buf);
93 EXPECT_STREQ(
"BE", buf);
94 FXSYS_IntToTwoHexChars(0xD0, buf);
95 EXPECT_STREQ(
"D0", buf);
96 FXSYS_IntToTwoHexChars(0xFF, buf);
97 EXPECT_STREQ(
"FF", buf);
100TEST(fxcrt, FXSYS_IntToFourHexChars) {
102 FXSYS_IntToFourHexChars(0x0, buf);
103 EXPECT_STREQ(
"0000", buf);
104 FXSYS_IntToFourHexChars(0xA23, buf);
105 EXPECT_STREQ(
"0A23", buf);
106 FXSYS_IntToFourHexChars(0xB701, buf);
107 EXPECT_STREQ(
"B701", buf);
108 FXSYS_IntToFourHexChars(0xFFFF, buf);
109 EXPECT_STREQ(
"FFFF", buf);
115 EXPECT_EQ(4U, FXSYS_ToUTF16BE(0x0, buf));
116 EXPECT_STREQ(
"0000", buf);
117 EXPECT_EQ(4U, FXSYS_ToUTF16BE(0xD7FF, buf));
118 EXPECT_STREQ(
"D7FF", buf);
119 EXPECT_EQ(4U, FXSYS_ToUTF16BE(0xE000, buf));
120 EXPECT_STREQ(
"E000", buf);
121 EXPECT_EQ(4U, FXSYS_ToUTF16BE(0xFFFF, buf));
122 EXPECT_STREQ(
"FFFF", buf);
124 EXPECT_EQ(8U, FXSYS_ToUTF16BE(0x10000, buf));
125 EXPECT_STREQ(
"D800DC00", buf);
126 EXPECT_EQ(8U, FXSYS_ToUTF16BE(0x10FFFF, buf));
127 EXPECT_STREQ(
"DBFFDFFF", buf);
128 EXPECT_EQ(8U, FXSYS_ToUTF16BE(0x2003E, buf));
129 EXPECT_STREQ(
"D840DC3E", buf);
134 EXPECT_FLOAT_EQ(-12.0f, FXSYS_wcstof(L"-12", 3, &used_len));
135 EXPECT_EQ(3u, used_len);
138 EXPECT_FLOAT_EQ(1.5362f, FXSYS_wcstof(L"1.5362", 6, &used_len));
139 EXPECT_EQ(6u, used_len);
142 EXPECT_FLOAT_EQ(0.875f, FXSYS_wcstof(L"0.875", 5, &used_len));
143 EXPECT_EQ(5u, used_len);
146 EXPECT_FLOAT_EQ(5.56e-2f, FXSYS_wcstof(L"5.56e-2", 7, &used_len));
147 EXPECT_EQ(7u, used_len);
150 EXPECT_FLOAT_EQ(1.234e10f, FXSYS_wcstof(L"1.234E10", 8, &used_len));
151 EXPECT_EQ(8u, used_len);
154 EXPECT_FLOAT_EQ(0.0f, FXSYS_wcstof(L"1.234E100000000000000", 21, &used_len));
155 EXPECT_EQ(0u, used_len);
158 EXPECT_FLOAT_EQ(0.0f, FXSYS_wcstof(L"1.234E-128", 21, &used_len));
159 EXPECT_EQ(0u, used_len);
164 EXPECT_FLOAT_EQ(123456789.012345678f,
165 FXSYS_wcstof(L"123456789.012345678", 19, &used_len));
166 EXPECT_EQ(19u, used_len);
172 EXPECT_FLOAT_EQ(99999999999999999.0f,
173 FXSYS_wcstof(L"99999999999999999", 17, &used_len));
174 EXPECT_EQ(17u, used_len);
177 EXPECT_FLOAT_EQ(0.0f, FXSYS_wcstof(L"e76", 3,
nullptr));
181 EXPECT_TRUE(isinf(FXSYS_wcstof(
182 L"88888888888888888888888888888888888888888888888888888888888888888888888"
183 L"88888888888888888888888888888888888888888888888888888888888",
185 EXPECT_EQ(130u, used_len);
188 EXPECT_TRUE(isinf(FXSYS_wcstof(
189 L"-8888888888888888888888888888888888888888888888888888888888888888888888"
190 L"888888888888888888888888888888888888888888888888888888888888",
192 EXPECT_EQ(131u, used_len);
196 EXPECT_EQ(FXSYS_wcsnicmp(L"foo", L"foo", 1), 0);
197 EXPECT_EQ(FXSYS_wcsnicmp(L"foo", L"foo", 2), 0);
198 EXPECT_EQ(FXSYS_wcsnicmp(L"foo", L"foo", 3), 0);
200 EXPECT_GT(FXSYS_wcsnicmp(L"foo", L"barr", 3), 0);
201 EXPECT_LT(FXSYS_wcsnicmp(L"bar", L"fooo", 3), 0);
203 EXPECT_EQ(FXSYS_wcsnicmp(L"FOO", L"foo", 3), 0);
204 EXPECT_EQ(FXSYS_wcsnicmp(L"foO", L"Foo", 3), 0);
205 EXPECT_EQ(FXSYS_wcsnicmp(L"food", L"FOOT", 3), 0);
206 EXPECT_LT(FXSYS_wcsnicmp(L"food", L"FOOT", 4), 0);
208 const wchar_t kMax16bitSigned[] = {
209 static_cast<
wchar_t>(std::numeric_limits<int16_t>::max()), 0};
210 EXPECT_GT(FXSYS_wcsnicmp(kMax16bitSigned, L"f", 1), 0);
211 const wchar_t kMax16bitUnsigned[] = {
212 static_cast<
wchar_t>(std::numeric_limits<uint16_t>::max()), 0};
213 EXPECT_GT(FXSYS_wcsnicmp(kMax16bitUnsigned, L"f", 1), 0);
215#if defined(WCHAR_T_IS_32_BIT)
216 const wchar_t kMaxUnicode[] = {
static_cast<
wchar_t>(0x10ffff), 0};
217 EXPECT_GT(FXSYS_wcsnicmp(kMaxUnicode, L"f", 1), 0);
222 const float fMin =
std::numeric_limits<
float>::min();
223 const float fMax =
std::numeric_limits<
float>::max();
224 const float fInf =
std::numeric_limits<
float>::infinity();
225 const float fNan =
std::numeric_limits<
float>::quiet_NaN();
226 const float ascending[] = {fMin, 1.0f, 2.0f, fMax, fInf, fNan};
228 for (size_t i = 0; i <
std::size(ascending); ++i) {
229 for (size_t j = 0; j <
std::size(ascending); ++j) {
231 EXPECT_TRUE(FXSYS_SafeEQ(ascending[i], ascending[j]))
232 <<
" at " << i <<
" " << j;
234 EXPECT_FALSE(FXSYS_SafeEQ(ascending[i], ascending[j]))
235 <<
" at " << i <<
" " << j;
238 EXPECT_TRUE(FXSYS_SafeLT(ascending[i], ascending[j]))
239 <<
" at " << i <<
" " << j;
241 EXPECT_FALSE(FXSYS_SafeLT(ascending[i], ascending[j]))
242 <<
" at " << i <<
" " << j;