brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 854b713 Raw
72 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 11// <filesystem>12 13// class path14 15// template <class charT, class traits>16// basic_ostream<charT, traits>&17// operator<<(basic_ostream<charT, traits>& os, const path& p);18//19// template <class charT, class traits>20// basic_istream<charT, traits>&21// operator>>(basic_istream<charT, traits>& is, path& p)22//23 24// TODO(EricWF) This test fails because "std::quoted" fails to compile25// for char16_t and char32_t types. Combine with path.io.pass.cpp when this26// passes.27// XFAIL: *28 29#include <filesystem>30#include <type_traits>31#include <sstream>32#include <cassert>33 34#include "test_macros.h"35#include "test_iterators.h"36#include "count_new.h"37#include "filesystem_test_helper.h"38namespace fs = std::filesystem;39 40MultiStringType InStr =  MKSTR("abcdefg/\"hijklmnop\"/qrstuvwxyz/123456789");41MultiStringType OutStr = MKSTR("\"abcdefg/\\\"hijklmnop\\\"/qrstuvwxyz/123456789\"");42 43template <class CharT>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 output53    auto& ret = (ss << p);54    assert(ss.str() == E);55    assert(&ret == &ss);56  }57  { // test input58    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 66int main(int, char**) {67  doIOTest<char16_t>();68  doIOTest<char32_t>();69 70  return 0;71}72