ios_base_storage.cc (test02): Set exception mask.

2003-03-06  Jerry Quinn  <jlquinn@optonline.net>

	* testsuite/27_io/ios_base_storage.cc (test02): Set exception
	mask.  Test setting small-numbered pword and iword slots.  Test
	behavior at limit of numeric_limits::max.  Check that values are
	still good after failures.

From-SVN: r63908
This commit is contained in:
Jerry Quinn 2003-03-06 22:37:01 +00:00 committed by Benjamin Kosnik
parent 37f5242b58
commit a9aa7083ed
2 changed files with 54 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2003-03-06 Jerry Quinn <jlquinn@optonline.net>
* testsuite/27_io/ios_base_storage.cc (test02): Set exception
mask. Test setting small-numbered pword and iword slots. Test
behavior at limit of numeric_limits::max. Check that values are
still good after failures.
2003-03-06 Jerry Quinn <jlquinn@optonline.net>
* src/ios.cc (ios_base::_M_init): Remove _M_word_size.

View File

@ -55,10 +55,15 @@ void test02()
std::stringbuf strbuf;
std::ios ios(&strbuf);
ios.exceptions(std::ios::badbit);
long l = 0;
void* v = 0;
// pword
ios.pword(1) = v;
VERIFY( ios.pword(1) == v );
try
{
v = ios.pword(max);
@ -74,7 +79,29 @@ void test02()
}
VERIFY( v == 0 );
VERIFY( ios.pword(1) == v );
// max is different code path from max-1
v = &test;
try
{
v = ios.pword(std::numeric_limits<int>::max());
}
catch(std::ios_base::failure& obj)
{
// Ok.
VERIFY( ios.bad() );
}
catch(...)
{
VERIFY( test = false );
}
VERIFY( v == &test );
// iword
ios.iword(1) = 1;
VERIFY( ios.iword(1) == 1 );
try
{
l = ios.iword(max);
@ -89,6 +116,26 @@ void test02()
VERIFY( test = false );
}
VERIFY( l == 0 );
VERIFY( ios.iword(1) == 1 );
// max is different code path from max-1
l = 1;
try
{
l = ios.iword(std::numeric_limits<int>::max());
}
catch(std::ios_base::failure& obj)
{
// Ok.
VERIFY( ios.bad() );
}
catch(...)
{
VERIFY( test = false );
}
VERIFY( l == 1 );
}
class derived : public std::ios_base