1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++98, c++03 11 12 // <filesystem> 13 14 // class path 15 16 // template <class charT, class traits> 17 // basic_ostream<charT, traits>& 18 // operator<<(basic_ostream<charT, traits>& os, const path& p); 19 // 20 // template <class charT, class traits> 21 // basic_istream<charT, traits>& 22 // operator>>(basic_istream<charT, traits>& is, path& p) 23 // 24 25 // TODO(EricWF) This test fails because "std::quoted" fails to compile 26 // for char16_t and char32_t types. Combine with path.io.pass.cpp when this 27 // passes. 28 // XFAIL: * 29 30 #include "filesystem_include.hpp" 31 #include <type_traits> 32 #include <sstream> 33 #include <cassert> 34 35 #include "test_macros.h" 36 #include "test_iterators.h" 37 #include "count_new.hpp" 38 #include "filesystem_test_helper.hpp" 39 40 MultiStringType InStr = MKSTR("abcdefg/\"hijklmnop\"/qrstuvwxyz/123456789"); 41 MultiStringType OutStr = MKSTR("\"abcdefg/\\\"hijklmnop\\\"/qrstuvwxyz/123456789\""); 42 43 template <class CharT> doIOTest()44void doIOTest() { 45 using namespace fs; 46 using Ptr = const CharT*; 47 using StrStream = std::basic_stringstream<CharT>; 48 const char* const InCStr = InStr; 49 const Ptr E = OutStr; 50 const path p((const char*)InStr); 51 StrStream ss; 52 { // test output 53 auto& ret = (ss << p); 54 assert(ss.str() == E); 55 assert(&ret == &ss); 56 } 57 { // test input 58 path p_in; 59 auto& ret = ss >> p_in; 60 assert(p_in.native() == (const char*)InStr); 61 assert(&ret == &ss); 62 } 63 } 64 65 main()66int main() { 67 doIOTest<char16_t>(); 68 doIOTest<char32_t>(); 69 } 70