summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-12-21 03:54:57 +0000
committerEric Fiselier <eric@efcs.ca>2018-12-21 03:54:57 +0000
commit866885e12a2278a77dcb195872730d8b0498e43e (patch)
tree174a81ced0bc340d2fb85bbd3a87829d937a4449 /libcxx/test/std
parent3eae3c459061b092c00f280da9761845b0e66504 (diff)
downloadbcm5719-llvm-866885e12a2278a77dcb195872730d8b0498e43e.tar.gz
bcm5719-llvm-866885e12a2278a77dcb195872730d8b0498e43e.zip
Implement LWG 3145: file_clock breaks ABI for C++17 implementations.
This patch adds std::chrono::file_clock, but without breaking the existing ABI for std::filesystem. llvm-svn: 349883
Diffstat (limited to 'libcxx/test/std')
-rw-r--r--libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp35
-rw-r--r--libcxx/test/std/utilities/time/time.clock/time.clock.file/file_time.pass.cpp29
-rw-r--r--libcxx/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp35
-rw-r--r--libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp29
4 files changed, 128 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/consistency.pass.cpp
new file mode 100644
index 00000000000..275faa6288d
--- /dev/null
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+//
+// TODO: Remove this when filesystem gets integrated into the dylib
+// REQUIRES: c++filesystem
+
+// <chrono>
+
+// file_clock
+
+// check clock invariants
+
+#include <chrono>
+
+template <class T>
+void test(const T &) {}
+
+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/libcxx/test/std/utilities/time/time.clock/time.clock.file/file_time.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/file_time.pass.cpp
new file mode 100644
index 00000000000..955e3ebe9d5
--- /dev/null
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/file_time.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: c++98, c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// file_time
+
+#include <chrono>
+
+#include "test_macros.h"
+
+template <class Dur>
+void test() {
+ ASSERT_SAME_TYPE(std::chrono::file_time<Dur>, std::chrono::time_point<std::chrono::file_clock, Dur>);
+}
+
+int main() {
+ test<std::chrono::nanoseconds>();
+ test<std::chrono::minutes>();
+ test<std::chrono::hours>();
+} \ No newline at end of file
diff --git a/libcxx/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/now.pass.cpp
new file mode 100644
index 00000000000..69dfa918093
--- /dev/null
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/now.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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+
+// TODO: Remove this when filesystem gets integrated into the dylib
+// REQUIRES: c++filesystem
+
+// <chrono>
+
+// file_clock
+
+// static time_point now() noexcept;
+
+#include <chrono>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ typedef std::chrono::file_clock C;
+ ASSERT_NOEXCEPT(C::now());
+
+ 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/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp b/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
new file mode 100644
index 00000000000..c0fa0b5beda
--- /dev/null
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.file/rep_signed.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: c++98, c++03, c++11, c++14, c++17
+
+// TODO: Remove this when filesystem gets integrated into the dylib
+// REQUIRES: c++filesystem
+
+// <chrono>
+
+// file_clock
+
+// rep should be signed
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+ static_assert(std::is_signed<std::chrono::file_clock::rep>::value, "");
+ assert(std::chrono::file_clock::duration::min() <
+ std::chrono::file_clock::duration::zero());
+}
OpenPOWER on IntegriCloud