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