blob: b4fb1f19af9f6d760524a0fae22a2699e815031a [file] [log] [blame]
Eric Fiselier6e9a6942016-06-17 19:46:40 +00001//===----------------------------------------------------------------------===//
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 Fiselierf1471a32018-03-26 05:46:57 +000020#include "filesystem_include.hpp"
Eric Fiselier6e9a6942016-06-17 19:46:40 +000021#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 Fiselierf1471a32018-03-26 05:46:57 +000028using namespace fs;
Eric Fiselier6e9a6942016-06-17 19:46:40 +000029
30TEST_SUITE(filesystem_system_complete_test_suite)
31
32TEST_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
41TEST_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
58TEST_SUITE_END()