diff options
Diffstat (limited to 'test/std/utilities/time/time.clock/time.clock.system')
5 files changed, 132 insertions, 0 deletions
diff --git a/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp new file mode 100644 index 000000000000..e277d4e67dc7 --- /dev/null +++ b/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_cxx_lib=x86_64-apple-darwin11 +// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 + +// <chrono> + +// system_clock + +// check clock invariants + +#include <chrono> + +template <class _Tp> +void test(const _Tp &) {} + +int main() +{ + typedef std::chrono::system_clock C; + static_assert((std::is_same<C::rep, C::duration::rep>::value), ""); + static_assert((std::is_same<C::period, C::duration::period>::value), ""); + static_assert((std::is_same<C::duration, C::time_point::duration>::value), ""); + static_assert((std::is_same<C::time_point::clock, C>::value), ""); + static_assert((C::is_steady || !C::is_steady), ""); + test(std::chrono::system_clock::is_steady); +} diff --git a/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp new file mode 100644 index 000000000000..f4a454f57801 --- /dev/null +++ b/test/std/utilities/time/time.clock/time.clock.system/from_time_t.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. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +// system_clock + +// static time_point from_time_t(time_t t); + +#include <chrono> +#include <ctime> + +int main() +{ + typedef std::chrono::system_clock C; + C::time_point t1 = C::from_time_t(C::to_time_t(C::now())); + ((void)t1); +} diff --git a/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/now.pass.cpp new file mode 100644 index 000000000000..ebc0db80b648 --- /dev/null +++ b/test/std/utilities/time/time.clock/time.clock.system/now.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. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +// system_clock + +// static time_point now(); + +#include <chrono> +#include <cassert> + +int main() +{ + typedef std::chrono::system_clock C; + C::time_point t1 = C::now(); + assert(t1.time_since_epoch().count() != 0); + assert(C::time_point::min() < t1); + assert(C::time_point::max() > t1); +} diff --git a/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp new file mode 100644 index 000000000000..b6a440e16dd4 --- /dev/null +++ b/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. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +// system_clock + +// rep should be signed + +#include <chrono> +#include <cassert> + +int main() +{ + assert(std::chrono::system_clock::duration::min() < + std::chrono::system_clock::duration::zero()); +} diff --git a/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp new file mode 100644 index 000000000000..c4028063bc53 --- /dev/null +++ b/test/std/utilities/time/time.clock/time.clock.system/to_time_t.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. +// +//===----------------------------------------------------------------------===// + +// <chrono> + +// system_clock + +// time_t to_time_t(const time_point& t); + +#include <chrono> +#include <ctime> + +int main() +{ + typedef std::chrono::system_clock C; + std::time_t t1 = C::to_time_t(C::now()); + ((void)t1); +} |