]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/filesystem/path/construct/locale.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / filesystem / path / construct / locale.cc
1 // { dg-options "-std=gnu++17" }
2 // { dg-do run { target c++17 } }
3
4 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
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
21 // 30.10.7.4.1 path constructors [fs.path.construct]
22
23 #include <filesystem>
24 #include <testsuite_hooks.h>
25 #include <testsuite_iterators.h>
26
27 using std::filesystem::path;
28
29 void
30 test01()
31 {
32 path p("/foo/bar", std::locale::classic());
33 #if defined(__MINGW32__) || defined(__MINGW64__)
34 VERIFY( p.native() == L"/foo/bar" );
35 #else
36 VERIFY( p.native() == "/foo/bar" );
37 #endif
38 }
39
40 void
41 test02()
42 {
43 using __gnu_test::test_container;
44 using __gnu_test::input_iterator_wrapper;
45 // Test with input iterators and const value_types
46
47 const std::locale loc;
48 const std::string s = "foo/bar/";
49 const path p0(s);
50
51 test_container<char, input_iterator_wrapper>
52 r1((char*)s.c_str(), (char*)s.c_str() + s.size());
53 path p1(r1.begin(), r1.end(), loc);
54 VERIFY( p1 == p0 );
55
56 test_container<char, input_iterator_wrapper>
57 r2((char*)s.c_str(), (char*)s.c_str() + s.size() + 1); // includes null-terminator
58 path p2(r2.begin(), loc);
59 VERIFY( p2 == p0 );
60
61 test_container<const char, input_iterator_wrapper>
62 r3(s.c_str(), s.c_str() + s.size());
63 path p3(r3.begin(), r3.end(), loc);
64 VERIFY( p3 == p0 );
65
66 test_container<const char, input_iterator_wrapper>
67 r4(s.c_str(), s.c_str() + s.size() + 1); // includes null-terminator
68 path p4(r4.begin(), loc);
69 VERIFY( p4 == p0 );
70 }
71
72 int
73 main()
74 {
75 test01();
76 test02();
77 }