summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-04-02 23:03:41 +0000
committerEric Fiselier <eric@efcs.ca>2018-04-02 23:03:41 +0000
commitd7fae181c3954886257fb33d0a57b954b26da745 (patch)
tree841df55a810bc7446cf7afdd6811b3f1d79a3fc8 /libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp
parent298ffc609bf5c67079dbeb77e3f75e5bc18fde7a (diff)
downloadbcm5719-llvm-d7fae181c3954886257fb33d0a57b954b26da745.tar.gz
bcm5719-llvm-d7fae181c3954886257fb33d0a57b954b26da745.zip
Implement filesystem NB comments, relative paths, and related issues.
This is a fairly large patch that implements all of the filesystem NB comments and the relative paths changes (ex. adding weakly_canonical). These issues and papers are all interrelated so their implementation couldn't be split up nicely. This patch upgrades <experimental/filesystem> to match the C++17 spec and not the published experimental TS spec. Some of the changes in this patch are both API and ABI breaking, however libc++ makes no guarantee about stability for experimental implementations. The major changes in this patch are: * Implement NB comments for filesystem (P0492R2), including: * Implement `perm_options` enum as part of NB comments, and update the `permissions` function to match. * Implement changes to `remove_filename` and `replace_filename` * Implement changes to `path::stem()` and `path::extension()` which support splitting examples like `.profile`. * Change path iteration to return an empty path instead of '.' for trailing separators. * Change `operator/=` to handle absolute paths on the RHS. * Change `absolute` to no longer accept a current path argument. * Implement relative paths according to NB comments (P0219r1) * Combine `path.cpp` and `operations.cpp` since some path functions require access to the operations internals, and some fs operations require access to the path parser. llvm-svn: 329028
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp')
-rw-r--r--libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp93
1 files changed, 17 insertions, 76 deletions
diff --git a/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp b/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp
index 97d168a4a53..9b73aedc8ef 100644
--- a/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp
+++ b/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp
@@ -28,89 +28,30 @@ TEST_SUITE(filesystem_absolute_path_test_suite)
TEST_CASE(absolute_signature_test)
{
const path p; ((void)p);
+ std::error_code ec;
ASSERT_NOT_NOEXCEPT(absolute(p));
- ASSERT_NOT_NOEXCEPT(absolute(p, p));
+ ASSERT_NOT_NOEXCEPT(absolute(p, ec));
}
-// There are 4 cases is the proposal for absolute path.
-// Each scope tests one of the cases.
-TEST_CASE(absolute_path_test)
-{
- // has_root_name() && has_root_directory()
- {
- const path p("//net/foo");
- const path base("//net/bar/baz");
- TEST_REQUIRE(p.has_root_name());
- TEST_REQUIRE(p.has_root_directory());
- TEST_CHECK(p.is_absolute());
- path ret = absolute(p, base);
- TEST_CHECK(ret.is_absolute());
- TEST_CHECK(ret == p);
- }
- // !has_root_name() && has_root_directory()
- {
- const path p("/foo");
- const path base("//net/bar");
- TEST_REQUIRE(not p.has_root_name());
- TEST_REQUIRE(p.has_root_directory());
- TEST_CHECK(p.is_absolute());
- // ensure absolute(base) is not recursively called
- TEST_REQUIRE(base.has_root_name());
- TEST_REQUIRE(base.has_root_directory());
-
- path ret = absolute(p, base);
- TEST_CHECK(ret.is_absolute());
- TEST_CHECK(ret.has_root_name());
- TEST_CHECK(ret.root_name() == path("//net"));
- TEST_CHECK(ret.has_root_directory());
- TEST_CHECK(ret.root_directory() == path("/"));
- TEST_CHECK(ret == path("//net/foo"));
- }
- // has_root_name() && !has_root_directory()
- {
- const path p("//net");
- const path base("//net/foo/bar");
- TEST_REQUIRE(p.has_root_name());
- TEST_REQUIRE(not p.has_root_directory());
- TEST_CHECK(not p.is_absolute());
- // absolute is called recursively on base. The following conditions
- // must be true for it to return base unmodified
- TEST_REQUIRE(base.has_root_name());
- TEST_REQUIRE(base.has_root_directory());
- path ret = absolute(p, base);
- const path expect("//net/foo/bar");
- TEST_CHECK(ret.is_absolute());
- TEST_CHECK(ret == path("//net/foo/bar"));
- }
- // !has_root_name() && !has_root_directory()
- {
- const path p("bar/baz");
- const path base("//net/foo");
- TEST_REQUIRE(not p.has_root_name());
- TEST_REQUIRE(not p.has_root_directory());
- TEST_REQUIRE(base.has_root_name());
- TEST_REQUIRE(base.has_root_directory());
-
- path ret = absolute(p, base);
- TEST_CHECK(ret.is_absolute());
- TEST_CHECK(ret == path("//net/foo/bar/baz"));
- }
-}
-TEST_CASE(absolute_path_with_default_base)
+TEST_CASE(basic_test)
{
- const path testCases[] = {
- "//net/foo", // has_root_name() && has_root_directory()
- "/foo", // !has_root_name() && has_root_directory()
- "//net", // has_root_name() && !has_root_directory()
- "bar/baz" // !has_root_name() && !has_root_directory()
+ const fs::path cwd = fs::current_path();
+ const struct {
+ std::string input;
+ std::string expect;
+ } TestCases [] = {
+ {"", cwd / ""},
+ {"foo", cwd / "foo"},
+ {"foo/", cwd / "foo/"},
+ {"/already_absolute", "/already_absolute"}
};
- const path base = current_path();
- for (auto& p : testCases) {
- const path ret = absolute(p);
- const path expect = absolute(p, base);
+ for (auto& TC : TestCases) {
+ std::error_code ec = GetTestEC();
+ const path ret = absolute(TC.input, ec);
+ TEST_CHECK(!ec);
TEST_CHECK(ret.is_absolute());
- TEST_CHECK(ret == expect);
+ TEST_CHECK(PathEq(ret, TC.expect));
}
}
OpenPOWER on IntegriCloud