Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79491 - in trunk: boost/chrono libs/chrono/test libs/chrono/test/duration libs/chrono/test/time_point
From: vicente.botet_at_[hidden]
Date: 2012-07-14 06:58:33


Author: viboes
Date: 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
New Revision: 79491
URL: http://svn.boost.org/trac/boost/changeset/79491

Log:
Chrono: Added some constexpr test + fix for duration
Text files modified:
   trunk/boost/chrono/duration.hpp | 14
   trunk/libs/chrono/test/duration/arithmetic_pass.cpp | 521 ++++++++++++++++++++++++---------------
   trunk/libs/chrono/test/duration/comparisons_pass.cpp | 263 +++++++++++++------
   trunk/libs/chrono/test/duration/constructor_pass.cpp | 68 ++++
   trunk/libs/chrono/test/duration/duration_cast_pass.cpp | 12
   trunk/libs/chrono/test/duration/duration_values_pass.cpp | 23 +
   trunk/libs/chrono/test/rep.h | 16
   trunk/libs/chrono/test/time_point/arithmetic_ext_pass.cpp | 40 --
   trunk/libs/chrono/test/time_point/arithmetic_pass.cpp | 124 +++++---
   trunk/libs/chrono/test/time_point/comparisons_pass.cpp | 187 +++++++++----
   trunk/libs/chrono/test/time_point/constructor_pass.cpp | 87 ++++--
   trunk/libs/chrono/test/time_point/min_max_pass.cpp | 13
   trunk/libs/chrono/test/time_point/time_point_cast_pass.cpp | 17 +
   13 files changed, 904 insertions(+), 481 deletions(-)

Modified: trunk/boost/chrono/duration.hpp
==============================================================================
--- trunk/boost/chrono/duration.hpp (original)
+++ trunk/boost/chrono/duration.hpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -340,17 +340,17 @@
 namespace detail {
     template <class T, bool = is_arithmetic<T>::value>
     struct chrono_numeric_limits {
- static T lowest() throw() {return (std::numeric_limits<T>::min) ();}
+ static BOOST_CONSTEXPR T lowest() throw() {return (std::numeric_limits<T>::min) ();}
     };
 
     template <class T>
     struct chrono_numeric_limits<T,true> {
- static T lowest() throw() {return (std::numeric_limits<T>::min) ();}
+ static BOOST_CONSTEXPR T lowest() throw() {return (std::numeric_limits<T>::min) ();}
     };
 
     template <>
     struct chrono_numeric_limits<float,true> {
- static float lowest() throw()
+ static BOOST_CONSTEXPR float lowest() throw()
         {
             return -(std::numeric_limits<float>::max) ();
         }
@@ -358,7 +358,7 @@
 
     template <>
     struct chrono_numeric_limits<double,true> {
- static double lowest() throw()
+ static BOOST_CONSTEXPR double lowest() throw()
         {
             return -(std::numeric_limits<double>::max) ();
         }
@@ -366,7 +366,7 @@
 
     template <>
     struct chrono_numeric_limits<long double,true> {
- static long double lowest() throw()
+ static BOOST_CONSTEXPR long double lowest() throw()
         {
             return -(std::numeric_limits<long double>::max)();
         }
@@ -484,7 +484,7 @@
         // arithmetic
 
         BOOST_CONSTEXPR
- duration operator+() const {return *this;}
+ duration operator+() const {return duration(rep_);;}
         BOOST_CONSTEXPR
         duration operator-() const {return duration(-rep_);}
         duration& operator++() {++rep_; return *this;}
@@ -761,7 +761,7 @@
     // Duration >=
 
     template <class Rep1, class Period1, class Rep2, class Period2>
- inline
+ inline BOOST_CONSTEXPR
     bool
     operator>=(const duration<Rep1, Period1>& lhs,
           const duration<Rep2, Period2>& rhs)

Modified: trunk/libs/chrono/test/duration/arithmetic_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/duration/arithmetic_pass.cpp (original)
+++ trunk/libs/chrono/test/duration/arithmetic_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -14,211 +14,328 @@
 #include <boost/chrono/duration.hpp>
 
 #include <boost/detail/lightweight_test.hpp>
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
 
 int main()
 {
 
+ // UNARY PLUS
+ {
+ boost::chrono::minutes m(3);
+ boost::chrono::minutes m2 = +m;
+ BOOST_TEST(m.count() == m2.count());
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::minutes m(3);
+ BOOST_CONSTEXPR boost::chrono::minutes m2(+m);
+ BOOST_CONSTEXPR_ASSERT(m.count() == m2.count());
+ }
+
+ // UNARY MINUS
+ {
+ boost::chrono::minutes m(3);
+ boost::chrono::minutes m2 = -m;
+ BOOST_TEST(m2.count() == -m.count());
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::minutes m(3);
+ BOOST_CONSTEXPR boost::chrono::minutes m2 = -m;
+ BOOST_CONSTEXPR_ASSERT(m2.count() == -m.count());
+ }
+ // PRE INCREMENT
+ {
+ boost::chrono::hours h(3);
+ boost::chrono::hours& href = ++h;
+ BOOST_TEST(&href == &h);
+ BOOST_TEST(h.count() == 4);
+ }
+ // POST INCREMENT
+ {
+ boost::chrono::hours h(3);
+ boost::chrono::hours h2 = h++;
+ BOOST_TEST(h.count() == 4);
+ BOOST_TEST(h2.count() == 3);
+ }
+ // PRE DECREMENT
+ {
+ boost::chrono::hours h(3);
+ boost::chrono::hours& href = --h;
+ BOOST_TEST(&href == &h);
+ BOOST_TEST(h.count() == 2);
+ }
+ // POST DECREMENT
+ {
+ boost::chrono::hours h(3);
+ boost::chrono::hours h2 = h--;
+ BOOST_TEST(h.count() == 2);
+ BOOST_TEST(h2.count() == 3);
+ }
+ // PLUS ASSIGN
+ {
+ boost::chrono::seconds s(3);
+ s += boost::chrono::seconds(2);
+ BOOST_TEST(s.count() == 5);
+ s += boost::chrono::minutes(2);
+ BOOST_TEST(s.count() == 125);
+ }
+ // MINUS ASSIGN
+ {
+ boost::chrono::seconds s(3);
+ s -= boost::chrono::seconds(2);
+ BOOST_TEST(s.count() == 1);
+ s -= boost::chrono::minutes(2);
+ BOOST_TEST(s.count() == -119);
+ }
+ // TIMES ASSIGN
+ {
+ boost::chrono::nanoseconds ns(3);
+ ns *= 5;
+ BOOST_TEST(ns.count() == 15);
+ }
+ // DIVIDE ASSIGN
+ {
+ boost::chrono::nanoseconds ns(15);
+ ns /= 5;
+ BOOST_TEST(ns.count() == 3);
+ }
+ // MODULUS ASSIGN duration
+ {
+ boost::chrono::microseconds us(11);
+ boost::chrono::microseconds us2(3);
+ us %= us2;
+ BOOST_TEST(us.count() == 2);
+ us %= boost::chrono::milliseconds(3);
+ BOOST_TEST(us.count() == 2);
+ }
+ // MODULUS ASSIGN Rep
+ {
+ boost::chrono::microseconds us(11);
+ us %= 3;
+ BOOST_TEST(us.count() == 2);
+ }
+ // PLUS
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(5);
+ boost::chrono::seconds r = s1 + s2;
+ BOOST_TEST(r.count() == 8);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::seconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::seconds s2(5);
+ BOOST_CONSTEXPR boost::chrono::seconds r = s1 + s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == 8);
+ }
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::microseconds s2(5);
+ boost::chrono::microseconds r = s1 + s2;
+ BOOST_TEST(r.count() == 3000005);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::seconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::microseconds s2(5);
+ BOOST_CONSTEXPR boost::chrono::microseconds r = s1 + s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == 3000005);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
+ boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
+ boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 + s2;
+ BOOST_TEST(r.count() == 75);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 + s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == 75);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
+ boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
+ boost::chrono::duration<double, boost::ratio<1, 15> > r = s1 + s2;
+ BOOST_TEST(r.count() == 75);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<1, 15> > r = s1 + s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == 75);
+ }
+
+ // MINUS
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(5);
+ boost::chrono::seconds r = s1 - s2;
+ BOOST_TEST(r.count() == -2);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::seconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::seconds s2(5);
+ BOOST_CONSTEXPR boost::chrono::seconds r = s1 - s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == -2);
+ }
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::microseconds s2(5);
+ boost::chrono::microseconds r = s1 - s2;
+ BOOST_TEST(r.count() == 2999995);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::seconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::microseconds s2(5);
+ BOOST_CONSTEXPR boost::chrono::microseconds r = s1 - s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == 2999995);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
+ boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
+ boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 - s2;
+ BOOST_TEST(r.count() == -15);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 - s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == -15);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
+ boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
+ boost::chrono::duration<double, boost::ratio<1, 15> > r = s1 - s2;
+ BOOST_TEST(r.count() == -15);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<1, 15> > r = s1 - s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == -15);
+ }
+
+ // TIMES rep
+ {
+ boost::chrono::nanoseconds ns(3);
+ boost::chrono::nanoseconds ns2 = ns * 5;
+ BOOST_TEST(ns2.count() == 15);
+ boost::chrono::nanoseconds ns3 = 6 * ns2;
+ BOOST_TEST(ns3.count() == 90);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns(3);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns * 5;
+ BOOST_CONSTEXPR_ASSERT(ns2.count() == 15);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns3 = 6 * ns2;
+ BOOST_CONSTEXPR_ASSERT(ns3.count() == 90);
+ }
+
+ // DIVIDE duration
+ {
+ boost::chrono::nanoseconds ns1(15);
+ boost::chrono::nanoseconds ns2(5);
+ BOOST_TEST(ns1 / ns2 == 3);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns1(15);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(5);
+ BOOST_CONSTEXPR_ASSERT(ns1 / ns2 == 3);
+ }
+ {
+ boost::chrono::microseconds us1(15);
+ boost::chrono::nanoseconds ns2(5);
+ BOOST_TEST(us1 / ns2 == 3000);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::microseconds us1(15);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(5);
+ BOOST_CONSTEXPR_ASSERT(us1 / ns2 == 3000);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(30);
+ boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
+ BOOST_TEST(s1 / s2 == 6);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(30);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
+ BOOST_CONSTEXPR_ASSERT(s1 / s2 == 6);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(30);
+ boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
+ BOOST_TEST(s1 / s2 == 20. / 3);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(30);
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
+ BOOST_CONSTEXPR_ASSERT(s1 / s2 == 20. / 3);
+ }
+ // DIVIDE rep
+ {
+ boost::chrono::nanoseconds ns(15);
+ boost::chrono::nanoseconds ns2 = ns / 5;
+ BOOST_TEST(ns2.count() == 3);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns(15);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns / 5;
+ BOOST_CONSTEXPR_ASSERT(ns2.count() == 3);
+ }
+
+ // MODULUS duration
+
+ {
+ boost::chrono::nanoseconds ns1(15);
+ boost::chrono::nanoseconds ns2(6);
+ boost::chrono::nanoseconds r = ns1 % ns2;
+ BOOST_TEST(r.count() == 3);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns1(15);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(6);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds r = ns1 % ns2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == 3);
+ }
+ {
+ boost::chrono::microseconds us1(15);
+ boost::chrono::nanoseconds ns2(28);
+ boost::chrono::nanoseconds r = us1 % ns2;
+ BOOST_TEST(r.count() == 20);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::microseconds us1(15);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(28);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds r = us1 % ns2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == 20);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<3, 5> > s1(6);
+ boost::chrono::duration<int, boost::ratio<2, 3> > s2(3);
+ boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 % s2;
+ BOOST_TEST(r.count() == 24);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s1(6);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s2(3);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 % s2;
+ BOOST_CONSTEXPR_ASSERT(r.count() == 24);
+ }
+ // MODULUS rep
+ {
+ boost::chrono::nanoseconds ns(15);
+ boost::chrono::nanoseconds ns2 = ns % 6;
+ BOOST_TEST(ns2.count() == 3);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns(15);
+ BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns % 6;
+ BOOST_CONSTEXPR_ASSERT(ns2.count() == 3);
+ }
 
- // UNARY PLUS
- {
- BOOST_CONSTEXPR boost::chrono::minutes m(3);
- boost::chrono::minutes m2 = +m;
- BOOST_TEST(m.count() == m2.count());
- }
-
- // UNARY MINUS
- {
- BOOST_CONSTEXPR boost::chrono::minutes m(3);
- boost::chrono::minutes m2 = -m;
- BOOST_TEST(m2.count() == -m.count());
- }
- // PRE INCREMENT
- {
- boost::chrono::hours h(3);
- boost::chrono::hours& href = ++h;
- BOOST_TEST(&href == &h);
- BOOST_TEST(h.count() == 4);
- }
- // POST INCREMENT
- {
- boost::chrono::hours h(3);
- boost::chrono::hours h2 = h++;
- BOOST_TEST(h.count() == 4);
- BOOST_TEST(h2.count() == 3);
- }
- // PRE DECREMENT
- {
- boost::chrono::hours h(3);
- boost::chrono::hours& href = --h;
- BOOST_TEST(&href == &h);
- BOOST_TEST(h.count() == 2);
- }
- // POST DECREMENT
- {
- boost::chrono::hours h(3);
- boost::chrono::hours h2 = h--;
- BOOST_TEST(h.count() == 2);
- BOOST_TEST(h2.count() == 3);
- }
- // PLUS ASSIGN
- {
- boost::chrono::seconds s(3);
- s += boost::chrono::seconds(2);
- BOOST_TEST(s.count() == 5);
- s += boost::chrono::minutes(2);
- BOOST_TEST(s.count() == 125);
- }
- // MINUS ASSIGN
- {
- boost::chrono::seconds s(3);
- s -= boost::chrono::seconds(2);
- BOOST_TEST(s.count() == 1);
- s -= boost::chrono::minutes(2);
- BOOST_TEST(s.count() == -119);
- }
- // TIMES ASSIGN
- {
- boost::chrono::nanoseconds ns(3);
- ns *= 5;
- BOOST_TEST(ns.count() == 15);
- }
- // DIVIDE ASSIGN
- {
- boost::chrono::nanoseconds ns(15);
- ns /= 5;
- BOOST_TEST(ns.count() == 3);
- }
- // MODULUS ASSIGN duration
- {
- boost::chrono::microseconds us(11);
- boost::chrono::microseconds us2(3);
- us %= us2;
- BOOST_TEST(us.count() == 2);
- us %= boost::chrono::milliseconds(3);
- BOOST_TEST(us.count() == 2);
- }
- // MODULUS ASSIGN Rep
- {
- boost::chrono::microseconds us(11);
- us %= 3;
- BOOST_TEST(us.count() == 2);
- }
- // PLUS
- {
- BOOST_CONSTEXPR boost::chrono::seconds s1(3);
- BOOST_CONSTEXPR boost::chrono::seconds s2(5);
- BOOST_CONSTEXPR boost::chrono::seconds r = s1 + s2;
- BOOST_TEST(r.count() == 8);
- }
- {
- BOOST_CONSTEXPR boost::chrono::seconds s1(3);
- BOOST_CONSTEXPR boost::chrono::microseconds s2(5);
- BOOST_CONSTEXPR boost::chrono::microseconds r = s1 + s2;
- BOOST_TEST(r.count() == 3000005);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 + s2;
- BOOST_TEST(r.count() == 75);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
- BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
- BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<1, 15> > r = s1 + s2;
- BOOST_TEST(r.count() == 75);
- }
-
-
- // MINUS
- {
- BOOST_CONSTEXPR boost::chrono::seconds s1(3);
- BOOST_CONSTEXPR boost::chrono::seconds s2(5);
- BOOST_CONSTEXPR boost::chrono::seconds r = s1 - s2;
- BOOST_TEST(r.count() == -2);
- }
- {
- BOOST_CONSTEXPR boost::chrono::seconds s1(3);
- BOOST_CONSTEXPR boost::chrono::microseconds s2(5);
- BOOST_CONSTEXPR boost::chrono::microseconds r = s1 - s2;
- BOOST_TEST(r.count() == 2999995);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 - s2;
- BOOST_TEST(r.count() == -15);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(3);
- BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
- BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<1, 15> > r = s1 - s2;
- BOOST_TEST(r.count() == -15);
- }
-
- // TIMES rep
- {
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns(3);
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns * 5;
- BOOST_TEST(ns2.count() == 15);
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns3 = 6 * ns2;
- BOOST_TEST(ns3.count() == 90);
- }
-
- // DIVIDE duration
- {
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns1(15);
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(5);
- BOOST_TEST(ns1 / ns2 == 3);
- }
- {
- BOOST_CONSTEXPR boost::chrono::microseconds us1(15);
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(5);
- BOOST_TEST(us1 / ns2 == 3000);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(30);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(5);
- BOOST_TEST(s1 / s2 == 6);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(30);
- BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(5);
- BOOST_TEST(s1 / s2 == 20./3);
- }
- // DIVIDE rep
- {
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns(15);
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns / 5;
- BOOST_TEST(ns2.count() == 3);
- }
-
- // MODULUS duration
-
- {
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns1(15);
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(6);
- BOOST_CONSTEXPR boost::chrono::nanoseconds r = ns1 % ns2;
- BOOST_TEST(r.count() == 3);
- }
- {
- BOOST_CONSTEXPR boost::chrono::microseconds us1(15);
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(28);
- BOOST_CONSTEXPR boost::chrono::nanoseconds r = us1 % ns2;
- BOOST_TEST(r.count() == 20);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s1(6);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s2(3);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<1, 15> > r = s1 % s2;
- BOOST_TEST(r.count() == 24);
- }
- // MODULUS rep
- {
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns(15);
- BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns % 6;
- BOOST_TEST(ns2.count() == 3);
- }
-
- return boost::report_errors();
+ return boost::report_errors();
 }

Modified: trunk/libs/chrono/test/duration/comparisons_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/duration/comparisons_pass.cpp (original)
+++ trunk/libs/chrono/test/duration/comparisons_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -13,109 +13,210 @@
 
 #include <boost/chrono/duration.hpp>
 #include <boost/detail/lightweight_test.hpp>
-
-#define BOOST_CHRONO_TEST(C) if (true) {BOOST_CONSTEXPR bool B = (C); BOOST_TEST(B);} else
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
 
 int main()
 {
- {
- BOOST_CONSTEXPR boost::chrono::seconds s1(3);
- BOOST_CONSTEXPR boost::chrono::seconds s2(3);
- BOOST_CONSTEXPR bool b1 = (s1 == s2);
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(3);
     BOOST_TEST(s1 == s2);
- BOOST_TEST(!(s1 != s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::seconds s1(3);
- BOOST_CONSTEXPR boost::chrono::seconds s2(4);
- BOOST_TEST(!(s1 == s2));
+ BOOST_TEST(! (s1 != s2));
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::seconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::seconds s2(3);
+ BOOST_CONSTEXPR_ASSERT(s1 == s2);
+ BOOST_CONSTEXPR_ASSERT(!(s1 != s2));
+ }
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(4);
+ BOOST_TEST(! (s1 == s2));
     BOOST_TEST(s1 != s2);
- }
- {
- BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
- BOOST_CONSTEXPR boost::chrono::microseconds s2(3000);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::seconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::seconds s2(4);
+ BOOST_CONSTEXPR_ASSERT(! (s1 == s2));
+ BOOST_CONSTEXPR_ASSERT(s1 != s2);
+ }
+ {
+ boost::chrono::milliseconds s1(3);
+ boost::chrono::microseconds s2(3000);
     BOOST_TEST(s1 == s2);
- BOOST_TEST(!(s1 != s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
- BOOST_CONSTEXPR boost::chrono::microseconds s2(4000);
- BOOST_TEST(!(s1 == s2));
+ BOOST_TEST(! (s1 != s2));
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::microseconds s2(3000);
+ BOOST_CONSTEXPR_ASSERT(s1 == s2);
+ BOOST_CONSTEXPR_ASSERT(! (s1 != s2));
+ }
+ {
+ boost::chrono::milliseconds s1(3);
+ boost::chrono::microseconds s2(4000);
+ BOOST_TEST(! (s1 == s2));
     BOOST_TEST(s1 != s2);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::microseconds s2(4000);
+ BOOST_CONSTEXPR_ASSERT(! (s1 == s2));
+ BOOST_CONSTEXPR_ASSERT(s1 != s2);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
+ boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
     BOOST_TEST(s1 == s2);
- BOOST_TEST(!(s1 != s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
- BOOST_TEST(!(s1 == s2));
+ BOOST_TEST(! (s1 != s2));
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
+ BOOST_CONSTEXPR_ASSERT(s1 == s2);
+ BOOST_CONSTEXPR_ASSERT(! (s1 != s2));
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
+ boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
+ BOOST_TEST(! (s1 == s2));
     BOOST_TEST(s1 != s2);
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
- BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
+ BOOST_CONSTEXPR_ASSERT(! (s1 == s2));
+ BOOST_CONSTEXPR_ASSERT(s1 != s2);
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
+ boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
     BOOST_TEST(s1 == s2);
- BOOST_TEST(!(s1 != s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::seconds s1(3);
- BOOST_CONSTEXPR boost::chrono::seconds s2(3);
- BOOST_TEST(!(s1 < s2));
- BOOST_TEST(!(s1 > s2));
+ BOOST_TEST(! (s1 != s2));
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
+ BOOST_CONSTEXPR_ASSERT(s1 == s2);
+ BOOST_CONSTEXPR_ASSERT(! (s1 != s2));
+ }
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(3);
+ BOOST_TEST(! (s1 < s2));
+ BOOST_TEST(! (s1 > s2));
     BOOST_TEST( (s1 <= s2));
     BOOST_TEST( (s1 >= s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::seconds s1(3);
- BOOST_CONSTEXPR boost::chrono::seconds s2(4);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::seconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::seconds s2(3);
+ BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
+ }
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(4);
     BOOST_TEST( (s1 < s2));
- BOOST_TEST(!(s1 > s2));
+ BOOST_TEST(! (s1 > s2));
     BOOST_TEST( (s1 <= s2));
- BOOST_TEST(!(s1 >= s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
- BOOST_CONSTEXPR boost::chrono::microseconds s2(3000);
- BOOST_TEST(!(s1 < s2));
- BOOST_TEST(!(s1 > s2));
+ BOOST_TEST(! (s1 >= s2));
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::seconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::seconds s2(4);
+ BOOST_CONSTEXPR_ASSERT( (s1 < s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 >= s2));
+ }
+ {
+ boost::chrono::milliseconds s1(3);
+ boost::chrono::microseconds s2(3000);
+ BOOST_TEST(! (s1 < s2));
+ BOOST_TEST(! (s1 > s2));
     BOOST_TEST( (s1 <= s2));
     BOOST_TEST( (s1 >= s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
- BOOST_CONSTEXPR boost::chrono::microseconds s2(4000);
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::microseconds s2(3000);
+ BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
+ }
+ {
+ boost::chrono::milliseconds s1(3);
+ boost::chrono::microseconds s2(4000);
     BOOST_TEST( (s1 < s2));
- BOOST_TEST(!(s1 > s2));
+ BOOST_TEST(! (s1 > s2));
     BOOST_TEST( (s1 <= s2));
- BOOST_TEST(!(s1 >= s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
- BOOST_TEST(!(s1 < s2));
- BOOST_TEST(!(s1 > s2));
+ BOOST_TEST(! (s1 >= s2));
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
+ BOOST_CONSTEXPR boost::chrono::microseconds s2(4000);
+ BOOST_CONSTEXPR_ASSERT( (s1 < s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 >= s2));
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
+ boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
+ BOOST_TEST(! (s1 < s2));
+ BOOST_TEST(! (s1 > s2));
     BOOST_TEST( (s1 <= s2));
     BOOST_TEST( (s1 >= s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
- BOOST_TEST(!(s1 < s2));
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
+ BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
+ boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
+ BOOST_TEST(! (s1 < s2));
     BOOST_TEST( (s1 > s2));
- BOOST_TEST(!(s1 <= s2));
+ BOOST_TEST(! (s1 <= s2));
     BOOST_TEST( (s1 >= s2));
- }
- {
- BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
- BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
- BOOST_TEST(!(s1 < s2));
- BOOST_TEST(!(s1 > s2));
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
+ BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 > s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 <= s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
+ }
+ {
+ boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
+ boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
+ BOOST_TEST(! (s1 < s2));
+ BOOST_TEST(! (s1 > s2));
     BOOST_TEST( (s1 <= s2));
     BOOST_TEST( (s1 >= s2));
- }
- return boost::report_errors();
+ }
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
+ BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
+ BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
+ BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
+ }
+ return boost::report_errors();
 }

Modified: trunk/libs/chrono/test/duration/constructor_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/duration/constructor_pass.cpp (original)
+++ trunk/libs/chrono/test/duration/constructor_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -19,23 +19,35 @@
 #include <libs/chrono/test/rep.h>
 #include <iostream>
 
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
+
 template <class D>
 void
 check_default()
 {
- //D d=D();
- D d;
- //std::cout << d.count() << std::endl;
- //std::cout << typename D::rep() << std::endl;
+ {
+ D d;
     BOOST_TEST(d.count() == typename D::rep());
+ }
+ {
+ BOOST_CONSTEXPR D d;
+ BOOST_CONSTEXPR_ASSERT(d.count() == typename D::rep());
+ }
 }
 
 template <class D, class R>
 void
 check_from_rep(R r)
 {
+ {
     D d(r);
     BOOST_TEST(d.count() == r);
+ }
 }
 
 int main()
@@ -45,39 +57,71 @@
         boost::chrono::milliseconds ms(1);
         boost::chrono::microseconds us = ms;
         BOOST_TEST(us.count() == 1000);
+ {
+ BOOST_CONSTEXPR boost::chrono::milliseconds ms(1);
+ BOOST_CONSTEXPR boost::chrono::microseconds us = ms;
+ BOOST_CONSTEXPR_ASSERT(us.count() == 1000);
+ }
     }
     // inexact conversions allowed for floating point reps
     {
         boost::chrono::duration<double, boost::micro> us(1);
         boost::chrono::duration<double, boost::milli> ms = us;
         BOOST_TEST(ms.count() == 1./1000);
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::micro> us(1);
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::milli> ms = us;
+ BOOST_CONSTEXPR_ASSERT(ms.count() == 1./1000);
+ }
     }
     // Convert int to float
     {
         boost::chrono::duration<int> i(3);
- boost::chrono::duration<int> d = i;
+ boost::chrono::duration<double> d = i;
         BOOST_TEST(d.count() == 3);
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int> i(3);
+ BOOST_CONSTEXPR boost::chrono::duration<double> d = i;
+ BOOST_CONSTEXPR_ASSERT(d.count() == 3);
+ }
     }
     // default constructor
     {
- check_default<boost::chrono::duration<Rep> >();
- // constexpr default constructor
- BOOST_CONSTEXPR boost::chrono::duration<int> d;
+ check_default<boost::chrono::duration<Rep> >();
     }
     // constructor from rep
     {
- check_from_rep<boost::chrono::duration<int> >(5);
- BOOST_CONSTEXPR boost::chrono::duration<int> d(5);
+ check_from_rep<boost::chrono::duration<int> >(5);
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int> d(5);
+ BOOST_CONSTEXPR_ASSERT(d.count() == 5);
+ }
         check_from_rep<boost::chrono::duration<int, boost::ratio<3, 2> > >(5);
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 2> > d(5);
+ BOOST_CONSTEXPR_ASSERT(d.count() == 5);
+ }
         check_from_rep<boost::chrono::duration<Rep, boost::ratio<3, 2> > >(Rep(3));
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<Rep, boost::ratio<3, 2> > d(Rep(3));
+ BOOST_CONSTEXPR_ASSERT(d.count() == Rep(3));
+ }
         check_from_rep<boost::chrono::duration<double, boost::ratio<2, 3> > >(5.5);
- boost::chrono::duration<double, boost::ratio<2, 3> > d2(5.5);
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 2> > d(5.5);
+ BOOST_CONSTEXPR_ASSERT(d.count() == 5.5);
+ }
+
+
     }
     // constructor from other rep
     {
         boost::chrono::duration<double> d(5);
         BOOST_TEST(d.count() == 5);
- return boost::report_errors();
+ {
+ BOOST_CONSTEXPR boost::chrono::duration<double> d(5);
+ BOOST_CONSTEXPR_ASSERT(d.count() == 5);
+ }
     }
 
     return boost::report_errors();

Modified: trunk/libs/chrono/test/duration/duration_cast_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/duration/duration_cast_pass.cpp (original)
+++ trunk/libs/chrono/test/duration/duration_cast_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -18,6 +18,14 @@
 #define NOTHING ""
 #endif
 
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
+
+
 template <class ToDuration, class FromDuration>
 void
 test(const FromDuration& f, const ToDuration& d)
@@ -43,5 +51,9 @@
          boost::chrono::duration<double, boost::ratio<3600> >(7265./3600));
     test(boost::chrono::duration<int, boost::ratio<2, 3> >(9),
          boost::chrono::duration<int, boost::ratio<3, 5> >(10));
+ {
+ BOOST_CONSTEXPR boost::chrono::hours h = boost::chrono::duration_cast<boost::chrono::hours>(boost::chrono::milliseconds(7265000));
+ BOOST_CONSTEXPR_ASSERT(h.count() == 2);
+ }
     return boost::report_errors();
 }

Modified: trunk/libs/chrono/test/duration/duration_values_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/duration/duration_values_pass.cpp (original)
+++ trunk/libs/chrono/test/duration/duration_values_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -15,6 +15,12 @@
 #include <boost/detail/lightweight_test.hpp>
 
 #include <libs/chrono/test/rep.h>
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
 
 template <class D>
 void check_max()
@@ -22,6 +28,11 @@
     typedef typename D::rep Rep;
     Rep max_rep = (boost::chrono::duration_values<Rep>::max)();
     BOOST_TEST((D::max)().count() == max_rep);
+ {
+ typedef typename D::rep Rep;
+ BOOST_CONSTEXPR Rep max_rep = (boost::chrono::duration_values<Rep>::max)();
+ BOOST_CONSTEXPR_ASSERT((D::max)().count() == max_rep);
+ }
 }
 
 template <class D>
@@ -30,6 +41,12 @@
     typedef typename D::rep Rep;
     Rep min_rep = (boost::chrono::duration_values<Rep>::min)();
     BOOST_TEST((D::min)().count() == min_rep);
+ {
+ typedef typename D::rep Rep;
+ BOOST_CONSTEXPR Rep min_rep = (boost::chrono::duration_values<Rep>::min)();
+ BOOST_CONSTEXPR_ASSERT((D::min)().count() == min_rep);
+
+ }
 }
 
 template <class D>
@@ -38,6 +55,12 @@
     typedef typename D::rep Rep;
     Rep zero_rep = boost::chrono::duration_values<Rep>::zero();
     BOOST_TEST(D::zero().count() == zero_rep);
+ {
+ typedef typename D::rep Rep;
+ BOOST_CONSTEXPR Rep zero_rep = boost::chrono::duration_values<Rep>::zero();
+ BOOST_CONSTEXPR_ASSERT(D::zero().count() == zero_rep);
+
+ }
 }
 
 

Modified: trunk/libs/chrono/test/rep.h
==============================================================================
--- trunk/libs/chrono/test/rep.h (original)
+++ trunk/libs/chrono/test/rep.h 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -14,15 +14,17 @@
 #ifndef REP_H
 #define REP_H
 
+#include <boost/config.hpp>
+
 class Rep
 {
 public:
     int data_;
- Rep() : data_() {}
- explicit Rep(int i) : data_(i) {}
+ BOOST_CONSTEXPR Rep() : data_() {}
+ explicit BOOST_CONSTEXPR Rep(int i) : data_(i) {}
 
- bool operator==(int i) const {return data_ == i;}
- bool operator==(const Rep& r) const {return data_ == r.data_;}
+ BOOST_CONSTEXPR bool operator==(int i) const {return data_ == i;}
+ BOOST_CONSTEXPR bool operator==(const Rep& r) const {return data_ == r.data_;}
 
     Rep& operator*=(Rep x) {data_ *= x.data_; return *this;}
     Rep& operator/=(Rep x) {data_ /= x.data_; return *this;}
@@ -30,7 +32,7 @@
 
 #if 0
 namespace std {
-
+
   template <>
   struct numeric_limits<Rep>
   {
@@ -38,7 +40,7 @@
     {
       return Rep((std::numeric_limits<int>::max)());
     }
-
+
   };
 } // namespace std
 
@@ -52,7 +54,7 @@
   {
     return Rep((std::numeric_limits<int>::max)());
   }
-
+
   static BOOST_CONSTEXPR Rep min BOOST_PREVENT_MACRO_SUBSTITUTION ()
   {
     return Rep(detail::numeric_limits<Rep>::lowest());

Modified: trunk/libs/chrono/test/time_point/arithmetic_ext_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/time_point/arithmetic_ext_pass.cpp (original)
+++ trunk/libs/chrono/test/time_point/arithmetic_ext_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -14,9 +14,15 @@
 #define BOOST_CHRONO_EXTENSIONS
 #include <boost/chrono/chrono.hpp>
 #include <boost/detail/lightweight_test.hpp>
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
 
 int main()
-{
+{
   {
     typedef boost::chrono::system_clock Clock;
     typedef boost::chrono::milliseconds Duration;
@@ -59,34 +65,6 @@
     --t;
     BOOST_TEST(t.time_since_epoch() == Duration(2));
   }
-#if 0
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration1;
- typedef boost::chrono::microseconds Duration2;
- boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
- boost::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
- BOOST_TEST(t2.time_since_epoch() == Duration2(2995));
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration1;
- typedef boost::chrono::microseconds Duration2;
- boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
- boost::chrono::time_point<Clock, Duration2> t2(Duration2(5));
- BOOST_TEST((t1 - t2) == Duration2(2995));
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration1;
- typedef boost::chrono::microseconds Duration2;
- boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
- boost::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
- BOOST_TEST(t2.time_since_epoch() == Duration2(3005));
- t2 = Duration2(6) + t1;
- BOOST_TEST(t2.time_since_epoch() == Duration2(3006));
- }
-#endif
-
- return boost::report_errors();
+
+ return boost::report_errors();
 }

Modified: trunk/libs/chrono/test/time_point/arithmetic_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/time_point/arithmetic_pass.cpp (original)
+++ trunk/libs/chrono/test/time_point/arithmetic_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -13,50 +13,82 @@
 
 #include <boost/chrono/chrono.hpp>
 #include <boost/detail/lightweight_test.hpp>
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
 
 int main()
 {
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration;
- boost::chrono::time_point<Clock, Duration> t(Duration(3));
- t += Duration(2);
- BOOST_TEST(t.time_since_epoch() == Duration(5));
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration;
- boost::chrono::time_point<Clock, Duration> t(Duration(3));
- t -= Duration(2);
- BOOST_TEST(t.time_since_epoch() == Duration(1));
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration1;
- typedef boost::chrono::microseconds Duration2;
- boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
- boost::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
- BOOST_TEST(t2.time_since_epoch() == Duration2(2995));
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration1;
- typedef boost::chrono::microseconds Duration2;
- boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
- boost::chrono::time_point<Clock, Duration2> t2(Duration2(5));
- BOOST_TEST((t1 - t2) == Duration2(2995));
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration1;
- typedef boost::chrono::microseconds Duration2;
- boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
- boost::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
- BOOST_TEST(t2.time_since_epoch() == Duration2(3005));
- t2 = Duration2(6) + t1;
- BOOST_TEST(t2.time_since_epoch() == Duration2(3006));
- }
-#ifdef BOOST_CHRONO_EXTENSIONS
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ boost::chrono::time_point<Clock, Duration> t(Duration(3));
+ t += Duration(2);
+ BOOST_TEST(t.time_since_epoch() == Duration(5));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ boost::chrono::time_point<Clock, Duration> t(Duration(3));
+ t -= Duration(2);
+ BOOST_TEST(t.time_since_epoch() == Duration(1));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ boost::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+ BOOST_TEST(t2.time_since_epoch() == Duration2(2995));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+ BOOST_CONSTEXPR_ASSERT(t2.time_since_epoch() == Duration2(2995));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ boost::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+ BOOST_TEST( (t1 - t2) == Duration2(2995));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+ BOOST_CONSTEXPR_ASSERT( (t1 - t2) == Duration2(2995));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ boost::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
+ BOOST_TEST(t2.time_since_epoch() == Duration2(3005));
+ t2 = Duration2(6) + t1;
+ BOOST_TEST(t2.time_since_epoch() == Duration2(3006));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
+ BOOST_CONSTEXPR_ASSERT(t2.time_since_epoch() == Duration2(3005));
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration2> t3 = Duration2(6) + t1;
+ BOOST_CONSTEXPR_ASSERT(t3.time_since_epoch() == Duration2(3006));
+ }
+#ifdef BOOST_CHRONO_EXTENSIONS
   {
     typedef boost::chrono::system_clock Clock;
     typedef boost::chrono::milliseconds Duration;
@@ -111,9 +143,9 @@
     BOOST_TEST(t2.time_since_epoch() == Duration2(3005));
     t2 = Duration2(6) + t1;
     BOOST_TEST(t2.time_since_epoch() == Duration2(3006));
- }
-#endif
-#endif
-
- return boost::report_errors();
+ }
+#endif
+#endif
+
+ return boost::report_errors();
 }

Modified: trunk/libs/chrono/test/time_point/comparisons_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/time_point/comparisons_pass.cpp (original)
+++ trunk/libs/chrono/test/time_point/comparisons_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -13,71 +13,134 @@
 
 #include <boost/chrono/chrono.hpp>
 #include <boost/detail/lightweight_test.hpp>
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
+
 
 int main()
 {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration1;
- typedef boost::chrono::microseconds Duration2;
- typedef boost::chrono::time_point<Clock, Duration1> T1;
- typedef boost::chrono::time_point<Clock, Duration2> T2;
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ typedef boost::chrono::time_point<Clock, Duration1> T1;
+ typedef boost::chrono::time_point<Clock, Duration2> T2;
 
- {
- T1 t1(Duration1(3));
- T1 t2(Duration1(3));
- BOOST_TEST( (t1 == t2));
- BOOST_TEST(!(t1 != t2));
- }
- {
- T1 t1(Duration1(3));
- T1 t2(Duration1(4));
- BOOST_TEST(!(t1 == t2));
- BOOST_TEST( (t1 != t2));
- }
- {
- T1 t1(Duration1(3));
- T2 t2(Duration2(3000));
- BOOST_TEST( (t1 == t2));
- BOOST_TEST(!(t1 != t2));
- }
- {
- T1 t1(Duration1(3));
- T2 t2(Duration2(3001));
- BOOST_TEST(!(t1 == t2));
- BOOST_TEST( (t1 != t2));
- }
- {
- T1 t1(Duration1(3));
- T1 t2(Duration1(3));
- BOOST_TEST(!(t1 < t2));
- BOOST_TEST(!(t1 > t2));
- BOOST_TEST( (t1 <= t2));
- BOOST_TEST( (t1 >= t2));
- }
- {
- T1 t1(Duration1(3));
- T1 t2(Duration1(4));
- BOOST_TEST( (t1 < t2));
- BOOST_TEST(!(t1 > t2));
- BOOST_TEST( (t1 <= t2));
- BOOST_TEST(!(t1 >= t2));
- }
- {
- T1 t1(Duration1(3));
- T2 t2(Duration2(3000));
- BOOST_TEST(!(t1 < t2));
- BOOST_TEST(!(t1 > t2));
- BOOST_TEST( (t1 <= t2));
- BOOST_TEST( (t1 >= t2));
- }
- {
- T1 t1(Duration1(3));
- T2 t2(Duration2(3001));
- BOOST_TEST( (t1 < t2));
- BOOST_TEST(!(t1 > t2));
- BOOST_TEST( (t1 <= t2));
- BOOST_TEST(!(t1 >= t2));
- }
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(3));
+ BOOST_TEST( (t1 == t2));
+ BOOST_TEST(! (t1 != t2));
+ }
+ {
+ BOOST_CONSTEXPR T1 t1(Duration1(3));
+ BOOST_CONSTEXPR T1 t2(Duration1(3));
+ BOOST_CONSTEXPR_ASSERT( (t1 == t2));
+ BOOST_CONSTEXPR_ASSERT(! (t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(4));
+ BOOST_TEST(! (t1 == t2));
+ BOOST_TEST( (t1 != t2));
+ }
+ {
+ BOOST_CONSTEXPR T1 t1(Duration1(3));
+ BOOST_CONSTEXPR T1 t2(Duration1(4));
+ BOOST_CONSTEXPR_ASSERT(! (t1 == t2));
+ BOOST_CONSTEXPR_ASSERT( (t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ BOOST_TEST( (t1 == t2));
+ BOOST_TEST(! (t1 != t2));
+ }
+ {
+ BOOST_CONSTEXPR T1 t1(Duration1(3));
+ BOOST_CONSTEXPR T2 t2(Duration2(3000));
+ BOOST_CONSTEXPR_ASSERT( (t1 == t2));
+ BOOST_CONSTEXPR_ASSERT(! (t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3001));
+ BOOST_TEST(! (t1 == t2));
+ BOOST_TEST( (t1 != t2));
+ }
+ {
+ BOOST_CONSTEXPR T1 t1(Duration1(3));
+ BOOST_CONSTEXPR T2 t2(Duration2(3001));
+ BOOST_CONSTEXPR_ASSERT(! (t1 == t2));
+ BOOST_CONSTEXPR_ASSERT( (t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(3));
+ BOOST_TEST(! (t1 < t2));
+ BOOST_TEST(! (t1 > t2));
+ BOOST_TEST( (t1 <= t2));
+ BOOST_TEST( (t1 >= t2));
+ }
+ {
+ BOOST_CONSTEXPR T1 t1(Duration1(3));
+ BOOST_CONSTEXPR T1 t2(Duration1(3));
+ BOOST_CONSTEXPR_ASSERT(! (t1 < t2));
+ BOOST_CONSTEXPR_ASSERT(! (t1 > t2));
+ BOOST_CONSTEXPR_ASSERT( (t1 <= t2));
+ BOOST_CONSTEXPR_ASSERT( (t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(4));
+ BOOST_TEST( (t1 < t2));
+ BOOST_TEST(! (t1 > t2));
+ BOOST_TEST( (t1 <= t2));
+ BOOST_TEST(! (t1 >= t2));
+ }
+ {
+ BOOST_CONSTEXPR T1 t1(Duration1(3));
+ BOOST_CONSTEXPR T1 t2(Duration1(4));
+ BOOST_CONSTEXPR_ASSERT( (t1 < t2));
+ BOOST_CONSTEXPR_ASSERT(! (t1 > t2));
+ BOOST_CONSTEXPR_ASSERT( (t1 <= t2));
+ BOOST_CONSTEXPR_ASSERT(! (t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ BOOST_TEST(! (t1 < t2));
+ BOOST_TEST(! (t1 > t2));
+ BOOST_TEST( (t1 <= t2));
+ BOOST_TEST( (t1 >= t2));
+ }
+ {
+ BOOST_CONSTEXPR T1 t1(Duration1(3));
+ BOOST_CONSTEXPR T2 t2(Duration2(3000));
+ BOOST_CONSTEXPR_ASSERT(! (t1 < t2));
+ BOOST_CONSTEXPR_ASSERT(! (t1 > t2));
+ BOOST_CONSTEXPR_ASSERT( (t1 <= t2));
+ BOOST_CONSTEXPR_ASSERT( (t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3001));
+ BOOST_TEST( (t1 < t2));
+ BOOST_TEST(! (t1 > t2));
+ BOOST_TEST( (t1 <= t2));
+ BOOST_TEST(! (t1 >= t2));
+ }
+ {
+ BOOST_CONSTEXPR T1 t1(Duration1(3));
+ BOOST_CONSTEXPR T2 t2(Duration2(3001));
+ BOOST_CONSTEXPR_ASSERT( (t1 < t2));
+ BOOST_CONSTEXPR_ASSERT(! (t1 > t2));
+ BOOST_CONSTEXPR_ASSERT( (t1 <= t2));
+ BOOST_CONSTEXPR_ASSERT(! (t1 >= t2));
+ }
 
- return boost::report_errors();
+ return boost::report_errors();
 }

Modified: trunk/libs/chrono/test/time_point/constructor_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/time_point/constructor_pass.cpp (original)
+++ trunk/libs/chrono/test/time_point/constructor_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -14,36 +14,67 @@
 #include <boost/chrono/chrono.hpp>
 #include <boost/detail/lightweight_test.hpp>
 #include <libs/chrono/test/rep.h>
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
 
 int main()
 {
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::microseconds Duration1;
- typedef boost::chrono::milliseconds Duration2;
- boost::chrono::time_point<Clock, Duration2> t2(Duration2(3));
- boost::chrono::time_point<Clock, Duration1> t1 = t2;
- BOOST_TEST(t1.time_since_epoch() == Duration1(3000));
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::duration<Rep, boost::milli> Duration;
- boost::chrono::time_point<Clock, Duration> t;
- BOOST_TEST(t.time_since_epoch() == Duration::zero());
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration;
- boost::chrono::time_point<Clock, Duration> t(Duration(3));
- BOOST_TEST(t.time_since_epoch() == Duration(3));
- }
- {
- typedef boost::chrono::system_clock Clock;
- typedef boost::chrono::milliseconds Duration;
- boost::chrono::time_point<Clock, Duration> t(boost::chrono::seconds(3));
- BOOST_TEST(t.time_since_epoch() == Duration(3000));
- }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::microseconds Duration1;
+ typedef boost::chrono::milliseconds Duration2;
+ boost::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+ boost::chrono::time_point<Clock, Duration1> t1 = t2;
+ BOOST_TEST(t1.time_since_epoch() == Duration1(3000));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::microseconds Duration1;
+ typedef boost::chrono::milliseconds Duration2;
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration1> t1 = t2;
+ BOOST_CONSTEXPR_ASSERT(t1.time_since_epoch() == Duration1(3000));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::duration<Rep, boost::milli> Duration;
+ boost::chrono::time_point<Clock, Duration> t;
+ BOOST_TEST(t.time_since_epoch() == Duration::zero());
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::duration<Rep, boost::milli> Duration;
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t;
+ BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration::zero());
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ boost::chrono::time_point<Clock, Duration> t(Duration(3));
+ BOOST_TEST(t.time_since_epoch() == Duration(3));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t(Duration(3));
+ BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration(3));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ boost::chrono::time_point<Clock, Duration> t(boost::chrono::seconds(3));
+ BOOST_TEST(t.time_since_epoch() == Duration(3000));
+ }
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t(boost::chrono::seconds(3));
+ BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration(3000));
+ }
 
-
- return boost::report_errors();
+ return boost::report_errors();
 }

Modified: trunk/libs/chrono/test/time_point/min_max_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/time_point/min_max_pass.cpp (original)
+++ trunk/libs/chrono/test/time_point/min_max_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -14,14 +14,21 @@
 #include <boost/chrono/chrono.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
+
 int main()
 {
     typedef boost::chrono::system_clock Clock;
     typedef boost::chrono::milliseconds Duration;
     typedef boost::chrono::time_point<Clock, Duration> TP;
-
- BOOST_TEST((TP::min)() == TP((Duration::min)()));
- BOOST_TEST((TP::max)() == TP((Duration::max)()));
+
+ BOOST_CONSTEXPR_ASSERT((TP::min)() == TP((Duration::min)()));
+ BOOST_CONSTEXPR_ASSERT((TP::max)() == TP((Duration::max)()));
 
     return boost::report_errors();
 }

Modified: trunk/libs/chrono/test/time_point/time_point_cast_pass.cpp
==============================================================================
--- trunk/libs/chrono/test/time_point/time_point_cast_pass.cpp (original)
+++ trunk/libs/chrono/test/time_point/time_point_cast_pass.cpp 2012-07-14 06:58:30 EDT (Sat, 14 Jul 2012)
@@ -18,6 +18,12 @@
 #if !defined(BOOST_NO_STATIC_ASSERT)
 #define NOTHING ""
 #endif
+#ifdef BOOST_NO_CONSTEXPR
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
+#else
+#include <boost/static_assert.hpp>
+#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
+#endif
 
 template <class FromDuration, class ToDuration>
 void
@@ -32,7 +38,7 @@
     //~ typedef BOOST_TYPEOF_TPL(boost::chrono::time_point_cast<ToDuration>(f)) R;
 //~ #else
     //~ typedef decltype(boost::chrono::time_point_cast<ToDuration>(f)) R;
-//~ #endif
+//~ #endif
     //~ BOOST_CHRONO_STATIC_ASSERT((boost::is_same<R, ToTimePoint>::value), NOTHING, ());
     BOOST_TEST(boost::chrono::time_point_cast<ToDuration>(f) == t);
 }
@@ -49,6 +55,13 @@
          boost::chrono::duration<double, boost::ratio<3600> >(7265./3600));
     test(boost::chrono::duration<int, boost::ratio<2, 3> >(9),
          boost::chrono::duration<int, boost::ratio<3, 5> >(10));
-
+ {
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::time_point<Clock, boost::chrono::milliseconds> FromTimePoint;
+ typedef boost::chrono::time_point<Clock, boost::chrono::hours> ToTimePoint;
+ BOOST_CONSTEXPR FromTimePoint f(boost::chrono::milliseconds(7265000));
+ BOOST_CONSTEXPR ToTimePoint tph = boost::chrono::time_point_cast<boost::chrono::hours>(f);
+ BOOST_CONSTEXPR_ASSERT(tph.time_since_epoch().count() == 2);
+ }
     return boost::report_errors();
 }


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