summaryrefslogtreecommitdiff
path: root/test/libcxx/experimental/filesystem
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:47:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:47:26 +0000
commit51072bd6bf79ef2bc6a922079bff57c31c1effbc (patch)
tree91a2effbc9e6f80bdbbf9eb70e06c51ad0867ea0 /test/libcxx/experimental/filesystem
parentbb5e33f003797b67974a8893f7f2930fc51b8210 (diff)
Notes
Diffstat (limited to 'test/libcxx/experimental/filesystem')
-rw-r--r--test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp101
-rw-r--r--test/libcxx/experimental/filesystem/lit.local.cfg3
-rw-r--r--test/libcxx/experimental/filesystem/version.pass.cpp22
3 files changed, 126 insertions, 0 deletions
diff --git a/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp b/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp
new file mode 100644
index 000000000000..94de2108f8b5
--- /dev/null
+++ b/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/filesystem>
+
+// template <class Tp> struct __is_pathable
+
+// [path.req]
+// In addition to the requirements (5), function template parameters named
+// `Source` shall be one of:
+// * basic_string<_ECharT, _Traits, _Alloc>
+// * InputIterator with a value_type of _ECharT
+// * A character array, which points to a NTCTS after array-to-pointer decay.
+
+
+#include <experimental/filesystem>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+namespace fs = std::experimental::filesystem;
+
+using fs::__is_pathable;
+
+template <class Tp>
+struct Identity { typedef Tp type; };
+
+template <class Source>
+Identity<Source> CheckSourceType(Source const&);
+
+template <class Tp>
+using GetSourceType = typename decltype(CheckSourceType(std::declval<Tp>()))::type;
+
+template <class Tp, class Exp,
+ class ExpQual = typename std::remove_const<Exp>::type>
+using CheckPass = std::is_same<ExpQual, GetSourceType<Tp>>;
+
+template <class Source>
+using CheckPassSource = std::integral_constant<bool,
+ CheckPass<Source&, Source>::value &&
+ CheckPass<Source const&, Source>::value &&
+ CheckPass<Source&&, Source>::value &&
+ CheckPass<Source const&&, Source>::value
+ >;
+
+template <class CharT>
+struct MakeTestType {
+ using value_type = CharT;
+ using string_type = std::basic_string<CharT>;
+ using string_type2 = std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>;
+ using cstr_type = CharT* const;
+ using const_cstr_type = const CharT*;
+ using array_type = CharT[25];
+ using const_array_type = const CharT[25];
+ using iter_type = input_iterator<CharT*>;
+ using bad_iter_type = input_iterator<signed char*>;
+
+ template <class TestT>
+ static void AssertPathable() {
+ static_assert(__is_pathable<TestT>::value, "");
+ static_assert(CheckPassSource<TestT>::value, "cannot pass as Source const&");
+ ASSERT_SAME_TYPE(CharT, typename __is_pathable<TestT>::__char_type);
+ }
+
+ template <class TestT>
+ static void AssertNotPathable() {
+ static_assert(!__is_pathable<TestT>::value, "");
+ }
+
+ static void Test() {
+ AssertPathable<string_type>();
+ AssertPathable<string_type2>();
+ AssertPathable<cstr_type>();
+ AssertPathable<const_cstr_type>();
+ AssertPathable<array_type>();
+ AssertPathable<const_array_type>();
+ AssertPathable<iter_type>();
+
+ AssertNotPathable<CharT>();
+ AssertNotPathable<bad_iter_type>();
+ AssertNotPathable<signed char*>();
+ }
+};
+
+int main() {
+ MakeTestType<char>::Test();
+ MakeTestType<wchar_t>::Test();
+ MakeTestType<char16_t>::Test();
+ MakeTestType<char32_t>::Test();
+}
diff --git a/test/libcxx/experimental/filesystem/lit.local.cfg b/test/libcxx/experimental/filesystem/lit.local.cfg
new file mode 100644
index 000000000000..3d9360431f48
--- /dev/null
+++ b/test/libcxx/experimental/filesystem/lit.local.cfg
@@ -0,0 +1,3 @@
+# Disable all of the filesystem tests if the correct feature is not available.
+if 'c++filesystem' not in config.available_features:
+ config.unsupported = True
diff --git a/test/libcxx/experimental/filesystem/version.pass.cpp b/test/libcxx/experimental/filesystem/version.pass.cpp
new file mode 100644
index 000000000000..723380a26fba
--- /dev/null
+++ b/test/libcxx/experimental/filesystem/version.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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/filesystem>
+
+#include <experimental/filesystem>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}