1 // file      : tests/cxx/parser/validation/built-in/date-time/driver.cxx
2 // copyright : Copyright (c) 2006-2017 Code Synthesis Tools CC
3 // license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
4 
5 // Test the built-in date and time types validation.
6 //
7 #include <cassert>
8 
9 #include <xsd/cxx/parser/validating/exceptions.hxx>
10 #include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
11 
12 using namespace xsd::cxx::parser::validating;
13 
14 template <typename T>
15 bool
test_post_fail(T & p)16 test_post_fail (T& p)
17 {
18   try
19   {
20     p._post ();
21   }
22   catch (invalid_value<char> const&)
23   {
24     return true;
25   }
26 
27   return false;
28 }
29 
30 int
main()31 main ()
32 {
33   typedef xsd::cxx::parser::gday gday;
34   typedef xsd::cxx::parser::gmonth gmonth;
35   typedef xsd::cxx::parser::gyear gyear;
36   typedef xsd::cxx::parser::gmonth_day gmonth_day;
37   typedef xsd::cxx::parser::gyear_month gyear_month;
38   typedef xsd::cxx::parser::date date;
39   typedef xsd::cxx::parser::time time;
40   typedef xsd::cxx::parser::date_time date_time;
41   typedef xsd::cxx::parser::duration duration;
42 
43   // Good.
44   //
45 
46   // gday & time zone parsing
47   //
48   {
49     gday_pimpl<char> p;
50     p.pre ();
51     p._pre ();
52     p._characters (" \t\n ");
53     p._characters ("---1");
54     p._characters ("2+12:00");
55     p._post ();
56     assert (p.post_gday () == gday (12, 12, 00));
57   }
58 
59   {
60     gday_pimpl<char> p;
61     p.pre ();
62     p._pre ();
63     p._characters ("---01");
64     p._post ();
65     assert (p.post_gday () == gday (1));
66   }
67 
68   {
69     gday_pimpl<char> p;
70     p.pre ();
71     p._pre ();
72     p._characters ("---31");
73     p._post ();
74     assert (p.post_gday () == gday (31));
75   }
76 
77   {
78     gday_pimpl<char> p;
79     p.pre ();
80     p._pre ();
81     p._characters ("---15Z");
82     p._post ();
83     assert (p.post_gday () == gday (15, 0, 0));
84   }
85 
86   {
87     gday_pimpl<char> p;
88     p.pre ();
89     p._pre ();
90     p._characters ("---15-14:00");
91     p._post ();
92     assert (p.post_gday () == gday (15, -14, 0));
93   }
94 
95   // gmonth
96   //
97   {
98     gmonth_pimpl<char> p;
99     p.pre ();
100     p._pre ();
101     p._characters (" \t\n ");
102     p._characters ("--1");
103     p._characters ("0+12:00");
104     p._post ();
105     assert (p.post_gmonth () == gmonth (10, 12, 0));
106   }
107 
108   {
109     gmonth_pimpl<char> p;
110     p.pre ();
111     p._pre ();
112     p._characters ("--01");
113     p._post ();
114     assert (p.post_gmonth () == gmonth (1));
115   }
116 
117   {
118     gmonth_pimpl<char> p;
119     p.pre ();
120     p._pre ();
121     p._characters ("--12Z");
122     p._post ();
123     assert (p.post_gmonth () == gmonth (12, 0, 0));
124   }
125 
126   // gyear
127   //
128   {
129     gyear_pimpl<char> p;
130     p.pre ();
131     p._pre ();
132     p._characters (" \t\n ");
133     p._characters ("20");
134     p._characters ("07+12:00");
135     p._post ();
136     assert (p.post_gyear () == gyear (2007, 12, 00));
137   }
138 
139   {
140     gyear_pimpl<char> p;
141     p.pre ();
142     p._pre ();
143     p._characters ("0001");
144     p._post ();
145     assert (p.post_gyear () == gyear (1));
146   }
147 
148   {
149     gyear_pimpl<char> p;
150     p.pre ();
151     p._pre ();
152     p._characters ("-20000Z");
153     p._post ();
154     assert (p.post_gyear () == gyear (-20000, 0, 0));
155   }
156 
157   // gmonth_day
158   //
159   {
160     gmonth_day_pimpl<char> p;
161     p.pre ();
162     p._pre ();
163     p._characters (" \t\n ");
164     p._characters ("--1");
165     p._characters ("0-28+12:00  ");
166     p._post ();
167     assert (p.post_gmonth_day () == gmonth_day (10, 28, 12, 00));
168   }
169 
170   {
171     gmonth_day_pimpl<char> p;
172     p.pre ();
173     p._pre ();
174     p._characters ("--12-31");
175     p._post ();
176     assert (p.post_gmonth_day () == gmonth_day (12, 31));
177   }
178 
179   {
180     gmonth_day_pimpl<char> p;
181     p.pre ();
182     p._pre ();
183     p._characters ("--01-01Z");
184     p._post ();
185     assert (p.post_gmonth_day () == gmonth_day (1, 1, 0, 0));
186   }
187 
188   // gyear_month
189   //
190   {
191     gyear_month_pimpl<char> p;
192     p.pre ();
193     p._pre ();
194     p._characters (" \t\n ");
195     p._characters ("200");
196     p._characters ("7-12+12:00  ");
197     p._post ();
198     assert (p.post_gyear_month () == gyear_month (2007, 12, 12, 00));
199   }
200 
201   {
202     gyear_month_pimpl<char> p;
203     p.pre ();
204     p._pre ();
205     p._characters ("-2007-10");
206     p._post ();
207     assert (p.post_gyear_month () == gyear_month (-2007, 10));
208   }
209 
210   {
211     gyear_month_pimpl<char> p;
212     p.pre ();
213     p._pre ();
214     p._characters ("20007-10Z");
215     p._post ();
216     assert (p.post_gyear_month () == gyear_month (20007, 10, 0, 0));
217   }
218 
219   {
220     gyear_month_pimpl<char> p;
221     p.pre ();
222     p._pre ();
223     p._characters ("-20007-01");
224     p._post ();
225     assert (p.post_gyear_month () == gyear_month (-20007, 1));
226   }
227 
228   // date
229   //
230   {
231     date_pimpl<char> p;
232     p.pre ();
233     p._pre ();
234     p._characters (" \t\n ");
235     p._characters ("200");
236     p._characters ("7-12-26+12:00  ");
237     p._post ();
238     assert (p.post_date () == date (2007, 12, 26, 12, 0));
239   }
240 
241   {
242     date_pimpl<char> p;
243     p.pre ();
244     p._pre ();
245     p._characters ("-2007-10-15");
246     p._post ();
247     assert (p.post_date () == date (-2007, 10, 15));
248   }
249 
250   {
251     date_pimpl<char> p;
252     p.pre ();
253     p._pre ();
254     p._characters ("20007-12-31Z");
255     p._post ();
256     assert (p.post_date () == date (20007, 12, 31, 0, 0));
257   }
258 
259   {
260     date_pimpl<char> p;
261     p.pre ();
262     p._pre ();
263     p._characters ("-20007-01-01");
264     p._post ();
265     assert (p.post_date () == date (-20007, 1, 1));
266   }
267 
268   // time
269   //
270   {
271     time_pimpl<char> p;
272     p.pre ();
273     p._pre ();
274     p._characters (" \t\n ");
275     p._characters ("12:");
276     p._characters ("46:23.456+12:00  ");
277     p._post ();
278     assert (p.post_time () == time (12, 46, 23.456, 12, 0));
279   }
280 
281   {
282     time_pimpl<char> p;
283     p.pre ();
284     p._pre ();
285     p._characters ("12:13:14");
286     p._post ();
287     assert (p.post_time () == time (12, 13, 14.0));
288   }
289 
290   {
291     time_pimpl<char> p;
292     p.pre ();
293     p._pre ();
294     p._characters ("12:13:14Z");
295     p._post ();
296     assert (p.post_time () == time (12, 13, 14.0, 0, 0));
297   }
298 
299   // date_time
300   //
301   {
302     date_time_pimpl<char> p;
303     p.pre ();
304     p._pre ();
305     p._characters (" \t\n ");
306     p._characters ("200");
307     p._characters ("7-12-26T12:13:14.123+12:00  ");
308     p._post ();
309     assert (p.post_date_time () ==
310             date_time (2007, 12, 26, 12, 13, 14.123, 12, 0));
311   }
312 
313   {
314     date_time_pimpl<char> p;
315     p.pre ();
316     p._pre ();
317     p._characters ("-2007-10-15T12:13:14");
318     p._post ();
319     assert (p.post_date_time () == date_time (-2007, 10, 15, 12, 13, 14.0));
320   }
321 
322   {
323     date_time_pimpl<char> p;
324     p.pre ();
325     p._pre ();
326     p._characters ("20007-12-31T12:13:14Z");
327     p._post ();
328     assert (p.post_date_time () ==
329             date_time (20007, 12, 31, 12, 13, 14.0, 0, 0));
330   }
331 
332   {
333     date_time_pimpl<char> p;
334     p.pre ();
335     p._pre ();
336     p._characters ("-20007-01-01T12:13:14");
337     p._post ();
338     assert (p.post_date_time () == date_time (-20007, 1, 1, 12, 13, 14.0));
339   }
340 
341   // duration
342   //
343   {
344     duration_pimpl<char> p;
345     p.pre ();
346     p._pre ();
347     p._characters (" \t\n ");
348     p._characters ("-P200");
349     p._characters ("7Y13M32DT25H61M61.123S  ");
350     p._post ();
351     assert (p.post_duration () ==
352             duration (true, 2007, 13, 32, 25, 61, 61.123));
353   }
354 
355   {
356     duration_pimpl<char> p;
357     p.pre ();
358     p._pre ();
359     p._characters ("P1Y");
360     p._post ();
361     assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 0.0));
362   }
363 
364   {
365     duration_pimpl<char> p;
366     p.pre ();
367     p._pre ();
368     p._characters ("P1M");
369     p._post ();
370     assert (p.post_duration () == duration (false, 0, 1, 0, 0, 0, 0.0));
371   }
372 
373   {
374     duration_pimpl<char> p;
375     p.pre ();
376     p._pre ();
377     p._characters ("P1D");
378     p._post ();
379     assert (p.post_duration () == duration (false, 0, 0, 1, 0, 0, 0.0));
380   }
381 
382   {
383     duration_pimpl<char> p;
384     p.pre ();
385     p._pre ();
386     p._characters ("PT1H");
387     p._post ();
388     assert (p.post_duration () == duration (false, 0, 0, 0, 1, 0, 0.0));
389   }
390 
391   {
392     duration_pimpl<char> p;
393     p.pre ();
394     p._pre ();
395     p._characters ("PT1M");
396     p._post ();
397     assert (p.post_duration () == duration (false, 0, 0, 0, 0, 1, 0.0));
398   }
399 
400   {
401     duration_pimpl<char> p;
402     p.pre ();
403     p._pre ();
404     p._characters ("PT1.1S");
405     p._post ();
406     assert (p.post_duration () == duration (false, 0, 0, 0, 0, 0, 1.1));
407   }
408 
409   {
410     duration_pimpl<char> p;
411     p.pre ();
412     p._pre ();
413     p._characters ("P1YT1S");
414     p._post ();
415     assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 1.0));
416   }
417 
418   // Bad
419   //
420 
421   // gday & time zone parsing
422   //
423   {
424     gday_pimpl<char> p;
425     p.pre ();
426     p._pre ();
427     // p._characters ("");
428     assert (test_post_fail (p));
429   }
430 
431   {
432     gday_pimpl<char> p;
433     p.pre ();
434     p._pre ();
435     p._characters ("--12");
436     assert (test_post_fail (p));
437   }
438 
439   {
440     gday_pimpl<char> p;
441     p.pre ();
442     p._pre ();
443     p._characters ("---1");
444     assert (test_post_fail (p));
445   }
446 
447   {
448     gday_pimpl<char> p;
449     p.pre ();
450     p._pre ();
451     p._characters ("---00");
452     assert (test_post_fail (p));
453   }
454 
455   {
456     gday_pimpl<char> p;
457     p.pre ();
458     p._pre ();
459     p._characters ("---32");
460     assert (test_post_fail (p));
461   }
462 
463   {
464     gday_pimpl<char> p;
465     p.pre ();
466     p._pre ();
467     p._characters ("---2X");
468     assert (test_post_fail (p));
469   }
470 
471   {
472     gday_pimpl<char> p;
473     p.pre ();
474     p._pre ();
475     p._characters ("---12asd");
476     assert (test_post_fail (p));
477   }
478 
479   {
480     gday_pimpl<char> p;
481     p.pre ();
482     p._pre ();
483     p._characters ("---12X");
484     assert (test_post_fail (p));
485   }
486 
487   {
488     gday_pimpl<char> p;
489     p.pre ();
490     p._pre ();
491     p._characters ("---1212:00");
492     assert (test_post_fail (p));
493   }
494 
495   {
496     gday_pimpl<char> p;
497     p.pre ();
498     p._pre ();
499     p._characters ("---12+2:00");
500     assert (test_post_fail (p));
501   }
502 
503   {
504     gday_pimpl<char> p;
505     p.pre ();
506     p._pre ();
507     p._characters ("---12+1200");
508     assert (test_post_fail (p));
509   }
510 
511   {
512     gday_pimpl<char> p;
513     p.pre ();
514     p._pre ();
515     p._characters ("---12+15:00");
516     assert (test_post_fail (p));
517   }
518 
519   {
520     gday_pimpl<char> p;
521     p.pre ();
522     p._pre ();
523     p._characters ("---12+12:60");
524     assert (test_post_fail (p));
525   }
526 
527   {
528     gday_pimpl<char> p;
529     p.pre ();
530     p._pre ();
531     p._characters ("---12+14:01");
532     assert (test_post_fail (p));
533   }
534 
535   // gmonth
536   //
537   {
538     gmonth_pimpl<char> p;
539     p.pre ();
540     p._pre ();
541     // p._characters ("");
542     assert (test_post_fail (p));
543   }
544 
545   {
546     gmonth_pimpl<char> p;
547     p.pre ();
548     p._pre ();
549     p._characters ("-12");
550     assert (test_post_fail (p));
551   }
552 
553   {
554     gmonth_pimpl<char> p;
555     p.pre ();
556     p._pre ();
557     p._characters ("--00");
558     assert (test_post_fail (p));
559   }
560 
561   {
562     gmonth_pimpl<char> p;
563     p.pre ();
564     p._pre ();
565     p._characters ("--13");
566     assert (test_post_fail (p));
567   }
568 
569   {
570     gmonth_pimpl<char> p;
571     p.pre ();
572     p._pre ();
573     p._characters ("--1X");
574     assert (test_post_fail (p));
575   }
576 
577   {
578     gmonth_pimpl<char> p;
579     p.pre ();
580     p._pre ();
581     p._characters ("--11+12:3o");
582     assert (test_post_fail (p));
583   }
584 
585   // gyear
586   //
587   {
588     gyear_pimpl<char> p;
589     p.pre ();
590     p._pre ();
591     // p._characters ("");
592     assert (test_post_fail (p));
593   }
594 
595   {
596     gyear_pimpl<char> p;
597     p.pre ();
598     p._pre ();
599     p._characters ("207");
600     assert (test_post_fail (p));
601   }
602 
603   {
604     gyear_pimpl<char> p;
605     p.pre ();
606     p._pre ();
607     p._characters ("-207");
608     assert (test_post_fail (p));
609   }
610 
611   {
612     gyear_pimpl<char> p;
613     p.pre ();
614     p._pre ();
615     p._characters ("-0000");
616     assert (test_post_fail (p));
617   }
618 
619   {
620     gyear_pimpl<char> p;
621     p.pre ();
622     p._pre ();
623     p._characters ("20X7");
624     assert (test_post_fail (p));
625   }
626 
627   {
628     gyear_pimpl<char> p;
629     p.pre ();
630     p._pre ();
631     p._characters ("2007+12:3o");
632     assert (test_post_fail (p));
633   }
634 
635   // gmonth_day
636   //
637   {
638     gmonth_day_pimpl<char> p;
639     p.pre ();
640     p._pre ();
641     // p._characters ("");
642     assert (test_post_fail (p));
643   }
644 
645   {
646     gmonth_day_pimpl<char> p;
647     p.pre ();
648     p._pre ();
649     p._characters ("-12-12");
650     assert (test_post_fail (p));
651   }
652 
653   {
654     gmonth_day_pimpl<char> p;
655     p.pre ();
656     p._pre ();
657     p._characters ("--1212");
658     assert (test_post_fail (p));
659   }
660 
661   {
662     gmonth_day_pimpl<char> p;
663     p.pre ();
664     p._pre ();
665     p._characters ("--12?12");
666     assert (test_post_fail (p));
667   }
668 
669   {
670     gmonth_day_pimpl<char> p;
671     p.pre ();
672     p._pre ();
673     p._characters ("--00-12");
674     assert (test_post_fail (p));
675   }
676 
677   {
678     gmonth_day_pimpl<char> p;
679     p.pre ();
680     p._pre ();
681     p._characters ("--12-00");
682     assert (test_post_fail (p));
683   }
684 
685   {
686     gmonth_day_pimpl<char> p;
687     p.pre ();
688     p._pre ();
689     p._characters ("--13-23");
690     assert (test_post_fail (p));
691   }
692 
693   {
694     gmonth_day_pimpl<char> p;
695     p.pre ();
696     p._pre ();
697     p._characters ("--12-32");
698     assert (test_post_fail (p));
699   }
700 
701   {
702     gmonth_day_pimpl<char> p;
703     p.pre ();
704     p._pre ();
705     p._characters ("--1X-12");
706     assert (test_post_fail (p));
707   }
708 
709   {
710     gmonth_day_pimpl<char> p;
711     p.pre ();
712     p._pre ();
713     p._characters ("--12-2X");
714     assert (test_post_fail (p));
715   }
716 
717   {
718     gmonth_day_pimpl<char> p;
719     p.pre ();
720     p._pre ();
721     p._characters ("--11-11+12:3o");
722     assert (test_post_fail (p));
723   }
724 
725   // gyear_month
726   //
727   {
728     gyear_month_pimpl<char> p;
729     p.pre ();
730     p._pre ();
731     // p._characters ("");
732     assert (test_post_fail (p));
733   }
734 
735   {
736     gyear_month_pimpl<char> p;
737     p.pre ();
738     p._pre ();
739     p._characters ("207-01");
740     assert (test_post_fail (p));
741   }
742 
743   {
744     gyear_month_pimpl<char> p;
745     p.pre ();
746     p._pre ();
747     p._characters ("-207-01");
748     assert (test_post_fail (p));
749   }
750 
751   {
752     gyear_month_pimpl<char> p;
753     p.pre ();
754     p._pre ();
755     p._characters ("0000-01");
756     assert (test_post_fail (p));
757   }
758 
759   {
760     gyear_month_pimpl<char> p;
761     p.pre ();
762     p._pre ();
763     p._characters ("20X7-01");
764     assert (test_post_fail (p));
765   }
766 
767   {
768     gyear_month_pimpl<char> p;
769     p.pre ();
770     p._pre ();
771     p._characters ("2007");
772     assert (test_post_fail (p));
773   }
774 
775   {
776     gyear_month_pimpl<char> p;
777     p.pre ();
778     p._pre ();
779     p._characters ("2007?12");
780     assert (test_post_fail (p));
781   }
782 
783   {
784     gyear_month_pimpl<char> p;
785     p.pre ();
786     p._pre ();
787     p._characters ("2007-0");
788     assert (test_post_fail (p));
789   }
790 
791   {
792     gyear_month_pimpl<char> p;
793     p.pre ();
794     p._pre ();
795     p._characters ("2007-00");
796     assert (test_post_fail (p));
797   }
798 
799   {
800     gyear_month_pimpl<char> p;
801     p.pre ();
802     p._pre ();
803     p._characters ("2007-13");
804     assert (test_post_fail (p));
805   }
806 
807   {
808     gyear_month_pimpl<char> p;
809     p.pre ();
810     p._pre ();
811     p._characters ("2007-1X");
812     assert (test_post_fail (p));
813   }
814 
815   {
816     gyear_month_pimpl<char> p;
817     p.pre ();
818     p._pre ();
819     p._characters ("2007-01+12:3o");
820     assert (test_post_fail (p));
821   }
822 
823   // date
824   //
825   {
826     date_pimpl<char> p;
827     p.pre ();
828     p._pre ();
829     // p._characters ("");
830     assert (test_post_fail (p));
831   }
832 
833   {
834     date_pimpl<char> p;
835     p.pre ();
836     p._pre ();
837     p._characters ("207-01-01");
838     assert (test_post_fail (p));
839   }
840 
841   {
842     date_pimpl<char> p;
843     p.pre ();
844     p._pre ();
845     p._characters ("-207-01-01");
846     assert (test_post_fail (p));
847   }
848 
849   {
850     date_pimpl<char> p;
851     p.pre ();
852     p._pre ();
853     p._characters ("0000-01-01");
854     assert (test_post_fail (p));
855   }
856 
857   {
858     date_pimpl<char> p;
859     p.pre ();
860     p._pre ();
861     p._characters ("20X7-01-01");
862     assert (test_post_fail (p));
863   }
864 
865   {
866     date_pimpl<char> p;
867     p.pre ();
868     p._pre ();
869     p._characters ("2007");
870     assert (test_post_fail (p));
871   }
872 
873   {
874     date_pimpl<char> p;
875     p.pre ();
876     p._pre ();
877     p._characters ("2007?01-01");
878     assert (test_post_fail (p));
879   }
880 
881   {
882     date_pimpl<char> p;
883     p.pre ();
884     p._pre ();
885     p._characters ("2007-0-01");
886     assert (test_post_fail (p));
887   }
888 
889   {
890     date_pimpl<char> p;
891     p.pre ();
892     p._pre ();
893     p._characters ("2007-00-01");
894     assert (test_post_fail (p));
895   }
896 
897   {
898     date_pimpl<char> p;
899     p.pre ();
900     p._pre ();
901     p._characters ("2007-13-01");
902     assert (test_post_fail (p));
903   }
904 
905   {
906     date_pimpl<char> p;
907     p.pre ();
908     p._pre ();
909     p._characters ("2007-1X-01");
910     assert (test_post_fail (p));
911   }
912 
913   {
914     date_pimpl<char> p;
915     p.pre ();
916     p._pre ();
917     p._characters ("2007-10");
918     assert (test_post_fail (p));
919   }
920 
921   {
922     date_pimpl<char> p;
923     p.pre ();
924     p._pre ();
925     p._characters ("2007-10?12");
926     assert (test_post_fail (p));
927   }
928 
929   {
930     date_pimpl<char> p;
931     p.pre ();
932     p._pre ();
933     p._characters ("2007-10-");
934     assert (test_post_fail (p));
935   }
936 
937   {
938     date_pimpl<char> p;
939     p.pre ();
940     p._pre ();
941     p._characters ("2007-10-0");
942     assert (test_post_fail (p));
943   }
944 
945   {
946     date_pimpl<char> p;
947     p.pre ();
948     p._pre ();
949     p._characters ("2007-10-00");
950     assert (test_post_fail (p));
951   }
952 
953   {
954     date_pimpl<char> p;
955     p.pre ();
956     p._pre ();
957     p._characters ("2007-10-32");
958     assert (test_post_fail (p));
959   }
960 
961   {
962     date_pimpl<char> p;
963     p.pre ();
964     p._pre ();
965     p._characters ("2007-10-2X");
966     assert (test_post_fail (p));
967   }
968 
969   {
970     date_pimpl<char> p;
971     p.pre ();
972     p._pre ();
973     p._characters ("2007-01-01+12:3o");
974     assert (test_post_fail (p));
975   }
976 
977   // time
978   //
979   {
980     time_pimpl<char> p;
981     p.pre ();
982     p._pre ();
983     // p._characters ("");
984     assert (test_post_fail (p));
985   }
986 
987   {
988     time_pimpl<char> p;
989     p.pre ();
990     p._pre ();
991     p._characters ("1:01:01");
992     assert (test_post_fail (p));
993   }
994 
995   {
996     time_pimpl<char> p;
997     p.pre ();
998     p._pre ();
999     p._characters ("2X:01:01");
1000     assert (test_post_fail (p));
1001   }
1002 
1003   {
1004     time_pimpl<char> p;
1005     p.pre ();
1006     p._pre ();
1007     p._characters ("23");
1008     assert (test_post_fail (p));
1009   }
1010 
1011   {
1012     time_pimpl<char> p;
1013     p.pre ();
1014     p._pre ();
1015     p._characters ("23?01:01");
1016     assert (test_post_fail (p));
1017   }
1018 
1019   {
1020     time_pimpl<char> p;
1021     p.pre ();
1022     p._pre ();
1023     p._characters ("23:0:01");
1024     assert (test_post_fail (p));
1025   }
1026 
1027   {
1028     time_pimpl<char> p;
1029     p.pre ();
1030     p._pre ();
1031     p._characters ("23:60:01");
1032     assert (test_post_fail (p));
1033   }
1034 
1035   {
1036     time_pimpl<char> p;
1037     p.pre ();
1038     p._pre ();
1039     p._characters ("23:4X:01");
1040     assert (test_post_fail (p));
1041   }
1042 
1043   {
1044     time_pimpl<char> p;
1045     p.pre ();
1046     p._pre ();
1047     p._characters ("23:10");
1048     assert (test_post_fail (p));
1049   }
1050 
1051   {
1052     time_pimpl<char> p;
1053     p.pre ();
1054     p._pre ();
1055     p._characters ("23:10?12");
1056     assert (test_post_fail (p));
1057   }
1058 
1059   {
1060     time_pimpl<char> p;
1061     p.pre ();
1062     p._pre ();
1063     p._characters ("23:10:");
1064     assert (test_post_fail (p));
1065   }
1066 
1067   {
1068     time_pimpl<char> p;
1069     p.pre ();
1070     p._pre ();
1071     p._characters ("23:10:0");
1072     assert (test_post_fail (p));
1073   }
1074 
1075   {
1076     time_pimpl<char> p;
1077     p.pre ();
1078     p._pre ();
1079     p._characters ("23:10:01.");
1080     assert (test_post_fail (p));
1081   }
1082 
1083   {
1084     time_pimpl<char> p;
1085     p.pre ();
1086     p._pre ();
1087     p._characters ("23:10:60");
1088     assert (test_post_fail (p));
1089   }
1090 
1091   {
1092     time_pimpl<char> p;
1093     p.pre ();
1094     p._pre ();
1095     p._characters ("23:10:2X");
1096     assert (test_post_fail (p));
1097   }
1098 
1099   {
1100     time_pimpl<char> p;
1101     p.pre ();
1102     p._pre ();
1103     p._characters ("24:01:00");
1104     assert (test_post_fail (p));
1105   }
1106 
1107   {
1108     time_pimpl<char> p;
1109     p.pre ();
1110     p._pre ();
1111     p._characters ("24:00:01");
1112     assert (test_post_fail (p));
1113   }
1114 
1115   {
1116     time_pimpl<char> p;
1117     p.pre ();
1118     p._pre ();
1119     p._characters ("23:01:01+12:3o");
1120     assert (test_post_fail (p));
1121   }
1122 
1123   // date_time
1124   //
1125   {
1126     date_time_pimpl<char> p;
1127     p.pre ();
1128     p._pre ();
1129     // p._characters ("");
1130     assert (test_post_fail (p));
1131   }
1132 
1133   {
1134     date_time_pimpl<char> p;
1135     p.pre ();
1136     p._pre ();
1137     p._characters ("207-01-01T12:13:14");
1138     assert (test_post_fail (p));
1139   }
1140 
1141   {
1142     date_time_pimpl<char> p;
1143     p.pre ();
1144     p._pre ();
1145     p._characters ("-207-01-01T12:13:14");
1146     assert (test_post_fail (p));
1147   }
1148 
1149   {
1150     date_time_pimpl<char> p;
1151     p.pre ();
1152     p._pre ();
1153     p._characters ("0000-01-01T12:13:14");
1154     assert (test_post_fail (p));
1155   }
1156 
1157   {
1158     date_time_pimpl<char> p;
1159     p.pre ();
1160     p._pre ();
1161     p._characters ("20X7-01-01T12:13:14");
1162     assert (test_post_fail (p));
1163   }
1164 
1165   {
1166     date_time_pimpl<char> p;
1167     p.pre ();
1168     p._pre ();
1169     p._characters ("2007");
1170     assert (test_post_fail (p));
1171   }
1172 
1173   {
1174     date_time_pimpl<char> p;
1175     p.pre ();
1176     p._pre ();
1177     p._characters ("2007?01-01T12:13:14");
1178     assert (test_post_fail (p));
1179   }
1180 
1181   {
1182     date_time_pimpl<char> p;
1183     p.pre ();
1184     p._pre ();
1185     p._characters ("2007-0-01T12:13:14");
1186     assert (test_post_fail (p));
1187   }
1188 
1189   {
1190     date_time_pimpl<char> p;
1191     p.pre ();
1192     p._pre ();
1193     p._characters ("2007-00-01T12:13:14");
1194     assert (test_post_fail (p));
1195   }
1196 
1197   {
1198     date_time_pimpl<char> p;
1199     p.pre ();
1200     p._pre ();
1201     p._characters ("2007-13-01T12:13:14");
1202     assert (test_post_fail (p));
1203   }
1204 
1205   {
1206     date_time_pimpl<char> p;
1207     p.pre ();
1208     p._pre ();
1209     p._characters ("2007-1X-01T12:13:14");
1210     assert (test_post_fail (p));
1211   }
1212 
1213   {
1214     date_time_pimpl<char> p;
1215     p.pre ();
1216     p._pre ();
1217     p._characters ("2007-10");
1218     assert (test_post_fail (p));
1219   }
1220 
1221   {
1222     date_time_pimpl<char> p;
1223     p.pre ();
1224     p._pre ();
1225     p._characters ("2007-10?12T12:13:14");
1226     assert (test_post_fail (p));
1227   }
1228 
1229   {
1230     date_time_pimpl<char> p;
1231     p.pre ();
1232     p._pre ();
1233     p._characters ("2007-10-T12:13:14");
1234     assert (test_post_fail (p));
1235   }
1236 
1237   {
1238     date_time_pimpl<char> p;
1239     p.pre ();
1240     p._pre ();
1241     p._characters ("2007-10-0T12:13:14");
1242     assert (test_post_fail (p));
1243   }
1244 
1245   {
1246     date_time_pimpl<char> p;
1247     p.pre ();
1248     p._pre ();
1249     p._characters ("2007-10-00T12:13:14");
1250     assert (test_post_fail (p));
1251   }
1252 
1253   {
1254     date_time_pimpl<char> p;
1255     p.pre ();
1256     p._pre ();
1257     p._characters ("2007-10-32T12:13:14");
1258     assert (test_post_fail (p));
1259   }
1260 
1261   {
1262     date_time_pimpl<char> p;
1263     p.pre ();
1264     p._pre ();
1265     p._characters ("2007-10-2XT12:13:14");
1266     assert (test_post_fail (p));
1267   }
1268 
1269   {
1270     date_time_pimpl<char> p;
1271     p.pre ();
1272     p._pre ();
1273     p._characters ("2007-01-01T1:01:01");
1274     assert (test_post_fail (p));
1275   }
1276 
1277   {
1278     date_time_pimpl<char> p;
1279     p.pre ();
1280     p._pre ();
1281     p._characters ("2007-01-01T2X:01:01");
1282     assert (test_post_fail (p));
1283   }
1284 
1285   {
1286     date_time_pimpl<char> p;
1287     p.pre ();
1288     p._pre ();
1289     p._characters ("2007-01-01T23");
1290     assert (test_post_fail (p));
1291   }
1292 
1293   {
1294     date_time_pimpl<char> p;
1295     p.pre ();
1296     p._pre ();
1297     p._characters ("2007-01-01T23?01:01");
1298     assert (test_post_fail (p));
1299   }
1300 
1301   {
1302     date_time_pimpl<char> p;
1303     p.pre ();
1304     p._pre ();
1305     p._characters ("2007-01-01T23:0:01");
1306     assert (test_post_fail (p));
1307   }
1308 
1309   {
1310     date_time_pimpl<char> p;
1311     p.pre ();
1312     p._pre ();
1313     p._characters ("2007-01-01T23:60:01");
1314     assert (test_post_fail (p));
1315   }
1316 
1317   {
1318     date_time_pimpl<char> p;
1319     p.pre ();
1320     p._pre ();
1321     p._characters ("2007-01-01T23:4X:01");
1322     assert (test_post_fail (p));
1323   }
1324 
1325   {
1326     date_time_pimpl<char> p;
1327     p.pre ();
1328     p._pre ();
1329     p._characters ("2007-01-01T23:10");
1330     assert (test_post_fail (p));
1331   }
1332 
1333   {
1334     date_time_pimpl<char> p;
1335     p.pre ();
1336     p._pre ();
1337     p._characters ("2007-01-01T23:10?12");
1338     assert (test_post_fail (p));
1339   }
1340 
1341   {
1342     date_time_pimpl<char> p;
1343     p.pre ();
1344     p._pre ();
1345     p._characters ("2007-01-01T23:10:");
1346     assert (test_post_fail (p));
1347   }
1348 
1349   {
1350     date_time_pimpl<char> p;
1351     p.pre ();
1352     p._pre ();
1353     p._characters ("2007-01-01T23:10:0");
1354     assert (test_post_fail (p));
1355   }
1356 
1357   {
1358     date_time_pimpl<char> p;
1359     p.pre ();
1360     p._pre ();
1361     p._characters ("2007-01-01T23:10:01.");
1362     assert (test_post_fail (p));
1363   }
1364 
1365   {
1366     date_time_pimpl<char> p;
1367     p.pre ();
1368     p._pre ();
1369     p._characters ("2007-01-01T23:10:60");
1370     assert (test_post_fail (p));
1371   }
1372 
1373   {
1374     date_time_pimpl<char> p;
1375     p.pre ();
1376     p._pre ();
1377     p._characters ("2007-01-01T23:10:2X");
1378     assert (test_post_fail (p));
1379   }
1380 
1381   {
1382     date_time_pimpl<char> p;
1383     p.pre ();
1384     p._pre ();
1385     p._characters ("2007-01-01T24:01:00");
1386     assert (test_post_fail (p));
1387   }
1388 
1389   {
1390     date_time_pimpl<char> p;
1391     p.pre ();
1392     p._pre ();
1393     p._characters ("2007-01-01T24:00:01");
1394     assert (test_post_fail (p));
1395   }
1396 
1397   {
1398     date_time_pimpl<char> p;
1399     p.pre ();
1400     p._pre ();
1401     p._characters ("23:01:01+12:3o");
1402     assert (test_post_fail (p));
1403   }
1404 
1405   {
1406     date_time_pimpl<char> p;
1407     p.pre ();
1408     p._pre ();
1409     p._characters ("2007-01-01T12:13:14+12:3o");
1410     assert (test_post_fail (p));
1411   }
1412 
1413   // duration
1414   //
1415   {
1416     duration_pimpl<char> p;
1417     p.pre ();
1418     p._pre ();
1419     // p._characters ("");
1420     assert (test_post_fail (p));
1421   }
1422 
1423   {
1424     duration_pimpl<char> p;
1425     p.pre ();
1426     p._pre ();
1427     p._characters ("2007Y");
1428     assert (test_post_fail (p));
1429   }
1430 
1431   {
1432     duration_pimpl<char> p;
1433     p.pre ();
1434     p._pre ();
1435     p._characters ("-2007Y");
1436     assert (test_post_fail (p));
1437   }
1438 
1439   {
1440     duration_pimpl<char> p;
1441     p.pre ();
1442     p._pre ();
1443     p._characters ("P-2007Y");
1444     assert (test_post_fail (p));
1445   }
1446 
1447   {
1448     duration_pimpl<char> p;
1449     p.pre ();
1450     p._pre ();
1451     p._characters ("P-1M");
1452     assert (test_post_fail (p));
1453   }
1454 
1455   {
1456     duration_pimpl<char> p;
1457     p.pre ();
1458     p._pre ();
1459     p._characters ("P-1D");
1460     assert (test_post_fail (p));
1461   }
1462 
1463   {
1464     duration_pimpl<char> p;
1465     p.pre ();
1466     p._pre ();
1467     p._characters ("PT-1H");
1468     assert (test_post_fail (p));
1469   }
1470 
1471   {
1472     duration_pimpl<char> p;
1473     p.pre ();
1474     p._pre ();
1475     p._characters ("PT-1M");
1476     assert (test_post_fail (p));
1477   }
1478 
1479   {
1480     duration_pimpl<char> p;
1481     p.pre ();
1482     p._pre ();
1483     p._characters ("PT-1.1S");
1484     assert (test_post_fail (p));
1485   }
1486 
1487   {
1488     duration_pimpl<char> p;
1489     p.pre ();
1490     p._pre ();
1491     p._characters ("P1H1M1S");
1492     assert (test_post_fail (p));
1493   }
1494 
1495   {
1496     duration_pimpl<char> p;
1497     p.pre ();
1498     p._pre ();
1499     p._characters ("P1M1Y");
1500     assert (test_post_fail (p));
1501   }
1502 
1503   {
1504     duration_pimpl<char> p;
1505     p.pre ();
1506     p._pre ();
1507     p._characters ("PT1S1H");
1508     assert (test_post_fail (p));
1509   }
1510 
1511   {
1512     duration_pimpl<char> p;
1513     p.pre ();
1514     p._pre ();
1515     p._characters ("PT1H1Y");
1516     assert (test_post_fail (p));
1517   }
1518 
1519   {
1520     duration_pimpl<char> p;
1521     p.pre ();
1522     p._pre ();
1523     p._characters ("P1Ygarbage");
1524     assert (test_post_fail (p));
1525   }
1526 
1527   {
1528     duration_pimpl<char> p;
1529     p.pre ();
1530     p._pre ();
1531     p._characters ("P1YT");
1532     assert (test_post_fail (p));
1533   }
1534 }
1535