path.io.pass.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. // UNSUPPORTED: c++98, c++03
  10. // <experimental/filesystem>
  11. // class path
  12. // template <class charT, class traits>
  13. // basic_ostream<charT, traits>&
  14. // operator<<(basic_ostream<charT, traits>& os, const path& p);
  15. //
  16. // template <class charT, class traits>
  17. // basic_istream<charT, traits>&
  18. // operator>>(basic_istream<charT, traits>& is, path& p)
  19. //
  20. #include <experimental/filesystem>
  21. #include <type_traits>
  22. #include <sstream>
  23. #include <cassert>
  24. #include "test_macros.h"
  25. #include "test_iterators.h"
  26. #include "count_new.hpp"
  27. #include "filesystem_test_helper.hpp"
  28. MultiStringType InStr = MKSTR("abcdefg/\"hijklmnop\"/qrstuvwxyz/123456789");
  29. MultiStringType OutStr = MKSTR("\"abcdefg/\\\"hijklmnop\\\"/qrstuvwxyz/123456789\"");
  30. template <class CharT>
  31. void doIOTest() {
  32. using namespace fs;
  33. using Ptr = const CharT*;
  34. using StrStream = std::basic_stringstream<CharT>;
  35. const char* const InCStr = InStr;
  36. const Ptr E = OutStr;
  37. const path p((const char*)InStr);
  38. StrStream ss;
  39. { // test output
  40. auto& ret = (ss << p);
  41. assert(ss.str() == E);
  42. assert(&ret == &ss);
  43. }
  44. { // test input
  45. path p_in;
  46. auto& ret = ss >> p_in;
  47. assert(p_in.native() == (const char*)InStr);
  48. assert(&ret == &ss);
  49. }
  50. }
  51. int main() {
  52. doIOTest<char>();
  53. doIOTest<wchar_t>();
  54. //doIOTest<char16_t>();
  55. //doIOTest<char32_t>();
  56. }