summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/time/time.point
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/utilities/time/time.point')
-rw-r--r--libcxx/test/utilities/time/time.point/default_duration.pass.cpp26
-rw-r--r--libcxx/test/utilities/time/time.point/duration.fail.cpp22
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp26
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp26
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp48
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp28
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp40
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp57
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp48
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp73
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.cons/convert.fail.cpp30
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.cons/convert.pass.cpp30
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.cons/default.pass.cpp27
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.cons/duration.fail.cpp25
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.cons/duration.pass.cpp31
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp35
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp29
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp29
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp12
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.special/max.pass.cpp25
-rw-r--r--libcxx/test/utilities/time/time.point/time.point.special/min.pass.cpp25
21 files changed, 692 insertions, 0 deletions
diff --git a/libcxx/test/utilities/time/time.point/default_duration.pass.cpp b/libcxx/test/utilities/time/time.point/default_duration.pass.cpp
new file mode 100644
index 00000000000..d4ac693df7d
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/default_duration.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::chrono::system_clock::duration,
+ std::chrono::time_point<std::chrono::system_clock>::duration>::value), "");
+}
diff --git a/libcxx/test/utilities/time/time.point/duration.fail.cpp b/libcxx/test/utilities/time/time.point/duration.fail.cpp
new file mode 100644
index 00000000000..5c2b71734c2
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/duration.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+
+int main()
+{
+ typedef std::chrono::time_point<std::chrono::system_clock, int> T;
+ T t;
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
new file mode 100644
index 00000000000..8eb2a41a7c3
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ std::chrono::time_point<Clock, Duration> t(Duration(3));
+ t += Duration(2);
+ assert(t.time_since_epoch() == Duration(5));
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
new file mode 100644
index 00000000000..0c28e7db642
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ std::chrono::time_point<Clock, Duration> t(Duration(3));
+ t -= Duration(2);
+ assert(t.time_since_epoch() == Duration(1));
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
new file mode 100644
index 00000000000..41544c9682a
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+test(const FromDuration& df, const ToDuration& d)
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
+ typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
+ FromTimePoint f(df);
+ ToTimePoint t(d);
+ typedef decltype(std::chrono::time_point_cast<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToTimePoint>::value), "");
+ assert(std::chrono::time_point_cast<ToDuration>(f) == t);
+}
+
+int main()
+{
+ test(std::chrono::milliseconds(7265000), std::chrono::hours(2));
+ test(std::chrono::milliseconds(7265000), std::chrono::minutes(121));
+ test(std::chrono::milliseconds(7265000), std::chrono::seconds(7265));
+ test(std::chrono::milliseconds(7265000), std::chrono::milliseconds(7265000));
+ test(std::chrono::milliseconds(7265000), std::chrono::microseconds(7265000000LL));
+ test(std::chrono::milliseconds(7265000), std::chrono::nanoseconds(7265000000000LL));
+ test(std::chrono::milliseconds(7265000),
+ std::chrono::duration<double, std::ratio<3600> >(7265./3600));
+ test(std::chrono::duration<int, std::ratio<2, 3> >(9),
+ std::chrono::duration<int, std::ratio<3, 5> >(10));
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp b/libcxx/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp
new file mode 100644
index 00000000000..af0f3786174
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::time_point<Clock, std::chrono::milliseconds> FromTimePoint;
+ typedef std::chrono::time_point<Clock, std::chrono::minutes> ToTimePoint;
+ std::chrono::time_point_cast<ToTimePoint>(FromTimePoint(std::chrono::milliseconds(3)));
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp b/libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp
new file mode 100644
index 00000000000..92502c1850a
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+
+#include "../../clock.h"
+
+int main()
+{
+ typedef std::chrono::system_clock Clock1;
+ typedef Clock Clock2;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ typedef std::chrono::time_point<Clock1, Duration1> T1;
+ typedef std::chrono::time_point<Clock2, Duration2> T2;
+
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ t1 == t2;
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
new file mode 100644
index 00000000000..f49cd3207d2
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ typedef std::chrono::time_point<Clock, Duration1> T1;
+ typedef std::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));
+ }
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp b/libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp
new file mode 100644
index 00000000000..e2c26c2603a
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+
+#include "../../clock.h"
+
+int main()
+{
+ typedef std::chrono::system_clock Clock1;
+ typedef Clock Clock2;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ typedef std::chrono::time_point<Clock1, Duration1> T1;
+ typedef std::chrono::time_point<Clock2, Duration2> T2;
+
+ T1 t1(Duration1(3));
+ T2 t2(Duration2(3000));
+ t1 < t2;
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
new file mode 100644
index 00000000000..cbb2f109190
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ typedef std::chrono::time_point<Clock, Duration1> T1;
+ typedef std::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));
+ }
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.cons/convert.fail.cpp b/libcxx/test/utilities/time/time.point/time.point.cons/convert.fail.cpp
new file mode 100644
index 00000000000..88cef151283
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.cons/convert.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ {
+ std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+ std::chrono::time_point<Clock, Duration1> t1 = t2;
+ }
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.cons/convert.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.cons/convert.pass.cpp
new file mode 100644
index 00000000000..bb8587f0db2
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.cons/convert.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::microseconds Duration1;
+ typedef std::chrono::milliseconds Duration2;
+ {
+ std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+ std::chrono::time_point<Clock, Duration1> t1 = t2;
+ assert(t1.time_since_epoch() == Duration1(3000));
+ }
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.cons/default.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.cons/default.pass.cpp
new file mode 100644
index 00000000000..736a0ca14ea
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.cons/default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::duration<Rep, std::milli> Duration;
+ std::chrono::time_point<Clock, Duration> t;
+ assert(t.time_since_epoch() == Duration::zero());
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.cons/duration.fail.cpp b/libcxx/test/utilities/time/time.point/time.point.cons/duration.fail.cpp
new file mode 100644
index 00000000000..4a742c85687
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.cons/duration.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ std::chrono::time_point<Clock, Duration> t = Duration(3);
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.cons/duration.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.cons/duration.pass.cpp
new file mode 100644
index 00000000000..3c53686ac3a
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.cons/duration.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ {
+ std::chrono::time_point<Clock, Duration> t(Duration(3));
+ assert(t.time_since_epoch() == Duration(3));
+ }
+ {
+ std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
+ assert(t.time_since_epoch() == Duration(3000));
+ }
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
new file mode 100644
index 00000000000..016391ee374
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ std::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));
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
new file mode 100644
index 00000000000..98cfa6c878d
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+ assert(t2.time_since_epoch() == Duration2(2995));
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
new file mode 100644
index 00000000000..76fb101dd41
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration1;
+ typedef std::chrono::microseconds Duration2;
+ std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+ std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+ assert((t1 - t2) == Duration2(2995));
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..fa4d462f18d
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.special/max.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.special/max.pass.cpp
new file mode 100644
index 00000000000..65d9598a327
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.special/max.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ typedef std::chrono::time_point<Clock, Duration> TP;
+ assert(TP::max() == TP(Duration::max()));
+}
diff --git a/libcxx/test/utilities/time/time.point/time.point.special/min.pass.cpp b/libcxx/test/utilities/time/time.point/time.point.special/min.pass.cpp
new file mode 100644
index 00000000000..e411f5b5285
--- /dev/null
+++ b/libcxx/test/utilities/time/time.point/time.point.special/min.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚ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 <chrono>
+#include <cassert>
+
+int main()
+{
+ typedef std::chrono::system_clock Clock;
+ typedef std::chrono::milliseconds Duration;
+ typedef std::chrono::time_point<Clock, Duration> TP;
+ assert(TP::min() == TP(Duration::min()));
+}
OpenPOWER on IntegriCloud