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 
20 #include <experimental/filesystem>
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 
28 using namespace std::experimental::filesystem;
29 
30 TEST_SUITE(filesystem_system_complete_test_suite)
31 
TEST_CASE(signature_test)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 
TEST_CASE(basic_system_complete_tests)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()
59