3 // Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation
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)
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.
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,
21 // 27.6.1.3 unformatted input functions
23 #include <cstring> // for strlen
26 #include <testsuite_hooks.h>
28 // [patch] bits/istream.tcc - getline(char_type*,streamsize,char_type)
29 // http://gcc.gnu.org/ml/libstdc++/2000-07/msg00003.html
33 const char* charray
= "\n"
49 bool test
__attribute__((unused
)) = true;
50 const std::streamsize it
= 5;
51 std::streamsize br
= 0;
53 std::stringbuf
sb(charray
, std::ios_base::in
);
54 std::istream
ifs(&sb
);
55 std::streamsize blen
= std::strlen(charray
);
57 while(ifs
.getline(tmp
, it
) || ifs
.gcount())
62 // Just sanity checks to make sure we've extracted the same
63 // number of chars that were in the streambuf
65 // Also, we should only set the failbit if we could
66 // _extract_ no chars from the stream, i.e. the first read
68 VERIFY(ifs
.fail() && ifs
.gcount() == 0);
75 // -> extracted no characters
77 // -> n - 1 characters are stored
78 ifs
.clear(ifs
.rdstate() & ~std::ios::failbit
);
79 VERIFY((ifs
.gcount() == 0) || (std::strlen(tmp
) == it
- 1));
85 // delimiter was read.
87 // -> strlen(__s) < n - 1
88 // -> delimiter was seen -> gcount() > strlen(__s)
89 VERIFY(ifs
.gcount() == static_cast<std::streamsize
>(std::strlen(tmp
) + 1) );