system_complete.pass.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // UNSUPPORTED: c++98, c++03
  10. // <experimental/filesystem>
  11. // path system_complete(const path& p);
  12. // path system_complete(const path& p, error_code& ec);
  13. // Note: For POSIX based operating systems, 'system_complete(p)' has the
  14. // same semantics as 'absolute(p, current_path())'.
  15. #include "filesystem_include.hpp"
  16. #include <type_traits>
  17. #include <cassert>
  18. #include "test_macros.h"
  19. #include "rapid-cxx-test.hpp"
  20. #include "filesystem_test_helper.hpp"
  21. using namespace fs;
  22. TEST_SUITE(filesystem_system_complete_test_suite)
  23. TEST_CASE(signature_test)
  24. {
  25. const path p; ((void)p);
  26. std::error_code ec; ((void)ec);
  27. ASSERT_NOT_NOEXCEPT(system_complete(p));
  28. ASSERT_NOT_NOEXCEPT(system_complete(p, ec));
  29. }
  30. TEST_CASE(basic_system_complete_tests)
  31. {
  32. const path testCases[] = {
  33. "//net/foo", // has_root_name() && has_root_directory()
  34. "/foo", // !has_root_name() && has_root_directory()
  35. "//net", // has_root_name() && !has_root_directory()
  36. "bar/baz" // !has_root_name() && !has_root_directory()
  37. };
  38. const path base = current_path();
  39. for (auto& p : testCases) {
  40. const path ret = system_complete(p);
  41. const path expect = absolute(p, base);
  42. TEST_CHECK(ret.is_absolute());
  43. TEST_CHECK(ret == expect);
  44. }
  45. }
  46. TEST_SUITE_END()