MCPcopy Create free account
hub / github.com/HowardHinnant/date / test_p

Function test_p

test/date_test/parse.pass.cpp:662–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660}
661
662void
663test_p()
664{
665 using namespace date;
666 using namespace std::chrono;
667 using date::sys_time;
668 {
669 std::istringstream in{"2016-12-11 11pm"};
670 sys_time<hours> tp;
671 in >> parse("%F %I%p", tp);
672 assert(!in.fail());
673 assert(!in.bad());
674 assert(tp == sys_days{2016_y/12/11} + hours{23});
675 }
676 {
677 std::istringstream in{"1986-12-01 01:01:01 pm"};
678 sys_time<seconds> tp;
679 in >> parse("%Y-%m-%d %I:%M:%S %p", tp);
680 assert(!in.fail());
681 assert(!in.bad());
682 assert(tp == sys_days{1986_y/12/01} + hours{13} + minutes{01} + seconds{01});
683 }
684 {
685 std::istringstream in{"1986-12-01 01:01:01"};
686 sys_time<seconds> tp;
687 in >> parse("%Y-%m-%d %I:%M:%S", tp);
688 // The test will fail because %I needs the %p option to shows if it is AM or PM
689 assert(in.fail());
690 }
691}
692
693void
694test_r()

Callers 1

mainFunction · 0.85

Calls 1

parseFunction · 0.85

Tested by

no test coverage detected