diff options
Diffstat (limited to 'libs/chrono/test/io/time_point_output.cpp')
-rw-r--r-- | libs/chrono/test/io/time_point_output.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libs/chrono/test/io/time_point_output.cpp b/libs/chrono/test/io/time_point_output.cpp index 7a9d81d80..0312c33d4 100644 --- a/libs/chrono/test/io/time_point_output.cpp +++ b/libs/chrono/test/io/time_point_output.cpp @@ -76,6 +76,8 @@ void test_good_utc_fmt_system_clock(const char* str, const char* fmt, D d) std::ostringstream out; boost::chrono::time_point<Clock, D> tp(d); + boost::chrono::time_fmt_io_saver<> fmts(out); + boost::chrono::timezone_io_saver tzs(out); out << time_fmt(boost::chrono::timezone::utc, fmt) << tp; BOOST_TEST(out.good()); std::cout << "Expected= " << str << std::endl; @@ -83,6 +85,22 @@ void test_good_utc_fmt_system_clock(const char* str, const char* fmt, D d) BOOST_TEST_EQ( out.str() , std::string(str) ); } +template <typename D> +void test_good_utc_fmt_system_clock2(const char* str, const char* fmt, D d) +{ + typedef boost::chrono::system_clock Clock; + + std::ostringstream out; + boost::chrono::time_point<Clock, D> tp(d); + boost::chrono::time_fmt_io_saver<> fmts(out, fmt); + boost::chrono::timezone_io_saver tzs(out, boost::chrono::timezone::utc); + out << tp; + BOOST_TEST(out.good()); + std::cout << "Expected= " << str << std::endl; + std::cout << "Obtained= " << out.str() << std::endl; + BOOST_TEST_EQ( out.str() , std::string(str) ); +} + template<typename Clock, typename D> void test_good(const char* str, D d, boost::chrono::duration_style style) { @@ -181,6 +199,14 @@ void check_all_system_clock() test_good_utc_fmt_system_clock ("% 1970-01-01 02:00", "%% %Y-%m-%d %R", hours(2)); test_good_utc_fmt_system_clock ("1970-01-01 02:00 Thursday January", "%Y-%m-%d %R %A %B", hours(2)); #endif + test_good_utc_fmt_system_clock2("1970-01-01 02:00:00", "%Y-%m-%d %H:%M:%S", hours(2)); + test_good_utc_fmt_system_clock2("1970-01-01 02", "%Y-%m-%d %H", hours(2)); +#if ! defined(BOOST_CHRONO_WINDOWS_API) + test_good_utc_fmt_system_clock2 ("1970-01-01 02:00:00", "%Y-%m-%d %T", hours(2)); + test_good_utc_fmt_system_clock2 ("1970-01-01 02:00", "%Y-%m-%d %R", hours(2)); + test_good_utc_fmt_system_clock2 ("% 1970-01-01 02:00", "%% %Y-%m-%d %R", hours(2)); + test_good_utc_fmt_system_clock2 ("1970-01-01 02:00 Thursday January", "%Y-%m-%d %R %A %B", hours(2)); +#endif } @@ -190,7 +216,7 @@ void check_all_system_clock() void test_gmtime(std::time_t t) { std::cout << "t " << t << std::endl; - puts(ctime(&t)); + std::puts(ctime(&t)); std::tm tm; std::memset(&tm, 0, sizeof(std::tm)); if (boost::chrono::detail::internal_gmtime(&t, &tm)) |