This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH] Improved fix for ostream_inserter_arith.cc test03
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Wed, 30 Jan 2002 21:24:52 +0100
- Subject: [PATCH] Improved fix for ostream_inserter_arith.cc test03
- References: <Pine.SOL.3.91.1020130121303.17522B-100000@taarna.cygnus.com>
Benjamin Kosnik wrote:
> Might as well do RTH's fix.
Ok, here it is, I could test it only on i686-pc-linux-gnu, but it should be
sufficiently safe not to bother again Andreas and Ulrich to test it on 64 bit
machines
(indeed RTH pre-approved it in this exact form and I'm pretty confident that ia64
at least is ok ;-)
Is it ok?
Paolo.
//////////
2002-01-30 Paolo Carlini <pcarlini@unitus.it>
* testsuite/27_io/ostream_inserter_arith.cc (test03):
Better fix for 32/64 bit architectures, avoiding the
implicit assumption that CHAR_BIT == 8.
diff -urN libstdc++-v3-orig/testsuite/27_io/ostream_inserter_arith.cc
libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc
--- libstdc++-v3-orig/testsuite/27_io/ostream_inserter_arith.cc Mon Jan 28
20:04:34 2002
+++ libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc Tue Jan 29 13:17:35
2002
@@ -312,26 +312,26 @@
ostream o(&strbuf);
o << oct << s << ' ' << hex << s;
- if (sizeof(short) == 2)
+ if (numeric_limits<short>::digits + 1 == 16)
VERIFY( strbuf.str() == "177777 ffff" );
- else // sizeof(short) == 4
+ else
VERIFY( strbuf.str() == "37777777777 ffffffff" );
strbuf.str(str_blank);
o << oct << i << ' ' << hex << i;
- if (sizeof(int) == 2)
+ if (numeric_limits<int>::digits + 1 == 16)
VERIFY( strbuf.str() == "177777 ffff" );
- else if (sizeof(int) == 4)
+ else if (numeric_limits<int>::digits + 1 == 32)
VERIFY( strbuf.str() == "37777777777 ffffffff" );
- else // sizeof(int) == 8
+ else
VERIFY( strbuf.str() == "1777777777777777777777 "
"ffffffffffffffff" );
strbuf.str(str_blank);
o << oct << l << ' ' << hex << l;
- if (sizeof(long) == 4)
+ if (numeric_limits<long>::digits + 1 == 32)
VERIFY( strbuf.str() == "37777777777 ffffffff" );
- else // sizeof(long) == 8
+ else
VERIFY( strbuf.str() == "1777777777777777777777 "
"ffffffffffffffff" );
strbuf.str(str_blank);