This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Test for ios_base::pword and iword


Tests the conditions that existing iword and pword values be valid, despite
failed attempts to allocate all of memory.

2003-03-04  Jerry Quinn  <jlquinn at optonline dot 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.

*** ios_base_storage.cc.~1.5.20.2.~	Fri Feb 28 10:01:37 2003
--- ios_base_storage.cc	Wed Mar  5 00:33:12 2003
***************
*** 55,64 ****
--- 55,69 ----
    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,80 ****
--- 79,107 ----
      }
    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,94 ****
--- 116,141 ----
        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 );
+ 
  }
  
  int main(void)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]