brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 596a3e7 Raw
71 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_ostringstream13 14// basic_ostringstream(basic_ostringstream&& rhs);15 16#include <sstream>17#include <cassert>18 19#include "operator_hijacker.h"20#include "test_macros.h"21 22int main(int, char**)23{24    {25        std::ostringstream ss0(" 123 456");26        std::ostringstream ss(std::move(ss0));27        assert(ss.rdbuf() != nullptr);28        assert(ss.good());29        assert(ss.str() == " 123 456");30        int i = 234;31        ss << i << ' ' << 567;32        assert(ss.str() == "234 5676");33    }34    {35      std::basic_ostringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss0(" 123 456");36      std::basic_ostringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss(std::move(ss0));37      assert(ss.rdbuf() != nullptr);38      assert(ss.good());39      assert(ss.str() == " 123 456");40      int i = 234;41      ss << i << ' ' << 567;42      assert(ss.str() == "234 5676");43    }44#ifndef TEST_HAS_NO_WIDE_CHARACTERS45    {46        std::wostringstream ss0(L" 123 456");47        std::wostringstream ss(std::move(ss0));48        assert(ss.rdbuf() != nullptr);49        assert(ss.good());50        assert(ss.str() == L" 123 456");51        int i = 234;52        ss << i << ' ' << 567;53        assert(ss.str() == L"234 5676");54    }55    {56      std::basic_ostringstream<wchar_t, std::char_traits<wchar_t>, operator_hijacker_allocator<wchar_t> > ss0(57          L" 123 456");58      std::basic_ostringstream<wchar_t, std::char_traits<wchar_t>, operator_hijacker_allocator<wchar_t> > ss(59          std::move(ss0));60      assert(ss.rdbuf() != nullptr);61      assert(ss.good());62      assert(ss.str() == L" 123 456");63      int i = 234;64      ss << i << ' ' << 567;65      assert(ss.str() == L"234 5676");66    }67#endif68 69  return 0;70}71