]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/2627.cc
streambuf_iterator.h (ostreambuf_iterator): Remove non-standard throw specs.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 24_iterators / istreambuf_iterator / 2627.cc
CommitLineData
e0ec69c9
BK
1// 1999-06-28 bkoz
2
3// Copyright (C) 1999, 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19// USA.
20
21// 24.5.3 template class istreambuf_iterator
22
23#include <sstream>
24#include <iterator>
25#include <testsuite_hooks.h>
26
27// libstdc++/2627
28void test03()
29{
30 bool test __attribute__((unused)) = true;
31 const std::string s("free the vieques");
32
33 // 1
34 std::string res_postfix;
35 std::istringstream iss01(s);
36 std::istreambuf_iterator<char> isbufit01(iss01);
37 for (std::size_t j = 0; j < s.size(); ++j, isbufit01++)
38 res_postfix += *isbufit01;
39
40 // 2
41 std::string res_prefix;
42 std::istringstream iss02(s);
43 std::istreambuf_iterator<char> isbufit02(iss02);
44 for (std::size_t j = 0; j < s.size(); ++j, ++isbufit02)
45 res_prefix += *isbufit02;
46
47 // 3 mixed
48 std::string res_mixed;
49 std::istringstream iss03(s);
50 std::istreambuf_iterator<char> isbufit03(iss03);
51 for (std::size_t j = 0; j < (s.size() / 2); ++j)
52 {
53 res_mixed += *isbufit03;
54 ++isbufit03;
55 res_mixed += *isbufit03;
56 isbufit03++;
57 }
58
59 VERIFY ( res_postfix == res_prefix );
60 VERIFY ( res_mixed == res_prefix );
61}
62
63int main()
64{
65 test03();
66 return 0;
67}