[PATCH] Fix test03 in ostream_inserter_arith.cc

Paolo Carlini pcarlini@unitus.it
Fri Jan 25 16:21:00 GMT 2002


Hi,

I have trivially generalized the test for the following cases: 16/32 shorts,
16/32/64 ints and 32/64 longs. Ulrich, could you please verify on your 64 bit
mainframes that the fix is correct?

Otherwise, would the patch (tested on i686-pc-linux-gnu) be ok?

Cheers,
Paolo.

////////////

2002-01-26  Paolo Carlini  <pcarlini@unitus.it>

        * testsuite/27_io/ostream_inserter_arith.cc (test03):
        Fix to deal correctly with both 32 bit and 64 bit architectures

--- ostream_inserter_arith.cc.orig Fri Jan 25 22:04:46 2002
+++ ostream_inserter_arith.cc Sat Jan 26 00:49:34 2002
@@ -312,15 +312,28 @@
   ostream o(&strbuf);

   o << oct << s << ' ' << hex << s;
-  VERIFY( strbuf.str() == "177777 ffff" ); // Assuming 2byte-shorts
+  if (numeric_limits<short>::digits == 16)
+    VERIFY( strbuf.str() == "177777 ffff" );
+  else // <short>::digits == 32
+    VERIFY( strbuf.str() == "37777777777 ffffffff" );
   strbuf.str(str_blank);

-  o << oct << i << ' ' << hex << i;
-  VERIFY( strbuf.str() == "37777777777 ffffffff" );
+  o << oct << i << ' ' << hex << i;
+  if (numeric_limits<int>::digits == 16)
+    VERIFY( strbuf.str() == "177777 ffff" );
+  else if (numeric_limits<int>::digits == 32)
+    VERIFY( strbuf.str() == "37777777777 ffffffff" );
+  else // <int>::digits == 64
+    VERIFY( strbuf.str() == "1777777777777777777777 "
+     "ffffffffffffffff" );
   strbuf.str(str_blank);

-  o << oct << l << ' ' << hex << l;
-  VERIFY( strbuf.str() == "37777777777 ffffffff" );
+  o << oct << l << ' ' << hex << l;
+  if (numeric_limits<long>::digits == 32)
+    VERIFY( strbuf.str() == "37777777777 ffffffff" );
+  else // <long>::digits == 64
+    VERIFY( strbuf.str() == "1777777777777777777777 "
+     "ffffffffffffffff" );
   strbuf.str(str_blank);

   o << showpos << hex << showbase << 11;




More information about the Libstdc++ mailing list