You can easily create and print C++11 dates and times.
For example:
std::chrono::system_clock::time_point dateTime =
DateUtils::createUtcDateTime(2000, 1, 13, 3, 34, 45);
std::string dateTimeString = DateUtils::toString(dateTime);
will produce:
Thu 2000-01-13 03:34:45 UTC
Times are printed in UTC, as this is a testing utility and consistency across machines is desirable.
There is an overload of DateUtils::toString()
that takes a format string, should you wish to print it differently.
ExceptionCollector is a utility that allows you to have multiple exceptions thrown, without stopping the execution of the program, and then throw them all later.
ExceptionCollector exceptions;
for (int i = 1; i <= 4; ++i)
{
exceptions.gather([&]() { /* Code that may throw errors here */ });
}
exceptions.release(); // All errors actually thrown together here
Use with Approval Tests: See Approving multiple files in one test.