diff options
Diffstat (limited to 'libstdc++-v3/testsuite/24_iterators')
-rw-r--r-- | libstdc++-v3/testsuite/24_iterators/istreambuf_iterator.cc | 41 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator.cc | 22 |
2 files changed, 53 insertions, 10 deletions
diff --git a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator.cc b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator.cc index 78d36331604..8325c97fa3b 100644 --- a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator.cc +++ b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator.cc @@ -1,6 +1,6 @@ // 1999-06-28 bkoz -// Copyright (C) 1999 Free Software Foundation, Inc. +// Copyright (C) 1999, 2001 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -102,7 +102,7 @@ bool test01(void) std::istringstream istrs02(str01); cistreambuf_iter istrb_it28(istrs02); - for (int i = 0; i < sizeof(slit01) - 3;) + for (int i = 0; i < sizeof(slit01) - 2;) { c = *++istrb_it28; VERIFY( c == slit01[++i] ); @@ -115,9 +115,46 @@ bool test01(void) return test; } +// libstdc++/2627 +void test02() +{ + bool test = true; + const std::string s("free the vieques"); + + // 1 + std::string res_postfix; + std::istringstream iss01(s); + std::istreambuf_iterator<char> isbufit01(iss01); + for (int j = 0; j < s.size(); ++j, isbufit01++) + res_postfix += *isbufit01; + + // 2 + std::string res_prefix; + std::istringstream iss02(s); + std::istreambuf_iterator<char> isbufit02(iss02); + for (int j = 0; j < s.size(); ++j, ++isbufit02) + res_prefix += *isbufit02; + + // 3 mixed + std::string res_mixed; + std::istringstream iss03(s); + std::istreambuf_iterator<char> isbufit03(iss03); + for (int j = 0; j < int(s.size() / 2); ++j) + { + res_mixed += *isbufit03; + ++isbufit03; + res_mixed += *isbufit03; + isbufit03++; + } + + VERIFY ( res_postfix == res_prefix ); + VERIFY ( res_mixed == res_prefix ); +} + int main() { test01(); + test02(); return 0; } diff --git a/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator.cc b/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator.cc index 9f1544f2a31..eec7f980577 100644 --- a/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator.cc +++ b/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator.cc @@ -30,7 +30,9 @@ bool test01(void) typedef costreambuf_iter::streambuf_type cstreambuf_type; bool test = true; const char slit01[] = "playa hermosa, liberia, guanacaste"; + const char slit02[] = "bodega bay, lost coast, california"; std::string str01(slit01); + std::string str02(slit02); std::string tmp; std::stringbuf strbuf01; std::stringbuf strbuf02(str01); @@ -61,21 +63,25 @@ bool test01(void) // charT operator*() const // ostreambuf_iterator& operator++(); // ostreambuf_iterator& operator++(int); - costreambuf_iter ostrb_it27(ostrs00); + costreambuf_iter ostrb_it27(ostrs01); VERIFY( !ostrb_it27.failed() ); - for (int i = 0; i < strlen(slit01) - 2; ++i) - ostrb_it27 = 'a'; + int j = str02.size(); + for (int i = 0; i < j; ++i) + ostrb_it27 = str02[i]; VERIFY( !ostrb_it27.failed() ); - tmp = ostrs00.str(); - VERIFY ( tmp == str01 ); + tmp = ostrs01.str(); + VERIFY ( tmp != str01 ); + VERIFY ( tmp == str02 ); - costreambuf_iter ostrb_it28(ostrs01); + costreambuf_iter ostrb_it28(ostrs00); VERIFY( !ostrb_it28.failed() ); - for (int i = 0; i < strlen(slit01) + 1; ++i) + j = ostrs00.str().size(); + for (int i = 0; i < j + 2; ++i) ostrb_it28 = 'b'; VERIFY( !ostrb_it28.failed() ); - tmp = ostrs01.str(); + tmp = ostrs00.str(); VERIFY ( tmp != str01 ); + VERIFY ( tmp != str02 ); #ifdef DEBUG_ASSERT assert(test); |