]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2016-2023 Free Software Foundation, Inc. |
26b1320e JW |
2 | // |
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) | |
7 | // any later version. | |
8 | ||
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. | |
13 | ||
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/>. | |
17 | ||
18 | // { dg-options "-lstdc++fs" } | |
19 | // { dg-do run { target c++11 } } | |
20 | // { dg-require-filesystem-ts "" } | |
21 | ||
22 | #include <experimental/filesystem> | |
23 | #include <string> | |
24 | #include <testsuite_hooks.h> | |
25 | #include <testsuite_allocator.h> | |
26 | ||
27 | template<typename C> | |
28 | using alloc = __gnu_test::uneq_allocator<C>; | |
29 | ||
30 | void | |
31 | test01() | |
32 | { | |
33 | using namespace std::experimental::filesystem; | |
34 | path p; | |
35 | ||
36 | auto str = p.string<char>(alloc<char>(1)); | |
37 | VERIFY( str == "" ); | |
38 | VERIFY( str.get_allocator() == alloc<char>(1) ); | |
39 | ||
40 | #ifdef _GLIBCXX_USE_CHAR8_T | |
41 | auto str8 = p.string<char8_t>(alloc<char8_t>(1)); | |
42 | VERIFY( str8 == u8"" ); | |
43 | VERIFY( str8.get_allocator() == alloc<char8_t>(1) ); | |
44 | #endif | |
45 | ||
43e2a441 | 46 | #ifdef _GLIBCXX_USE_WCHAR_T |
26b1320e JW |
47 | auto strw = p.string<wchar_t>(alloc<wchar_t>(2)); |
48 | VERIFY( strw == L"" ); | |
49 | VERIFY( strw.get_allocator() == alloc<wchar_t>(2) ); | |
43e2a441 | 50 | #endif |
26b1320e JW |
51 | |
52 | auto str16 = p.string<char16_t>(alloc<char16_t>(3)); | |
53 | VERIFY( str16 == u"" ); | |
54 | VERIFY( str16.get_allocator() == alloc<char16_t>(3) ); | |
55 | ||
56 | auto str32 = p.string<char32_t>(alloc<char32_t>(4)); | |
57 | VERIFY( str32 == U"" ); | |
58 | VERIFY( str32.get_allocator() == alloc<char32_t>(4) ); | |
59 | } | |
60 | ||
61 | void | |
62 | test02() | |
63 | { | |
64 | using namespace std::experimental::filesystem; | |
65 | path p = "abcdefghijklmnopqrstuvwxyz"; | |
66 | ||
67 | auto str = p.string<char>(alloc<char>(1)); | |
68 | VERIFY( str == "abcdefghijklmnopqrstuvwxyz" ); | |
69 | VERIFY( str.get_allocator() == alloc<char>(1) ); | |
70 | ||
71 | #ifdef _GLIBCXX_USE_CHAR8_T | |
72 | auto str8 = p.string<char8_t>(alloc<char8_t>(1)); | |
73 | VERIFY( str8 == u8"abcdefghijklmnopqrstuvwxyz" ); | |
74 | VERIFY( str8.get_allocator() == alloc<char8_t>(1) ); | |
75 | #endif | |
76 | ||
43e2a441 | 77 | #ifdef _GLIBCXX_USE_WCHAR_T |
26b1320e JW |
78 | auto strw = p.string<wchar_t>(alloc<wchar_t>(2)); |
79 | VERIFY( strw == L"abcdefghijklmnopqrstuvwxyz" ); | |
80 | VERIFY( strw.get_allocator() == alloc<wchar_t>(2) ); | |
43e2a441 | 81 | #endif |
26b1320e JW |
82 | |
83 | auto str16 = p.string<char16_t>(alloc<char16_t>(3)); | |
84 | VERIFY( str16 == u"abcdefghijklmnopqrstuvwxyz" ); | |
85 | VERIFY( str16.get_allocator() == alloc<char16_t>(3) ); | |
86 | ||
87 | auto str32 = p.string<char32_t>(alloc<char32_t>(4)); | |
88 | VERIFY( str32 == U"abcdefghijklmnopqrstuvwxyz" ); | |
89 | VERIFY( str32.get_allocator() == alloc<char32_t>(4) ); | |
90 | } | |
91 | ||
92 | int | |
93 | main() | |
94 | { | |
95 | test01(); | |
96 | test02(); | |
97 | } |