|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81041 - trunk/libs/chrono/test/io
From: vicente.botet_at_[hidden]
Date: 2012-10-21 14:00:08
Author: viboes
Date: 2012-10-21 14:00:08 EDT (Sun, 21 Oct 2012)
New Revision: 81041
URL: http://svn.boost.org/trac/boost/changeset/81041
Log:
Chrono: rework the time_point_input test for system_clock
Text files modified:
trunk/libs/chrono/test/io/time_point_input.cpp | 58 +++++++++++++++++----------------------
1 files changed, 25 insertions(+), 33 deletions(-)
Modified: trunk/libs/chrono/test/io/time_point_input.cpp
==============================================================================
--- trunk/libs/chrono/test/io/time_point_input.cpp (original)
+++ trunk/libs/chrono/test/io/time_point_input.cpp 2012-10-21 14:00:08 EDT (Sun, 21 Oct 2012)
@@ -20,6 +20,7 @@
BOOST_TEST( (tp == boost::chrono::time_point<Clock, D>(res)));
}
+#if BOOST_CHRONO_VERSION >= 2
template <typename D>
void test_good_system_clock(std::string str, D res)
{
@@ -34,6 +35,7 @@
std::cout << "Obtained= " << tp << std::endl;
BOOST_TEST( (tp == boost::chrono::time_point<Clock, D>(res)));
}
+#endif
template <typename Clock, typename D>
void test_fail(const char* str, D)
{
@@ -85,7 +87,7 @@
test_good<Clock> ("5000 [1/30]seconds", duration<boost::int_least64_t, ratio<1, 30> > (5000));
test_good<Clock> ("5000 h", hours(5000));
-#if BOOST_CHRONO_VERSION==2
+#if BOOST_CHRONO_VERSION >= 2
test_good<Clock>("5000 min", minutes(5000));
#else
test_good<Clock> ("5000 m", minutes(5000));
@@ -105,47 +107,34 @@
}
+#if BOOST_CHRONO_VERSION >= 2
void check_all_system_clock()
{
using namespace boost::chrono;
using namespace boost;
- //test_good_system_clock ("1970-01-01 02:00:00.000000 +0000", hours(2));
- //test_good_system_clock ("5000 hours", hours(5000));
-// test_good<Clock> ("5000 minutes", minutes(5000));
-// test_good<Clock> ("5000 seconds", seconds(5000));
-// test_good<Clock> ("1 seconds", seconds(1));
-// test_good<Clock> ("1 second", seconds(1));
-// test_good<Clock> ("-1 seconds", seconds(-1));
-// test_good<Clock> ("0 second", seconds(0));
-// test_good<Clock> ("0 seconds", seconds(0));
-// test_good<Clock> ("5000 milliseconds", milliseconds(5000));
-// test_good<Clock> ("5000 microseconds", microseconds(5000));
-// test_good<Clock> ("5000 nanoseconds", nanoseconds(5000));
-// test_good<Clock> ("5000 deciseconds", duration<boost::int_least64_t, deci> (5000));
-// test_good<Clock> ("5000 [1/30]seconds", duration<boost::int_least64_t, ratio<1, 30> > (5000));
-//
-// test_good<Clock> ("5000 h", hours(5000));
-//#if BOOST_CHRONO_VERSION==2
-// test_good<Clock>("5000 min", minutes(5000));
-//#else
-// test_good<Clock> ("5000 m", minutes(5000));
-//#endif
-// test_good<Clock> ("5000 s", seconds(5000));
-// test_good<Clock> ("5000 ms", milliseconds(5000));
-// test_good<Clock> ("5000 ns", nanoseconds(5000));
-// test_good<Clock> ("5000 ds", duration<boost::int_least64_t, deci> (5000));
-// test_good<Clock> ("5000 [1/30]s", duration<boost::int_least64_t, ratio<1, 30> > (5000));
-//
-// test_good<Clock> ("5000 milliseconds", seconds(5));
-// test_good<Clock> ("5 milliseconds", nanoseconds(5000000));
-// test_good<Clock> ("4000 ms", seconds(4));
+ test_good_system_clock ("1970-01-01 02:00:00.000000 +0000", hours(2));
+ test_good_system_clock ("1970-07-28 08:00:00.000000 +0000", hours(5000));
+ test_good_system_clock ("1970-01-04 11:20:00.000000 +0000", minutes(5000));
+ test_good_system_clock ("1970-01-01 01:23:20.000000 +0000", seconds(5000));
+ test_good_system_clock ("1970-01-01 00:00:01.000000 +0000", seconds(1));
+ test_good_system_clock ("1970-01-01 00:00:01.000000 +0000", seconds(1));
+ test_good_system_clock ("1969-12-31 23:59:59.000000 +0000", seconds(-1));
+ test_good_system_clock ("1970-01-01 00:00:00.000000 +0000", seconds(0));
+ test_good_system_clock ("1970-01-01 00:00:00.000000 +0000", seconds(0));
+ test_good_system_clock ("1970-01-01 00:00:05.000000 +0000", milliseconds(5000));
+ test_good_system_clock ("1970-01-01 00:00:00.005000 +0000", microseconds(5000));
+ test_good_system_clock ("1970-01-01 00:00:00.000005 +0000", nanoseconds(5000));
+ test_good_system_clock ("1970-01-01 00:08:20.000000 +0000", duration<boost::int_least64_t, deci> (5000));
+ test_good_system_clock ("1970-01-01 00:02:46.666667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (5000));
+
+
// test_fail<Clock> ("3001 ms", seconds(3));
// test_fail_epoch<Clock> ("3001 ms", seconds(3));
// test_fail_epoch<Clock> ("3001 ms since", seconds(3));
}
-
+#endif
int main()
{
std::cout << "high_resolution_clock=" << std::endl;
@@ -155,8 +144,11 @@
check_all<boost::chrono::steady_clock> ();
#endif
std::cout << "system_clock=";
+#if BOOST_CHRONO_VERSION >= 2
check_all_system_clock();
-
+#else
+ check_all<boost::chrono::system_clock> ();
+#endif
#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
std::cout << "thread_clock="<< std::endl;
check_all<boost::chrono::thread_clock>();
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk