brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 4f9e7e0 Raw
83 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// <sstream>10 11// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >12// class basic_stringstream13 14// explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++2015// basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {}            // C++2016// explicit basic_stringstream(ios_base::openmode which);                                // C++2017 18#include <sstream>19#include <cassert>20 21#include "test_macros.h"22#include "operator_hijacker.h"23#if TEST_STD_VER >= 1124#include "test_convertible.h"25 26template <typename S>27void test() {28  static_assert(test_convertible<S>(), "");29  static_assert(!test_convertible<S, std::ios_base::openmode>(), "");30}31#endif32 33int main(int, char**)34{35    {36        std::stringstream ss;37        assert(ss.rdbuf() != nullptr);38        assert(ss.good());39        assert(ss.str() == "");40    }41    {42      std::basic_stringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss;43      assert(ss.rdbuf() != nullptr);44      assert(ss.good());45      assert(ss.str() == "");46    }47    {48        std::stringstream ss(std::ios_base::in);49        assert(ss.rdbuf() != nullptr);50        assert(ss.good());51        assert(ss.str() == "");52    }53    {54      std::basic_stringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss(std::ios_base::in);55      assert(ss.rdbuf() != nullptr);56      assert(ss.good());57      assert(ss.str() == "");58    }59#ifndef TEST_HAS_NO_WIDE_CHARACTERS60    {61        std::wstringstream ss;62        assert(ss.rdbuf() != nullptr);63        assert(ss.good());64        assert(ss.str() == L"");65    }66    {67        std::wstringstream ss(std::ios_base::in);68        assert(ss.rdbuf() != nullptr);69        assert(ss.good());70        assert(ss.str() == L"");71    }72#endif73 74#if TEST_STD_VER >= 1175    test<std::stringstream>();76#  ifndef TEST_HAS_NO_WIDE_CHARACTERS77    test<std::wstringstream>();78#   endif79#endif80 81    return 0;82}83