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, c++11, c++14 10 // UNSUPPORTED: availability-filesystem-missing 11 12 // These tests require locale for non-char paths 13 // UNSUPPORTED: no-localization 14 15 // <filesystem> 16 17 // class path 18 19 // std::string string() const; 20 // std::wstring wstring() const; 21 // std::u8string u8string() const; 22 // std::u16string u16string() const; 23 // std::u32string u32string() const; 24 25 #include <filesystem> 26 #include <cassert> 27 #include <string> 28 #include <type_traits> 29 30 #include "assert_macros.h" 31 #include "count_new.h" 32 #include "make_string.h" 33 #include "min_allocator.h" 34 #include "test_iterators.h" 35 #include "test_macros.h" 36 namespace fs = std::filesystem; 37 38 MultiStringType longString = MKSTR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/123456789/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); 39 main(int,char **)40int main(int, char**) 41 { 42 using namespace fs; 43 auto const& MS = longString; 44 const char* value = longString; 45 const path p(value); 46 { 47 std::string s = p.string(); 48 assert(s == value); 49 } 50 { 51 #if TEST_STD_VER > 17 && defined(__cpp_char8_t) 52 ASSERT_SAME_TYPE(decltype(p.u8string()), std::u8string); 53 std::u8string s = p.u8string(); 54 assert(s == (const char8_t*)MS); 55 #else 56 ASSERT_SAME_TYPE(decltype(p.u8string()), std::string); 57 std::string s = p.u8string(); 58 assert(s == (const char*)MS); 59 #endif 60 } 61 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 62 { 63 std::wstring s = p.wstring(); 64 assert(s == (const wchar_t*)MS); 65 } 66 #endif 67 { 68 std::u16string s = p.u16string(); 69 assert(s == (const char16_t*)MS); 70 } 71 { 72 std::u32string s = p.u32string(); 73 assert(s == (const char32_t*)MS); 74 } 75 76 return 0; 77 } 78