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 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS 11 12 // <filesystem> 13 14 // template <class Source> 15 // path u8path(Source const&); 16 // template <class InputIter> 17 // path u8path(InputIter, InputIter); 18 19 #include "filesystem_include.h" 20 #include <type_traits> 21 #include <cassert> 22 23 #include "test_macros.h" 24 #include "test_iterators.h" 25 #include "count_new.h" 26 #include "filesystem_test_helper.h" 27 28 29 int main(int, char**) 30 { 31 using namespace fs; 32 const char* In1 = "abcd/efg"; 33 const std::string In2(In1); 34 const auto In3 = In2.begin(); 35 const auto In3End = In2.end(); 36 { 37 path p = fs::u8path(In1); 38 assert(p == In1); 39 } 40 { 41 path p = fs::u8path(In2); 42 assert(p == In1); 43 } 44 { 45 path p = fs::u8path(In2.data()); 46 assert(p == In1); 47 } 48 { 49 path p = fs::u8path(In3, In3End); 50 assert(p == In1); 51 } 52 #if TEST_STD_VER > 17 && defined(__cpp_char8_t) && defined(_LIBCPP_VERSION) && \ 53 !defined(_LIBCPP_HAS_NO_LOCALIZATION) 54 const char8_t* u8In1 = u8"abcd/efg"; 55 const std::u8string u8In2(u8In1); 56 const auto u8In3 = u8In2.begin(); 57 const auto u8In3End = u8In2.end(); 58 // Proposed in P1423, marked tested only for libc++ 59 { 60 path p = fs::u8path(u8In1); 61 assert(p == In1); 62 } 63 { 64 path p = fs::u8path(u8In2); 65 assert(p == In1); 66 } 67 { 68 path p = fs::u8path(u8In2.data()); 69 assert(p == In1); 70 } 71 { 72 path p = fs::u8path(u8In3, u8In3End); 73 assert(p == In1); 74 } 75 #endif 76 77 return 0; 78 } 79