1// 2001-04-30 Benjamin Kosnik <bkoz@redhat.com> 2 3// Copyright (C) 2001, 2003 Free Software Foundation, Inc. 4// 5// This file is part of the GNU ISO C++ Library. This library is free 6// software; you can redistribute it and/or modify it under the 7// terms of the GNU General Public License as published by the 8// Free Software Foundation; either version 2, or (at your option) 9// any later version. 10 11// This library is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15 16// You should have received a copy of the GNU General Public License along 17// with this library; see the file COPYING. If not, write to the Free 18// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19// USA. 20 21// 24.5.4 template class ostreambuf_iterator 22 23#include <sstream> 24#include <iterator> 25#include <testsuite_hooks.h> 26 27bool test02(void) 28{ 29 typedef std::ostreambuf_iterator<char> costreambuf_iter; 30 typedef costreambuf_iter::streambuf_type cstreambuf_type; 31 bool test __attribute__((unused)) = true; 32 const char slit01[] = "playa hermosa, liberia, guanacaste"; 33 const char slit02[] = "bodega bay, lost coast, california"; 34 std::string str01(slit01); 35 std::string str02(slit02); 36 std::string tmp; 37 std::stringbuf strbuf01; 38 std::stringbuf strbuf02(str01); 39 std::ostringstream ostrs00(str01); 40 std::ostringstream ostrs01(str01); 41 42 // ctor sanity checks 43 costreambuf_iter ostrb_it01(ostrs00); 44 VERIFY( !ostrb_it01.failed() ); 45 ostrb_it01++; 46 ++ostrb_it01; 47 VERIFY( !ostrb_it01.failed() ); 48 ostrb_it01 = 'a'; 49 VERIFY( !ostrb_it01.failed() ); 50 *ostrb_it01; 51 VERIFY( !ostrb_it01.failed() ); 52 53 costreambuf_iter ostrb_it02(NULL); 54 VERIFY( ostrb_it02.failed() ); 55 ostrb_it02++; 56 ++ostrb_it02; 57 VERIFY( ostrb_it02.failed() ); 58 *ostrb_it02; 59 VERIFY( ostrb_it02.failed() ); 60 ostrb_it02 = 'a'; 61 VERIFY( ostrb_it02.failed() ); 62 63 // charT operator*() const 64 // ostreambuf_iterator& operator++(); 65 // ostreambuf_iterator& operator++(int); 66 costreambuf_iter ostrb_it27(ostrs01); 67 VERIFY( !ostrb_it27.failed() ); 68 int j = str02.size(); 69 for (int i = 0; i < j; ++i) 70 ostrb_it27 = str02[i]; 71 VERIFY( !ostrb_it27.failed() ); 72 tmp = ostrs01.str(); 73 VERIFY ( tmp != str01 ); 74 VERIFY ( tmp == str02 ); 75 76 costreambuf_iter ostrb_it28(ostrs00); 77 VERIFY( !ostrb_it28.failed() ); 78 j = ostrs00.str().size(); 79 for (int i = 0; i < j + 2; ++i) 80 ostrb_it28 = 'b'; 81 VERIFY( !ostrb_it28.failed() ); 82 tmp = ostrs00.str(); 83 VERIFY ( tmp != str01 ); 84 VERIFY ( tmp != str02 ); 85 return test; 86} 87 88int main() 89{ 90 test02(); 91 return 0; 92} 93