1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03 10 11 // These tests require locale for non-char paths 12 // UNSUPPORTED: libcpp-has-no-localization 13 14 // <filesystem> 15 16 // class path 17 18 // std::string string() const; 19 // std::wstring wstring() const; 20 // std::u8string u8string() const; 21 // std::u16string u16string() const; 22 // std::u32string u32string() const; 23 24 25 #include "filesystem_include.h" 26 #include <type_traits> 27 #include <cassert> 28 29 #include "test_macros.h" 30 #include "test_iterators.h" 31 #include "count_new.h" 32 #include "min_allocator.h" 33 #include "filesystem_test_helper.h" 34 35 36 MultiStringType longString = MKSTR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/123456789/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); 37 38 int main(int, char**) 39 { 40 using namespace fs; 41 auto const& MS = longString; 42 const char* value = longString; 43 const path p(value); 44 { 45 std::string s = p.string(); 46 assert(s == value); 47 } 48 { 49 std::string s = p.u8string(); 50 assert(s == (const char*)MS); 51 } 52 { 53 std::wstring s = p.wstring(); 54 assert(s == (const wchar_t*)MS); 55 } 56 { 57 std::u16string s = p.u16string(); 58 assert(s == (const char16_t*)MS); 59 } 60 { 61 std::u32string s = p.u32string(); 62 assert(s == (const char32_t*)MS); 63 } 64 65 return 0; 66 } 67