]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc
1 // Copyright (C) 2016-2023 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++17 } }
22 #include <testsuite_hooks.h>
27 using namespace std::filesystem
;
28 using string_type
= std::basic_string
<path::value_type
>;
29 const string_type s
{ 'a', 'b', 'c' };
32 VERIFY( p
.native() == s
);
33 VERIFY( p
.c_str() == s
);
34 VERIFY( static_cast<string_type
>(p
) == s
);
36 string_type s2
= p
; // implicit conversion
37 VERIFY( s2
== p
.native() );
43 using namespace std::filesystem
;
44 const char* s
= "abc";
47 auto str
= p
.string
<char>();
48 VERIFY( str
== "abc" );
49 VERIFY( str
== p
.string() );
51 #ifdef _GLIBCXX_USE_WCHAR_T
52 auto strw
= p
.string
<wchar_t>();
53 VERIFY( strw
== L
"abc" );
54 VERIFY( strw
== p
.wstring() );
57 auto str16
= p
.string
<char16_t
>();
58 VERIFY( str16
== u
"abc" );
59 VERIFY( str16
== p
.u16string() );
61 auto str32
= p
.string
<char32_t
>();
62 VERIFY( str32
== U
"abc" );
63 VERIFY( str32
== p
.u32string() );
69 std::filesystem::path p
;
70 auto str8
= p
.u8string();
71 VERIFY( str8
== u8
"" );
72 auto str16
= p
.u16string();
73 VERIFY( str16
== u
"" );
74 auto str32
= p
.u32string();
75 VERIFY( str32
== U
"" );
82 auto p
= std::filesystem::u8path("\xf0\x9d\x84\x9e");
83 auto str8
= p
.u8string();
84 VERIFY( str8
== u8
"\U0001D11E" );
85 auto str16
= p
.u16string();
86 VERIFY( str16
== u
"\U0001D11E" );
87 auto str32
= p
.u32string();
88 VERIFY( str32
== U
"\U0001D11E" );