ios_base_storage.cc (test02): Set exception mask.
authorJerry Quinn <jlquinn@optonline.net>
Thu, 6 Mar 2003 22:37:01 +0000 (22:37 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Thu, 6 Mar 2003 22:37:01 +0000 (22:37 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/27_io/ios_base_storage.cc

index 965a33302df7730ecb4d16b3feb23461e7d2f96c..f0bd09abe6ee91ec422120b3080ba90004ab8f22 100644 (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.
index 6af52c0a8c076ec512b7ef6011dcc1ef89cbf486..7033466e69128198fc9f2e51a79cdb71960f8645 100644 (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