summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-07-27 03:07:09 +0000
committerEric Fiselier <eric@efcs.ca>2018-07-27 03:07:09 +0000
commit998a5c88312066fcc2b2de1358edc76587611354 (patch)
treef3e74cc7ce9e55f30e7019dd6e379571c91aaa1f /libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers
parent567485a72ff71e34c9e25aaab8eecfda3aa6cd62 (diff)
downloadbcm5719-llvm-998a5c88312066fcc2b2de1358edc76587611354.tar.gz
bcm5719-llvm-998a5c88312066fcc2b2de1358edc76587611354.zip
Implement <filesystem>
This patch implements the <filesystem> header and uses that to provide <experimental/filesystem>. Unlike other standard headers, the symbols needed for <filesystem> have not yet been placed in libc++.so. Instead they live in the new libc++fs.a library. Users of filesystem are required to link this library. (Also note that libc++experimental no longer contains the definition of <experimental/filesystem>, which now requires linking libc++fs). The reason for keeping <filesystem> out of the dylib for now is that it's still somewhat experimental, and the possibility of requiring an ABI breaking change is very real. In the future the symbols will likely be moved into the dylib, or the dylib will be made to link libc++fs automagically). Note that moving the symbols out of libc++experimental may break user builds until they update to -lc++fs. This should be OK, because the experimental library provides no stability guarantees. However, I plan on looking into ways we can force libc++experimental to automagically link libc++fs. In order to use a single implementation and set of tests for <filesystem>, it has been placed in a special `__fs` namespace. This namespace is inline in C++17 onward, but not before that. As such implementation is available in C++11 onward, but no filesystem namespace is present "directly", and as such name conflicts shouldn't occur in C++11 or C++14. llvm-svn: 338093
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers')
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp44
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/make_preferred.pass.cpp54
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp73
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/replace_extension.pass.cpp72
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/replace_filename.pass.cpp71
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/swap.pass.cpp80
6 files changed, 0 insertions, 394 deletions
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp
deleted file mode 100644
index 1d697571c49..00000000000
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// void clear() noexcept
-
-#include "filesystem_include.hpp"
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "test_iterators.h"
-#include "count_new.hpp"
-#include "filesystem_test_helper.hpp"
-
-
-int main() {
- using namespace fs;
- {
- path p;
- ASSERT_NOEXCEPT(p.clear());
- ASSERT_SAME_TYPE(void, decltype(p.clear()));
- p.clear();
- assert(p.empty());
- }
- {
- const path p("/foo/bar/baz");
- path p2(p);
- assert(p == p2);
- p2.clear();
- assert(p2.empty());
- }
-}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/make_preferred.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/make_preferred.pass.cpp
deleted file mode 100644
index b09806c2354..00000000000
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/make_preferred.pass.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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& make_preferred()
-
-#include "filesystem_include.hpp"
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "test_iterators.h"
-#include "count_new.hpp"
-#include "filesystem_test_helper.hpp"
-
-
-struct MakePreferredTestcase {
- const char* value;
-};
-
-const MakePreferredTestcase TestCases[] =
- {
- {""}
- , {"hello_world"}
- , {"/"}
- , {"/foo/bar/baz/"}
- , {"\\"}
- , {"\\foo\\bar\\baz\\"}
- , {"\\foo\\/bar\\/baz\\"}
- };
-
-int main()
-{
- // This operation is an identity operation on linux.
- using namespace fs;
- for (auto const & TC : TestCases) {
- path p(TC.value);
- assert(p == TC.value);
- path& Ref = (p.make_preferred());
- assert(p.native() == TC.value);
- assert(&Ref == &p);
- }
-}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp
deleted file mode 100644
index ec885f15c8c..00000000000
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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& remove_filename()
-
-#include "filesystem_include.hpp"
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "test_iterators.h"
-#include "count_new.hpp"
-#include "filesystem_test_helper.hpp"
-#include "verbose_assert.h"
-
-struct RemoveFilenameTestcase {
- const char* value;
- const char* expect;
-};
-
-const RemoveFilenameTestcase TestCases[] =
- {
- {"", ""}
- , {"/", "/"}
- , {"//", "//"}
- , {"///", "///"}
- , {"\\", ""}
- , {".", ""}
- , {"..", ""}
- , {"/foo", "/"}
- , {"foo/bar", "foo/"}
- , {"foo/", "foo/"}
- , {"//foo", "//"}
- , {"//foo/", "//foo/"}
- , {"//foo///", "//foo///"}
- , {"///foo", "///"}
- , {"///foo/", "///foo/"}
- , {"/foo/", "/foo/"}
- , {"/foo/.", "/foo/"}
- , {"/foo/..", "/foo/"}
- , {"/foo/////", "/foo/////"}
- , {"/foo\\\\", "/"}
- , {"/foo//\\/", "/foo//\\/"}
- , {"///foo", "///"}
- , {"file.txt", ""}
- , {"bar/../baz/./file.txt", "bar/../baz/./"}
- };
-
-int main()
-{
- using namespace fs;
- for (auto const & TC : TestCases) {
- path const p_orig(TC.value);
- path p(p_orig);
- assert(p == TC.value);
- path& Ref = (p.remove_filename());
- ASSERT_EQ(p, TC.expect) << DISPLAY(p_orig);
- assert(&Ref == &p);
- assert(!p.has_filename());
- }
-}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/replace_extension.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/replace_extension.pass.cpp
deleted file mode 100644
index 2e7d925553b..00000000000
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/replace_extension.pass.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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& replace_extension(path const& p = path())
-
-#include "filesystem_include.hpp"
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "test_iterators.h"
-#include "count_new.hpp"
-#include "filesystem_test_helper.hpp"
-
-
-struct ReplaceExtensionTestcase {
- const char* value;
- const char* expect;
- const char* extension;
-};
-
-const ReplaceExtensionTestcase TestCases[] =
- {
- {"", "", ""}
- , {"foo.cpp", "foo", ""}
- , {"foo.cpp", "foo.", "."}
- , {"foo..cpp", "foo..txt", "txt"}
- , {"", ".txt", "txt"}
- , {"", ".txt", ".txt"}
- , {"/foo", "/foo.txt", ".txt"}
- , {"/foo", "/foo.txt", "txt"}
- , {"/foo.cpp", "/foo.txt", ".txt"}
- , {"/foo.cpp", "/foo.txt", "txt"}
- };
-const ReplaceExtensionTestcase NoArgCases[] =
- {
- {"", "", ""}
- , {"foo", "foo", ""}
- , {"foo.cpp", "foo", ""}
- , {"foo..cpp", "foo.", ""}
-};
-
-int main()
-{
- using namespace fs;
- for (auto const & TC : TestCases) {
- path p(TC.value);
- assert(p == TC.value);
- path& Ref = (p.replace_extension(TC.extension));
- assert(p == TC.expect);
- assert(&Ref == &p);
- }
- for (auto const& TC : NoArgCases) {
- path p(TC.value);
- assert(p == TC.value);
- path& Ref = (p.replace_extension());
- assert(p == TC.expect);
- assert(&Ref == &p);
- }
-}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/replace_filename.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/replace_filename.pass.cpp
deleted file mode 100644
index bfb3b6a19cd..00000000000
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/replace_filename.pass.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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& replace_filename()
-
-#include "filesystem_include.hpp"
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "test_iterators.h"
-#include "count_new.hpp"
-#include "filesystem_test_helper.hpp"
-#include "assert_checkpoint.h"
-#include "verbose_assert.h"
-
-struct ReplaceFilenameTestcase {
- const char* value;
- const char* expect;
- const char* filename;
-};
-
-const ReplaceFilenameTestcase TestCases[] =
- {
- {"/foo", "/bar", "bar"}
- , {"/foo", "/", ""}
- , {"foo", "bar", "bar"}
- , {"/", "/bar", "bar"}
- , {"\\", "bar", "bar"}
- , {"///", "///bar", "bar"}
- , {"\\\\", "bar", "bar"}
- , {"\\/\\", "\\/bar", "bar"}
- , {".", "bar", "bar"}
- , {"..", "bar", "bar"}
- , {"/foo\\baz/bong/", "/foo\\baz/bong/bar", "bar"}
- , {"/foo\\baz/bong", "/foo\\baz/bar", "bar"}
- };
-
-int main()
-{
- using namespace fs;
- for (auto const & TC : TestCases) {
- path p(TC.value);
- ASSERT_EQ(p, TC.value);
- path& Ref = (p.replace_filename(TC.filename));
- ASSERT_EQ(p, TC.expect)
- << DISPLAY(TC.value)
- << DISPLAY(TC.filename);
- assert(&Ref == &p);
- // Tests Effects "as-if": remove_filename() append(filename)
- {
- path p2(TC.value);
- path replace(TC.filename);
- p2.remove_filename();
- p2 /= replace;
- ASSERT_EQ(p, p2);
- }
- }
-}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/swap.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/swap.pass.cpp
deleted file mode 100644
index 3aac1ed60fa..00000000000
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.modifiers/swap.pass.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// void swap(path& rhs) noexcept;
-
-#include "filesystem_include.hpp"
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "test_iterators.h"
-#include "count_new.hpp"
-#include "filesystem_test_helper.hpp"
-
-
-struct SwapTestcase {
- const char* value1;
- const char* value2;
-};
-
-#define LONG_STR1 "_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG"
-#define LONG_STR2 "_THIS_IS_LONG2_THIS_IS_LONG2_THIS_IS_LONG2_THIS_IS_LONG2_THIS_IS_LONG2_THIS_IS_LONG2_THIS_IS_LONG2"
-const SwapTestcase TestCases[] =
- {
- {"", ""}
- , {"shortstr", LONG_STR1}
- , {LONG_STR1, "shortstr"}
- , {LONG_STR1, LONG_STR2}
- };
-#undef LONG_STR1
-#undef LONG_STR2
-
-int main()
-{
- using namespace fs;
- {
- path p;
- ASSERT_NOEXCEPT(p.swap(p));
- ASSERT_SAME_TYPE(void, decltype(p.swap(p)));
- }
- for (auto const & TC : TestCases) {
- path p1(TC.value1);
- path p2(TC.value2);
- {
- DisableAllocationGuard g;
- p1.swap(p2);
- }
- assert(p1 == TC.value2);
- assert(p2 == TC.value1);
- {
- DisableAllocationGuard g;
- p1.swap(p2);
- }
- assert(p1 == TC.value1);
- assert(p2 == TC.value2);
- }
- // self-swap
- {
- const char* Val = "aoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeu";
- path p1(Val);
- assert(p1 == Val);
- {
- DisableAllocationGuard g;
- p1.swap(p1);
- }
- assert(p1 == Val);
- }
-}
OpenPOWER on IntegriCloud