|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65493 - in sandbox/chrono/libs/chrono/test: clock_req time_point time_point/arithmetic time_point/cast time_point/comparisons time_point/cons time_point/nonmember time_point/observer time_point/special
From: vicente.botet_at_[hidden]
Date: 2010-09-20 16:50:50
Author: viboes
Date: 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
New Revision: 65493
URL: http://svn.boost.org/trac/boost/changeset/65493
Log:
Adapt tests from llvm/libc++/test/chrono clock
Added:
sandbox/chrono/libs/chrono/test/clock_req/
sandbox/chrono/libs/chrono/test/time_point/
sandbox/chrono/libs/chrono/test/time_point/arithmetic/
sandbox/chrono/libs/chrono/test/time_point/arithmetic/op_minus_ass.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/arithmetic/op_plus_ass.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/cast/
sandbox/chrono/libs/chrono/test/time_point/cast/time_point_cast.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/cast/toduration.fail.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/comparisons/
sandbox/chrono/libs/chrono/test/time_point/comparisons/op_equal.fail.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/comparisons/op_equal.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/comparisons/op_less.fail.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/comparisons/op_less.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/cons/
sandbox/chrono/libs/chrono/test/time_point/cons/convert.fail.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/cons/convert.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/cons/default.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/cons/duration.fail.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/cons/duration.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/default_duration.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/duration.fail.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/nonmember/
sandbox/chrono/libs/chrono/test/time_point/nonmember/op_minus_duration.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/nonmember/op_minus_time_point.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/nonmember/op_plus.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/observer/
sandbox/chrono/libs/chrono/test/time_point/observer/tested_elsewhere.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/special/
sandbox/chrono/libs/chrono/test/time_point/special/max.pass.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/time_point/special/min.pass.cpp (contents, props changed)
Added: sandbox/chrono/libs/chrono/test/time_point/arithmetic/op_minus_ass.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/arithmetic/op_minus_ass.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,31 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point& operator-=(const duration& d);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+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);
+ assert(t.time_since_epoch() == Duration(1));
+}
Added: sandbox/chrono/libs/chrono/test/time_point/arithmetic/op_plus_ass.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/arithmetic/op_plus_ass.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,31 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point& operator+=(const duration& d);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+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);
+ assert(t.time_since_epoch() == Duration(5));
+}
Added: sandbox/chrono/libs/chrono/test/time_point/cast/time_point_cast.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/cast/time_point_cast.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,60 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// time_point_cast(const time_point<Clock, Duration>& t);
+
+#include <boost/chrono.hpp>
+#include <boost/type_traits.hpp>
+#include <cassert>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+template <class FromDuration, class ToDuration>
+void
+test(const FromDuration& df, const ToDuration& d)
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::time_point<Clock, FromDuration> FromTimePoint;
+ typedef boost::chrono::time_point<Clock, ToDuration> ToTimePoint;
+ FromTimePoint f(df);
+ ToTimePoint t(d);
+#if defined(BOOST_NO_DECLTYPE)
+ typedef BOOST_TYPEOF_TPL(boost::chrono::time_point_cast<ToDuration>(f)) R;
+#else
+ typedef decltype(boost::chrono::time_point_cast<ToDuration>(f)) R;
+#endif
+ BOOST_CHRONO_STATIC_ASSERT((boost::is_same<R, ToTimePoint>::value), NOTHING, ());
+ assert(boost::chrono::time_point_cast<ToDuration>(f) == t);
+}
+
+int main()
+{
+ test(boost::chrono::milliseconds(7265000), boost::chrono::hours(2));
+ test(boost::chrono::milliseconds(7265000), boost::chrono::minutes(121));
+ test(boost::chrono::milliseconds(7265000), boost::chrono::seconds(7265));
+ test(boost::chrono::milliseconds(7265000), boost::chrono::milliseconds(7265000));
+ test(boost::chrono::milliseconds(7265000), boost::chrono::microseconds(7265000000LL));
+ test(boost::chrono::milliseconds(7265000), boost::chrono::nanoseconds(7265000000000LL));
+ test(boost::chrono::milliseconds(7265000),
+ 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));
+}
Added: sandbox/chrono/libs/chrono/test/time_point/cast/toduration.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/cast/toduration.fail.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,33 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// time_point_cast(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <boost/chrono.hpp>
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::time_point<Clock, boost::chrono::milliseconds> FromTimePoint;
+ typedef boost::chrono::time_point<Clock, boost::chrono::minutes> ToTimePoint;
+ boost::chrono::time_point_cast<ToTimePoint>(FromTimePoint(boost::chrono::milliseconds(3)));
+}
Added: sandbox/chrono/libs/chrono/test/time_point/comparisons/op_equal.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/comparisons/op_equal.fail.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,45 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_points with different clocks should not compare
+
+#include <boost/chrono.hpp>
+
+#include "../../clock.h"
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock1;
+ typedef Clock Clock2;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ typedef boost::chrono::time_point<Clock1, Duration1> T1;
+ typedef boost::chrono::time_point<Clock2, Duration2> T2;
+
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ t1 == t2;
+}
Added: sandbox/chrono/libs/chrono/test/time_point/comparisons/op_equal.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/comparisons/op_equal.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,62 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+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;
+
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(3));
+ assert( (t1 == t2));
+ assert(!(t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(4));
+ assert(!(t1 == t2));
+ assert( (t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ assert( (t1 == t2));
+ assert(!(t1 != t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3001));
+ assert(!(t1 == t2));
+ assert( (t1 != t2));
+ }
+}
Added: sandbox/chrono/libs/chrono/test/time_point/comparisons/op_less.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/comparisons/op_less.fail.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,53 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_points with different clocks should not compare
+
+#include <boost/chrono.hpp>
+
+#include "../../clock.h"
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock1;
+ typedef Clock Clock2;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ typedef boost::chrono::time_point<Clock1, Duration1> T1;
+ typedef boost::chrono::time_point<Clock2, Duration2> T2;
+
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ t1 < t2;
+}
Added: sandbox/chrono/libs/chrono/test/time_point/comparisons/op_less.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/comparisons/op_less.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,78 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+// bool
+// operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+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;
+
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(3));
+ assert(!(t1 < t2));
+ assert(!(t1 > t2));
+ assert( (t1 <= t2));
+ assert( (t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T1 t2(Duration1(4));
+ assert( (t1 < t2));
+ assert(!(t1 > t2));
+ assert( (t1 <= t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ assert(!(t1 < t2));
+ assert(!(t1 > t2));
+ assert( (t1 <= t2));
+ assert( (t1 >= t2));
+ }
+ {
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3001));
+ assert( (t1 < t2));
+ assert(!(t1 > t2));
+ assert( (t1 <= t2));
+ assert(!(t1 >= t2));
+ }
+}
Added: sandbox/chrono/libs/chrono/test/time_point/cons/convert.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/cons/convert.fail.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,35 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Duration2>
+// time_point(const time_point<clock, Duration2>& t);
+
+// Duration2 shall be implicitly convertible to duration.
+
+#include <boost/chrono.hpp>
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration1;
+ typedef boost::chrono::microseconds Duration2;
+ {
+ boost::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+ boost::chrono::time_point<Clock, Duration1> t1 = t2;
+ }
+}
Added: sandbox/chrono/libs/chrono/test/time_point/cons/convert.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/cons/convert.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,35 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Duration2>
+// time_point(const time_point<clock, Duration2>& t);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+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;
+ assert(t1.time_since_epoch() == Duration1(3000));
+ }
+}
Added: sandbox/chrono/libs/chrono/test/time_point/cons/default.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/cons/default.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,32 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point();
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::duration<Rep, boost::milli> Duration;
+ boost::chrono::time_point<Clock, Duration> t;
+ assert(t.time_since_epoch() == Duration::zero());
+}
Added: sandbox/chrono/libs/chrono/test/time_point/cons/duration.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/cons/duration.fail.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,30 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// explicit time_point(const duration& d);
+
+// test for explicit
+
+#include <boost/chrono.hpp>
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ boost::chrono::time_point<Clock, Duration> t = Duration(3);
+}
Added: sandbox/chrono/libs/chrono/test/time_point/cons/duration.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/cons/duration.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,36 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// explicit time_point(const duration& d);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ {
+ boost::chrono::time_point<Clock, Duration> t(Duration(3));
+ assert(t.time_since_epoch() == Duration(3));
+ }
+ {
+ boost::chrono::time_point<Clock, Duration> t(boost::chrono::seconds(3));
+ assert(t.time_since_epoch() == Duration(3000));
+ }
+}
Added: sandbox/chrono/libs/chrono/test/time_point/default_duration.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/default_duration.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,34 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// Test default template arg:
+
+// template <class Clock, class Duration = typename Clock::duration>
+// class time_point;
+
+#include <boost/chrono.hpp>
+#include <boost/type_traits.hpp>
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+int main()
+{
+ BOOST_CHRONO_STATIC_ASSERT((boost::is_same<boost::chrono::system_clock::duration,
+ boost::chrono::time_point<boost::chrono::system_clock>::duration>::value), NOTHING, ());
+}
Added: sandbox/chrono/libs/chrono/test/time_point/duration.fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/duration.fail.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,27 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// Duration shall be an instance of duration.
+
+#include <boost/chrono.hpp>
+
+int main()
+{
+ typedef boost::chrono::time_point<boost::chrono::system_clock, int> T;
+ T t;
+}
Added: sandbox/chrono/libs/chrono/test/time_point/nonmember/op_minus_duration.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/nonmember/op_minus_duration.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,34 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Rep2, class Period2>
+// time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+// operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+int main()
+{
+ 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);
+ assert(t2.time_since_epoch() == Duration2(2995));
+}
Added: sandbox/chrono/libs/chrono/test/time_point/nonmember/op_minus_time_point.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/nonmember/op_minus_time_point.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,34 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+// typename common_type<Duration1, Duration2>::type
+// operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+int main()
+{
+ 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));
+ assert((t1 - t2) == Duration2(2995));
+}
Added: sandbox/chrono/libs/chrono/test/time_point/nonmember/op_plus.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/nonmember/op_plus.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,40 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Rep2, class Period2>
+// time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+// operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Clock, class Duration2>
+// time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
+// operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+int main()
+{
+ 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);
+ assert(t2.time_since_epoch() == Duration2(3005));
+ t2 = Duration2(6) + t1;
+ assert(t2.time_since_epoch() == Duration2(3006));
+}
Added: sandbox/chrono/libs/chrono/test/time_point/observer/tested_elsewhere.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/observer/tested_elsewhere.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,17 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: sandbox/chrono/libs/chrono/test/time_point/special/max.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/special/max.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,30 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// static constexpr time_point max();
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ typedef boost::chrono::time_point<Clock, Duration> TP;
+ assert(TP::max() == TP(Duration::max()));
+}
Added: sandbox/chrono/libs/chrono/test/time_point/special/min.pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/time_point/special/min.pass.cpp 2010-09-20 16:50:47 EDT (Mon, 20 Sep 2010)
@@ -0,0 +1,30 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Adapted from llvm/libcxx/test/utilities/chrono
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// static constexpr time_point min();
+
+#include <boost/chrono.hpp>
+#include <cassert>
+
+int main()
+{
+ typedef boost::chrono::system_clock Clock;
+ typedef boost::chrono::milliseconds Duration;
+ typedef boost::chrono::time_point<Clock, Duration> TP;
+ assert(TP::min() == TP(Duration::min()));
+}
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