Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // UNSUPPORTED: c++98, c++03 |
| 11 | |
| 12 | // <experimental/filesystem> |
| 13 | |
| 14 | // path system_complete(const path& p); |
| 15 | // path system_complete(const path& p, error_code& ec); |
| 16 | |
| 17 | // Note: For POSIX based operating systems, 'system_complete(p)' has the |
| 18 | // same semantics as 'absolute(p, current_path())'. |
| 19 | |
Eric Fiselier | f1471a3 | 2018-03-26 05:46:57 +0000 | [diff] [blame] | 20 | #include "filesystem_include.hpp" |
Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 21 | #include <type_traits> |
| 22 | #include <cassert> |
| 23 | |
| 24 | #include "test_macros.h" |
| 25 | #include "rapid-cxx-test.hpp" |
| 26 | #include "filesystem_test_helper.hpp" |
| 27 | |
Eric Fiselier | f1471a3 | 2018-03-26 05:46:57 +0000 | [diff] [blame] | 28 | using namespace fs; |
Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 29 | |
| 30 | TEST_SUITE(filesystem_system_complete_test_suite) |
| 31 | |
| 32 | TEST_CASE(signature_test) |
| 33 | { |
| 34 | const path p; ((void)p); |
| 35 | std::error_code ec; ((void)ec); |
| 36 | ASSERT_NOT_NOEXCEPT(system_complete(p)); |
| 37 | ASSERT_NOT_NOEXCEPT(system_complete(p, ec)); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | TEST_CASE(basic_system_complete_tests) |
| 42 | { |
| 43 | const path testCases[] = { |
| 44 | "//net/foo", // has_root_name() && has_root_directory() |
| 45 | "/foo", // !has_root_name() && has_root_directory() |
| 46 | "//net", // has_root_name() && !has_root_directory() |
| 47 | "bar/baz" // !has_root_name() && !has_root_directory() |
| 48 | }; |
| 49 | const path base = current_path(); |
| 50 | for (auto& p : testCases) { |
| 51 | const path ret = system_complete(p); |
| 52 | const path expect = absolute(p, base); |
| 53 | TEST_CHECK(ret.is_absolute()); |
| 54 | TEST_CHECK(ret == expect); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | TEST_SUITE_END() |