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]

Re: [PATCH] Fix test03 in ostream_inserter_arith.cc


Paolo Carlini wrote:

> 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?

Sorry! I sent the wrong patch (the very first version, indeed) which does *not*
work (since, f.i., on i686, numeric_limits<short>::digits == 15 *not* 16).

It is much easier to use sizeof()...

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 02:26:42 2002
@@ -311,16 +311,29 @@
   stringbuf strbuf;
   ostream o(&strbuf);

-  o << oct << s << ' ' << hex << s;
-  VERIFY( strbuf.str() == "177777 ffff" ); // Assuming 2byte-shorts
+  o << oct << s << ' ' << hex << s;
+  if (sizeof(short) == 2)
+    VERIFY( strbuf.str() == "177777 ffff" );
+  else // sizeof(short) == 4
+    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 (sizeof(int) == 2)
+    VERIFY( strbuf.str() == "177777 ffff" );
+  else if (sizeof(int) == 4)
+    VERIFY( strbuf.str() == "37777777777 ffffffff" );
+  else // sizeof(int) == 8
+    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 (sizeof(long) == 4)
+    VERIFY( strbuf.str() == "37777777777 ffffffff" );
+  else // sizeof(long) == 8
+    VERIFY( strbuf.str() == "1777777777777777777777 "
+     "ffffffffffffffff" );
   strbuf.str(str_blank);

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



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