]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/filesystem/path/append/path.cc
1 // { dg-options "-std=gnu++17 -lstdc++fs" }
2 // { dg-do run { target c++17 } }
3 // { dg-require-filesystem-ts "" }
5 // Copyright (C) 2014-2019 Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // C++17 30.10.8.4.3 path appends [fs.path.append]
25 #include <testsuite_hooks.h>
26 #include <testsuite_fs.h>
28 using std::filesystem::path
;
29 using __gnu_test::compare_paths
;
31 // path::operator/=(const path&)
33 path
append(path l
, const path
& r
)
42 compare_paths( append("/foo/bar", "/foo/"), "/foo/" );
44 #ifndef _GLIBCXX_FILESYSTEM_IS_WINDOWS
45 compare_paths( append("baz", "baz"), "baz/baz" );
47 compare_paths( append("baz", "baz"), "baz\\baz" );
49 compare_paths( append("baz/", "baz"), "baz/baz" );
50 compare_paths( append("baz", "/foo/bar"), "/foo/bar" );
51 compare_paths( append("baz/", "/foo/bar"), "/foo/bar" );
53 VERIFY( append("", "").empty() );
54 VERIFY( !append("", "rel").is_absolute() );
56 compare_paths( append("dir/", "/file"), "/file" );
57 compare_paths( append("dir/", "file"), "dir/file" );
59 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
60 compare_paths( append("c:/foo", "/bar"), "c:/bar" );
67 // C++17 [fs.path.append] p4
68 #ifndef _GLIBCXX_FILESYSTEM_IS_WINDOWS
69 compare_paths( append("//host", "foo"), "//host/foo" );
71 compare_paths( append("//host/", "foo"), "//host/foo" );
73 // path("foo") / ""; // yields "foo/"
74 compare_paths( append("foo", ""), "foo/" );
76 // path("foo") / "/bar"; // yields "/bar"
77 compare_paths( append("foo", "/bar"), "/bar" );
79 compare_paths( append("//host", "foo"), "//host\\foo" );
81 compare_paths( append("//host/", "foo"), "//host/foo" );
83 // path("foo") / ""; // yields "foo/"
84 compare_paths( append("foo", ""), "foo\\" );
86 // path("foo") / "/bar"; // yields "/bar"
87 compare_paths( append("foo", "/bar"), "/bar" );
89 // path("foo") / "c:/bar"; // yields "c:/bar"
90 compare_paths( append("foo", "c:/bar"), "c:/bar" );
92 // path("foo") / "c:"; // yields "c:"
93 compare_paths( append("foo", "c:"), "c:" );
95 // path("c:") / ""; // yields "c:"
96 compare_paths( append("c:", ""), "c:" );
98 // path("c:foo") / "/bar"; // yields "c:/bar"
99 compare_paths( append("c:foo", "/bar"), "c:/bar" );
101 // path("c:foo") / "c:bar"; // yields "c:foo/bar"
102 compare_paths( append("foo", "c:\\bar"), "c:\\bar" );