40 const wchar_t* locale;
42 const wchar_t* pattern;
43 const wchar_t* output;
45 {L"en", L"2002-10-25", L"MMMM DD, YYYY", L"October 25, 2002"},
48 {L"en", L"20040722", L"'Week of the month is' w",
49 L"Week of the month is 3"},
50 {L"en", L"20040722", L"e 'days after Sunday'", L"4 days after Sunday"},
51 {L"en", L"20040722", L"YYYY-'W'WW-e", L"2004-W30-4"},
52 {L"en", L"20040722", L"E 'days after Saturday'",
53 L"5 days after Saturday"},
54 {L"en", L"2000-01-01", L"EEE, 'the' D 'of' MMMM, YYYY",
55 L"Sat, the 1 of January, 2000"},
56 {L"en", L"2000-01-01", L"EEEE, 'the' D 'of' MMMM, YYYY",
57 L"Saturday, the 1 of January, 2000"},
58 {L"en", L"19991202", L"MM/D/YY", L"12/2/99"},
59 {L"en", L"19990110", L"MMM D, YYYY", L"Jan 10, 1999"},
60 {L"en", L"19990202", L"J", L"33"},
61 {L"en", L"19990202", L"JJJ", L"033"},
62 {L"en", L"19991231", L"J", L"365"},
63 {L"en", L"20001231", L"J", L"366"},
64 {L"en", L"19990501", L"J", L"121"},
65 {L"en", L"19990901", L"J", L"244"},
66 {L"en", L"19990228", L"J", L"59"},
67 {L"en", L"20000229", L"J", L"60"},
68 {L"en", L"21000501", L"J", L"121"},
69 {L"en", L"19990102", L"M", L"1"},
70 {L"en", L"19990102", L"MMM", L"Jan"},
71 {L"en", L"19990102", L"YYYY G", L"1999 AD"},
79 {L"de_CH", L"20041030", L"D. MMMM YYYY", L"30. Oktober 2004"},
80 {L"fr_CA", L"20041030", L"D MMMM YYYY", L"30 octobre 2004"},
81 {L"en", L"2002-10-25", L"date(fr){DD MMMM, YYYY}", L"25 octobre, 2002"},
82 {L"en", L"2002-10-25", L"date(es){EEEE, D 'de' MMMM 'de' YYYY}",
83 L"viernes, 25 de octubre de 2002"},
93 for (size_t i = 0; i <
std::size(tests); ++i) {
99 EXPECT_STREQ(tests[i].output, result
.c_str()) <<
" TEST: " << i;
105 const wchar_t* locale;
106 const wchar_t* input;
107 const wchar_t* pattern;
108 const wchar_t* output;
109 } tests[] = {{L"en", L"01:01:11", L"h:M A", L"1:1 AM"},
110 {L"en", L"13:01:11", L"h:M A", L"1:1 PM"},
111 {L"en", L"01:01:11", L"hh:MM:SS A", L"01:01:11 AM"},
112 {L"en", L"13:01:11", L"hh:MM:SS A", L"01:01:11 PM"},
113 {L"en", L"01:01:11", L"hh:MM:SS A Z", L"01:01:11 AM GMT-02:00"},
114 {L"en", L"01:01:11", L"hh:MM:SS A z", L"01:01:11 AM -02:00"},
118 {L"en", L"12:01:01", L"k:MM:SS", L"12:01:01"},
119 {L"en", L"14:01:01", L"k:MM:SS", L"2:01:01"},
120 {L"en", L"12:01:11", L"kk:MM", L"12:01"},
121 {L"en", L"14:01:11", L"kk:MM", L"02:01"},
122 {L"en", L"12:01:11 +04:30", L"kk:MM", L"05:31"},
123 {L"en", L"12:01:11", L"kk:MM A", L"12:01 PM"},
124 {L"en", L"00:01:01", L"H:M:S", L"0:1:1"},
125 {L"en", L"13:02:11", L"H:M:S", L"13:2:11"},
126 {L"en", L"00:01:11.001", L"HH:M:S.FFF", L"00:1:11.001"},
127 {L"en", L"13:02:11", L"HH:M", L"13:2"},
128 {L"en", L"00:01:11", L"K:M", L"24:1"},
129 {L"en", L"00:02:11", L"KK:M", L"24:2"},
130 {L"en", L"11:11:11", L"HH:MM:SS 'o''clock' A Z",
131 L"11:11:11 o'clock AM GMT-02:00"},
132 {L"en", L"14:30:59", L"h:MM A", L"2:30 PM"},
133 {L"en", L"14:30:59", L"HH:MM:SS A Z", L"14:30:59 PM GMT-02:00"}};
144 for (size_t i = 0; i <
std::size(tests); ++i) {
150 EXPECT_STREQ(tests[i].output, result
.c_str()) <<
" TEST: " << i;
328 const wchar_t* locale;
329 const wchar_t* input;
330 const wchar_t* pattern;
331 const wchar_t* output;
334 static const TestCase tests[] = {
338 {L"en", L"12.345e3", L"99.999E", L"12345.000000"},
339 {L"en", L"12.345e+3", L"99.999E", L"12345.000000"},
340 {L"en", L"12.345E-2", L"99.999E", L"0.123450"},
343 {L"en", L"150", L"z999", L"150"},
344 {L"en", L"150.50$", L"zzz.zz$", L"150.50"},
345 {L"en", L"0150", L"z999", L"0150"},
346 {L"en", L"123CR", L"999cr", L"-123"},
347 {L"en", L"123", L"999cr", L"123"},
348 {L"en", L"123CR", L"999CR", L"-123"},
349 {L"en", L"123 ", L"999CR", L"123"},
350 {L"en", L"123DB", L"999db", L"-123"},
351 {L"en", L"123", L"999db", L"123"},
352 {L"en", L"123DB", L"999DB", L"-123"},
353 {L"en", L"123 ", L"999DB", L"123"},
354 {L"en", L"123.5CR", L"999.9cr", L"-123.5"},
355 {L"en", L"123.5", L"999.9cr", L"123.5"},
356 {L"en", L"123.5CR", L"999.9CR", L"-123.5"},
358 {L"en", L"123.5DB", L"999.9db", L"-123.5"},
359 {L"en", L"123.5", L"999.9db", L"123.5"},
360 {L"en", L"123.5DB", L"999.9DB", L"-123.5"},
362 {L"en", L"10.50", L"z,zz9.99", L"10.50"},
363 {L"en", L"3,125.00", L"z,zz9.99", L"3125.00"},
364 {L"en", L"$1,234.00", L"$z,zz9.99DB", L"1234.00"},
367 {L"en", L"1.234", L"zz9.zzz", L"1.234"},
368 {L"en", L"1 text", L"num{z 'text'}", L"1"},
369 {L"en", L"1.234 text", L"z.zzz 'text'", L"1.234"},
370 {L"en", L" 1.234", L"ZZ9.ZZZ", L"1.234"},
371 {L"en", L"12.345", L"zz9.zzz", L"12.345"},
372 {L"en", L" 12.345", L"ZZ9.ZZZ", L"12.345"},
373 {L"en", L"123.456", L"zz9.zzz", L"123.456"},
374 {L"en", L"123.456", L"ZZ9.ZZZ", L"123.456"},
375 {L"en", L"123.456-", L"ZZ9.ZZZS", L"-123.456"},
376 {L"en", L"123.456+", L"ZZ9.ZZZS", L"123.456"},
377 {L"en", L"123.456 ", L"ZZ9.ZZZS", L"123.456"},
378 {L"en", L"123.456-", L"ZZ9.ZZZS", L"-123.456"},
379 {L"en", L"123.456+", L"ZZ9.ZZZS", L"123.456"},
380 {L"en", L"123", L"zz9.zzz", L"123"},
381 {L"en", L"123.", L"ZZ9.ZZZ", L"123."},
382 {L"en", L"123.", L"zz9.zzz", L"123."},
383 {L"en", L"123.", L"ZZ9.ZZZ", L"123."},
384 {L"en", L"123.0", L"zz9.zzz", L"123.0"},
385 {L"en", L"123.0", L"ZZ9.ZZZ", L"123.0"},
386 {L"en", L"123.000", L"zz9.zzz", L"123.000"},
387 {L"en", L"123.000", L"ZZ9.ZZZ", L"123.000"},
388 {L"en", L"12,345.67", L"zzz,zz9.88888888", L"12345.67"},
389 {L"en", L"12,345.0000", L"zzz,zz9.88888888", L"12345.0000"},
390 {L"en", L"12,345.6789", L"zzz,zz9.8", L"12345.6789"},
391 {L"en", L"12,345.", L"zzz,zz9.8", L"12345."},
392 {L"en", L"123,456.000", L"zzz,zz9.8888", L"123456.000"},
393 {L"en", L"123,456.0", L"zzz,zz9.8888", L"123456.0"},
394 {L"en", L"123,456", L"zzz,zz9.8888", L"123456"},
395 {L"en", L"123,456", L"ZZZ,ZZ9.88", L"123456"},
396 {L"en", L"12,345.67", L"zzz,zz9.88888888", L"12345.67"},
397 {L"en", L"12,345.0000", L"zzz,zz9.88888888", L"12345.0000"},
398 {L"en", L"12,345.6789", L"zzz,zz9.8", L"12345.6789"},
399 {L"en", L"12,345.", L"zzz,zz9.8", L"12345."},
402 {L"en", L"1,234.50%", L"zzz,zz9.99%%", L"12.345"},
404 {L"en", L" 001.23", L"S999V99", L"001.23"},
406 {L"en", L" 12.30", L"SZZ9.99", L"12.30"},
407 {L"en", L"- 12.30", L"SZ99.99", L"-12.30"},
408 {L"en", L"123.00", L"szz9.99", L"123.00"},
409 {L"en", L"-123.00", L"szz9.99", L"-123.00"},
413 {L"en", L"$1,234.00DB", L"$z,zz9.99DB", L"-1234.00"},
417 L"num(fr){z,zzz}", L"1234"},
426 L"zzz,zzz", L"123456"},
427 {L"en", L"12%", L"zz%", L"0.12"},
428 {L"en", L"(123", L"(zzz", L"-123"},
429 {L"en", L"123)", L"zzz)", L"-123"},
430 {L"en", L"(123)", L"(zzz)", L"-123"},
431 {L"en", L"123 ", L"zzz)", L"123"},
432 {L"en", L" 123", L"(zzz", L"123"},
433 {L"en", L" 123 ", L"(zzz)", L"123"},
434 {L"en", L"123.5(", L"zzz.z(", L"-123.5"},
435 {L"en", L"123.5)", L"zzz.z)", L"-123.5"},
436 {L"en", L"123.5 ", L"zzz.z)", L"123.5"},
437 {L"en", L"123.5 ", L"zzz.z(", L"123.5"},
438 {L"en", L"123.545,4", L"zzz.zzz,z", L"123.5454"},
440 {L"en", L"1", L" num.().().}", L"1"},
443 static const TestCase failures[] = {
445 {L"en", L"..", L"VC", L"."},
448 {L"en", L"PDF", L"num( ", L"."},
451 {L"en", L"9.E99999999999", L"EdEE.E999", L""},
454 {L"en", L"-3.E98998998 ", L" 35EEEE.EE98", L""},
457 for (
const auto& test : tests) {
460 EXPECT_TRUE(fmt
.ParseNum(Mgr(test.locale)
, test.input
, &result
))
461 <<
" TEST: " << test.input <<
", " << test.pattern;
462 EXPECT_STREQ(test.output, result
.c_str())
463 <<
" TEST: " << test.input <<
", " << test.pattern;
466 for (
const auto& test : failures) {
469 EXPECT_FALSE(fmt
.ParseNum(Mgr(test.locale)
, test.input
, &result
))
470 <<
" TEST: " << test.input <<
", " << test.pattern;
476 const wchar_t* locale;
477 const wchar_t* input;
478 const wchar_t* pattern;
479 const wchar_t* output;
482 static const TestCase tests[] = {
483 {L"en", L"1.234", L"zz9.zzz", L"1.234"},
484 {L"en", L"1", L"num{z 'text'}", L"1 text"},
485 {L"en", L"1", L"num{'text' z}", L"text 1"},
486 {L"en", L"1.234", L"ZZ9.ZZZ", L" 1.234"},
487 {L"en", L"12.345", L"zz9.zzz", L"12.345"},
488 {L"en", L"12.345", L"ZZ9.ZZZ", L" 12.345"},
489 {L"en", L"123.456", L"zz9.zzz", L"123.456"},
490 {L"en", L"123.456", L"ZZ9.ZZZ", L"123.456"},
491 {L"en", L"123", L"zz9.zzz", L"123"},
492 {L"en", L"123", L"ZZ9.ZZZ", L"123.000"},
493 {L"en", L"123.", L"zz9.zzz", L"123."},
494 {L"en", L"123.", L"ZZ9.ZZZ", L"123.000"},
495 {L"en", L"123.0", L"zz9.zzz", L"123"},
496 {L"en", L"123.0", L"ZZ9.ZZZ", L"123.000"},
497 {L"en", L"123.000", L"zz9.zzz", L"123"},
498 {L"en", L"123.000", L"ZZ9.ZZZ", L"123.000"},
505 {L"en", L"123456", L"zzz,zz9.8888", L"123,456"},
506 {L"en", L"123456", L"ZZZ,ZZ9.88", L"123,456"},
513 {L"en", L"-1.23", L"S999v99", L"-00123"},
514 {L"en", L"1.23", L"S999V99", L" 001.23"},
515 {L"en", L"123", L"S999V99", L" 123.00"},
516 {L"en", L"12.3", L"SZZ9.99", L" 12.30"},
517 {L"en", L"-12.3", L"SZ99.99", L"- 12.30"},
518 {L"en", L"123", L"szz9.99", L"123.00"},
519 {L"en", L"-123", L"szz9.99", L"-123.00"},
523 {L"en", L"-1234", L"$z,zz9.99DB", L"$1,234.00DB"},
524 {L"en", L"12345", L"99.999E", L"12.345E+3"},
525 {L"en", L"12345", L"99999E", L"12345E+0"},
526 {L"en", L".12345", L"99.999E", L"12.345E-2"},
527 {L"en", L"12345", L"99,999", L"12,345"},
528 {L"en", L"1234", L"num(fr){z,zzz}",
531 {L"en", L"12.34", L"num.percent{}", L"1,234%"},
532 {L"en", L"12.34", L"num(fr).percent{}",
536 {L"en", L"-123", L"zzzCR", L"123CR"},
537 {L"en", L"123", L"zzzCR", L"123 "},
538 {L"en", L"-123", L"zzzcr", L"123CR"},
539 {L"en", L"123", L"zzzcr", L"123"},
540 {L"en", L"123", L"zzz$", L"123$"},
541 {L"en", L"-123.5", L"zzz.zCR", L"123.5CR"},
542 {L"en", L"123.5", L"zzz.zCR", L"123.5 "},
543 {L"en", L"-123.5", L"zzz.zcr", L"123.5CR"},
544 {L"en", L"123.5", L"zzz.zcr", L"123.5"},
546 {L"en", L"-123.5", L"999.9db", L"123.5db"},
547 {L"en", L"123.5", L"999.9db", L"123.5"},
548 {L"en", L"-123.5", L"999.9DB", L"123.5DB"},
549 {L"en", L"123.5", L"999.9DB", L"123.5 "},
551 {L"en", L"-123", L"(zzz", L"(123"},
553 {L"en", L"-123", L"(zzz)", L"(123)"},
554 {L"en", L"123", L"zzz)", L"123 "},
555 {L"en", L"123", L"(zzz", L" 123"},
556 {L"en", L"123", L"(zzz)", L" 123 "},
557 {L"en", L"-123.5", L"zzz.z(", L"123.5("},
559 {L"en", L"123.5", L"zzz.z)", L"123.5 "},
560 {L"en", L"123.5", L"zzz.z(", L"123.5 "},
562 {L"en", L"1", L"r9", L"r1"},
563 {L"en", L"1", L"R9", L"R1"},
564 {L"en", L"1", L"b9", L"b1"},
565 {L"en", L"1", L"B9", L"B1"},
566 {L"en", L"1", L"9.c", L"1"},
567 {L"en", L"1", L"9.C", L"1"},
568 {L"en", L"1", L"9.d", L"1"},
569 {L"en", L"1", L"9.D", L"1"},
571 {L"en", L"1", L"E", L"1"},
572 {L"en", L"0", L"E", L"0"},
573 {L"en", L"-1", L"E", L"-1"},
574 {L"en", L"900000000000000000000", L"E", L"900,000,000,000,000,000,000"},
578 {L"en", L"1", L"| num.().().", L"1"},
580 {L"en", L"1", L"9.", L"1"},
583 static const TestCase failures[] = {
585 {L"en", L"1", L"num.{E", L""},
588 for (
const auto& test : tests) {
592 <<
" TEST: " << test.input <<
", " << test.pattern;
593 EXPECT_STREQ(test.output, result
.c_str())
594 <<
" TEST: " << test.input <<
", " << test.pattern;
597 for (
const auto& test : failures) {
600 EXPECT_FALSE(fmt
.FormatNum(Mgr(test.locale)
, test.input
, &result
))
601 <<
" TEST: " << test.input <<
", " << test.pattern;