path.io.unicode_bug.pass.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // TODO(EricWF) This test fails because "std::quoted" fails to compile
  21. // for char16_t and char32_t types. Combine with path.io.pass.cpp when this
  22. // passes.
  23. // XFAIL: *
  24. #include "filesystem_include.hpp"
  25. #include <type_traits>
  26. #include <sstream>
  27. #include <cassert>
  28. #include "test_macros.h"
  29. #include "test_iterators.h"
  30. #include "count_new.hpp"
  31. #include "filesystem_test_helper.hpp"
  32. MultiStringType InStr = MKSTR("abcdefg/\"hijklmnop\"/qrstuvwxyz/123456789");
  33. MultiStringType OutStr = MKSTR("\"abcdefg/\\\"hijklmnop\\\"/qrstuvwxyz/123456789\"");
  34. template <class CharT>
  35. void doIOTest() {
  36. using namespace fs;
  37. using Ptr = const CharT*;
  38. using StrStream = std::basic_stringstream<CharT>;
  39. const char* const InCStr = InStr;
  40. const Ptr E = OutStr;
  41. const path p((const char*)InStr);
  42. StrStream ss;
  43. { // test output
  44. auto& ret = (ss << p);
  45. assert(ss.str() == E);
  46. assert(&ret == &ss);
  47. }
  48. { // test input
  49. path p_in;
  50. auto& ret = ss >> p_in;
  51. assert(p_in.native() == (const char*)InStr);
  52. assert(&ret == &ss);
  53. }
  54. }
  55. int main() {
  56. doIOTest<char16_t>();
  57. doIOTest<char32_t>();
  58. }