str.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <sstream> 11 12// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 13// class basic_istringstream 14 15// void str(const basic_string<charT,traits,Allocator>& s); 16 17#include <sstream> 18#include <cassert> 19 20int main() 21{ 22 { 23 std::istringstream ss(" 123 456"); 24 assert(ss.rdbuf() != 0); 25 assert(ss.good()); 26 assert(ss.str() == " 123 456"); 27 int i = 0; 28 ss >> i; 29 assert(i == 123); 30 ss >> i; 31 assert(i == 456); 32 ss.str(" 789"); 33 ss.clear(); 34 assert(ss.good()); 35 assert(ss.str() == " 789"); 36 ss >> i; 37 assert(i == 789); 38 } 39 { 40 std::wistringstream ss(L" 123 456"); 41 assert(ss.rdbuf() != 0); 42 assert(ss.good()); 43 assert(ss.str() == L" 123 456"); 44 int i = 0; 45 ss >> i; 46 assert(i == 123); 47 ss >> i; 48 assert(i == 456); 49 ss.str(L" 789"); 50 ss.clear(); 51 assert(ss.good()); 52 assert(ss.str() == L" 789"); 53 ss >> i; 54 assert(i == 789); 55 } 56} 57