aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
index 432ed6cdab5..e1d9a38f75e 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
@@ -38,12 +38,12 @@ void test05()
typedef filebuf::int_type int_type;
typedef filebuf::traits_type traits_type;
- bool test = true;
+ bool test = true;
streamsize strmsz_1, strmsz_2, strmsz_3;
- int i = 0, j = 0, k = 0;
char carray1[13] = "";
char carray2[8192] = "";
+ char buffer[8192] = "";
int_type c1, c2, c3, c4;
// streamsize sgetn(char_type *s, streamsize n)
@@ -55,19 +55,22 @@ void test05()
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
- VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
strmsz_1 = fb_03.sgetn(carray1, 10);
VERIFY( strmsz_1 == 0 );
- VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
// in | out 2
{
- constraint_filebuf fb_01;
+ constraint_filebuf fb_01;
+ // Need this since BUFSIZ is only guaranteed >= 255 and we want
+ // to trigger the same underflow situation everywhere.
+ fb_01.pubsetbuf(buffer, 8192);
fb_01.open(name_01, ios_base::in | ios_base::out);
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
strmsz_1 = fb_01.in_avail();
strmsz_2 = fb_01.sgetn(carray1, 10);
VERIFY( strmsz_2 == 10 );
@@ -84,7 +87,7 @@ void test05()
VERIFY( strmsz_1 > 0 );
strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
VERIFY( strmsz_1 == strmsz_2 ); //at the end of the actual file
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}