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

Function test_z

test/date_test/parse.pass.cpp:792–846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790}
791
792void
793test_z()
794{
795 using namespace date;
796 using namespace std::chrono;
797 using date::local_seconds, date::local_days;
798 {
799 std::istringstream in{"2016-12-26 15:53:22 -0500"};
800 sys_seconds tp;
801 in >> parse("%F %T %z", tp);
802 assert(!in.fail());
803 assert(!in.bad());
804 assert(tp == sys_days{2016_y/12/26} + hours{20} + minutes{53} + seconds{22});
805 }
806 {
807 std::istringstream in{"2016-12-26 15:53:22 -0500"};
808 local_seconds tp;
809 in >> parse("%F %T %z", tp);
810 assert(!in.fail());
811 assert(!in.bad());
812 assert(tp == local_days{2016_y/12/26} + hours{15} + minutes{53} + seconds{22});
813 }
814 {
815 std::istringstream in{"2016-12-26 15:53:22 -05:00"};
816 sys_seconds tp;
817 in >> parse("%F %T %Ez", tp);
818 assert(!in.fail());
819 assert(!in.bad());
820 assert(tp == sys_days{2016_y/12/26} + hours{20} + minutes{53} + seconds{22});
821 }
822 {
823 std::istringstream in{"2016-12-26 15:53:22 -+500"};
824 sys_seconds tp;
825 in >> parse("%F %T %z", tp);
826 assert(in.fail());
827 }
828 {
829 std::istringstream in{"2016-12-26 15:53:22 -+500"};
830 sys_seconds tp;
831 in >> parse("%F %T %Ez", tp);
832 assert(in.fail());
833 }
834 {
835 std::istringstream in{"2016-12-26 15:53:22 --500"};
836 sys_seconds tp;
837 in >> parse("%F %T %z", tp);
838 assert(in.fail());
839 }
840 {
841 std::istringstream in{"2016-12-26 15:53:22 --500"};
842 sys_seconds tp;
843 in >> parse("%F %T %Ez", tp);
844 assert(in.fail());
845 }
846}
847
848void
849test_Z()

Callers 1

mainFunction · 0.85

Calls 1

parseFunction · 0.85

Tested by

no test coverage detected