Skip to content

Commit

Permalink
Add tests for %I and %p format options
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonylouisbsb authored and HowardHinnant committed Apr 17, 2021
1 parent 39b4edf commit 6e921e1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/date_test/parse.pass.cpp
Expand Up @@ -623,6 +623,21 @@ test_p()
assert(!in.bad());
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
Expand Down

0 comments on commit 6e921e1

Please sign in to comment.