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 // <filesystem> 12 13 // class path 14 15 // template <class charT, class traits> 16 // basic_ostream<charT, traits>& 17 // operator<<(basic_ostream<charT, traits>& os, const path& p); 18 // 19 // template <class charT, class traits> 20 // basic_istream<charT, traits>& 21 // operator>>(basic_istream<charT, traits>& is, path& p) 22 // 23 24 // TODO(EricWF) This test fails because "std::quoted" fails to compile 25 // for char16_t and char32_t types. Combine with path.io.pass.cpp when this 26 // passes. 27 // XFAIL: * 28 29 #include "filesystem_include.h" 30 #include <type_traits> 31 #include <sstream> 32 #include <cassert> 33 34 #include "test_macros.h" 35 #include "test_iterators.h" 36 #include "count_new.h" 37 #include "filesystem_test_helper.h" 38 39 MultiStringType InStr = MKSTR("abcdefg/\"hijklmnop\"/qrstuvwxyz/123456789"); 40 MultiStringType OutStr = MKSTR("\"abcdefg/\\\"hijklmnop\\\"/qrstuvwxyz/123456789\""); 41 42 template <class CharT> 43 void doIOTest() { 44 using namespace fs; 45 using Ptr = const CharT*; 46 using StrStream = std::basic_stringstream<CharT>; 47 const char* const InCStr = InStr; 48 const Ptr E = OutStr; 49 const path p((const char*)InStr); 50 StrStream ss; 51 { // test output 52 auto& ret = (ss << p); 53 assert(ss.str() == E); 54 assert(&ret == &ss); 55 } 56 { // test input 57 path p_in; 58 auto& ret = ss >> p_in; 59 assert(p_in.native() == (const char*)InStr); 60 assert(&ret == &ss); 61 } 62 } 63 64 65 int main(int, char**) { 66 doIOTest<char16_t>(); 67 doIOTest<char32_t>(); 68 69 return 0; 70 } 71