]>
Commit | Line | Data |
---|---|---|
2b522535 | 1 | // { dg-options "-std=gnu++17" } |
641cb5a6 | 2 | // { dg-do run { target c++17 } } |
641cb5a6 | 3 | |
99dee823 | 4 | // Copyright (C) 2014-2021 Free Software Foundation, Inc. |
641cb5a6 JW |
5 | // |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
9 | // Free Software Foundation; either version 3, or (at your option) | |
10 | // any later version. | |
11 | ||
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | ||
17 | // You should have received a copy of the GNU General Public License along | |
18 | // with this library; see the file COPYING3. If not see | |
19 | // <http://www.gnu.org/licenses/>. | |
20 | ||
eeb517d3 | 21 | // 30.10.7.4.9 path decomposition [fs.path.decompose] |
641cb5a6 JW |
22 | |
23 | #include <filesystem> | |
24 | #include <testsuite_hooks.h> | |
25 | #include <testsuite_fs.h> | |
26 | ||
27 | using std::filesystem::path; | |
28 | ||
29 | void | |
30 | test01() | |
31 | { | |
32 | path p1 = "foo/bar"; | |
33 | VERIFY( p1.root_directory() == path() ); | |
34 | path p2 = "/foo/bar"; | |
35 | VERIFY( p2.root_directory() == path("/") ); | |
36 | path p3 = "//foo"; | |
2b462958 JW |
37 | #ifdef __CYGWIN__ |
38 | VERIFY( p3.root_directory() == path() ); | |
39 | #else | |
641cb5a6 | 40 | VERIFY( p3.root_directory() == path("/") ); |
2b462958 | 41 | #endif |
641cb5a6 JW |
42 | path p4 = "///foo"; |
43 | VERIFY( p4.root_directory() == path("/") ); | |
44 | } | |
45 | ||
46 | void | |
47 | test02() | |
48 | { | |
4a7c7999 | 49 | for (const path p : __gnu_test::test_paths) |
641cb5a6 JW |
50 | { |
51 | path rootdir = p.root_directory(); | |
52 | VERIFY( !rootdir.has_relative_path() ); | |
9534a5e6 JW |
53 | if (!rootdir.empty()) |
54 | #if defined(__MINGW32__) || defined(__MINGW64__) | |
55 | VERIFY( rootdir.string() == "/" || rootdir.string() == "\\" ); | |
56 | #else | |
57 | VERIFY( rootdir.string() == "/" ); | |
58 | #endif | |
641cb5a6 JW |
59 | } |
60 | } | |
61 | ||
62 | int | |
63 | main() | |
64 | { | |
65 | test01(); | |
66 | test02(); | |
67 | } |