path.io.pass.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 Ptr E = OutStr;
  36. const path p((const char*)InStr);
  37. StrStream ss;
  38. { // test output
  39. auto& ret = (ss << p);
  40. assert(ss.str() == E);
  41. assert(&ret == &ss);
  42. }
  43. { // test input
  44. path p_in;
  45. auto& ret = ss >> p_in;
  46. assert(p_in.native() == (const char*)InStr);
  47. assert(&ret == &ss);
  48. }
  49. }
  50. int main() {
  51. doIOTest<char>();
  52. doIOTest<wchar_t>();
  53. //doIOTest<char16_t>();
  54. //doIOTest<char32_t>();
  55. }