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 // <filesystem>
13 
14 // path absolute(const path& p, const path& base=current_path());
15 
16 #include "filesystem_include.hpp"
17 #include <type_traits>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 #include "rapid-cxx-test.hpp"
22 #include "filesystem_test_helper.hpp"
23 
24 using namespace fs;
25 
26 TEST_SUITE(filesystem_absolute_path_test_suite)
27 
TEST_CASE(absolute_signature_test)28 TEST_CASE(absolute_signature_test)
29 {
30     const path p; ((void)p);
31     std::error_code ec;
32     ASSERT_NOT_NOEXCEPT(absolute(p));
33     ASSERT_NOT_NOEXCEPT(absolute(p, ec));
34 }
35 
36 
TEST_CASE(basic_test)37 TEST_CASE(basic_test)
38 {
39     const fs::path cwd = fs::current_path();
40     const struct {
41       std::string input;
42       std::string expect;
43     } TestCases [] = {
44         {"", cwd / ""},
45         {"foo", cwd / "foo"},
46         {"foo/", cwd / "foo/"},
47         {"/already_absolute", "/already_absolute"}
48     };
49     for (auto& TC : TestCases) {
50         std::error_code ec = GetTestEC();
51         const path ret = absolute(TC.input, ec);
52         TEST_CHECK(!ec);
53         TEST_CHECK(ret.is_absolute());
54         TEST_CHECK(PathEq(ret, TC.expect));
55     }
56 }
57 
58 TEST_SUITE_END()
59