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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14 10 // UNSUPPORTED: no-localization 11 12 // <filesystem> 13 // 14 // class directory_entry 15 // 16 // template<class charT, class traits> 17 // friend basic_ostream<charT, traits>& 18 // operator<<(basic_ostream<charT, traits>& os, const directory_entry& d); 19 20 #include <filesystem> 21 #include <cassert> 22 #include <sstream> 23 24 #include "test_macros.h" 25 #include "make_string.h" 26 namespace fs = std::filesystem; 27 28 MultiStringType InStr = MKSTR("abcdefg/\"hijklmnop\"/qrstuvwxyz/123456789"); 29 MultiStringType OutStr = MKSTR("\"abcdefg/\\\"hijklmnop\\\"/qrstuvwxyz/123456789\""); 30 31 template <class CharT> TestOutput()32void TestOutput() { 33 const char* input = static_cast<const char*>(InStr); 34 const CharT* expected_output = static_cast<const CharT*>(OutStr); 35 const fs::directory_entry dir = fs::directory_entry(fs::path(input)); 36 std::basic_stringstream<CharT> stream; 37 38 auto& result = stream << dir; 39 assert(stream.str() == expected_output); 40 assert(&result == &stream); 41 } 42 main(int,char **)43int main(int, char**) { 44 TestOutput<char>(); 45 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 46 TestOutput<wchar_t>(); 47 #endif 48 // TODO(var-const): uncomment when it becomes possible to instantiate a `basic_ostream` object with a sized character 49 // type (see https://llvm.org/PR53119). 50 //TestOutput<char8_t>(); 51 //TestOutput<char16_t>(); 52 //TestOutput<char32_t>(); 53 54 return 0; 55 } 56