68 EXPECT_FLOAT_EQ(0.0f, StringToFloat(
""));
69 EXPECT_FLOAT_EQ(0.0f, StringToFloat(
"0"));
70 EXPECT_FLOAT_EQ(0.0f, StringToFloat(
"0.0"));
71 EXPECT_FLOAT_EQ(0.0f, StringToFloat(
"-0.0"));
73 EXPECT_FLOAT_EQ(0.25f, StringToFloat(
"0.25"));
74 EXPECT_FLOAT_EQ(-0.25f, StringToFloat(
"-0.25"));
76 EXPECT_FLOAT_EQ(100.0f, StringToFloat(
"100"));
77 EXPECT_FLOAT_EQ(100.0f, StringToFloat(
"100.0"));
78 EXPECT_FLOAT_EQ(100.0f, StringToFloat(
" 100.0"));
79 EXPECT_FLOAT_EQ(-100.0f, StringToFloat(
"-100.0000"));
81 EXPECT_FLOAT_EQ(3.402823e+38f,
82 StringToFloat(
"340282300000000000000000000000000000000"));
83 EXPECT_FLOAT_EQ(-3.402823e+38f,
84 StringToFloat(
"-340282300000000000000000000000000000000"));
86 EXPECT_FLOAT_EQ(1.000000119f, StringToFloat(
"1.000000119"));
87 EXPECT_FLOAT_EQ(1.999999881f, StringToFloat(
"1.999999881"));
91 EXPECT_FLOAT_EQ(0.0f, StringToFloat(L""));
92 EXPECT_FLOAT_EQ(0.0f, StringToFloat(L"0"));
93 EXPECT_FLOAT_EQ(0.0f, StringToFloat(L"0.0"));
94 EXPECT_FLOAT_EQ(0.0f, StringToFloat(L"-0.0"));
96 EXPECT_FLOAT_EQ(0.25f, StringToFloat(L"0.25"));
97 EXPECT_FLOAT_EQ(-0.25f, StringToFloat(L"-0.25"));
99 EXPECT_FLOAT_EQ(100.0f, StringToFloat(L"100"));
100 EXPECT_FLOAT_EQ(100.0f, StringToFloat(L"100.0"));
101 EXPECT_FLOAT_EQ(100.0f, StringToFloat(L" 100.0"));
102 EXPECT_FLOAT_EQ(-100.0f, StringToFloat(L"-100.0000"));
104 EXPECT_FLOAT_EQ(3.402823e+38f,
105 StringToFloat(L"340282300000000000000000000000000000000"));
106 EXPECT_FLOAT_EQ(-3.402823e+38f,
107 StringToFloat(L"-340282300000000000000000000000000000000"));
109 EXPECT_FLOAT_EQ(1.000000119f, StringToFloat(L"1.000000119"));
110 EXPECT_FLOAT_EQ(1.999999881f, StringToFloat(L"1.999999881"));
116 EXPECT_STREQ(
"0", TerminatedFloatToString(0.0f, buf));
117 EXPECT_STREQ(
"0", TerminatedFloatToString(-0.0f, buf));
119 TerminatedFloatToString(std::numeric_limits<
float>::min(), buf));
121 "0", TerminatedFloatToString(-std::numeric_limits<
float>::min(), buf));
123 EXPECT_STREQ(
"0.25", TerminatedFloatToString(0.25f, buf));
124 EXPECT_STREQ(
"-0.25", TerminatedFloatToString(-0.25f, buf));
126 EXPECT_STREQ(
"100", TerminatedFloatToString(100.0f, buf));
127 EXPECT_STREQ(
"-100", TerminatedFloatToString(-100.0f, buf));
131 EXPECT_STREQ(
"2147483647", TerminatedFloatToString(2147483647.0f, buf));
132 EXPECT_STREQ(
"2147483647", TerminatedFloatToString(2147483647.5f, buf));
133 EXPECT_STREQ(
"2147483647",
134 TerminatedFloatToString(std::numeric_limits<
float>::max(), buf));
138 EXPECT_STREQ(
"-2147483647", TerminatedFloatToString(-2147483647.0f, buf));
139 EXPECT_STREQ(
"-2147483647", TerminatedFloatToString(-2147483647.5f, buf));
140 EXPECT_STREQ(
"-2147483647", TerminatedFloatToString(
141 -std::numeric_limits<
float>::max(), buf));
145 EXPECT_STREQ(
"1", TerminatedFloatToString(1.000001119f, buf));
146 EXPECT_STREQ(
"1.00001", TerminatedFloatToString(1.000011119f, buf));
147 EXPECT_STREQ(
"1.99999", TerminatedFloatToString(1.999988881f, buf));
148 EXPECT_STREQ(
"2", TerminatedFloatToString(1.999999881f, buf));
152 EXPECT_FLOAT_EQ(0.0, StringToDouble(
""));
153 EXPECT_FLOAT_EQ(0.0, StringToDouble(
"0"));
154 EXPECT_FLOAT_EQ(0.0, StringToDouble(
"0.0"));
155 EXPECT_FLOAT_EQ(0.0, StringToDouble(
"-0.0"));
157 EXPECT_FLOAT_EQ(0.25, StringToDouble(
"0.25"));
158 EXPECT_FLOAT_EQ(-0.25, StringToDouble(
"-0.25"));
160 EXPECT_FLOAT_EQ(100.0, StringToDouble(
"100"));
161 EXPECT_FLOAT_EQ(100.0, StringToDouble(
"100.0"));
162 EXPECT_FLOAT_EQ(100.0, StringToDouble(
" 100.0"));
163 EXPECT_FLOAT_EQ(-100.0, StringToDouble(
"-100.0000"));
165 EXPECT_FLOAT_EQ(3.402823e+38,
166 StringToDouble(
"340282300000000000000000000000000000000"));
167 EXPECT_FLOAT_EQ(-3.402823e+38,
168 StringToDouble(
"-340282300000000000000000000000000000000"));
170 EXPECT_FLOAT_EQ(1.000000119, StringToDouble(
"1.000000119"));
171 EXPECT_FLOAT_EQ(1.999999881, StringToDouble(
"1.999999881"));
175 EXPECT_FLOAT_EQ(0.0, StringToDouble(L""));
176 EXPECT_FLOAT_EQ(0.0, StringToDouble(L"0"));
177 EXPECT_FLOAT_EQ(0.0, StringToDouble(L"0.0"));
178 EXPECT_FLOAT_EQ(0.0, StringToDouble(L"-0.0"));
180 EXPECT_FLOAT_EQ(0.25, StringToDouble(L"0.25"));
181 EXPECT_FLOAT_EQ(-0.25, StringToDouble(L"-0.25"));
183 EXPECT_FLOAT_EQ(100.0, StringToDouble(L"100"));
184 EXPECT_FLOAT_EQ(100.0, StringToDouble(L"100.0"));
185 EXPECT_FLOAT_EQ(100.0, StringToDouble(L" 100.0"));
186 EXPECT_FLOAT_EQ(-100.0, StringToDouble(L"-100.0000"));
188 EXPECT_FLOAT_EQ(3.402823e+38,
189 StringToDouble(L"340282300000000000000000000000000000000"));
190 EXPECT_FLOAT_EQ(-3.402823e+38,
191 StringToDouble(L"-340282300000000000000000000000000000000"));
193 EXPECT_FLOAT_EQ(1.000000119, StringToDouble(L"1.000000119"));
194 EXPECT_FLOAT_EQ(1.999999881, StringToDouble(L"1.999999881"));
197TEST(fxstring, DoubleToString) {
200 EXPECT_STREQ(
"0", TerminatedDoubleToString(0.0f, buf));
201 EXPECT_STREQ(
"0", TerminatedDoubleToString(-0.0f, buf));
203 "0", TerminatedDoubleToString(std::numeric_limits<
double>::min(), buf));
205 "0", TerminatedDoubleToString(-std::numeric_limits<
double>::min(), buf));
207 EXPECT_STREQ(
"0.25", TerminatedDoubleToString(0.25f, buf));
208 EXPECT_STREQ(
"-0.25", TerminatedDoubleToString(-0.25f, buf));
210 EXPECT_STREQ(
"100", TerminatedDoubleToString(100.0f, buf));
211 EXPECT_STREQ(
"-100", TerminatedDoubleToString(-100.0f, buf));
215 EXPECT_STREQ(
"2147483647", TerminatedDoubleToString(2147483647.0f, buf));
216 EXPECT_STREQ(
"2147483647", TerminatedDoubleToString(2147483647.5f, buf));
217 EXPECT_STREQ(
"2147483647", TerminatedDoubleToString(
218 std::numeric_limits<
double>::max(), buf));
222 EXPECT_STREQ(
"-2147483647", TerminatedDoubleToString(-2147483647.0f, buf));
223 EXPECT_STREQ(
"-2147483647", TerminatedDoubleToString(-2147483647.5f, buf));
224 EXPECT_STREQ(
"-2147483647", TerminatedDoubleToString(
225 -std::numeric_limits<
double>::max(), buf));
229 EXPECT_STREQ(
"1", TerminatedDoubleToString(1.000001119f, buf));
230 EXPECT_STREQ(
"1.00001", TerminatedDoubleToString(1.000011119f, buf));
231 EXPECT_STREQ(
"1.99999", TerminatedDoubleToString(1.999988881f, buf));
232 EXPECT_STREQ(
"2", TerminatedDoubleToString(1.999999881f, buf));
236 std::vector<ByteString> result;
237 result =
fxcrt::Split(ByteString
(""),
',');
238 ASSERT_EQ(1u, result.size());
239 EXPECT_EQ(
"", result[0]);
241 result =
fxcrt::Split(ByteString
("a"),
',');
242 ASSERT_EQ(1u, result.size());
243 EXPECT_EQ(
"a", result[0]);
245 result =
fxcrt::Split(ByteString
(","),
',');
246 ASSERT_EQ(2u, result.size());
247 EXPECT_EQ(
"", result[0]);
248 EXPECT_EQ(
"", result[1]);
250 result =
fxcrt::Split(ByteString
("a,"),
',');
251 ASSERT_EQ(2u, result.size());
252 EXPECT_EQ(
"a", result[0]);
253 EXPECT_EQ(
"", result[1]);
255 result =
fxcrt::Split(ByteString
(",b"),
',');
256 ASSERT_EQ(2u, result.size());
257 EXPECT_EQ(
"", result[0]);
258 EXPECT_EQ(
"b", result[1]);
260 result =
fxcrt::Split(ByteString
("a,b"),
',');
261 ASSERT_EQ(2u, result.size());
262 EXPECT_EQ(
"a", result[0]);
263 EXPECT_EQ(
"b", result[1]);
265 result =
fxcrt::Split(ByteString
("a,b,"),
',');
266 ASSERT_EQ(3u, result.size());
267 EXPECT_EQ(
"a", result[0]);
268 EXPECT_EQ(
"b", result[1]);
269 EXPECT_EQ(
"", result[2]);
271 result =
fxcrt::Split(ByteString
("a,,"),
',');
272 ASSERT_EQ(3u, result.size());
273 EXPECT_EQ(
"a", result[0]);
274 EXPECT_EQ(
"", result[1]);
275 EXPECT_EQ(
"", result[2]);
277 result =
fxcrt::Split(ByteString
(",,a"),
',');
278 ASSERT_EQ(3u, result.size());
279 EXPECT_EQ(
"", result[0]);
280 EXPECT_EQ(
"", result[1]);
281 EXPECT_EQ(
"a", result[2]);
285 std::vector<ByteStringView> result;
286 result =
fxcrt::Split(ByteStringView(
""),
',');
287 ASSERT_EQ(1u, result.size());
288 EXPECT_EQ(
"", result[0]);
290 result =
fxcrt::Split(ByteStringView(
"a"),
',');
291 ASSERT_EQ(1u, result.size());
292 EXPECT_EQ(
"a", result[0]);
294 result =
fxcrt::Split(ByteStringView(
","),
',');
295 ASSERT_EQ(2u, result.size());
296 EXPECT_EQ(
"", result[0]);
297 EXPECT_EQ(
"", result[1]);
299 result =
fxcrt::Split(ByteStringView(
"a,"),
',');
300 ASSERT_EQ(2u, result.size());
301 EXPECT_EQ(
"a", result[0]);
302 EXPECT_EQ(
"", result[1]);
304 result =
fxcrt::Split(ByteStringView(
",b"),
',');
305 ASSERT_EQ(2u, result.size());
306 EXPECT_EQ(
"", result[0]);
307 EXPECT_EQ(
"b", result[1]);
309 result =
fxcrt::Split(ByteStringView(
"a,b"),
',');
310 ASSERT_EQ(2u, result.size());
311 EXPECT_EQ(
"a", result[0]);
312 EXPECT_EQ(
"b", result[1]);
314 result =
fxcrt::Split(ByteStringView(
"a,b,"),
',');
315 ASSERT_EQ(3u, result.size());
316 EXPECT_EQ(
"a", result[0]);
317 EXPECT_EQ(
"b", result[1]);
318 EXPECT_EQ(
"", result[2]);
320 result =
fxcrt::Split(ByteStringView(
"a,,"),
',');
321 ASSERT_EQ(3u, result.size());
322 EXPECT_EQ(
"a", result[0]);
323 EXPECT_EQ(
"", result[1]);
324 EXPECT_EQ(
"", result[2]);
326 result =
fxcrt::Split(ByteStringView(
",,a"),
',');
327 ASSERT_EQ(3u, result.size());
328 EXPECT_EQ(
"", result[0]);
329 EXPECT_EQ(
"", result[1]);
330 EXPECT_EQ(
"a", result[2]);
334 std::vector<WideString> result;
335 result =
fxcrt::Split(WideString
(L""
), L',');
336 ASSERT_EQ(1u, result.size());
337 EXPECT_EQ(L"", result[0]);
339 result =
fxcrt::Split(WideString
(L"a"
), L',');
340 ASSERT_EQ(1u, result.size());
341 EXPECT_EQ(L"a", result[0]);
343 result =
fxcrt::Split(WideString
(L","
), L',');
344 ASSERT_EQ(2u, result.size());
345 EXPECT_EQ(L"", result[0]);
346 EXPECT_EQ(L"", result[1]);
348 result =
fxcrt::Split(WideString
(L"a,"
), L',');
349 ASSERT_EQ(2u, result.size());
350 EXPECT_EQ(L"a", result[0]);
351 EXPECT_EQ(L"", result[1]);
353 result =
fxcrt::Split(WideString
(L",b"
), L',');
354 ASSERT_EQ(2u, result.size());
355 EXPECT_EQ(L"", result[0]);
356 EXPECT_EQ(L"b", result[1]);
358 result =
fxcrt::Split(WideString
(L"a,b"
), L',');
359 ASSERT_EQ(2u, result.size());
360 EXPECT_EQ(L"a", result[0]);
361 EXPECT_EQ(L"b", result[1]);
363 result =
fxcrt::Split(WideString
(L"a,b,"
), L',');
364 ASSERT_EQ(3u, result.size());
365 EXPECT_EQ(L"a", result[0]);
366 EXPECT_EQ(L"b", result[1]);
367 EXPECT_EQ(L"", result[2]);
369 result =
fxcrt::Split(WideString
(L"a,,"
), L',');
370 ASSERT_EQ(3u, result.size());
371 EXPECT_EQ(L"a", result[0]);
372 EXPECT_EQ(L"", result[1]);
373 EXPECT_EQ(L"", result[2]);
375 result =
fxcrt::Split(WideString
(L",,a"
), L',');
376 ASSERT_EQ(3u, result.size());
377 EXPECT_EQ(L"", result[0]);
378 EXPECT_EQ(L"", result[1]);
379 EXPECT_EQ(L"a", result[2]);
383 std::vector<WideStringView> result;
384 result =
fxcrt::Split(WideStringView(L""), L',');
385 ASSERT_EQ(1u, result.size());
386 EXPECT_EQ(L"", result[0]);
388 result =
fxcrt::Split(WideStringView(L"a"), L',');
389 ASSERT_EQ(1u, result.size());
390 EXPECT_EQ(L"a", result[0]);
392 result =
fxcrt::Split(WideStringView(L","), L',');
393 ASSERT_EQ(2u, result.size());
394 EXPECT_EQ(L"", result[0]);
395 EXPECT_EQ(L"", result[1]);
397 result =
fxcrt::Split(WideStringView(L"a,"), L',');
398 ASSERT_EQ(2u, result.size());
399 EXPECT_EQ(L"a", result[0]);
400 EXPECT_EQ(L"", result[1]);
402 result =
fxcrt::Split(WideStringView(L",b"), L',');
403 ASSERT_EQ(2u, result.size());
404 EXPECT_EQ(L"", result[0]);
405 EXPECT_EQ(L"b", result[1]);
407 result =
fxcrt::Split(WideStringView(L"a,b"), L',');
408 ASSERT_EQ(2u, result.size());
409 EXPECT_EQ(L"a", result[0]);
410 EXPECT_EQ(L"b", result[1]);
412 result =
fxcrt::Split(WideStringView(L"a,b,"), L',');
413 ASSERT_EQ(3u, result.size());
414 EXPECT_EQ(L"a", result[0]);
415 EXPECT_EQ(L"b", result[1]);
416 EXPECT_EQ(L"", result[2]);
418 result =
fxcrt::Split(WideStringView(L"a,,"), L',');
419 ASSERT_EQ(3u, result.size());
420 EXPECT_EQ(L"a", result[0]);
421 EXPECT_EQ(L"", result[1]);
422 EXPECT_EQ(L"", result[2]);
424 result =
fxcrt::Split(WideStringView(L",,a"), L',');
425 ASSERT_EQ(3u, result.size());
426 EXPECT_EQ(L"", result[0]);
427 EXPECT_EQ(L"", result[1]);
428 EXPECT_EQ(L"a", result[2]);