$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r58280 - in sandbox/chrono/libs/chrono: example test
From: vicente.botet_at_[hidden]
Date: 2009-12-10 18:25:57
Author: viboes
Date: 2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
New Revision: 58280
URL: http://svn.boost.org/trac/boost/changeset/58280
Log:
Boost.Chrono: Version 0.2.3, Bug fixes
* Compile issue with MSVC
Added:
   sandbox/chrono/libs/chrono/test/explore_limits.cpp   (contents, props changed)
   sandbox/chrono/libs/chrono/test/intmax_c.cpp   (contents, props changed)
   sandbox/chrono/libs/chrono/test/manipulate_clock_object.cpp   (contents, props changed)
   sandbox/chrono/libs/chrono/test/miscellaneous.cpp   (contents, props changed)
   sandbox/chrono/libs/chrono/test/test_duration.cpp   (contents, props changed)
   sandbox/chrono/libs/chrono/test/test_special_values.cpp   (contents, props changed)
   sandbox/chrono/libs/chrono/test/test_system_clock.cpp   (contents, props changed)
Text files modified: 
   sandbox/chrono/libs/chrono/example/runtime_resolution.cpp              |     2 ++                                      
   sandbox/chrono/libs/chrono/example/simulated_thread_interface_demo.cpp |    14 +++++++-------                          
   sandbox/chrono/libs/chrono/example/time2_demo.cpp                      |    12 ++++--------                            
   sandbox/chrono/libs/chrono/example/timeval_demo.cpp                    |     4 ++++                                    
   4 files changed, 17 insertions(+), 15 deletions(-)
Modified: sandbox/chrono/libs/chrono/example/runtime_resolution.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/runtime_resolution.cpp	(original)
+++ sandbox/chrono/libs/chrono/example/runtime_resolution.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -25,6 +25,7 @@
                    Daniel Krügler,
                    Anthony Williams.
 */
+#define _CRT_SECURE_NO_WARNINGS  // disable VC++ foolishness
 
 #include <boost/chrono/chrono.hpp>
 #include <boost/type_traits.hpp>
@@ -32,6 +33,7 @@
 #include <iostream>
 
 #if defined(BOOST_CHRONO_WINDOWS_API)
+#include <windows.h>  
 
 namespace
 {
Modified: sandbox/chrono/libs/chrono/example/simulated_thread_interface_demo.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/simulated_thread_interface_demo.cpp	(original)
+++ sandbox/chrono/libs/chrono/example/simulated_thread_interface_demo.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -32,12 +32,15 @@
 #include <boost/type_traits.hpp>
 
 #include <iostream>
+#include <ostream>
+#include <stdexcept>
+#include <climits>
 
-#include <windows.h>  
 #undef min
 #undef max
 
 #if defined(BOOST_CHRONO_WINDOWS_API)
+#include <windows.h>  
 
 namespace
 {
@@ -65,12 +68,13 @@
 
 #endif
 
+#undef min
+#undef max
+
 //////////////////////////////////////////////////////////
 ///////////// simulated thread interface /////////////////
 //////////////////////////////////////////////////////////
 
-#include <iostream>
-
 namespace std {
 
 void __print_time(boost::chrono::system_clock::time_point t)
@@ -229,9 +233,6 @@
 // (like IEEE floating point) but otherwise obeys signed integral arithmetic.
 // This class is subsequently used as the rep in boost::chrono::duration to demonstrate a
 // duration class that does not silently ignore overflow.
-#include <ostream>
-#include <stdexcept>
-#include <climits>
 
 namespace User2
 {
@@ -615,7 +616,6 @@
 
 }  // namespace boost
 
-#include <iostream>
 
 void testUser2()
 {
Modified: sandbox/chrono/libs/chrono/example/time2_demo.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/time2_demo.cpp	(original)
+++ sandbox/chrono/libs/chrono/example/time2_demo.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -30,7 +30,11 @@
 #include <boost/chrono/chrono.hpp>
 #include <boost/type_traits.hpp>
 
+#include <cassert>
+#include <climits>
 #include <iostream>
+#include <ostream>
+#include <stdexcept>
 
 #include <windows.h>  
 #undef min
@@ -64,7 +68,6 @@
 ///////////// simulated thread interface /////////////////
 //////////////////////////////////////////////////////////
 
-#include <iostream>
 
 namespace std {
 
@@ -380,7 +383,6 @@
 
 } // User1
 
-#include <iostream>
 
 // Exercise example type-safe physics function and show interoperation
 // of custom time durations (User1::seconds) and standard time durations (std::hours).
@@ -427,9 +429,6 @@
 // (like IEEE floating point) but otherwise obeys signed integral arithmetic.
 // This class is subsequently used as the rep in boost::chrono::duration to demonstrate a
 // duration class that does not silently ignore overflow.
-#include <ostream>
-#include <stdexcept>
-#include <climits>
 
 namespace User2
 {
@@ -813,7 +812,6 @@
 
 }  // namespace boost
 
-#include <iostream>
 
 void testUser2()
 {
@@ -1141,8 +1139,6 @@
 
 // miscellaneous tests and demos:
 
-#include <cassert>
-#include <iostream>
 
 using namespace boost::chrono;
 
Modified: sandbox/chrono/libs/chrono/example/timeval_demo.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/timeval_demo.cpp	(original)
+++ sandbox/chrono/libs/chrono/example/timeval_demo.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -25,11 +25,15 @@
                    Daniel Krügler,
                    Anthony Williams.
 */
+#define _CRT_SECURE_NO_WARNINGS  // disable VC++ foolishness
 
 #include <boost/chrono/chrono.hpp>
 #include <boost/type_traits.hpp>
 
 #include <iostream>
+#if defined(BOOST_CHRONO_WINDOWS_API)
+#	include <windows.h>  
+#endif
 
 #undef min
 #undef max
Added: sandbox/chrono/libs/chrono/test/explore_limits.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/explore_limits.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -0,0 +1,60 @@
+//  explore_limits.cpp  ----------------------------------------------------------//
+
+//  Copyright 2008 Howard Hinnant
+//  Copyright 2008 Beman Dawes
+//  Copyright 2009 Vicente J. Botet Escriba
+
+//  Distributed under the Boost Software License, Version 1.0.
+//  See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+This code was extracted by Vicente J. Botet Escriba from Beman Dawes time2_demo.cpp which
+was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section 
+20.9 Time utilities [time] of the C++ committee's working paper N2798. 
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+    Much thanks to Andrei Alexandrescu,
+                   Walter Brown,
+                   Peter Dimov,
+                   Jeff Garland,
+                   Terry Golubiewski,
+                   Daniel Krügler,
+                   Anthony Williams.
+*/
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/type_traits.hpp>
+
+#include <iostream>
+
+using namespace boost::chrono;
+
+
+void explore_limits()
+{
+    typedef duration<long long, boost::ratio_multiply<boost::ratio<24*3652425,10000>,
+      hours::period>::type> Years;
+#ifdef BOOST_CHRONO_HAS_CLOCK_MONOTONIC 
+    monotonic_clock::time_point t1( Years(250));
+    monotonic_clock::time_point t2(-Years(250));
+#else    
+    system_clock::time_point t1( Years(250));
+    system_clock::time_point t2(-Years(250));
+#endif    
+    // nanosecond resolution is likely to overflow.  "up cast" to microseconds.
+    //   The "up cast" trades precision for range.
+    microseconds d = time_point_cast<microseconds>(t1) - time_point_cast<microseconds>(t2);
+    std::cout << d.count() << " microseconds\n";
+}
+
+
+int main()
+{
+    explore_limits();
+    return 0;
+}
+
Added: sandbox/chrono/libs/chrono/test/intmax_c.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/intmax_c.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -0,0 +1,14 @@
+//#include <iostream>
+#include <boost/cstdint.hpp>
+
+#ifdef INTMAX_C
+#define BOOST_INTMAX_C(a) INTMAX_C(a)
+#else
+#define BOOST_INTMAX_C(a) a##LL
+#endif
+
+boost::intmax_t i = BOOST_INTMAX_C(1000000000);
+int main() {
+    //std::cout << i << std::endl;
+    return (i);
+}
Added: sandbox/chrono/libs/chrono/test/manipulate_clock_object.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/manipulate_clock_object.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -0,0 +1,58 @@
+//  manipulate_clock_object.cpp  ----------------------------------------------------------//
+
+//  Copyright 2008 Howard Hinnant
+//  Copyright 2008 Beman Dawes
+//  Copyright 2009 Vicente J. Botet Escriba
+
+//  Distributed under the Boost Software License, Version 1.0.
+//  See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+This code was extracted by Vicente J. Botet Escriba from Beman Dawes time2_demo.cpp which
+was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section 
+20.9 Time utilities [time] of the C++ committee's working paper N2798. 
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+    Much thanks to Andrei Alexandrescu,
+                   Walter Brown,
+                   Peter Dimov,
+                   Jeff Garland,
+                   Terry Golubiewski,
+                   Daniel Krügler,
+                   Anthony Williams.
+*/
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/type_traits.hpp>
+
+#include <iostream>
+
+#undef min
+#undef max
+
+using namespace boost::chrono;
+
+
+void manipulate_clock_object(system_clock clock)
+{
+    system_clock::duration delay = milliseconds(5);
+    system_clock::time_point start = clock.now();
+
+    while (clock.now() - start <= delay);
+        
+    system_clock::time_point stop = clock.now();
+    system_clock::duration elapsed = stop - start;
+    std::cout << "paused " << nanoseconds(elapsed).count() << " nanoseconds\n";
+};
+
+
+int main()
+{
+    manipulate_clock_object(system_clock());
+    return 0;
+}
+
Added: sandbox/chrono/libs/chrono/test/miscellaneous.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/miscellaneous.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -0,0 +1,161 @@
+//  miscellaneous.cpp  ----------------------------------------------------------//
+
+//  Copyright 2008 Howard Hinnant
+//  Copyright 2008 Beman Dawes
+//  Copyright 2009 Vicente J. Botet Escriba
+
+//  Distributed under the Boost Software License, Version 1.0.
+//  See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+This code was extracted by Vicente J. Botet Escriba from Beman Dawes time2_demo.cpp which
+was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section 
+20.9 Time utilities [time] of the C++ committee's working paper N2798. 
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+    Much thanks to Andrei Alexandrescu,
+                   Walter Brown,
+                   Peter Dimov,
+                   Jeff Garland,
+                   Terry Golubiewski,
+                   Daniel Krügler,
+                   Anthony Williams.
+*/
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/type_traits.hpp>
+
+#include <iostream>
+
+#undef min
+#undef max
+
+// miscellaneous tests and demos:
+
+#include <cassert>
+#include <iostream>
+
+using namespace boost::chrono;
+
+void physics_function(duration<double> d)
+{
+    std::cout << "d = " << d.count() << '\n';
+}
+
+void drive_physics_function()
+{
+    physics_function(nanoseconds(3));
+    physics_function(hours(3));
+    physics_function(duration<double>(2./3));
+    std::cout.precision(16);
+    physics_function( hours(3) + nanoseconds(-3) );
+}
+
+void test_range()
+{
+    using namespace boost::chrono;
+    hours h1 = hours(24 * ( 365 * 292 + 292/4));
+    nanoseconds n1 = h1 + nanoseconds(1);
+    nanoseconds delta = n1 - h1;
+    std::cout << "292 years of hours = " << h1.count() << "hr\n";
+    std::cout << "Add a nanosecond = " << n1.count() << "ns\n";
+    std::cout << "Find the difference = " << delta.count() << "ns\n";
+}
+
+void test_extended_range()
+{
+    using namespace boost::chrono;
+    hours h1 = hours(24 * ( 365 * 244000 + 244000/4));
+    /*auto*/ microseconds u1 = h1 + microseconds(1);
+    /*auto*/ microseconds delta = u1 - h1;
+    std::cout << "244,000 years of hours = " << h1.count() << "hr\n";
+    std::cout << "Add a microsecond = " << u1.count() << "us\n";
+    std::cout << "Find the difference = " << delta.count() << "us\n";
+}
+
+template <class Rep, class Period>
+void inspect_duration(boost::chrono::duration<Rep, Period> d, const std::string& name)
+{
+    typedef boost::chrono::duration<Rep, Period> Duration;
+    std::cout << "********* " << name << " *********\n";
+    std::cout << "The period of " << name << " is " << (double)Period::num/Period::den << " seconds.\n";
+    std::cout << "The frequency of " << name << " is " << (double)Period::den/Period::num << " Hz.\n";
+    std::cout << "The representation is ";
+    if (boost::is_floating_point<Rep>::value)
+    {
+        std::cout << "floating point\n";
+        std::cout << "The precision is the most significant ";
+        std::cout << std::numeric_limits<Rep>::digits10 << " decimal digits.\n";
+    }
+    else if (boost::is_integral<Rep>::value)
+    {
+        std::cout << "integral\n";
+        d = Duration(Rep(1));
+        boost::chrono::duration<double> dsec = d;
+        std::cout << "The precision is " << dsec.count() << " seconds.\n";
+    }
+    else
+    {
+        std::cout << "a class type\n";
+        d = Duration(Rep(1));
+        boost::chrono::duration<double> dsec = d;
+        std::cout << "The precision is " << dsec.count() << " seconds.\n";
+    }
+    d = Duration(std::numeric_limits<Rep>::max());
+    using namespace boost::chrono;
+    using namespace std;
+    typedef duration<double, boost::ratio_multiply<boost::ratio<24*3652425,10000>, hours::period>::type> Years;
+    Years years = d;
+    std::cout << "The range is +/- " << years.count() << " years.\n";
+    std::cout << "sizeof(" << name << ") = " << sizeof(d) << '\n';
+}
+
+void inspect_all()
+{
+    using namespace boost::chrono;
+    std::cout.precision(6);
+    inspect_duration(nanoseconds(), "nanoseconds");
+    inspect_duration(microseconds(), "microseconds");
+    inspect_duration(milliseconds(), "milliseconds");
+    inspect_duration(seconds(), "seconds");
+    inspect_duration(minutes(), "minutes");
+    inspect_duration(hours(), "hours");
+    inspect_duration(duration<double>(), "duration<double>");
+}
+
+void test_milliseconds()
+{
+    using namespace boost::chrono;
+    milliseconds ms(250);
+    ms += milliseconds(1);
+    milliseconds ms2(150);
+    milliseconds msdiff = ms - ms2;
+    if (msdiff == milliseconds(101))
+        std::cout << "success\n";
+    else
+        std::cout << "failure: " << msdiff.count() << '\n';
+}
+
+int main()
+{
+    drive_physics_function();
+    test_range();
+    test_extended_range();
+    inspect_all();
+    test_milliseconds();
+#if BOOST_VARIADIC_COMMON_TYPE
+    inspect_duration(common_type<duration<double>, hours, microseconds>::type(),
+                    "common_type<duration<double>, hours, microseconds>::type");
+#endif
+    duration<double, boost::milli> d = milliseconds(3) * 2.5;
+    inspect_duration(milliseconds(3) * 2.5, "milliseconds(3) * 2.5");
+    std::cout << d.count() << '\n';
+//    milliseconds ms(3.5);  // doesn't compile
+    std::cout << "milliseconds ms(3.5) doesn't compile\n";
+    return 0;
+}
+
Added: sandbox/chrono/libs/chrono/test/test_duration.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/test_duration.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -0,0 +1,197 @@
+//  test_duration.cpp  ----------------------------------------------------------//
+
+//  Copyright 2008 Howard Hinnant
+//  Copyright 2008 Beman Dawes
+//  Copyright 2009 Vicente J. Botet Escriba
+
+//  Distributed under the Boost Software License, Version 1.0.
+//  See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+This code was extracted by Vicente J. Botet Escriba from Beman Dawes time2_demo.cpp which
+was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section 
+20.9 Time utilities [time] of the C++ committee's working paper N2798. 
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+    Much thanks to Andrei Alexandrescu,
+                   Walter Brown,
+                   Peter Dimov,
+                   Jeff Garland,
+                   Terry Golubiewski,
+                   Daniel Krügler,
+                   Anthony Williams.
+*/
+
+#include <cassert>
+#include <boost/chrono/chrono.hpp>
+#include <boost/type_traits.hpp>
+
+#include <iostream>
+
+template <class Rep, class Period>
+void inspect_duration(boost::chrono::duration<Rep, Period> d, const std::string& name)
+{
+    typedef boost::chrono::duration<Rep, Period> Duration;
+    std::cout << "********* " << name << " *********\n";
+    std::cout << "The period of " << name << " is " << (double)Period::num/Period::den << " seconds.\n";
+    std::cout << "The frequency of " << name << " is " << (double)Period::den/Period::num << " Hz.\n";
+    std::cout << "The representation is ";
+    if (boost::is_floating_point<Rep>::value)
+    {
+        std::cout << "floating point\n";
+        std::cout << "The precision is the most significant ";
+        std::cout << std::numeric_limits<Rep>::digits10 << " decimal digits.\n";
+    }
+    else if (boost::is_integral<Rep>::value)
+    {
+        std::cout << "integral\n";
+        d = Duration(Rep(1));
+        boost::chrono::duration<double> dsec = d;
+        std::cout << "The precision is " << dsec.count() << " seconds.\n";
+    }
+    else
+    {
+        std::cout << "a class type\n";
+        d = Duration(Rep(1));
+        boost::chrono::duration<double> dsec = d;
+        std::cout << "The precision is " << dsec.count() << " seconds.\n";
+    }
+    d = Duration(std::numeric_limits<Rep>::max());
+    using namespace boost::chrono;
+    using namespace std;
+    typedef duration<double, boost::ratio_multiply<boost::ratio<24*3652425,10000>, hours::period>::type> Years;
+    Years years = d;
+    std::cout << "The range is +/- " << years.count() << " years.\n";
+    std::cout << "sizeof(" << name << ") = " << sizeof(d) << '\n';
+}
+
+void inspect_all()
+{
+    using namespace boost::chrono;
+    std::cout.precision(6);
+    inspect_duration(nanoseconds(), "nanoseconds");
+    inspect_duration(microseconds(), "microseconds");
+    inspect_duration(milliseconds(), "milliseconds");
+    inspect_duration(seconds(), "seconds");
+    inspect_duration(minutes(), "minutes");
+    inspect_duration(hours(), "hours");
+    inspect_duration(duration<double>(), "duration<double>");
+}
+
+
+
+using namespace boost::chrono;
+void test_duration_division()
+{
+    typedef boost::common_type<boost::chrono::hours::rep, boost::chrono::minutes::rep>::type h_min_rep;
+    h_min_rep r3 = hours(3) / minutes(5);
+    std::cout << r3 << '\n';
+    std::cout << hours(3) / minutes(5) << '\n';
+    std::cout << hours(3) / milliseconds(5) << '\n';
+    std::cout << milliseconds(5) / hours(3) << '\n';
+    std::cout << hours(1) / milliseconds(1) << '\n';
+}
+
+void test_duration_multiply()
+{
+    hours h15= 5 * hours(3);
+    hours h6= hours(3) *2;
+}
+
+void f(duration<double> d, double res)  // accept floating point seconds
+{
+    // d.count() == 3.e-6 when passed microseconds(3)
+    assert(d.count()==res);
+}
+
+void g(nanoseconds d, boost::intmax_t res)
+{
+    // d.count() == 3000 when passed microseconds(3)
+    std::cout << d.count() << " " <<res << std::endl;
+    assert(d.count()==res);
+}
+
+template <class Rep, class Period>
+void tmpl(duration<Rep, Period> d, boost::intmax_t res)
+{
+    // convert d to nanoseconds, rounding up if it is not an exact conversion
+    nanoseconds ns = duration_cast<nanoseconds>(d);
+    if (ns < d)
+        ++ns;
+    // ns.count() == 333333334 when passed 1/3 of a floating point second
+    assert(ns.count()==res);
+}
+
+template <class Period>
+void tmpl2(duration<long long, Period> d, boost::intmax_t res)
+{
+    // convert d to nanoseconds, rounding up if it is not an exact conversion
+    nanoseconds ns = duration_cast<nanoseconds>(d);
+    if (ns < d)
+        ++ns;
+    // ns.count() == 333333334 when passed 333333333333 picoseconds
+    assert(ns.count()==res);
+}
+
+
+
+int main()
+{
+    minutes m1(3);                 // m1 stores 3
+    minutes m2(2);                 // m2 stores 2
+    minutes m3 = m1 + m2;          // m3 stores 5
+    assert(m3.count()==5);
+
+    microseconds us1(3);           // us1 stores 3
+    microseconds us2(2);           // us2 stores 2
+    microseconds us3 = us1 + us2;  // us3 stores 5
+    assert(us3.count()==5);
+
+    microseconds us4 = m3 + us3;   // us4 stores 300000005
+    assert(us4.count()==300000005);
+    microseconds us5 = m3;   // us4 stores 300000000
+    assert(us5.count()==300000000);
+
+    //minutes m4 = m3 + us3; // won't compile
+    
+    minutes m4 = duration_cast<minutes>(m3 + us3);  // m4.count() == 5
+    assert(m4.count()==5);
+
+    typedef duration<double, boost::ratio<60> > dminutes;
+    dminutes dm4 = m3 + us3;  // dm4.count() == 5.000000083333333
+    assert(dm4.count()==5.000000083333333);
+
+    f(microseconds(3), 0.000003);
+    g(microseconds(3), 3000);
+    duration<double> s(1./3);  // 1/3 of a second
+    g(duration_cast<nanoseconds>(s), 333333333);  // round towards zero in conversion to nanoseconds
+    //f(s);  // does not compile
+    tmpl(duration<double>(1./3), 333333334);
+    tmpl2(duration<long long, boost::pico>(333333333333LL), 333333334);  // About 1/3 of a second worth of picoseconds
+
+    //f(3,3);  // Will not compile, 3 is not implicitly convertible to any `duration`
+    //g(3,3);  // Will not compile, 3 is not implicitly convertible to any `duration`
+    //tmpl(3,3);  // Will not compile, 3 is not implicitly convertible to any `duration`
+    //tmpl2(3,3);  // Will not compile, 3 is not implicitly convertible to any `duration`
+
+    {
+    double r = milliseconds(3) / milliseconds(3);
+    duration<double, boost::milli> d = milliseconds(3) * 2.5;
+    duration<double, boost::milli> d2 = 2.5 * milliseconds(3) ;
+    duration<double, boost::milli> d3 = milliseconds(3) / 2.5;
+    duration<double, boost::milli> d4 = milliseconds(3) + milliseconds(5) ;
+    inspect_duration(milliseconds(3) * 2.5, "milliseconds(3) * 2.5");
+    std::cout << d.count() << '\n';
+//    milliseconds ms(3.5);  // doesn't compile
+    std::cout << "milliseconds ms(3.5) doesn't compile\n";
+    }
+
+    test_duration_division();
+    test_duration_multiply();
+    return 0;
+}
+
Added: sandbox/chrono/libs/chrono/test/test_special_values.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/test_special_values.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -0,0 +1,53 @@
+//  test_special_values.cpp  ----------------------------------------------------------//
+
+//  Copyright 2008 Howard Hinnant
+//  Copyright 2008 Beman Dawes
+//  Copyright 2009 Vicente J. Botet Escriba
+
+//  Distributed under the Boost Software License, Version 1.0.
+//  See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+This code was extracted by Vicente J. Botet Escriba from Beman Dawes time2_demo.cpp which
+was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section 
+20.9 Time utilities [time] of the C++ committee's working paper N2798. 
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+    Much thanks to Andrei Alexandrescu,
+                   Walter Brown,
+                   Peter Dimov,
+                   Jeff Garland,
+                   Terry Golubiewski,
+                   Daniel Krügler,
+                   Anthony Williams.
+*/
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/type_traits.hpp>
+
+#include <iostream>
+
+#undef min
+#undef max
+using namespace boost::chrono;
+
+void test_special_values()
+{
+    std::cout << "duration<unsigned>::min().count()  = " << duration<unsigned>::min().count() << '\n';
+    std::cout << "duration<unsigned>::zero().count() = " << duration<unsigned>::zero().count() << '\n';
+    std::cout << "duration<unsigned>::max().count()  = " << duration<unsigned>::max().count() << '\n';
+    std::cout << "duration<int>::min().count()       = " << duration<int>::min().count() << '\n';
+    std::cout << "duration<int>::zero().count()      = " << duration<int>::zero().count() << '\n';
+    std::cout << "duration<int>::max().count()       = " << duration<int>::max().count() << '\n';
+}
+
+int main()
+{
+    test_special_values();
+    return 0;
+}
+
Added: sandbox/chrono/libs/chrono/test/test_system_clock.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/test_system_clock.cpp	2009-12-10 18:25:55 EST (Thu, 10 Dec 2009)
@@ -0,0 +1,127 @@
+//  test_system_clock.cpp  ----------------------------------------------------------//
+
+//  Copyright 2008 Howard Hinnant
+//  Copyright 2008 Beman Dawes
+//  Copyright 2009 Vicente J. Botet Escriba
+
+//  Distributed under the Boost Software License, Version 1.0.
+//  See http://www.boost.org/LICENSE_1_0.txt
+
+/*
+This code was extracted by Vicente J. Botet Escriba from Beman Dawes time2_demo.cpp which
+was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
+Many thanks to Howard for making his code available under the Boost license.
+The original code was modified to conform to Boost conventions and to section 
+20.9 Time utilities [time] of the C++ committee's working paper N2798. 
+See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
+
+time2_demo contained this comment:
+
+    Much thanks to Andrei Alexandrescu,
+                   Walter Brown,
+                   Peter Dimov,
+                   Jeff Garland,
+                   Terry Golubiewski,
+                   Daniel Krügler,
+                   Anthony Williams.
+*/
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/type_traits.hpp>
+
+#include <iostream>
+
+#undef min
+#undef max
+
+using namespace boost::chrono;
+
+void test_system_clock()
+{
+    std::cout << "system_clock test" << std::endl;
+    system_clock::duration delay = milliseconds(5);
+    system_clock::time_point start = system_clock::now();
+    while (system_clock::now() - start <= delay)
+        ;
+    system_clock::time_point stop = system_clock::now();
+    system_clock::duration elapsed = stop - start;
+    std::cout << "paused " << nanoseconds(elapsed).count() << " nanoseconds\n";
+    start = system_clock::now();
+    stop = system_clock::now();
+    std::cout << "system_clock resolution estimate: " << nanoseconds(stop-start).count() << " nanoseconds\n";
+}
+
+void test_monotonic_clock()
+{
+#ifdef BOOST_CHRONO_HAS_CLOCK_MONOTONIC 
+    std::cout << "monotonic_clock test" << std::endl;
+    monotonic_clock::duration delay = milliseconds(5);
+    monotonic_clock::time_point start = monotonic_clock::now();
+    while (monotonic_clock::now() - start <= delay)
+        ;
+    monotonic_clock::time_point stop = monotonic_clock::now();
+    monotonic_clock::duration elapsed = stop - start;
+    std::cout << "paused " << nanoseconds(elapsed).count() << " nanoseconds\n";
+    start = monotonic_clock::now();
+    stop = monotonic_clock::now();
+    std::cout << "monotonic_clock resolution estimate: " << nanoseconds(stop-start).count() << " nanoseconds\n";
+#endif
+}
+void test_hi_resolution_clock()
+{
+    std::cout << "high_resolution_clock test" << std::endl;
+    high_resolution_clock::duration delay = milliseconds(5);
+    high_resolution_clock::time_point start = high_resolution_clock::now();
+    while (high_resolution_clock::now() - start <= delay)
+      ;
+    high_resolution_clock::time_point stop = high_resolution_clock::now();
+    high_resolution_clock::duration elapsed = stop - start;
+    std::cout << "paused " << nanoseconds(elapsed).count() << " nanoseconds\n";
+    start = high_resolution_clock::now();
+    stop = high_resolution_clock::now();
+    std::cout << "high_resolution_clock resolution estimate: " << nanoseconds(stop-start).count() << " nanoseconds\n";
+}
+
+//void test_mixed_clock()
+//{
+//    std::cout << "mixed clock test" << std::endl;
+//    high_resolution_clock::time_point hstart = high_resolution_clock::now();
+//    std::cout << "Add 5 milliseconds to a high_resolution_clock::time_point\n";
+//    monotonic_clock::time_point mend = hstart + milliseconds(5);
+//    bool b = hstart == mend;
+//    system_clock::time_point sstart = system_clock::now();
+//    std::cout << "Subtracting system_clock::time_point from monotonic_clock::time_point doesn't compile\n";
+////  mend - sstart; // doesn't compile
+//    std::cout << "subtract high_resolution_clock::time_point from monotonic_clock::time_point"
+//            " and add that to a system_clock::time_point\n";
+//    system_clock::time_point send = sstart + duration_cast<system_clock::duration>(mend - hstart);
+//    std::cout << "subtract two system_clock::time_point's and output that in microseconds:\n";
+//    microseconds ms = send - sstart;
+//    std::cout << ms.count() << " microseconds\n";
+//}
+//
+//void test_c_mapping()
+//{
+//    std::cout << "C map test\n";
+//    using namespace boost::chrono;
+//    system_clock::time_point t1 = system_clock::now();
+//    std::time_t c_time = system_clock::to_time_t(t1);
+//    std::tm* tmptr = std::localtime(&c_time);
+//    std::cout << "It is now " << tmptr->tm_hour << ':' << tmptr->tm_min << ':' << tmptr->tm_sec << ' '
+//              << tmptr->tm_year + 1900 << '-' << tmptr->tm_mon + 1 << '-' << tmptr->tm_mday << '\n';
+//    c_time = std::mktime(tmptr);
+//    system_clock::time_point t2 = system_clock::from_time_t(c_time);
+//    microseconds ms = t1 - t2;
+//    std::cout << "Round-tripping through the C interface truncated the precision by " << ms.count() << " microseconds\n";
+//}
+
+
+int main()
+{
+    test_system_clock();
+    test_monotonic_clock();
+    test_hi_resolution_clock();
+    //test_mixed_clock();
+    return 0;
+}
+