43 const wchar_t* locale;
45 const wchar_t* pattern;
46 const wchar_t* output;
48 {L"en", L"2002-10-25", L"MMMM DD, YYYY", L"October 25, 2002"},
51 {L"en", L"20040722", L"'Week of the month is' w",
52 L"Week of the month is 3"},
53 {L"en", L"20040722", L"e 'days after Sunday'", L"4 days after Sunday"},
54 {L"en", L"20040722", L"YYYY-'W'WW-e", L"2004-W30-4"},
55 {L"en", L"20040722", L"E 'days after Saturday'",
56 L"5 days after Saturday"},
57 {L"en", L"2000-01-01", L"EEE, 'the' D 'of' MMMM, YYYY",
58 L"Sat, the 1 of January, 2000"},
59 {L"en", L"2000-01-01", L"EEEE, 'the' D 'of' MMMM, YYYY",
60 L"Saturday, the 1 of January, 2000"},
61 {L"en", L"19991202", L"MM/D/YY", L"12/2/99"},
62 {L"en", L"19990110", L"MMM D, YYYY", L"Jan 10, 1999"},
63 {L"en", L"19990202", L"J", L"33"},
64 {L"en", L"19990202", L"JJJ", L"033"},
65 {L"en", L"19991231", L"J", L"365"},
66 {L"en", L"20001231", L"J", L"366"},
67 {L"en", L"19990501", L"J", L"121"},
68 {L"en", L"19990901", L"J", L"244"},
69 {L"en", L"19990228", L"J", L"59"},
70 {L"en", L"20000229", L"J", L"60"},
71 {L"en", L"21000501", L"J", L"121"},
72 {L"en", L"19990102", L"M", L"1"},
73 {L"en", L"19990102", L"MMM", L"Jan"},
74 {L"en", L"19990102", L"YYYY G", L"1999 AD"},
82 {L"de_CH", L"20041030", L"D. MMMM YYYY", L"30. Oktober 2004"},
83 {L"fr_CA", L"20041030", L"D MMMM YYYY", L"30 octobre 2004"},
84 {L"en", L"2002-10-25", L"date(fr){DD MMMM, YYYY}", L"25 octobre, 2002"},
85 {L"en", L"2002-10-25", L"date(es){EEEE, D 'de' MMMM 'de' YYYY}",
86 L"viernes, 25 de octubre de 2002"},
97 for (
const auto& test : kTests) {
103 EXPECT_EQ(test.output, result) <<
" TEST: " << i;
109 static const struct {
110 const wchar_t* locale;
111 const wchar_t* input;
112 const wchar_t* pattern;
113 const wchar_t* output;
115 {L"en", L"01:01:11", L"h:M A", L"1:1 AM"},
116 {L"en", L"13:01:11", L"h:M A", L"1:1 PM"},
117 {L"en", L"01:01:11", L"hh:MM:SS A", L"01:01:11 AM"},
118 {L"en", L"13:01:11", L"hh:MM:SS A", L"01:01:11 PM"},
119 {L"en", L"01:01:11", L"hh:MM:SS A Z", L"01:01:11 AM GMT-02:00"},
120 {L"en", L"01:01:11", L"hh:MM:SS A z", L"01:01:11 AM -02:00"},
124 {L"en", L"12:01:01", L"k:MM:SS", L"12:01:01"},
125 {L"en", L"14:01:01", L"k:MM:SS", L"2:01:01"},
126 {L"en", L"12:01:11", L"kk:MM", L"12:01"},
127 {L"en", L"14:01:11", L"kk:MM", L"02:01"},
128 {L"en", L"12:01:11 +04:30", L"kk:MM", L"05:31"},
129 {L"en", L"12:01:11", L"kk:MM A", L"12:01 PM"},
130 {L"en", L"00:01:01", L"H:M:S", L"0:1:1"},
131 {L"en", L"13:02:11", L"H:M:S", L"13:2:11"},
132 {L"en", L"00:01:11.001", L"HH:M:S.FFF", L"00:1:11.001"},
133 {L"en", L"13:02:11", L"HH:M", L"13:2"},
134 {L"en", L"00:01:11", L"K:M", L"24:1"},
135 {L"en", L"00:02:11", L"KK:M", L"24:2"},
136 {L"en", L"11:11:11", L"HH:MM:SS 'o''clock' A Z",
137 L"11:11:11 o'clock AM GMT-02:00"},
138 {L"en", L"14:30:59", L"h:MM A", L"2:30 PM"},
139 {L"en", L"14:30:59", L"HH:MM:SS A Z", L"14:30:59 PM GMT-02:00"}};
150 for (
const auto& test : kTests) {
156 EXPECT_EQ(test.output, result) <<
" TEST: " << i;
227 static const struct {
228 const wchar_t* locale;
229 const wchar_t* input;
230 const wchar_t* pattern;
233 {L"en", L"12/2/99", L"MM/D/YY",
CFX_DateTime(1999
, 12
, 2
, 0
, 0
, 0
, 0
)},
234 {L"en", L"2/2/99", L"M/D/YY",
CFX_DateTime(1999
, 2
, 2
, 0
, 0
, 0
, 0
)},
235 {L"en", L"2/2/10", L"M/D/YY",
CFX_DateTime(2010
, 2
, 2
, 0
, 0
, 0
, 0
)},
236 {L"en", L"Jan 10, 1999", L"MMM D, YYYY",
238 {L"en", L"Jan 10, 1999 AD", L"MMM D, YYYY G",
241 {L"en", L"Jan 10, 0002 BC", L"MMM D, YYYY G",
243 {L"en", L"October 25, 2002", L"MMMM DD, YYYY",
247 {L"en", L"1999-33", L"YYYY-J",
CFX_DateTime(1999
, 1
, 1
, 0
, 0
, 0
, 0
)},
248 {L"en", L"1999-033", L"YYYY-JJJ",
CFX_DateTime(1999
, 1
, 1
, 0
, 0
, 0
, 0
)},
249 {L"de_CH", L"30. Oktober 2004", L"D. MMMM YYYY",
251 {L"fr_CA", L"30 octobre 2004", L"D MMMM YYYY",
253 {L"en", L"Saturday, the 1 of January, 2000",
254 L"EEEE, 'the' D 'of' MMMM, YYYY",
CFX_DateTime(2000
, 1
, 1
, 0
, 0
, 0
, 0
)},
255 {L"en", L"Sat, the 1 of January, 2000", L"EEE, 'the' D 'of' MMMM, YYYY",
257 {L"en", L"7, the 1 of January, 2000",
258 L"E, 'the' D 'of' MMMM, YYYY",
CFX_DateTime(2000
, 1
, 1
, 0
, 0
, 0
, 0
)},
259 {L"en", L"6, the 1 of January, 2000",
260 L"e, 'the' D 'of' MMMM, YYYY",
CFX_DateTime(2000
, 1
, 1
, 0
, 0
, 0
, 0
)},
261 {L"en", L"2004-07-22 Week of the month is 3",
262 L"YYYY-MM-DD 'Week of the month is' w",
264 {L"en", L"2004-07-22 Week of the year is 03",
265 L"YYYY-MM-DD 'Week of the year is' WW",
279 for (
const auto& test : kTests) {
285 EXPECT_EQ(test.output, result) <<
" TEST: " << i;
337 const wchar_t* locale;
338 const wchar_t* input;
339 const wchar_t* pattern;
340 const wchar_t* output;
343 static const TestCase tests[] = {
347 {L"en", L"12.345e3", L"99.999E", L"12345.000000"},
348 {L"en", L"12.345e+3", L"99.999E", L"12345.000000"},
349 {L"en", L"12.345E-2", L"99.999E", L"0.123450"},
352 {L"en", L"150", L"z999", L"150"},
353 {L"en", L"150.50$", L"zzz.zz$", L"150.50"},
354 {L"en", L"0150", L"z999", L"0150"},
355 {L"en", L"123CR", L"999cr", L"-123"},
356 {L"en", L"123", L"999cr", L"123"},
357 {L"en", L"123CR", L"999CR", L"-123"},
358 {L"en", L"123 ", L"999CR", L"123"},
359 {L"en", L"123DB", L"999db", L"-123"},
360 {L"en", L"123", L"999db", L"123"},
361 {L"en", L"123DB", L"999DB", L"-123"},
362 {L"en", L"123 ", L"999DB", L"123"},
363 {L"en", L"123.5CR", L"999.9cr", L"-123.5"},
364 {L"en", L"123.5", L"999.9cr", L"123.5"},
365 {L"en", L"123.5CR", L"999.9CR", L"-123.5"},
367 {L"en", L"123.5DB", L"999.9db", L"-123.5"},
368 {L"en", L"123.5", L"999.9db", L"123.5"},
369 {L"en", L"123.5DB", L"999.9DB", L"-123.5"},
371 {L"en", L"10.50", L"z,zz9.99", L"10.50"},
372 {L"en", L"3,125.00", L"z,zz9.99", L"3125.00"},
373 {L"en", L"$1,234.00", L"$z,zz9.99DB", L"1234.00"},
376 {L"en", L"1.234", L"zz9.zzz", L"1.234"},
377 {L"en", L"1 text", L"num{z 'text'}", L"1"},
378 {L"en", L"1.234 text", L"z.zzz 'text'", L"1.234"},
379 {L"en", L" 1.234", L"ZZ9.ZZZ", L"1.234"},
380 {L"en", L"12.345", L"zz9.zzz", L"12.345"},
381 {L"en", L" 12.345", L"ZZ9.ZZZ", L"12.345"},
382 {L"en", L"123.456", L"zz9.zzz", L"123.456"},
383 {L"en", L"123.456", L"ZZ9.ZZZ", L"123.456"},
384 {L"en", L"123.456-", L"ZZ9.ZZZS", L"-123.456"},
385 {L"en", L"123.456+", L"ZZ9.ZZZS", L"123.456"},
386 {L"en", L"123.456 ", L"ZZ9.ZZZS", L"123.456"},
387 {L"en", L"123.456-", L"ZZ9.ZZZS", L"-123.456"},
388 {L"en", L"123.456+", L"ZZ9.ZZZS", L"123.456"},
389 {L"en", L"123", L"zz9.zzz", L"123"},
390 {L"en", L"123.", L"ZZ9.ZZZ", L"123."},
391 {L"en", L"123.", L"zz9.zzz", L"123."},
392 {L"en", L"123.", L"ZZ9.ZZZ", L"123."},
393 {L"en", L"123.0", L"zz9.zzz", L"123.0"},
394 {L"en", L"123.0", L"ZZ9.ZZZ", L"123.0"},
395 {L"en", L"123.000", L"zz9.zzz", L"123.000"},
396 {L"en", L"123.000", L"ZZ9.ZZZ", L"123.000"},
397 {L"en", L"12,345.67", L"zzz,zz9.88888888", L"12345.67"},
398 {L"en", L"12,345.0000", L"zzz,zz9.88888888", L"12345.0000"},
399 {L"en", L"12,345.6789", L"zzz,zz9.8", L"12345.6789"},
400 {L"en", L"12,345.", L"zzz,zz9.8", L"12345."},
401 {L"en", L"123,456.000", L"zzz,zz9.8888", L"123456.000"},
402 {L"en", L"123,456.0", L"zzz,zz9.8888", L"123456.0"},
403 {L"en", L"123,456", L"zzz,zz9.8888", L"123456"},
404 {L"en", L"123,456", L"ZZZ,ZZ9.88", L"123456"},
405 {L"en", L"12,345.67", L"zzz,zz9.88888888", L"12345.67"},
406 {L"en", L"12,345.0000", L"zzz,zz9.88888888", L"12345.0000"},
407 {L"en", L"12,345.6789", L"zzz,zz9.8", L"12345.6789"},
408 {L"en", L"12,345.", L"zzz,zz9.8", L"12345."},
411 {L"en", L"1,234.50%", L"zzz,zz9.99%%", L"12.345"},
413 {L"en", L" 001.23", L"S999V99", L"001.23"},
415 {L"en", L" 12.30", L"SZZ9.99", L"12.30"},
416 {L"en", L"- 12.30", L"SZ99.99", L"-12.30"},
417 {L"en", L"123.00", L"szz9.99", L"123.00"},
418 {L"en", L"-123.00", L"szz9.99", L"-123.00"},
422 {L"en", L"$1,234.00DB", L"$z,zz9.99DB", L"-1234.00"},
426 L"num(fr){z,zzz}", L"1234"},
435 L"zzz,zzz", L"123456"},
436 {L"en", L"12%", L"zz%", L"0.12"},
437 {L"en", L"(123", L"(zzz", L"-123"},
438 {L"en", L"123)", L"zzz)", L"-123"},
439 {L"en", L"(123)", L"(zzz)", L"-123"},
440 {L"en", L"123 ", L"zzz)", L"123"},
441 {L"en", L" 123", L"(zzz", L"123"},
442 {L"en", L" 123 ", L"(zzz)", L"123"},
443 {L"en", L"123.5(", L"zzz.z(", L"-123.5"},
444 {L"en", L"123.5)", L"zzz.z)", L"-123.5"},
445 {L"en", L"123.5 ", L"zzz.z)", L"123.5"},
446 {L"en", L"123.5 ", L"zzz.z(", L"123.5"},
447 {L"en", L"123.545,4", L"zzz.zzz,z", L"123.5454"},
449 {L"en", L"1", L" num.().().}", L"1"},
452 static const TestCase failures[] = {
454 {L"en", L"..", L"VC", L"."},
457 {L"en", L"PDF", L"num( ", L"."},
460 {L"en", L"9.E99999999999", L"EdEE.E999", L""},
463 {L"en", L"-3.E98998998 ", L" 35EEEE.EE98", L""},
466 for (
const auto& test : tests) {
469 EXPECT_TRUE(fmt
.ParseNum(Mgr(test.locale)
, test.input
, &result
))
470 <<
" TEST: " << test.input <<
", " << test.pattern;
471 EXPECT_EQ(test.output, result)
472 <<
" TEST: " << test.input <<
", " << test.pattern;
475 for (
const auto& test : failures) {
478 EXPECT_FALSE(fmt
.ParseNum(Mgr(test.locale)
, test.input
, &result
))
479 <<
" TEST: " << test.input <<
", " << test.pattern;
485 const wchar_t* locale;
486 const wchar_t* input;
487 const wchar_t* pattern;
488 const wchar_t* output;
491 static const TestCase tests[] = {
492 {L"en", L"1.234", L"zz9.zzz", L"1.234"},
493 {L"en", L"1", L"num{z 'text'}", L"1 text"},
494 {L"en", L"1", L"num{'text' z}", L"text 1"},
495 {L"en", L"1.234", L"ZZ9.ZZZ", L" 1.234"},
496 {L"en", L"12.345", L"zz9.zzz", L"12.345"},
497 {L"en", L"12.345", L"ZZ9.ZZZ", L" 12.345"},
498 {L"en", L"123.456", L"zz9.zzz", L"123.456"},
499 {L"en", L"123.456", L"ZZ9.ZZZ", L"123.456"},
500 {L"en", L"123", L"zz9.zzz", L"123"},
501 {L"en", L"123", L"ZZ9.ZZZ", L"123.000"},
502 {L"en", L"123.", L"zz9.zzz", L"123."},
503 {L"en", L"123.", L"ZZ9.ZZZ", L"123.000"},
504 {L"en", L"123.0", L"zz9.zzz", L"123"},
505 {L"en", L"123.0", L"ZZ9.ZZZ", L"123.000"},
506 {L"en", L"123.000", L"zz9.zzz", L"123"},
507 {L"en", L"123.000", L"ZZ9.ZZZ", L"123.000"},
514 {L"en", L"123456", L"zzz,zz9.8888", L"123,456"},
515 {L"en", L"123456", L"ZZZ,ZZ9.88", L"123,456"},
522 {L"en", L"-1.23", L"S999v99", L"-00123"},
523 {L"en", L"1.23", L"S999V99", L" 001.23"},
524 {L"en", L"123", L"S999V99", L" 123.00"},
525 {L"en", L"12.3", L"SZZ9.99", L" 12.30"},
526 {L"en", L"-12.3", L"SZ99.99", L"- 12.30"},
527 {L"en", L"123", L"szz9.99", L"123.00"},
528 {L"en", L"-123", L"szz9.99", L"-123.00"},
532 {L"en", L"-1234", L"$z,zz9.99DB", L"$1,234.00DB"},
533 {L"en", L"12345", L"99.999E", L"12.345E+3"},
534 {L"en", L"12345", L"99999E", L"12345E+0"},
535 {L"en", L".12345", L"99.999E", L"12.345E-2"},
536 {L"en", L"12345", L"99,999", L"12,345"},
537 {L"en", L"1234", L"num(fr){z,zzz}",
540 {L"en", L"12.34", L"num.percent{}", L"1,234%"},
541 {L"en", L"12.34", L"num(fr).percent{}",
545 {L"en", L"-123", L"zzzCR", L"123CR"},
546 {L"en", L"123", L"zzzCR", L"123 "},
547 {L"en", L"-123", L"zzzcr", L"123CR"},
548 {L"en", L"123", L"zzzcr", L"123"},
549 {L"en", L"123", L"zzz$", L"123$"},
550 {L"en", L"-123.5", L"zzz.zCR", L"123.5CR"},
551 {L"en", L"123.5", L"zzz.zCR", L"123.5 "},
552 {L"en", L"-123.5", L"zzz.zcr", L"123.5CR"},
553 {L"en", L"123.5", L"zzz.zcr", L"123.5"},
555 {L"en", L"-123.5", L"999.9db", L"123.5db"},
556 {L"en", L"123.5", L"999.9db", L"123.5"},
557 {L"en", L"-123.5", L"999.9DB", L"123.5DB"},
558 {L"en", L"123.5", L"999.9DB", L"123.5 "},
560 {L"en", L"-123", L"(zzz", L"(123"},
562 {L"en", L"-123", L"(zzz)", L"(123)"},
563 {L"en", L"123", L"zzz)", L"123 "},
564 {L"en", L"123", L"(zzz", L" 123"},
565 {L"en", L"123", L"(zzz)", L" 123 "},
566 {L"en", L"-123.5", L"zzz.z(", L"123.5("},
568 {L"en", L"123.5", L"zzz.z)", L"123.5 "},
569 {L"en", L"123.5", L"zzz.z(", L"123.5 "},
571 {L"en", L"1", L"r9", L"r1"},
572 {L"en", L"1", L"R9", L"R1"},
573 {L"en", L"1", L"b9", L"b1"},
574 {L"en", L"1", L"B9", L"B1"},
575 {L"en", L"1", L"9.c", L"1"},
576 {L"en", L"1", L"9.C", L"1"},
577 {L"en", L"1", L"9.d", L"1"},
578 {L"en", L"1", L"9.D", L"1"},
580 {L"en", L"1", L"E", L"1"},
581 {L"en", L"0", L"E", L"0"},
582 {L"en", L"-1", L"E", L"-1"},
583 {L"en", L"900000000000000000000", L"E", L"900,000,000,000,000,000,000"},
587 {L"en", L"1", L"| num.().().", L"1"},
589 {L"en", L"1", L"9.", L"1"},
592 static const TestCase failures[] = {
594 {L"en", L"1", L"num.{E", L""},
597 for (
const auto& test : tests) {
601 <<
" TEST: " << test.input <<
", " << test.pattern;
602 EXPECT_EQ(test.output, result)
603 <<
" TEST: " << test.input <<
", " << test.pattern;
606 for (
const auto& test : failures) {
609 EXPECT_FALSE(fmt
.FormatNum(Mgr(test.locale)
, test.input
, &result
))
610 <<
" TEST: " << test.input <<
", " << test.pattern;