Differential D91292 Diff 308912 libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// <sstream> | // <sstream> | ||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > | // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > | ||||
// class basic_ostringstream | // class basic_ostringstream | ||||
// explicit basic_ostringstream(ios_base::openmode which = ios_base::in); | // explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20 | ||||
// basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20 | |||||
// explicit basic_ostringstream(ios_base::openmode which); // C++20 | |||||
#include <sstream> | #include <sstream> | ||||
#include <cassert> | #include <cassert> | ||||
#include "test_macros.h" | #include "test_macros.h" | ||||
#if TEST_STD_VER >= 11 | |||||
#include "test_convertible.h" | |||||
template <typename S> | |||||
void test() { | |||||
#if TEST_STD_VER > 17 | |||||
static_assert(test_convertible<S>(), ""); | |||||
#else | |||||
static_assert(!test_convertible<S>(), ""); | |||||
#endif | |||||
static_assert(!test_convertible<S, std::ios_base::openmode>(), ""); | |||||
} | |||||
#endif | |||||
int main(int, char**) | int main(int, char**) | ||||
{ | { | ||||
{ | { | ||||
std::ostringstream ss; | std::ostringstream ss; | ||||
assert(ss.rdbuf() != 0); | assert(ss.rdbuf() != 0); | ||||
assert(ss.good()); | assert(ss.good()); | ||||
assert(ss.str() == ""); | assert(ss.str() == ""); | ||||
Show All 12 Lines | int main(int, char**) | ||||
} | } | ||||
{ | { | ||||
std::wostringstream ss(std::ios_base::out); | std::wostringstream ss(std::ios_base::out); | ||||
assert(ss.rdbuf() != 0); | assert(ss.rdbuf() != 0); | ||||
assert(ss.good()); | assert(ss.good()); | ||||
assert(ss.str() == L""); | assert(ss.str() == L""); | ||||
} | } | ||||
#if TEST_STD_VER >= 11 | |||||
test<std::ostringstream>(); | |||||
test<std::wostringstream>(); | |||||
#endif | |||||
return 0; | return 0; | ||||
} | } |