From 5a83710e371fe68a06e6e3876c6a2c8b820a8976 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 20 Dec 2014 01:40:03 +0000 Subject: Move test into test/std subdirectory. llvm-svn: 224658 --- libcxx/test/std/utilities/time/clock.h | 26 ++++ libcxx/test/std/utilities/time/hours.pass.cpp | 27 ++++ .../test/std/utilities/time/microseconds.pass.cpp | 27 ++++ .../test/std/utilities/time/milliseconds.pass.cpp | 27 ++++ libcxx/test/std/utilities/time/minutes.pass.cpp | 27 ++++ .../test/std/utilities/time/nanoseconds.pass.cpp | 27 ++++ libcxx/test/std/utilities/time/rep.h | 27 ++++ libcxx/test/std/utilities/time/seconds.pass.cpp | 27 ++++ .../time/time.clock.req/nothing_to_do.pass.cpp | 12 ++ .../time/time.clock/nothing_to_do.pass.cpp | 12 ++ .../time.clock.hires/consistency.pass.cpp | 34 +++++ .../time/time.clock/time.clock.hires/now.pass.cpp | 22 +++ .../time.clock.steady/consistency.pass.cpp | 35 +++++ .../time/time.clock/time.clock.steady/now.pass.cpp | 27 ++++ .../time.clock.system/consistency.pass.cpp | 35 +++++ .../time.clock.system/from_time_t.pass.cpp | 23 ++++ .../time/time.clock/time.clock.system/now.pass.cpp | 22 +++ .../time.clock.system/rep_signed.pass.cpp | 23 ++++ .../time.clock.system/to_time_t.pass.cpp | 23 ++++ .../time/time.duration/default_ratio.pass.cpp | 26 ++++ .../utilities/time/time.duration/duration.fail.cpp | 23 ++++ .../time/time.duration/positive_num.fail.cpp | 22 +++ .../utilities/time/time.duration/ratio.fail.cpp | 30 ++++ .../time.duration.arithmetic/op_++.pass.cpp | 25 ++++ .../time.duration.arithmetic/op_++int.pass.cpp | 25 ++++ .../time.duration.arithmetic/op_+.pass.cpp | 33 +++++ .../time.duration.arithmetic/op_+=.pass.cpp | 26 ++++ .../time.duration.arithmetic/op_--.pass.cpp | 25 ++++ .../time.duration.arithmetic/op_--int.pass.cpp | 25 ++++ .../time.duration.arithmetic/op_-.pass.cpp | 33 +++++ .../time.duration.arithmetic/op_-=.pass.cpp | 26 ++++ .../time.duration.arithmetic/op_divide=.pass.cpp | 24 ++++ .../op_mod=duration.pass.cpp | 27 ++++ .../time.duration.arithmetic/op_mod=rep.pass.cpp | 24 ++++ .../time.duration.arithmetic/op_times=.pass.cpp | 24 ++++ .../time.duration.cast/duration_cast.pass.cpp | 52 +++++++ .../time.duration.cast/toduration.fail.cpp | 25 ++++ .../time.duration.comparisons/op_equal.pass.cpp | 115 ++++++++++++++++ .../time.duration.comparisons/op_less.pass.cpp | 153 +++++++++++++++++++++ .../time.duration.cons/convert_exact.pass.cpp | 36 +++++ .../convert_float_to_int.fail.cpp | 25 ++++ .../time.duration.cons/convert_inexact.fail.cpp | 25 ++++ .../time.duration.cons/convert_inexact.pass.cpp | 36 +++++ .../convert_int_to_float.pass.cpp | 36 +++++ .../time.duration.cons/convert_overflow.pass.cpp | 37 +++++ .../time.duration.cons/default.pass.cpp | 38 +++++ .../time.duration/time.duration.cons/rep.pass.cpp | 40 ++++++ .../time.duration.cons/rep01.fail.cpp | 26 ++++ .../time.duration.cons/rep02.fail.cpp | 26 ++++ .../time.duration.cons/rep02.pass.cpp | 30 ++++ .../time.duration.cons/rep03.fail.cpp | 24 ++++ .../time.duration.literals/literals.pass.cpp | 59 ++++++++ .../time.duration.literals/literals1.fail.cpp | 21 +++ .../time.duration.literals/literals1.pass.cpp | 48 +++++++ .../time.duration.literals/literals2.fail.cpp | 22 +++ .../time.duration.literals/literals2.pass.cpp | 51 +++++++ .../time.duration.nonmember/op_+.pass.cpp | 73 ++++++++++ .../time.duration.nonmember/op_-.pass.cpp | 74 ++++++++++ .../op_divide_duration.pass.cpp | 66 +++++++++ .../time.duration.nonmember/op_divide_rep.fail.cpp | 26 ++++ .../time.duration.nonmember/op_divide_rep.pass.cpp | 36 +++++ .../op_mod_duration.pass.cpp | 62 +++++++++ .../time.duration.nonmember/op_mod_rep.fail.cpp | 26 ++++ .../time.duration.nonmember/op_mod_rep.pass.cpp | 36 +++++ .../time.duration.nonmember/op_times_rep.pass.cpp | 45 ++++++ .../time.duration.nonmember/op_times_rep1.fail.cpp | 30 ++++ .../time.duration.nonmember/op_times_rep2.fail.cpp | 30 ++++ .../tested_elsewhere.pass.cpp | 12 ++ .../time.duration.special/max.pass.cpp | 43 ++++++ .../time.duration.special/min.pass.cpp | 43 ++++++ .../time.duration.special/zero.pass.cpp | 42 ++++++ .../utilities/time/time.duration/types.pass.cpp | 27 ++++ .../time/time.point/default_duration.pass.cpp | 26 ++++ .../utilities/time/time.point/duration.fail.cpp | 22 +++ .../time.point.arithmetic/op_+=.pass.cpp | 26 ++++ .../time.point.arithmetic/op_-=.pass.cpp | 26 ++++ .../time.point.cast/time_point_cast.pass.cpp | 80 +++++++++++ .../time.point/time.point.cast/toduration.fail.cpp | 28 ++++ .../time.point.comparisons/op_equal.fail.cpp | 40 ++++++ .../time.point.comparisons/op_equal.pass.cpp | 84 +++++++++++ .../time.point.comparisons/op_less.fail.cpp | 48 +++++++ .../time.point.comparisons/op_less.pass.cpp | 108 +++++++++++++++ .../time.point/time.point.cons/convert.fail.cpp | 30 ++++ .../time.point/time.point.cons/convert.pass.cpp | 37 +++++ .../time.point/time.point.cons/default.pass.cpp | 35 +++++ .../time.point/time.point.cons/duration.fail.cpp | 25 ++++ .../time.point/time.point.cons/duration.pass.cpp | 41 ++++++ .../time.point/time.point.nonmember/op_+.pass.cpp | 46 +++++++ .../time.point.nonmember/op_-duration.pass.cpp | 38 +++++ .../time.point.nonmember/op_-time_point.pass.cpp | 38 +++++ .../time.point.observer/tested_elsewhere.pass.cpp | 12 ++ .../time.point/time.point.special/max.pass.cpp | 25 ++++ .../time.point/time.point.special/min.pass.cpp | 25 ++++ .../time/time.traits/nothing_to_do.pass.cpp | 12 ++ .../time.traits.duration_values/max.pass.cpp | 36 +++++ .../time.traits.duration_values/min.pass.cpp | 36 +++++ .../time.traits.duration_values/zero.pass.cpp | 27 ++++ .../treat_as_floating_point.pass.cpp | 37 +++++ .../time.traits.specializations/duration.pass.cpp | 42 ++++++ .../time_point.pass.cpp | 46 +++++++ libcxx/test/std/utilities/time/version.pass.cpp | 20 +++ 101 files changed, 3593 insertions(+) create mode 100644 libcxx/test/std/utilities/time/clock.h create mode 100644 libcxx/test/std/utilities/time/hours.pass.cpp create mode 100644 libcxx/test/std/utilities/time/microseconds.pass.cpp create mode 100644 libcxx/test/std/utilities/time/milliseconds.pass.cpp create mode 100644 libcxx/test/std/utilities/time/minutes.pass.cpp create mode 100644 libcxx/test/std/utilities/time/nanoseconds.pass.cpp create mode 100644 libcxx/test/std/utilities/time/rep.h create mode 100644 libcxx/test/std/utilities/time/seconds.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/duration.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/positive_num.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/ratio.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.duration/types.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/default_duration.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/duration.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.special/max.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.point/time.point.special/min.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.traits/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp create mode 100644 libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp create mode 100644 libcxx/test/std/utilities/time/version.pass.cpp (limited to 'libcxx/test/std/utilities/time') diff --git a/libcxx/test/std/utilities/time/clock.h b/libcxx/test/std/utilities/time/clock.h new file mode 100644 index 00000000000..c72470c9cc8 --- /dev/null +++ b/libcxx/test/std/utilities/time/clock.h @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef CLOCK_H +#define CLOCK_H + +#include + +class Clock +{ + typedef std::chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef std::chrono::time_point time_point; + static const bool is_steady = false; + + static time_point now(); +}; + +#endif // CLOCK_H diff --git a/libcxx/test/std/utilities/time/hours.pass.cpp b/libcxx/test/std/utilities/time/hours.pass.cpp new file mode 100644 index 00000000000..e4c39f7859e --- /dev/null +++ b/libcxx/test/std/utilities/time/hours.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration> hours; + +#include +#include +#include + +int main() +{ + typedef std::chrono::hours D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 22, ""); + static_assert((std::is_same >::value), ""); +} diff --git a/libcxx/test/std/utilities/time/microseconds.pass.cpp b/libcxx/test/std/utilities/time/microseconds.pass.cpp new file mode 100644 index 00000000000..1fe6b10da5a --- /dev/null +++ b/libcxx/test/std/utilities/time/microseconds.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration microseconds; + +#include +#include +#include + +int main() +{ + typedef std::chrono::microseconds D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 54, ""); + static_assert((std::is_same::value), ""); +} diff --git a/libcxx/test/std/utilities/time/milliseconds.pass.cpp b/libcxx/test/std/utilities/time/milliseconds.pass.cpp new file mode 100644 index 00000000000..75df301f7a6 --- /dev/null +++ b/libcxx/test/std/utilities/time/milliseconds.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration milliseconds; + +#include +#include +#include + +int main() +{ + typedef std::chrono::milliseconds D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 44, ""); + static_assert((std::is_same::value), ""); +} diff --git a/libcxx/test/std/utilities/time/minutes.pass.cpp b/libcxx/test/std/utilities/time/minutes.pass.cpp new file mode 100644 index 00000000000..14214861c07 --- /dev/null +++ b/libcxx/test/std/utilities/time/minutes.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration> minutes; + +#include +#include +#include + +int main() +{ + typedef std::chrono::minutes D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 28, ""); + static_assert((std::is_same >::value), ""); +} diff --git a/libcxx/test/std/utilities/time/nanoseconds.pass.cpp b/libcxx/test/std/utilities/time/nanoseconds.pass.cpp new file mode 100644 index 00000000000..d422803f452 --- /dev/null +++ b/libcxx/test/std/utilities/time/nanoseconds.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration nanoseconds; + +#include +#include +#include + +int main() +{ + typedef std::chrono::nanoseconds D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 63, ""); + static_assert((std::is_same::value), ""); +} diff --git a/libcxx/test/std/utilities/time/rep.h b/libcxx/test/std/utilities/time/rep.h new file mode 100644 index 00000000000..2ec3514ab56 --- /dev/null +++ b/libcxx/test/std/utilities/time/rep.h @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef REP_H +#define REP_H + +class Rep +{ + int data_; +public: + _LIBCPP_CONSTEXPR Rep() : data_(-1) {} + explicit _LIBCPP_CONSTEXPR Rep(int i) : data_(i) {} + + bool _LIBCPP_CONSTEXPR operator==(int i) const {return data_ == i;} + bool _LIBCPP_CONSTEXPR operator==(const Rep& r) const {return data_ == r.data_;} + + Rep& operator*=(Rep x) {data_ *= x.data_; return *this;} + Rep& operator/=(Rep x) {data_ /= x.data_; return *this;} +}; + +#endif // REP_H diff --git a/libcxx/test/std/utilities/time/seconds.pass.cpp b/libcxx/test/std/utilities/time/seconds.pass.cpp new file mode 100644 index 00000000000..231d59695a0 --- /dev/null +++ b/libcxx/test/std/utilities/time/seconds.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// typedef duration seconds; + +#include +#include +#include + +int main() +{ + typedef std::chrono::seconds D; + typedef D::rep Rep; + typedef D::period Period; + static_assert(std::is_signed::value, ""); + static_assert(std::is_integral::value, ""); + static_assert(std::numeric_limits::digits >= 34, ""); + static_assert((std::is_same >::value), ""); +} diff --git a/libcxx/test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock.req/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/time/time.clock/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/time/time.clock/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp new file mode 100644 index 00000000000..848534d6179 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This test uses new symbols that were not defined in the libc++ shipped on +// darwin11 and darwin12: +// XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 + +// + +// high_resolution_clock + +// check clock invariants + +#include + +template +void test(const _Tp &) {} + +int main() +{ + typedef std::chrono::high_resolution_clock C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert(C::is_steady || !C::is_steady, ""); + test(std::chrono::high_resolution_clock::is_steady); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp new file mode 100644 index 00000000000..0bcd99d76ad --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.hires/now.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// high_resolution_clock + +// static time_point now(); + +#include + +int main() +{ + typedef std::chrono::high_resolution_clock C; + C::time_point t1 = C::now(); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp new file mode 100644 index 00000000000..60c646147ce --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This test uses new symbols that were not defined in the libc++ shipped on +// darwin11 and darwin12: +// XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 +// UNSUPPORTED: libcpp-has-no-monotonic-clock + +// + +// steady_clock + +// check clock invariants + +#include + +template +void test(const _Tp &) {} + +int main() +{ + typedef std::chrono::steady_clock C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert(C::is_steady, ""); + test(std::chrono::steady_clock::is_steady); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp new file mode 100644 index 00000000000..4b86d9e8cbc --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-monotonic-clock + +// + +// steady_clock + +// static time_point now(); + +#include +#include + +int main() +{ + typedef std::chrono::steady_clock C; + C::time_point t1 = C::now(); + C::time_point t2 = C::now(); + assert(t2 >= t1); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp new file mode 100644 index 00000000000..d9d6b04d631 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This test uses new symbols that were not defined in the libc++ shipped on +// darwin11 and darwin12: +// XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 + +// + +// system_clock + +// check clock invariants + +#include + +template +void test(const _Tp &) {} + +int main() +{ + typedef std::chrono::system_clock C; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((C::is_steady || !C::is_steady), ""); + test(std::chrono::system_clock::is_steady); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp new file mode 100644 index 00000000000..9b12a667ffd --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// system_clock + +// static time_point from_time_t(time_t t); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock C; + C::time_point t1 = C::from_time_t(C::to_time_t(C::now())); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp new file mode 100644 index 00000000000..60530fdf3a9 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// system_clock + +// static time_point now(); + +#include + +int main() +{ + typedef std::chrono::system_clock C; + C::time_point t1 = C::now(); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp new file mode 100644 index 00000000000..b6a440e16dd --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// system_clock + +// rep should be signed + +#include +#include + +int main() +{ + assert(std::chrono::system_clock::duration::min() < + std::chrono::system_clock::duration::zero()); +} diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp new file mode 100644 index 00000000000..2a82d5375e1 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// system_clock + +// time_t to_time_t(const time_point& t); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock C; + std::time_t t1 = C::to_time_t(C::now()); +} diff --git a/libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp b/libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp new file mode 100644 index 00000000000..a34e27832bd --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/default_ratio.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// Test default template arg: + +// template > +// class duration; + +#include +#include + +int main() +{ + static_assert((std::is_same >, + std::chrono::duration >::value), ""); +} diff --git a/libcxx/test/std/utilities/time/time.duration/duration.fail.cpp b/libcxx/test/std/utilities/time/time.duration/duration.fail.cpp new file mode 100644 index 00000000000..053616b79b4 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/duration.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// If a program instantiates duration with a duration type for the template +// argument Rep a diagnostic is required. + +#include + +int main() +{ + typedef std::chrono::duration D; + D d; +} diff --git a/libcxx/test/std/utilities/time/time.duration/positive_num.fail.cpp b/libcxx/test/std/utilities/time/time.duration/positive_num.fail.cpp new file mode 100644 index 00000000000..e9096fd3fcb --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/positive_num.fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// Period::num shall be positive, diagnostic required. + +#include + +int main() +{ + typedef std::chrono::duration > D; + D d; +} diff --git a/libcxx/test/std/utilities/time/time.duration/ratio.fail.cpp b/libcxx/test/std/utilities/time/time.duration/ratio.fail.cpp new file mode 100644 index 00000000000..4ce0aaad003 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/ratio.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// Period shall be a specialization of ratio, diagnostic required. + +#include + +template +class Ratio +{ +public: + static const int num = N; + static const int den = D; +}; + +int main() +{ + typedef std::chrono::duration > D; + D d; +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp new file mode 100644 index 00000000000..8a8f4b1c0d9 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator++(); + +#include +#include + +int main() +{ + std::chrono::hours h(3); + std::chrono::hours& href = ++h; + assert(&href == &h); + assert(h.count() == 4); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp new file mode 100644 index 00000000000..cf502828100 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration operator++(int); + +#include +#include + +int main() +{ + std::chrono::hours h(3); + std::chrono::hours h2 = h++; + assert(h.count() == 4); + assert(h2.count() == 3); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp new file mode 100644 index 00000000000..c0f10147ee8 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration operator+() const; + +#include +#include + +int main() +{ + { + const std::chrono::minutes m(3); + std::chrono::minutes m2 = +m; + assert(m.count() == m2.count()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::minutes m(3); + constexpr std::chrono::minutes m2 = +m; + static_assert(m.count() == m2.count(), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp new file mode 100644 index 00000000000..8d8cf4539c1 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator+=(const duration& d); + +#include +#include + +int main() +{ + std::chrono::seconds s(3); + s += std::chrono::seconds(2); + assert(s.count() == 5); + s += std::chrono::minutes(2); + assert(s.count() == 125); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp new file mode 100644 index 00000000000..0aadfbcd599 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator--(); + +#include +#include + +int main() +{ + std::chrono::hours h(3); + std::chrono::hours& href = --h; + assert(&href == &h); + assert(h.count() == 2); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp new file mode 100644 index 00000000000..7fc6a1df603 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration operator--(int); + +#include +#include + +int main() +{ + std::chrono::hours h(3); + std::chrono::hours h2 = h--; + assert(h.count() == 2); + assert(h2.count() == 3); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp new file mode 100644 index 00000000000..00da6f69ca5 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration operator-() const; + +#include +#include + +int main() +{ + { + const std::chrono::minutes m(3); + std::chrono::minutes m2 = -m; + assert(m2.count() == -m.count()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::minutes m(3); + constexpr std::chrono::minutes m2 = -m; + static_assert(m2.count() == -m.count(), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp new file mode 100644 index 00000000000..a0a7aed202b --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator-=(const duration& d); + +#include +#include + +int main() +{ + std::chrono::seconds s(3); + s -= std::chrono::seconds(2); + assert(s.count() == 1); + s -= std::chrono::minutes(2); + assert(s.count() == -119); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp new file mode 100644 index 00000000000..09786bcd8cf --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator/=(const rep& rhs); + +#include +#include + +int main() +{ + std::chrono::nanoseconds ns(15); + ns /= 5; + assert(ns.count() == 3); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp new file mode 100644 index 00000000000..8a4a2b47232 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator%=(const duration& rhs) + +#include +#include + +int main() +{ + std::chrono::microseconds us(11); + std::chrono::microseconds us2(3); + us %= us2; + assert(us.count() == 2); + us %= std::chrono::milliseconds(3); + assert(us.count() == 2); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp new file mode 100644 index 00000000000..8758e17ba6a --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator%=(const rep& rhs) + +#include +#include + +int main() +{ + std::chrono::microseconds us(11); + us %= 3; + assert(us.count() == 2); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp new file mode 100644 index 00000000000..b97534a3615 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration& operator*=(const rep& rhs); + +#include +#include + +int main() +{ + std::chrono::nanoseconds ns(3); + ns *= 5; + assert(ns.count() == 15); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp new file mode 100644 index 00000000000..1c87fcd909e --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// ToDuration +// duration_cast(const duration& d); + +#include +#include +#include + +template +void +test(const FromDuration& f, const ToDuration& d) +{ + { + typedef decltype(std::chrono::duration_cast(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::duration_cast(f) == d); + } +} + +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 >(7265./3600)); + test(std::chrono::duration >(9), + std::chrono::duration >(10)); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::hours h = std::chrono::duration_cast(std::chrono::milliseconds(7265000)); + static_assert(h.count() == 2, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp new file mode 100644 index 00000000000..13dd8f44c36 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// ToDuration +// duration_cast(const duration& d); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + std::chrono::duration_cast(std::chrono::milliseconds(3)); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp new file mode 100644 index 00000000000..2d0dd94d4cf --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp @@ -0,0 +1,115 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// bool +// operator==(const duration& lhs, const duration& rhs); + +// template +// constexpr +// bool +// operator!=(const duration& lhs, const duration& rhs); + +#include +#include + +int main() +{ + { + std::chrono::seconds s1(3); + std::chrono::seconds s2(3); + assert(s1 == s2); + assert(!(s1 != s2)); + } + { + std::chrono::seconds s1(3); + std::chrono::seconds s2(4); + assert(!(s1 == s2)); + assert(s1 != s2); + } + { + std::chrono::milliseconds s1(3); + std::chrono::microseconds s2(3000); + assert(s1 == s2); + assert(!(s1 != s2)); + } + { + std::chrono::milliseconds s1(3); + std::chrono::microseconds s2(4000); + assert(!(s1 == s2)); + assert(s1 != s2); + } + { + std::chrono::duration > s1(9); + std::chrono::duration > s2(10); + assert(s1 == s2); + assert(!(s1 != s2)); + } + { + std::chrono::duration > s1(10); + std::chrono::duration > s2(9); + assert(!(s1 == s2)); + assert(s1 != s2); + } + { + std::chrono::duration > s1(9); + std::chrono::duration > s2(10); + assert(s1 == s2); + assert(!(s1 != s2)); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::seconds s1(3); + constexpr std::chrono::seconds s2(3); + static_assert(s1 == s2, ""); + static_assert(!(s1 != s2), ""); + } + { + constexpr std::chrono::seconds s1(3); + constexpr std::chrono::seconds s2(4); + static_assert(!(s1 == s2), ""); + static_assert(s1 != s2, ""); + } + { + constexpr std::chrono::milliseconds s1(3); + constexpr std::chrono::microseconds s2(3000); + static_assert(s1 == s2, ""); + static_assert(!(s1 != s2), ""); + } + { + constexpr std::chrono::milliseconds s1(3); + constexpr std::chrono::microseconds s2(4000); + static_assert(!(s1 == s2), ""); + static_assert(s1 != s2, ""); + } + { + constexpr std::chrono::duration > s1(9); + constexpr std::chrono::duration > s2(10); + static_assert(s1 == s2, ""); + static_assert(!(s1 != s2), ""); + } + { + constexpr std::chrono::duration > s1(10); + constexpr std::chrono::duration > s2(9); + static_assert(!(s1 == s2), ""); + static_assert(s1 != s2, ""); + } + { + constexpr std::chrono::duration > s1(9); + constexpr std::chrono::duration > s2(10); + static_assert(s1 == s2, ""); + static_assert(!(s1 != s2), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp new file mode 100644 index 00000000000..9d875579f32 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp @@ -0,0 +1,153 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// bool +// operator< (const duration& lhs, const duration& rhs); + +// template +// constexpr +// bool +// operator> (const duration& lhs, const duration& rhs); + +// template +// constexpr +// bool +// operator<=(const duration& lhs, const duration& rhs); + +// template +// constexpr +// bool +// operator>=(const duration& lhs, const duration& rhs); + +#include +#include + +int main() +{ + { + std::chrono::seconds s1(3); + std::chrono::seconds s2(3); + assert(!(s1 < s2)); + assert(!(s1 > s2)); + assert( (s1 <= s2)); + assert( (s1 >= s2)); + } + { + std::chrono::seconds s1(3); + std::chrono::seconds s2(4); + assert( (s1 < s2)); + assert(!(s1 > s2)); + assert( (s1 <= s2)); + assert(!(s1 >= s2)); + } + { + std::chrono::milliseconds s1(3); + std::chrono::microseconds s2(3000); + assert(!(s1 < s2)); + assert(!(s1 > s2)); + assert( (s1 <= s2)); + assert( (s1 >= s2)); + } + { + std::chrono::milliseconds s1(3); + std::chrono::microseconds s2(4000); + assert( (s1 < s2)); + assert(!(s1 > s2)); + assert( (s1 <= s2)); + assert(!(s1 >= s2)); + } + { + std::chrono::duration > s1(9); + std::chrono::duration > s2(10); + assert(!(s1 < s2)); + assert(!(s1 > s2)); + assert( (s1 <= s2)); + assert( (s1 >= s2)); + } + { + std::chrono::duration > s1(10); + std::chrono::duration > s2(9); + assert(!(s1 < s2)); + assert( (s1 > s2)); + assert(!(s1 <= s2)); + assert( (s1 >= s2)); + } + { + std::chrono::duration > s1(9); + std::chrono::duration > s2(10); + assert(!(s1 < s2)); + assert(!(s1 > s2)); + assert( (s1 <= s2)); + assert( (s1 >= s2)); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::seconds s1(3); + constexpr std::chrono::seconds s2(3); + static_assert(!(s1 < s2), ""); + static_assert(!(s1 > s2), ""); + static_assert( (s1 <= s2), ""); + static_assert( (s1 >= s2), ""); + } + { + constexpr std::chrono::seconds s1(3); + constexpr std::chrono::seconds s2(4); + static_assert( (s1 < s2), ""); + static_assert(!(s1 > s2), ""); + static_assert( (s1 <= s2), ""); + static_assert(!(s1 >= s2), ""); + } + { + constexpr std::chrono::milliseconds s1(3); + constexpr std::chrono::microseconds s2(3000); + static_assert(!(s1 < s2), ""); + static_assert(!(s1 > s2), ""); + static_assert( (s1 <= s2), ""); + static_assert( (s1 >= s2), ""); + } + { + constexpr std::chrono::milliseconds s1(3); + constexpr std::chrono::microseconds s2(4000); + static_assert( (s1 < s2), ""); + static_assert(!(s1 > s2), ""); + static_assert( (s1 <= s2), ""); + static_assert(!(s1 >= s2), ""); + } + { + constexpr std::chrono::duration > s1(9); + constexpr std::chrono::duration > s2(10); + static_assert(!(s1 < s2), ""); + static_assert(!(s1 > s2), ""); + static_assert( (s1 <= s2), ""); + static_assert( (s1 >= s2), ""); + } + { + constexpr std::chrono::duration > s1(10); + constexpr std::chrono::duration > s2(9); + static_assert(!(s1 < s2), ""); + static_assert( (s1 > s2), ""); + static_assert(!(s1 <= s2), ""); + static_assert( (s1 >= s2), ""); + } + { + constexpr std::chrono::duration > s1(9); + constexpr std::chrono::duration > s2(10); + static_assert(!(s1 < s2), ""); + static_assert(!(s1 > s2), ""); + static_assert( (s1 <= s2), ""); + static_assert( (s1 >= s2), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp new file mode 100644 index 00000000000..152227d82a8 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// exact conversions allowed for integral reps + +#include +#include + +int main() +{ + { + std::chrono::milliseconds ms(1); + std::chrono::microseconds us = ms; + assert(us.count() == 1000); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::milliseconds ms(1); + constexpr std::chrono::microseconds us = ms; + static_assert(us.count() == 1000, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp new file mode 100644 index 00000000000..04c08257828 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// conversions from floating point to integral durations disallowed + +#include + +int main() +{ + std::chrono::duration d; + std::chrono::duration i = d; +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp new file mode 100644 index 00000000000..e82e25e8f69 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// inexact conversions disallowed for integral reps + +#include + +int main() +{ + std::chrono::microseconds us(1); + std::chrono::milliseconds ms = us; +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp new file mode 100644 index 00000000000..519b2b141c2 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// inexact conversions allowed for floating point reps + +#include +#include + +int main() +{ + { + std::chrono::duration us(1); + std::chrono::duration ms = us; + assert(ms.count() == 1./1000); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::duration us(1); + constexpr std::chrono::duration ms = us; + static_assert(ms.count() == 1./1000, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp new file mode 100644 index 00000000000..59fefe2e002 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// conversions from integral to floating point durations allowed + +#include +#include + +int main() +{ + { + std::chrono::duration i(3); + std::chrono::duration d = i; + assert(d.count() == 3000); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::duration i(3); + constexpr std::chrono::duration d = i; + static_assert(d.count() == 3000, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp new file mode 100644 index 00000000000..74b65d6b9cc --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration(const duration& d); + +// overflow should SFINAE instead of error out, LWG 2094 + +#include +#include + +bool called = false; + +void f(std::chrono::milliseconds); +void f(std::chrono::seconds) +{ + called = true; +} + +int main() +{ + { + std::chrono::duration r(1); + f(r); + assert(called); + } +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp new file mode 100644 index 00000000000..c52990961c2 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// duration() = default; + +// Rep must be default initialized, not initialized with 0 + +#include +#include + +#include "../../rep.h" + +template +void +test() +{ + D d; + assert(d.count() == typename D::rep()); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + constexpr D d2 = D(); + static_assert(d2.count() == typename D::rep(), ""); +#endif +} + +int main() +{ + test >(); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp new file mode 100644 index 00000000000..20f81619bd1 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +#include +#include + +#include "../../rep.h" + +template +void +test(R r) +{ + D d(r); + assert(d.count() == r); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + constexpr D d2(R(2)); + static_assert(d2.count() == 2, ""); +#endif +} + +int main() +{ + test >(5); + test > >(5); + test > >(Rep(3)); + test > >(5.5); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp new file mode 100644 index 00000000000..9f071ca1afc --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +// test for explicit + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration d = 1; +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp new file mode 100644 index 00000000000..37f32e77686 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +// Rep2 shall be implicitly convertible to rep + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration d(1); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp new file mode 100644 index 00000000000..b3ba9f7081e --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +// construct double with int + +#include +#include + +int main() +{ + std::chrono::duration d(5); + assert(d.count() == 5); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + constexpr std::chrono::duration d2(5); + static_assert(d2.count() == 5, ""); +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp new file mode 100644 index 00000000000..4ace54b231f --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// explicit duration(const Rep2& r); + +// treat_as_floating_point::value shall be false + +#include + +int main() +{ + std::chrono::duration d(1.); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp new file mode 100644 index 00000000000..48324ae8365 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals::chrono_literals; + +// Make sure the types are right + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + static_assert ( std::is_same::value, "" ); + + std::chrono::hours h = 4h; + assert ( h == std::chrono::hours(4)); + auto h2 = 4.0h; + assert ( h == h2 ); + + std::chrono::minutes min = 36min; + assert ( min == std::chrono::minutes(36)); + auto min2 = 36.0min; + assert ( min == min2 ); + + std::chrono::seconds s = 24s; + assert ( s == std::chrono::seconds(24)); + auto s2 = 24.0s; + assert ( s == s2 ); + + std::chrono::milliseconds ms = 247ms; + assert ( ms == std::chrono::milliseconds(247)); + auto ms2 = 247.0ms; + assert ( ms == ms2 ); + + std::chrono::microseconds us = 867us; + assert ( us == std::chrono::microseconds(867)); + auto us2 = 867.0us; + assert ( us == us2 ); + + std::chrono::nanoseconds ns = 645ns; + assert ( ns == std::chrono::nanoseconds(645)); + auto ns2 = 645.ns; + assert ( ns == ns2 ); +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp new file mode 100644 index 00000000000..46aaa30e51e --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp @@ -0,0 +1,21 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + std::chrono::hours h = 4h; // should fail w/conversion operator not found +#else +#error +#endif +} + diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp new file mode 100644 index 00000000000..574f9bcce87 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp @@ -0,0 +1,48 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::chrono; + + hours h = 4h; + assert ( h == hours(4)); + auto h2 = 4.0h; + assert ( h == h2 ); + + minutes min = 36min; + assert ( min == minutes(36)); + auto min2 = 36.0min; + assert ( min == min2 ); + + seconds s = 24s; + assert ( s == seconds(24)); + auto s2 = 24.0s; + assert ( s == s2 ); + + milliseconds ms = 247ms; + assert ( ms == milliseconds(247)); + auto ms2 = 247.0ms; + assert ( ms == ms2 ); + + microseconds us = 867us; + assert ( us == microseconds(867)); + auto us2 = 867.0us; + assert ( us == us2 ); + + nanoseconds ns = 645ns; + assert ( ns == nanoseconds(645)); + auto ns2 = 645.ns; + assert ( ns == ns2 ); +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp new file mode 100644 index 00000000000..17358e589f4 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp @@ -0,0 +1,22 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using std::chrono::hours; + + hours foo = 4h; // should fail w/conversion operator not found +#else +#error +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp new file mode 100644 index 00000000000..e37bc6e6796 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include + +int main() +{ +#if _LIBCPP_STD_VER > 11 + using namespace std::literals; + + std::chrono::hours h = 4h; + assert ( h == std::chrono::hours(4)); + auto h2 = 4.0h; + assert ( h == h2 ); + + std::chrono::minutes min = 36min; + assert ( min == std::chrono::minutes(36)); + auto min2 = 36.0min; + assert ( min == min2 ); + + std::chrono::seconds s = 24s; + assert ( s == std::chrono::seconds(24)); + auto s2 = 24.0s; + assert ( s == s2 ); + + std::chrono::milliseconds ms = 247ms; + assert ( ms == std::chrono::milliseconds(247)); + auto ms2 = 247.0ms; + assert ( ms == ms2 ); + + std::chrono::microseconds us = 867us; + assert ( us == std::chrono::microseconds(867)); + auto us2 = 867.0us; + assert ( us == us2 ); + + std::chrono::nanoseconds ns = 645ns; + assert ( ns == std::chrono::nanoseconds(645)); + auto ns2 = 645.ns; + assert ( ns == ns2 ); +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp new file mode 100644 index 00000000000..6585351cb4c --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// typename common_type, duration>::type +// operator+(const duration& lhs, const duration& rhs); + +#include +#include + +int main() +{ + { + std::chrono::seconds s1(3); + std::chrono::seconds s2(5); + std::chrono::seconds r = s1 + s2; + assert(r.count() == 8); + } + { + std::chrono::seconds s1(3); + std::chrono::microseconds s2(5); + std::chrono::microseconds r = s1 + s2; + assert(r.count() == 3000005); + } + { + std::chrono::duration > s1(3); + std::chrono::duration > s2(5); + std::chrono::duration > r = s1 + s2; + assert(r.count() == 75); + } + { + std::chrono::duration > s1(3); + std::chrono::duration > s2(5); + std::chrono::duration > r = s1 + s2; + assert(r.count() == 75); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::seconds s1(3); + constexpr std::chrono::seconds s2(5); + constexpr std::chrono::seconds r = s1 + s2; + static_assert(r.count() == 8, ""); + } + { + constexpr std::chrono::seconds s1(3); + constexpr std::chrono::microseconds s2(5); + constexpr std::chrono::microseconds r = s1 + s2; + static_assert(r.count() == 3000005, ""); + } + { + constexpr std::chrono::duration > s1(3); + constexpr std::chrono::duration > s2(5); + constexpr std::chrono::duration > r = s1 + s2; + static_assert(r.count() == 75, ""); + } + { + constexpr std::chrono::duration > s1(3); + constexpr std::chrono::duration > s2(5); + constexpr std::chrono::duration > r = s1 + s2; + static_assert(r.count() == 75, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp new file mode 100644 index 00000000000..fac58b9716d --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// typename common_type, duration>::type +// operator-(const duration& lhs, const duration& rhs); + +#include +#include + +int main() +{ + { + std::chrono::seconds s1(3); + std::chrono::seconds s2(5); + std::chrono::seconds r = s1 - s2; + assert(r.count() == -2); + } + { + std::chrono::seconds s1(3); + std::chrono::microseconds s2(5); + std::chrono::microseconds r = s1 - s2; + assert(r.count() == 2999995); + } + { + std::chrono::duration > s1(3); + std::chrono::duration > s2(5); + std::chrono::duration > r = s1 - s2; + assert(r.count() == -15); + } + { + std::chrono::duration > s1(3); + std::chrono::duration > s2(5); + std::chrono::duration > r = s1 - s2; + assert(r.count() == -15); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::seconds s1(3); + constexpr std::chrono::seconds s2(5); + constexpr std::chrono::seconds r = s1 - s2; + static_assert(r.count() == -2, ""); + } + { + constexpr std::chrono::seconds s1(3); + constexpr std::chrono::microseconds s2(5); + constexpr std::chrono::microseconds r = s1 - s2; + static_assert(r.count() == 2999995, ""); + } + { + constexpr std::chrono::duration > s1(3); + constexpr std::chrono::duration > s2(5); + constexpr std::chrono::duration > r = s1 - s2; + static_assert(r.count() == -15, ""); + } + { + constexpr std::chrono::duration > s1(3); + constexpr std::chrono::duration > s2(5); + constexpr std::chrono::duration > r = s1 - s2; + static_assert(r.count() == -15, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp new file mode 100644 index 00000000000..6b24676f100 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// typename common_type::type +// operator/(const duration& lhs, const duration& rhs); + +#include +#include + +int main() +{ + { + std::chrono::nanoseconds ns1(15); + std::chrono::nanoseconds ns2(5); + assert(ns1 / ns2 == 3); + } + { + std::chrono::microseconds us1(15); + std::chrono::nanoseconds ns2(5); + assert(us1 / ns2 == 3000); + } + { + std::chrono::duration > s1(30); + std::chrono::duration > s2(5); + assert(s1 / s2 == 6); + } + { + std::chrono::duration > s1(30); + std::chrono::duration > s2(5); + assert(s1 / s2 == 20./3); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::nanoseconds ns1(15); + constexpr std::chrono::nanoseconds ns2(5); + static_assert(ns1 / ns2 == 3, ""); + } + { + constexpr std::chrono::microseconds us1(15); + constexpr std::chrono::nanoseconds ns2(5); + static_assert(us1 / ns2 == 3000, ""); + } + { + constexpr std::chrono::duration > s1(30); + constexpr std::chrono::duration > s2(5); + static_assert(s1 / s2 == 6, ""); + } + { + constexpr std::chrono::duration > s1(30); + constexpr std::chrono::duration > s2(5); + static_assert(s1 / s2 == 20./3, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp new file mode 100644 index 00000000000..db725773fd4 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration::type, Period> +// operator/(const duration& d, const Rep2& s); + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration d(Rep(15)); + d = d / 5; +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp new file mode 100644 index 00000000000..3036cde5bf6 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// duration::type, Period> +// operator/(const duration& d, const Rep2& s); + +#include +#include + +int main() +{ + { + std::chrono::nanoseconds ns(15); + ns = ns / 5; + assert(ns.count() == 3); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::nanoseconds ns(15); + constexpr std::chrono::nanoseconds ns2 = ns / 5; + static_assert(ns2.count() == 3, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp new file mode 100644 index 00000000000..e69f3205d14 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// typename common_type, duration>::type +// operator%(const duration& lhs, const duration& rhs); + +#include +#include + +int main() +{ + { + std::chrono::nanoseconds ns1(15); + std::chrono::nanoseconds ns2(6); + std::chrono::nanoseconds r = ns1 % ns2; + assert(r.count() == 3); + } + { + std::chrono::microseconds us1(15); + std::chrono::nanoseconds ns2(28); + std::chrono::nanoseconds r = us1 % ns2; + assert(r.count() == 20); + } + { + std::chrono::duration > s1(6); + std::chrono::duration > s2(3); + std::chrono::duration > r = s1 % s2; + assert(r.count() == 24); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::nanoseconds ns1(15); + constexpr std::chrono::nanoseconds ns2(6); + constexpr std::chrono::nanoseconds r = ns1 % ns2; + static_assert(r.count() == 3, ""); + } + { + constexpr std::chrono::microseconds us1(15); + constexpr std::chrono::nanoseconds ns2(28); + constexpr std::chrono::nanoseconds r = us1 % ns2; + static_assert(r.count() == 20, ""); + } + { + constexpr std::chrono::duration > s1(6); + constexpr std::chrono::duration > s2(3); + constexpr std::chrono::duration > r = s1 % s2; + static_assert(r.count() == 24, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp new file mode 100644 index 00000000000..16e511d44f6 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration::type, Period> +// operator%(const duration& d, const Rep2& s) + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration d(Rep(15)); + d = d % 5; +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp new file mode 100644 index 00000000000..1acbe34ea5e --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// duration::type, Period> +// operator%(const duration& d, const Rep2& s) + +#include +#include + +int main() +{ + { + std::chrono::nanoseconds ns(15); + ns = ns % 6; + assert(ns.count() == 3); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::nanoseconds ns(15); + constexpr std::chrono::nanoseconds ns2 = ns % 6; + static_assert(ns2.count() == 3, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp new file mode 100644 index 00000000000..190e74b1dc3 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// constexpr +// duration::type, Period> +// operator*(const duration& d, const Rep2& s); + +// template +// constexpr +// duration::type, Period> +// operator*(const Rep1& s, const duration& d); + +#include +#include + +int main() +{ + { + std::chrono::nanoseconds ns(3); + ns = ns * 5; + assert(ns.count() == 15); + ns = 6 * ns; + assert(ns.count() == 90); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::chrono::nanoseconds ns(3); + constexpr std::chrono::nanoseconds ns2 = ns * 5; + static_assert(ns2.count() == 15, ""); + constexpr std::chrono::nanoseconds ns3 = 6 * ns; + static_assert(ns3.count() == 18, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp new file mode 100644 index 00000000000..d8160500f91 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration::type, Period> +// operator*(const duration& d, const Rep2& s); + +// template +// duration::type, Period> +// operator*(const Rep1& s, const duration& d); + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration d; + d = d * 5; +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp new file mode 100644 index 00000000000..e224ba94210 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// template +// duration::type, Period> +// operator*(const duration& d, const Rep2& s); + +// template +// duration::type, Period> +// operator*(const Rep1& s, const duration& d); + +#include + +#include "../../rep.h" + +int main() +{ + std::chrono::duration d; + d = 5 * d; +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp new file mode 100644 index 00000000000..405461e88ae --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// static constexpr duration max(); + +#include +#include +#include + +#include "../../rep.h" + +template +void test() +{ + { + typedef typename D::rep Rep; + Rep max_rep = std::chrono::duration_values::max(); + assert(D::max().count() == max_rep); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + typedef typename D::rep Rep; + constexpr Rep max_rep = std::chrono::duration_values::max(); + static_assert(D::max().count() == max_rep, ""); + } +#endif +} + +int main() +{ + test >(); + test >(); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp new file mode 100644 index 00000000000..44cd64eff3d --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// static constexpr duration min(); + +#include +#include +#include + +#include "../../rep.h" + +template +void test() +{ + { + typedef typename D::rep Rep; + Rep min_rep = std::chrono::duration_values::min(); + assert(D::min().count() == min_rep); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + typedef typename D::rep Rep; + constexpr Rep min_rep = std::chrono::duration_values::min(); + static_assert(D::min().count() == min_rep, ""); + } +#endif +} + +int main() +{ + test >(); + test >(); +} diff --git a/libcxx/test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp b/libcxx/test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp new file mode 100644 index 00000000000..18350fe2ff4 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// static constexpr duration zero(); + +#include +#include + +#include "../../rep.h" + +template +void test() +{ + { + typedef typename D::rep Rep; + Rep zero_rep = std::chrono::duration_values::zero(); + assert(D::zero().count() == zero_rep); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + typedef typename D::rep Rep; + constexpr Rep zero_rep = std::chrono::duration_values::zero(); + static_assert(D::zero().count() == zero_rep, ""); + } +#endif +} + +int main() +{ + test >(); + test >(); +} diff --git a/libcxx/test/std/utilities/time/time.duration/types.pass.cpp b/libcxx/test/std/utilities/time/time.duration/types.pass.cpp new file mode 100644 index 00000000000..8eaffe77651 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.duration/types.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration + +// Test nested types + +// typedef Rep rep; +// typedef Period period; + +#include +#include + +int main() +{ + typedef std::chrono::duration > D; + static_assert((std::is_same::value), ""); + static_assert((std::is_same >::value), ""); +} diff --git a/libcxx/test/std/utilities/time/time.point/default_duration.pass.cpp b/libcxx/test/std/utilities/time/time.point/default_duration.pass.cpp new file mode 100644 index 00000000000..dfdf225ed47 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/default_duration.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// Test default template arg: + +// template +// class time_point; + +#include +#include + +int main() +{ + static_assert((std::is_same::duration>::value), ""); +} diff --git a/libcxx/test/std/utilities/time/time.point/duration.fail.cpp b/libcxx/test/std/utilities/time/time.point/duration.fail.cpp new file mode 100644 index 00000000000..ee48bcb392e --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/duration.fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// Duration shall be an instance of duration. + +#include + +int main() +{ + typedef std::chrono::time_point T; + T t; +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp new file mode 100644 index 00000000000..ffe855ce903 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// time_point& operator+=(const duration& d); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + std::chrono::time_point t(Duration(3)); + t += Duration(2); + assert(t.time_since_epoch() == Duration(5)); +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp new file mode 100644 index 00000000000..acad1cfecb4 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// time_point& operator-=(const duration& d); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + std::chrono::time_point t(Duration(3)); + t -= Duration(2); + assert(t.time_since_epoch() == Duration(1)); +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp new file mode 100644 index 00000000000..7d7e82ac5e2 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point +// time_point_cast(const time_point& t); + +#include +#include +#include + +template +void +test(const FromDuration& df, const ToDuration& d) +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + FromTimePoint f(df); + ToTimePoint t(d); + typedef decltype(std::chrono::time_point_cast(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::time_point_cast(f) == t); + } +} + +#if _LIBCPP_STD_VER > 11 + +template +void test_constexpr () +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + constexpr FromTimePoint f{FromDuration{From}}; + constexpr ToTimePoint t{ToDuration{To}}; + static_assert(std::chrono::time_point_cast(f) == t, ""); + } + +} + +#endif + +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 >(7265./3600)); + test(std::chrono::duration >(9), + std::chrono::duration >(10)); +#if _LIBCPP_STD_VER > 11 + { + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + typedef std::chrono::duration> T1; + test_constexpr>, 9, T1, 10> (); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp new file mode 100644 index 00000000000..de1e5bb3e27 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.cast/toduration.fail.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point +// time_point_cast(const time_point& t); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + std::chrono::time_point_cast(FromTimePoint(std::chrono::milliseconds(3))); +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp b/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp new file mode 100644 index 00000000000..f5ff11958ba --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// bool +// operator==(const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator!=(const time_point& lhs, const time_point& rhs); + +// time_points with different clocks should not compare + +#include + +#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 T1; + typedef std::chrono::time_point T2; + + T1 t1(Duration1(3)); + T2 t2(Duration2(3000)); + t1 == t2; +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp new file mode 100644 index 00000000000..fbd3a1386d3 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// bool +// operator==(const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator!=(const time_point& lhs, const time_point& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + typedef std::chrono::time_point T1; + typedef std::chrono::time_point 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)); + } + +#if _LIBCPP_STD_VER > 11 + { + constexpr T1 t1(Duration1(3)); + constexpr T1 t2(Duration1(3)); + static_assert( (t1 == t2), ""); + static_assert(!(t1 != t2), ""); + } + { + constexpr T1 t1(Duration1(3)); + constexpr T1 t2(Duration1(4)); + static_assert(!(t1 == t2), ""); + static_assert( (t1 != t2), ""); + } + { + constexpr T1 t1(Duration1(3)); + constexpr T2 t2(Duration2(3000)); + static_assert( (t1 == t2), ""); + static_assert(!(t1 != t2), ""); + } + { + constexpr T1 t1(Duration1(3)); + constexpr T2 t2(Duration2(3001)); + static_assert(!(t1 == t2), ""); + static_assert( (t1 != t2), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp b/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp new file mode 100644 index 00000000000..f9745cbf9de --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// bool +// operator< (const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator> (const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator<=(const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator>=(const time_point& lhs, const time_point& rhs); + +// time_points with different clocks should not compare + +#include + +#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 T1; + typedef std::chrono::time_point T2; + + T1 t1(Duration1(3)); + T2 t2(Duration2(3000)); + t1 < t2; +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp new file mode 100644 index 00000000000..9d94400ed3d --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp @@ -0,0 +1,108 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// bool +// operator< (const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator> (const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator<=(const time_point& lhs, const time_point& rhs); + +// template +// bool +// operator>=(const time_point& lhs, const time_point& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + typedef std::chrono::time_point T1; + typedef std::chrono::time_point 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)); + } + +#if _LIBCPP_STD_VER > 11 + { + constexpr T1 t1(Duration1(3)); + constexpr T1 t2(Duration1(3)); + static_assert(!(t1 < t2), ""); + static_assert(!(t1 > t2), ""); + static_assert( (t1 <= t2), ""); + static_assert( (t1 >= t2), ""); + } + { + constexpr T1 t1(Duration1(3)); + constexpr T1 t2(Duration1(4)); + static_assert( (t1 < t2), ""); + static_assert(!(t1 > t2), ""); + static_assert( (t1 <= t2), ""); + static_assert(!(t1 >= t2), ""); + } + { + constexpr T1 t1(Duration1(3)); + constexpr T2 t2(Duration2(3000)); + static_assert(!(t1 < t2), ""); + static_assert(!(t1 > t2), ""); + static_assert( (t1 <= t2), ""); + static_assert( (t1 >= t2), ""); + } + { + constexpr T1 t1(Duration1(3)); + constexpr T2 t2(Duration2(3001)); + static_assert( (t1 < t2), ""); + static_assert(!(t1 > t2), ""); + static_assert( (t1 <= t2), ""); + static_assert(!(t1 >= t2), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp new file mode 100644 index 00000000000..565aa6c4f52 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.cons/convert.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point(const time_point& t); + +// Duration2 shall be implicitly convertible to duration. + +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + { + std::chrono::time_point t2(Duration2(3)); + std::chrono::time_point t1 = t2; + } +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp new file mode 100644 index 00000000000..6cd7dcb7d2f --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.cons/convert.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point(const time_point& t); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::microseconds Duration1; + typedef std::chrono::milliseconds Duration2; + { + std::chrono::time_point t2(Duration2(3)); + std::chrono::time_point t1 = t2; + assert(t1.time_since_epoch() == Duration1(3000)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t2(Duration2(3)); + constexpr std::chrono::time_point t1 = t2; + static_assert(t1.time_since_epoch() == Duration1(3000), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp new file mode 100644 index 00000000000..01f0bc16993 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.cons/default.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// time_point(); + +#include +#include + +#include "../../rep.h" + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::duration Duration; + { + std::chrono::time_point t; + assert(t.time_since_epoch() == Duration::zero()); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t; + static_assert(t.time_since_epoch() == Duration::zero(), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp new file mode 100644 index 00000000000..810007ed942 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.cons/duration.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// explicit time_point(const duration& d); + +// test for explicit + +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + std::chrono::time_point t = Duration(3); +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp new file mode 100644 index 00000000000..9d53d86dea3 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.cons/duration.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// explicit time_point(const duration& d); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + { + std::chrono::time_point t(Duration(3)); + assert(t.time_since_epoch() == Duration(3)); + } + { + std::chrono::time_point t(std::chrono::seconds(3)); + assert(t.time_since_epoch() == Duration(3000)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t(Duration(3)); + static_assert(t.time_since_epoch() == Duration(3), ""); + } + { + constexpr std::chrono::time_point t(std::chrono::seconds(3)); + static_assert(t.time_since_epoch() == Duration(3000), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp new file mode 100644 index 00000000000..7a8fa6dcf14 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point>::type> +// operator+(const time_point& lhs, const duration& rhs); + +// template +// time_point, Duration2>::type> +// operator+(const duration& lhs, const time_point& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + { + std::chrono::time_point t1(Duration1(3)); + std::chrono::time_point t2 = t1 + Duration2(5); + assert(t2.time_since_epoch() == Duration2(3005)); + t2 = Duration2(6) + t1; + assert(t2.time_since_epoch() == Duration2(3006)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t1(Duration1(3)); + constexpr std::chrono::time_point t2 = t1 + Duration2(5); + static_assert(t2.time_since_epoch() == Duration2(3005), ""); + constexpr std::chrono::time_point t3 = Duration2(6) + t1; + static_assert(t3.time_since_epoch() == Duration2(3006), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp new file mode 100644 index 00000000000..342d27b5aeb --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// time_point>::type> +// operator-(const time_point& lhs, const duration& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + { + std::chrono::time_point t1(Duration1(3)); + std::chrono::time_point t2 = t1 - Duration2(5); + assert(t2.time_since_epoch() == Duration2(2995)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t1(Duration1(3)); + constexpr std::chrono::time_point t2 = t1 - Duration2(5); + static_assert(t2.time_since_epoch() == Duration2(2995), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp new file mode 100644 index 00000000000..5267f07e1b8 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// template +// typename common_type::type +// operator-(const time_point& lhs, const time_point& rhs); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration1; + typedef std::chrono::microseconds Duration2; + { + std::chrono::time_point t1(Duration1(3)); + std::chrono::time_point t2(Duration2(5)); + assert((t1 - t2) == Duration2(2995)); + } +#if _LIBCPP_STD_VER > 11 + { + constexpr std::chrono::time_point t1(Duration1(3)); + constexpr std::chrono::time_point t2(Duration2(5)); + static_assert((t1 - t2) == Duration2(2995), ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.special/max.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.special/max.pass.cpp new file mode 100644 index 00000000000..6bba6fc8278 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.special/max.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// static constexpr time_point max(); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + typedef std::chrono::time_point TP; + assert(TP::max() == TP(Duration::max())); +} diff --git a/libcxx/test/std/utilities/time/time.point/time.point.special/min.pass.cpp b/libcxx/test/std/utilities/time/time.point/time.point.special/min.pass.cpp new file mode 100644 index 00000000000..b1d955c252a --- /dev/null +++ b/libcxx/test/std/utilities/time/time.point/time.point.special/min.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// time_point + +// static constexpr time_point min(); + +#include +#include + +int main() +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::milliseconds Duration; + typedef std::chrono::time_point TP; + assert(TP::min() == TP(Duration::min())); +} diff --git a/libcxx/test/std/utilities/time/time.traits/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/time/time.traits/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.traits/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp b/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp new file mode 100644 index 00000000000..89dc1dcc1a5 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration_values::max + +#include +#include +#include + +#include "../../rep.h" + +int main() +{ + assert(std::chrono::duration_values::max() == + std::numeric_limits::max()); + assert(std::chrono::duration_values::max() == + std::numeric_limits::max()); + assert(std::chrono::duration_values::max() == + std::numeric_limits::max()); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert(std::chrono::duration_values::max() == + std::numeric_limits::max(), ""); + static_assert(std::chrono::duration_values::max() == + std::numeric_limits::max(), ""); + static_assert(std::chrono::duration_values::max() == + std::numeric_limits::max(), ""); +#endif +} diff --git a/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp b/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp new file mode 100644 index 00000000000..69812bba006 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration_values::min + +#include +#include +#include + +#include "../../rep.h" + +int main() +{ + assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest()); + assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest()); + assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest()); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest(), ""); + static_assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest(), ""); + static_assert(std::chrono::duration_values::min() == + std::numeric_limits::lowest(), ""); +#endif +} diff --git a/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp b/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp new file mode 100644 index 00000000000..234b4bc31c9 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// duration_values::zero + +#include +#include + +#include "../../rep.h" + +int main() +{ + assert(std::chrono::duration_values::zero() == 0); + assert(std::chrono::duration_values::zero() == 0); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert(std::chrono::duration_values::zero() == 0, ""); + static_assert(std::chrono::duration_values::zero() == 0, ""); +#endif +} diff --git a/libcxx/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp b/libcxx/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp new file mode 100644 index 00000000000..c32350faa83 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// treat_as_floating_point + +#include +#include + +template +void +test() +{ + static_assert((std::is_base_of, + std::chrono::treat_as_floating_point >::value), ""); +} + +struct A {}; + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} diff --git a/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp b/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp new file mode 100644 index 00000000000..f942844b60a --- /dev/null +++ b/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct common_type, chrono::duration> +// { +// typedef chrono::duration::type, see below }> type; +// }; + +#include + +template +void +test() +{ + typedef typename std::common_type::type Dc; + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); +} diff --git a/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp b/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp new file mode 100644 index 00000000000..a0786b49924 --- /dev/null +++ b/libcxx/test/std/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// struct common_type, chrono::time_point> +// { +// typedef chrono::time_point::type> type; +// }; + +#include + +template +void +test() +{ + typedef std::chrono::system_clock C; + typedef std::chrono::time_point T1; + typedef std::chrono::time_point T2; + typedef std::chrono::time_point Te; + typedef typename std::common_type::type Tc; + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); + test >, + std::chrono::duration >, + std::chrono::duration > >(); +} diff --git a/libcxx/test/std/utilities/time/version.pass.cpp b/libcxx/test/std/utilities/time/version.pass.cpp new file mode 100644 index 00000000000..bfa3f6d6797 --- /dev/null +++ b/libcxx/test/std/utilities/time/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} -- cgit v1.2.3