summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct')
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/copy.pass.cpp35
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/default.pass.cpp31
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/move.pass.cpp41
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp83
4 files changed, 190 insertions, 0 deletions
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/copy.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/copy.pass.cpp
new file mode 100644
index 00000000000..67b8a04049e
--- /dev/null
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/copy.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
+
+// <experimental/filesystem>
+
+// class path
+
+// path(path const&)
+
+#include <experimental/filesystem>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+namespace fs = std::experimental::filesystem;
+
+int main() {
+ using namespace fs;
+ static_assert(std::is_copy_constructible<path>::value, "");
+ static_assert(!std::is_nothrow_copy_constructible<path>::value, "should not be noexcept");
+ const std::string s("foo");
+ const path p(s);
+ path p2(p);
+ assert(p.native() == s);
+ assert(p2.native() == s);
+}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/default.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/default.pass.cpp
new file mode 100644
index 00000000000..f26504616d5
--- /dev/null
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class path
+
+// path() noexcept
+
+#include <experimental/filesystem>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+namespace fs = std::experimental::filesystem;
+
+int main() {
+ using namespace fs;
+ static_assert(std::is_nothrow_default_constructible<path>::value, "");
+ const path p;
+ assert(p.empty());
+}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/move.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/move.pass.cpp
new file mode 100644
index 00000000000..b8ac4b30700
--- /dev/null
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/filesystem>
+
+// class path
+
+// path(path&&) noexcept
+
+#include <experimental/filesystem>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "count_new.hpp"
+
+namespace fs = std::experimental::filesystem;
+
+int main() {
+ using namespace fs;
+ static_assert(std::is_nothrow_move_constructible<path>::value, "");
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ const std::string s("we really really really really really really really "
+ "really really long string so that we allocate");
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ path p(s);
+ {
+ DisableAllocationGuard g;
+ path p2(std::move(p));
+ assert(p2.native() == s);
+ assert(p.native() != s); // Testing moved from state
+ }
+}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp
new file mode 100644
index 00000000000..d89e7c815ef
--- /dev/null
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class path
+
+// template <class Source>
+// path(const Source& source);
+// template <class InputIterator>
+// path(InputIterator first, InputIterator last);
+
+
+#include <experimental/filesystem>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+#include "filesystem_test_helper.hpp"
+
+namespace fs = std::experimental::filesystem;
+
+template <class CharT>
+void RunTestCase(MultiStringType const& MS) {
+ using namespace fs;
+ const char* Expect = MS;
+ const CharT* TestPath = MS;
+ const CharT* TestPathEnd = StrEnd(TestPath);
+ const std::size_t Size = TestPathEnd - TestPath;
+ const std::size_t SSize = StrEnd(Expect) - Expect;
+ assert(Size == SSize);
+ // StringTypes
+ {
+ const std::basic_string<CharT> S(TestPath);
+ path p(S);
+ assert(p.native() == Expect);
+ assert(p.string<CharT>() == TestPath);
+ assert(p.string<CharT>() == S);
+ }
+ // Char* pointers
+ {
+ path p(TestPath);
+ assert(p.native() == Expect);
+ assert(p.string<CharT>() == TestPath);
+ }
+ {
+ path p(TestPath, TestPathEnd);
+ assert(p.native() == Expect);
+ assert(p.string<CharT>() == TestPath);
+ }
+ // Iterators
+ {
+ using It = input_iterator<const CharT*>;
+ path p(It{TestPath});
+ assert(p.native() == Expect);
+ assert(p.string<CharT>() == TestPath);
+ }
+ {
+ using It = input_iterator<const CharT*>;
+ path p(It{TestPath}, It{TestPathEnd});
+ assert(p.native() == Expect);
+ assert(p.string<CharT>() == TestPath);
+ }
+}
+
+int main() {
+ for (auto const& MS : PathList) {
+ RunTestCase<char>(MS);
+ RunTestCase<wchar_t>(MS);
+ RunTestCase<char16_t>(MS);
+ RunTestCase<char32_t>(MS);
+ }
+}
OpenPOWER on IntegriCloud