Add tests for %I and %p format options

This commit is contained in:
Anthony Louis 2021-04-16 22:08:32 -03:00 committed by Howard Hinnant
parent 39b4edf279
commit 6e921e1b1d

View File

@ -623,6 +623,21 @@ test_p()
assert(!in.bad()); assert(!in.bad());
assert(tp == sys_days{2016_y/12/11} + hours{23}); assert(tp == sys_days{2016_y/12/11} + hours{23});
} }
{
std::istringstream in{"1986-12-01 01:01:01 pm"};
sys_time<seconds> tp;
in >> parse("%Y-%m-%d %I:%M:%S %p", tp);
assert(!in.fail());
assert(!in.bad());
assert(tp == sys_days{1986_y/12/01} + hours{13} + minutes{01} + seconds{01});
}
{
std::istringstream in{"1986-12-01 01:01:01"};
sys_time<seconds> tp;
in >> parse("%Y-%m-%d %I:%M:%S", tp);
// The test will fail because %I needs the %p option to shows if it is AM or PM
assert(in.fail());
}
} }
void void