make_preferred.pass.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // UNSUPPORTED: c++98, c++03
  9. // <filesystem>
  10. // class path
  11. // path& make_preferred()
  12. #include "filesystem_include.hpp"
  13. #include <type_traits>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. #include "test_iterators.h"
  17. #include "count_new.hpp"
  18. #include "filesystem_test_helper.hpp"
  19. struct MakePreferredTestcase {
  20. const char* value;
  21. };
  22. const MakePreferredTestcase TestCases[] =
  23. {
  24. {""}
  25. , {"hello_world"}
  26. , {"/"}
  27. , {"/foo/bar/baz/"}
  28. , {"\\"}
  29. , {"\\foo\\bar\\baz\\"}
  30. , {"\\foo\\/bar\\/baz\\"}
  31. };
  32. int main(int, char**)
  33. {
  34. // This operation is an identity operation on linux.
  35. using namespace fs;
  36. for (auto const & TC : TestCases) {
  37. path p(TC.value);
  38. assert(p == TC.value);
  39. path& Ref = (p.make_preferred());
  40. assert(p.native() == TC.value);
  41. assert(&Ref == &p);
  42. }
  43. return 0;
  44. }