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: 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 
main(int,char **)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 #if TEST_STD_VER > 17 && defined(__cpp_char8_t)
50     ASSERT_SAME_TYPE(decltype(p.u8string()), std::u8string);
51     std::u8string s = p.u8string();
52     assert(s == (const char8_t*)MS);
53 #else
54     ASSERT_SAME_TYPE(decltype(p.u8string()), std::string);
55     std::string s = p.u8string();
56     assert(s == (const char*)MS);
57 #endif
58   }
59 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
60   {
61     std::wstring s = p.wstring();
62     assert(s == (const wchar_t*)MS);
63   }
64 #endif
65   {
66     std::u16string s = p.u16string();
67     assert(s == (const char16_t*)MS);
68   }
69   {
70     std::u32string s = p.u32string();
71     assert(s == (const char32_t*)MS);
72   }
73 
74   return 0;
75 }
76