79 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_istringstream13 14// basic_istringstream(basic_istringstream&& rhs);15 16#include <sstream>17#include <cassert>18 19#include "test_macros.h"20#include "operator_hijacker.h"21 22int main(int, char**)23{24 {25 std::istringstream ss0(" 123 456");26 std::istringstream ss(std::move(ss0));27 assert(ss.rdbuf() != 0);28 assert(ss.good());29 assert(ss.str() == " 123 456");30 int i = 0;31 ss >> i;32 assert(i == 123);33 ss >> i;34 assert(i == 456);35 }36 {37 std::basic_istringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss0(" 123 456");38 std::basic_istringstream<char, std::char_traits<char>, operator_hijacker_allocator<char> > ss(std::move(ss0));39 assert(ss.rdbuf() != 0);40 assert(ss.good());41 assert(ss.str() == " 123 456");42 int i = 0;43 ss >> i;44 assert(i == 123);45 ss >> i;46 assert(i == 456);47 }48#ifndef TEST_HAS_NO_WIDE_CHARACTERS49 {50 std::wistringstream ss0(L" 123 456");51 std::wistringstream ss(std::move(ss0));52 assert(ss.rdbuf() != 0);53 assert(ss.good());54 assert(ss.str() == L" 123 456");55 int i = 0;56 ss >> i;57 assert(i == 123);58 ss >> i;59 assert(i == 456);60 }61 {62 std::basic_istringstream<wchar_t, std::char_traits<wchar_t>, operator_hijacker_allocator<wchar_t> > ss0(63 L" 123 456");64 std::basic_istringstream<wchar_t, std::char_traits<wchar_t>, operator_hijacker_allocator<wchar_t> > ss(65 std::move(ss0));66 assert(ss.rdbuf() != 0);67 assert(ss.good());68 assert(ss.str() == L" 123 456");69 int i = 0;70 ss >> i;71 assert(i == 123);72 ss >> i;73 assert(i == 456);74 }75#endif76 77 return 0;78}79