Home | History | Annotate | Download | only in path.nonmember
      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 // <experimental/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 #include <experimental/filesystem>
     26 #include <type_traits>
     27 #include <sstream>
     28 #include <cassert>
     29 
     30 #include "test_macros.h"
     31 #include "test_iterators.h"
     32 #include "count_new.hpp"
     33 #include "filesystem_test_helper.hpp"
     34 
     35 MultiStringType InStr =  MKSTR("abcdefg/\"hijklmnop\"/qrstuvwxyz/123456789");
     36 MultiStringType OutStr = MKSTR("\"abcdefg/\\\"hijklmnop\\\"/qrstuvwxyz/123456789\"");
     37 
     38 template <class CharT>
     39 void doIOTest() {
     40   using namespace fs;
     41   using Ptr = const CharT*;
     42   using StrStream = std::basic_stringstream<CharT>;
     43   const Ptr E = OutStr;
     44   const path p((const char*)InStr);
     45   StrStream ss;
     46   { // test output
     47     auto& ret = (ss << p);
     48     assert(ss.str() == E);
     49     assert(&ret == &ss);
     50   }
     51   { // test input
     52     path p_in;
     53     auto& ret = ss >> p_in;
     54     assert(p_in.native() == (const char*)InStr);
     55     assert(&ret == &ss);
     56   }
     57 }
     58 
     59 
     60 int main() {
     61   doIOTest<char>();
     62   doIOTest<wchar_t>();
     63   //doIOTest<char16_t>();
     64   //doIOTest<char32_t>();
     65 }
     66