Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66323 - in sandbox/chrono/libs/chrono/test/duration: . cons nonmember
From: vicente.botet_at_[hidden]
Date: 2010-11-01 14:58:55


Author: viboes
Date: 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
New Revision: 66323
URL: http://svn.boost.org/trac/boost/changeset/66323

Log:
Chrono: Refactor tests

Added:
   sandbox/chrono/libs/chrono/test/duration/arithmetic_pass.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/comparisons_pass.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/cons/convert_float_to_int_fail.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/cons/convert_inexact_fail.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/cons/implicit_constructot_fail.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/cons/non_implicit_convertible_rep_fail.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/cons/treat_as_floating_point_Rep2_true_fail.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/constructor_pass.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/default_ratio_pass.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/nonmember/divide_rep2_fail.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/nonmember/modulus_rep2_fail.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/nonmember/times_rep2_lhs_fail.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/duration/nonmember/times_rep2_rhs_fail.cpp (contents, props changed)
Removed:
   sandbox/chrono/libs/chrono/test/duration/cons/convert_float_to_int.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/cons/convert_inexact.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/cons/rep01.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/cons/rep02.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/cons/rep03.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/duration.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_duration.pass.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_rep.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_rep.pass.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_minus.pass.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_duration.pass.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_rep.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_rep.pass.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_plus.pass.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep.pass.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep1.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep2.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/positive_num.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/ratio.fail.cpp
   sandbox/chrono/libs/chrono/test/duration/types.pass.cpp

Added: sandbox/chrono/libs/chrono/test/duration/arithmetic_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/arithmetic_pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,215 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/chrono.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ // UNARY PLUS
+ {
+ const boost::chrono::minutes m(3);
+ boost::chrono::minutes m2 = +m;
+ BOOST_TEST(m.count() == m2.count());
+ }
+
+ // UNARY MINUS
+ {
+ const 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);
+ return boost::report_errors();
+ }
+ // 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);
+ return boost::report_errors();
+ }
+ // 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::chrono::seconds s1(3);
+ boost::chrono::microseconds s2(5);
+ boost::chrono::microseconds r = s1 + s2;
+ BOOST_TEST(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::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);
+ }
+
+
+ // MINUS
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(5);
+ boost::chrono::seconds r = s1 - s2;
+ BOOST_TEST(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::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::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);
+ }
+
+ // TIMES rep
+ {
+ boost::chrono::nanoseconds ns(3);
+ ns = ns * 5;
+ BOOST_TEST(ns.count() == 15);
+ ns = 6 * ns;
+ BOOST_TEST(ns.count() == 90);
+ return boost::report_errors();
+ }
+
+ // DIVIDE duration
+ {
+ boost::chrono::nanoseconds ns1(15);
+ boost::chrono::nanoseconds ns2(5);
+ BOOST_TEST(ns1 / ns2 == 3);
+ }
+ {
+ boost::chrono::microseconds us1(15);
+ boost::chrono::nanoseconds ns2(5);
+ BOOST_TEST(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::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);
+ }
+ // DIVIDE rep
+ {
+ boost::chrono::nanoseconds ns(15);
+ ns = ns / 5;
+ BOOST_TEST(ns.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::chrono::microseconds us1(15);
+ boost::chrono::nanoseconds ns2(28);
+ boost::chrono::nanoseconds r = us1 % ns2;
+ BOOST_TEST(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);
+ }
+ // MODULUS rep
+ {
+ boost::chrono::nanoseconds ns(15);
+ ns = ns % 6;
+ BOOST_TEST(ns.count() == 3);
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/chrono/libs/chrono/test/duration/comparisons_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/comparisons_pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,109 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/chrono.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(3);
+ BOOST_TEST(s1 == s2);
+ BOOST_TEST(!(s1 != s2));
+ }
+ {
+ boost::chrono::seconds s1(3);
+ boost::chrono::seconds s2(4);
+ BOOST_TEST(!(s1 == s2));
+ BOOST_TEST(s1 != s2);
+ }
+ {
+ boost::chrono::milliseconds s1(3);
+ boost::chrono::microseconds s2(3000);
+ BOOST_TEST(s1 == s2);
+ BOOST_TEST(!(s1 != s2));
+ }
+ {
+ boost::chrono::milliseconds s1(3);
+ boost::chrono::microseconds s2(4000);
+ BOOST_TEST(!(s1 == s2));
+ BOOST_TEST(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::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::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::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::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::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::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::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::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::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();
+}

Deleted: sandbox/chrono/libs/chrono/test/duration/cons/convert_float_to_int.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/cons/convert_float_to_int.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// conversions from floating point to integral durations disallowed
-
-#include <boost/chrono.hpp>
-
-void test()
-{
- boost::chrono::duration<double> d;
- boost::chrono::duration<int> i = d;
-}

Added: sandbox/chrono/libs/chrono/test/duration/cons/convert_float_to_int_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/cons/convert_float_to_int_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,13 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// conversions from floating point to integral durations disallowed
+
+#include <boost/chrono.hpp>
+
+void test()
+{
+ boost::chrono::duration<double> d;
+ boost::chrono::duration<int> i = d;
+}

Deleted: sandbox/chrono/libs/chrono/test/duration/cons/convert_inexact.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/cons/convert_inexact.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// inexact conversions disallowed for integral reps
-
-#include <boost/chrono.hpp>
-
-void test()
-{
- boost::chrono::microseconds us(1);
- boost::chrono::milliseconds ms = us;
-}

Added: sandbox/chrono/libs/chrono/test/duration/cons/convert_inexact_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/cons/convert_inexact_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,13 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// inexact conversions disallowed for integral reps
+
+#include <boost/chrono.hpp>
+
+void test()
+{
+ boost::chrono::microseconds us(1);
+ boost::chrono::milliseconds ms = us;
+}

Added: sandbox/chrono/libs/chrono/test/duration/cons/implicit_constructot_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/cons/implicit_constructot_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,14 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// test for explicit
+
+#include <boost/chrono.hpp>
+
+#include "../../rep.h"
+
+void test()
+{
+ boost::chrono::duration<int> d = 1;
+}

Added: sandbox/chrono/libs/chrono/test/duration/cons/non_implicit_convertible_rep_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/cons/non_implicit_convertible_rep_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,14 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Rep2 shall be implicitly convertible to rep
+
+#include <boost/chrono.hpp>
+
+#include "../../rep.h"
+
+void test()
+{
+ boost::chrono::duration<Rep> d(1);
+}

Deleted: sandbox/chrono/libs/chrono/test/duration/cons/rep01.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/cons/rep01.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,14 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// test for explicit
-
-#include <boost/chrono.hpp>
-
-#include "../../rep.h"
-
-void test()
-{
- boost::chrono::duration<int> d = 1;
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/cons/rep02.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/cons/rep02.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,14 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// Rep2 shall be implicitly convertible to rep
-
-#include <boost/chrono.hpp>
-
-#include "../../rep.h"
-
-void test()
-{
- boost::chrono::duration<Rep> d(1);
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/cons/rep03.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/cons/rep03.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,12 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// treat_as_floating_point<Rep2>::value must be false
-
-#include <boost/chrono.hpp>
-
-void test()
-{
- boost::chrono::duration<int> d(1.);
-}

Added: sandbox/chrono/libs/chrono/test/duration/cons/treat_as_floating_point_Rep2_true_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/cons/treat_as_floating_point_Rep2_true_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,12 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// treat_as_floating_point<Rep2>::value must be false
+
+#include <boost/chrono.hpp>
+
+void test()
+{
+ boost::chrono::duration<int> d(1.);
+}

Added: sandbox/chrono/libs/chrono/test/duration/constructor_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/constructor_pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,67 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+
+#include <boost/chrono.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+
+#include <libs/chrono/test/rep.h>
+
+template <class D>
+void
+check_default()
+{
+ D d;
+ BOOST_TEST(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()
+{
+ // exact conversions allowed for integral reps
+ {
+ boost::chrono::milliseconds ms(1);
+ boost::chrono::microseconds us = ms;
+ BOOST_TEST(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);
+ }
+ // Convert int to float
+ {
+ boost::chrono::duration<int> i(3);
+ boost::chrono::duration<int> d = i;
+ BOOST_TEST(d.count() == 3);
+ }
+ // default constructor
+ {
+ check_default<boost::chrono::duration<Rep> >();
+ }
+ // constructor from rep
+ {
+ check_from_rep<boost::chrono::duration<int> >(5);
+ check_from_rep<boost::chrono::duration<int, boost::ratio<3, 2> > >(5);
+ check_from_rep<boost::chrono::duration<Rep, boost::ratio<3, 2> > >(Rep(3));
+ check_from_rep<boost::chrono::duration<double, boost::ratio<2, 3> > >(5.5);
+ }
+ // constructor from other rep
+ {
+ boost::chrono::duration<double> d(5);
+ BOOST_TEST(d.count() == 5);
+ return boost::report_errors();
+ }
+
+ return boost::report_errors();
+}

Added: sandbox/chrono/libs/chrono/test/duration/default_ratio_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/default_ratio_pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,20 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// duration
+// Test default template arg:
+
+// template <class Rep, class Period = ratio<1>>
+// class duration;
+
+#include <boost/chrono.hpp>
+#include <boost/type_traits.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+BOOST_CHRONO_STATIC_ASSERT((boost::is_same<
+ boost::chrono::duration<int, boost::ratio<1> >,
+ boost::chrono::duration<int>
+>::value), NOTHING, ());

Deleted: sandbox/chrono/libs/chrono/test/duration/duration.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/duration.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,15 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// duration
-// If a program instantiates duration with a duration type for the template
-// argument Rep a diagnostic is required.
-
-#include <boost/chrono.hpp>
-
-void test()
-{
- typedef boost::chrono::duration<boost::chrono::milliseconds> D;
- D d;
-}

Added: sandbox/chrono/libs/chrono/test/duration/nonmember/divide_rep2_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/nonmember/divide_rep2_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,13 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/chrono.hpp>
+
+#include "../../rep.h"
+
+void test()
+{
+ boost::chrono::duration<Rep> d(Rep(15));
+ d = d / 5;
+}

Added: sandbox/chrono/libs/chrono/test/duration/nonmember/modulus_rep2_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/nonmember/modulus_rep2_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,13 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/chrono.hpp>
+
+#include "../../rep.h"
+
+void test()
+{
+ boost::chrono::duration<Rep> d(Rep(15));
+ d = d % 5;
+}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_duration.pass.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_duration.pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,31 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-int main()
-{
- {
- boost::chrono::nanoseconds ns1(15);
- boost::chrono::nanoseconds ns2(5);
- BOOST_TEST(ns1 / ns2 == 3);
- }
- {
- boost::chrono::microseconds us1(15);
- boost::chrono::nanoseconds ns2(5);
- BOOST_TEST(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::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);
- }
- return boost::report_errors();
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_rep.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_rep.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-
-#include "../../rep.h"
-
-void test()
-{
- boost::chrono::duration<Rep> d(Rep(15));
- d = d / 5;
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_rep.pass.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_divide_rep.pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,14 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-int main()
-{
- boost::chrono::nanoseconds ns(15);
- ns = ns / 5;
- BOOST_TEST(ns.count() == 3);
- return boost::report_errors();
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_minus.pass.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_minus.pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,35 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-int main()
-{
- {
- boost::chrono::seconds s1(3);
- boost::chrono::seconds s2(5);
- boost::chrono::seconds r = s1 - s2;
- assert(r.count() == -2);
- }
- {
- boost::chrono::seconds s1(3);
- boost::chrono::microseconds s2(5);
- boost::chrono::microseconds r = s1 - s2;
- 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;
- 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;
- assert(r.count() == -15);
- }
- return boost::report_errors();
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_duration.pass.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_duration.pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,29 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-int main()
-{
- {
- boost::chrono::nanoseconds ns1(15);
- boost::chrono::nanoseconds ns2(6);
- boost::chrono::nanoseconds r = ns1 % ns2;
- BOOST_TEST(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::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);
- }
- return boost::report_errors();
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_rep.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_rep.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-
-#include "../../rep.h"
-
-void test()
-{
- boost::chrono::duration<Rep> d(Rep(15));
- d = d % 5;
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_rep.pass.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_mod_rep.pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,14 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-int main()
-{
- boost::chrono::nanoseconds ns(15);
- ns = ns % 6;
- assert(ns.count() == 3);
- return boost::report_errors();
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_plus.pass.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_plus.pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,35 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-int main()
-{
- {
- boost::chrono::seconds s1(3);
- boost::chrono::seconds s2(5);
- boost::chrono::seconds r = s1 + s2;
- BOOST_TEST(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::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::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);
- }
- return boost::report_errors();
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep.pass.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep.pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,16 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-int main()
-{
- boost::chrono::nanoseconds ns(3);
- ns = ns * 5;
- BOOST_TEST(ns.count() == 15);
- ns = 6 * ns;
- BOOST_TEST(ns.count() == 90);
- return boost::report_errors();
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep1.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep1.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-
-#include "../../rep.h"
-
-void test()
-{
- boost::chrono::duration<Rep> d;
- d = d * 5;
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep2.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/nonmember/op_times_rep2.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/chrono.hpp>
-
-#include "../../rep.h"
-
-void test()
-{
- boost::chrono::duration<Rep> d;
- d = 5 * d;
-}

Added: sandbox/chrono/libs/chrono/test/duration/nonmember/times_rep2_lhs_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/nonmember/times_rep2_lhs_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,13 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/chrono.hpp>
+
+#include "../../rep.h"
+
+void test()
+{
+ boost::chrono::duration<Rep> d;
+ d = 5 * d;
+}

Added: sandbox/chrono/libs/chrono/test/duration/nonmember/times_rep2_rhs_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/duration/nonmember/times_rep2_rhs_fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
@@ -0,0 +1,13 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/chrono.hpp>
+
+#include "../../rep.h"
+
+void test()
+{
+ boost::chrono::duration<Rep> d;
+ d = d * 5;
+}

Deleted: sandbox/chrono/libs/chrono/test/duration/positive_num.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/positive_num.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,14 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// duration
-// Period::num must be positive, diagnostic required.
-
-#include <boost/chrono.hpp>
-
-void test()
-{
- typedef boost::chrono::duration<int, boost::ratio<5, -1> > D;
- D d;
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/ratio.fail.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/ratio.fail.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,14 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// duration
-// Period shall be a specialization of ratio, diagnostic required.
-
-#include <boost/chrono.hpp>
-
-void test()
-{
- typedef boost::chrono::duration<int, int > D;
- D d;
-}

Deleted: sandbox/chrono/libs/chrono/test/duration/types.pass.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/test/duration/types.pass.cpp 2010-11-01 14:58:51 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,19 +0,0 @@
-// Copyright 2010 Vicente J. Botet Escriba
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// duration
-// Test nested types
-
-// typedef Rep rep;
-// typedef Period period;
-
-#include <boost/chrono.hpp>
-#include <boost/type_traits.hpp>
-#if !defined(BOOST_NO_STATIC_ASSERT)
-#define NOTHING ""
-#endif
-
-typedef boost::chrono::duration<long, boost::ratio<3, 2> > D;
-BOOST_CHRONO_STATIC_ASSERT((boost::is_same<D::rep, long>::value), NOTHING, ());
-BOOST_CHRONO_STATIC_ASSERT((boost::is_same<D::period, boost::ratio<3, 2> >::value), NOTHING, ());


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