make_preferred.pass.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. // class path
  12. // path& make_preferred()
  13. #include <experimental/filesystem>
  14. #include <type_traits>
  15. #include <cassert>
  16. #include "test_macros.h"
  17. #include "test_iterators.h"
  18. #include "count_new.hpp"
  19. #include "filesystem_test_helper.hpp"
  20. namespace fs = std::experimental::filesystem;
  21. struct MakePreferredTestcase {
  22. const char* value;
  23. };
  24. const MakePreferredTestcase TestCases[] =
  25. {
  26. {""}
  27. , {"hello_world"}
  28. , {"/"}
  29. , {"/foo/bar/baz/"}
  30. , {"\\"}
  31. , {"\\foo\\bar\\baz\\"}
  32. , {"\\foo\\/bar\\/baz\\"}
  33. };
  34. int main()
  35. {
  36. // This operation is an identity operation on linux.
  37. using namespace fs;
  38. for (auto const & TC : TestCases) {
  39. path p(TC.value);
  40. assert(p == TC.value);
  41. path& Ref = (p.make_preferred());
  42. assert(p.native() == TC.value);
  43. assert(&Ref == &p);
  44. }
  45. }