From a9aa7083edffef0a326154cc39f429e55a12d846 Mon Sep 17 00:00:00 2001 From: Jerry Quinn Date: Thu, 6 Mar 2003 22:37:01 +0000 Subject: [PATCH] ios_base_storage.cc (test02): Set exception mask. 2003-03-06 Jerry Quinn * 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 --- libstdc++-v3/ChangeLog | 7 +++ .../testsuite/27_io/ios_base_storage.cc | 47 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 965a33302df..f0bd09abe6e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2003-03-06 Jerry Quinn + + * 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 * src/ios.cc (ios_base::_M_init): Remove _M_word_size. diff --git a/libstdc++-v3/testsuite/27_io/ios_base_storage.cc b/libstdc++-v3/testsuite/27_io/ios_base_storage.cc index 6af52c0a8c0..7033466e691 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base_storage.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base_storage.cc @@ -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::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::max()); + } + catch(std::ios_base::failure& obj) + { + // Ok. + VERIFY( ios.bad() ); + } + catch(...) + { + VERIFY( test = false ); + } + VERIFY( l == 1 ); + } class derived : public std::ios_base