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