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