aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2002-01-30 16:03:31 -0800
committerRichard Henderson <rth@gcc.gnu.org>2002-01-30 16:03:31 -0800
commit2a4a2f1da2a8155e26508ed70a45e64bc1e3238a (patch)
treebf8ae3fd03c7183ca8f55aaf6a6bce7b447f33ca
parent41ff8055c5caf3e399783c728a6c8a820b2c7a29 (diff)
downloadgcc-2a4a2f1da2a8155e26508ed70a45e64bc1e3238a.zip
gcc-2a4a2f1da2a8155e26508ed70a45e64bc1e3238a.tar.gz
gcc-2a4a2f1da2a8155e26508ed70a45e64bc1e3238a.tar.bz2
ostream_inserter_arith.cc (test03_check): Break out from test03 and templatize.
* testsuite/27_io/ostream_inserter_arith.cc (test03_check): Break out from test03 and templatize. (test03): Use it. From-SVN: r49348
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc64
2 files changed, 36 insertions, 34 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 3412605..117b122 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2002-01-30 Richard Henderson <rth@redhat.com>
+
+ * testsuite/27_io/ostream_inserter_arith.cc (test03_check): Break
+ out from test03 and templatize.
+ (test03): Use it.
+
2002-01-30 Paolo Carlini <pcarlini@unitus.it>
* config/locale/numpunct_members_gnu.cc
diff --git a/libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc b/libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc
index 0025425..bbe2759 100644
--- a/libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc
+++ b/libstdc++-v3/testsuite/27_io/ostream_inserter_arith.cc
@@ -298,6 +298,30 @@ test02()
return 0;
}
+template<typename T>
+bool
+test03_check(T n)
+{
+ stringbuf strbuf;
+ ostream o(&strbuf);
+ const char *expect;
+ bool test = true;
+
+ if (numeric_limits<T>::digits + 1 == 16)
+ expect = "177777 ffff";
+ else if (numeric_limits<T>::digits + 1 == 32)
+ expect = "37777777777 ffffffff";
+ else if (numeric_limits<T>::digits + 1 == 64)
+ expect = "1777777777777777777777 ffffffffffffffff";
+ else
+ expect = "wow, you've got some big numbers here";
+
+ o << oct << n << ' ' << hex << n;
+ VERIFY ( strbuf.str() == expect );
+
+ return test;
+}
+
int
test03()
{
@@ -306,41 +330,10 @@ test03()
long l = -1;
bool test = true;
- const string str_blank;
- string str_tmp;
- stringbuf strbuf;
- ostream o(&strbuf);
-
- o << oct << s << ' ' << hex << s;
- if (numeric_limits<short>::digits + 1 == 16)
- VERIFY( strbuf.str() == "177777 ffff" );
- else
- VERIFY( strbuf.str() == "37777777777 ffffffff" );
- strbuf.str(str_blank);
-
- o << oct << i << ' ' << hex << i;
- if (numeric_limits<int>::digits + 1 == 16)
- VERIFY( strbuf.str() == "177777 ffff" );
- else if (numeric_limits<int>::digits + 1 == 32)
- VERIFY( strbuf.str() == "37777777777 ffffffff" );
- else
- VERIFY( strbuf.str() == "1777777777777777777777 "
- "ffffffffffffffff" );
- strbuf.str(str_blank);
-
- o << oct << l << ' ' << hex << l;
- if (numeric_limits<long>::digits + 1 == 32)
- VERIFY( strbuf.str() == "37777777777 ffffffff" );
- else
- VERIFY( strbuf.str() == "1777777777777777777777 "
- "ffffffffffffffff" );
- strbuf.str(str_blank);
+ test &= test03_check (s);
+ test &= test03_check (i);
+ test &= test03_check (l);
- o << showpos << hex << showbase << 11;
- VERIFY( strbuf.str() == "0xb" );
-
- VERIFY(test);
-
return 0;
}
@@ -350,12 +343,15 @@ test04()
{
stringbuf strbuf1, strbuf2;
ostream o1(&strbuf1), o2(&strbuf2);
+ bool test = true;
+
o1 << hex << showbase << setw(6) << internal << 0xff;
VERIFY( strbuf1.str() == "0x ff" );
// ... vs internal-adjusted const char*-type objects
o2 << hex << showbase << setw(6) << internal << "0xff";
VERIFY( strbuf2.str() == " 0xff" );
+
return 0;
}