Commit 2a4a2f1d by Richard Henderson Committed by Richard Henderson

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
parent 41ff8055
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> 2002-01-30 Paolo Carlini <pcarlini@unitus.it>
* config/locale/numpunct_members_gnu.cc * config/locale/numpunct_members_gnu.cc
......
...@@ -298,48 +298,41 @@ test02() ...@@ -298,48 +298,41 @@ test02()
return 0; return 0;
} }
int template<typename T>
test03() bool
test03_check(T n)
{ {
short s = -1;
int i = -1;
long l = -1;
bool test = true;
const string str_blank;
string str_tmp;
stringbuf strbuf; stringbuf strbuf;
ostream o(&strbuf); ostream o(&strbuf);
const char *expect;
bool test = true;
o << oct << s << ' ' << hex << s; if (numeric_limits<T>::digits + 1 == 16)
if (numeric_limits<short>::digits + 1 == 16) expect = "177777 ffff";
VERIFY( strbuf.str() == "177777 ffff" ); else if (numeric_limits<T>::digits + 1 == 32)
else expect = "37777777777 ffffffff";
VERIFY( strbuf.str() == "37777777777 ffffffff" ); else if (numeric_limits<T>::digits + 1 == 64)
strbuf.str(str_blank); expect = "1777777777777777777777 ffffffffffffffff";
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 else
VERIFY( strbuf.str() == "1777777777777777777777 " expect = "wow, you've got some big numbers here";
"ffffffffffffffff" );
strbuf.str(str_blank);
o << oct << l << ' ' << hex << l; o << oct << n << ' ' << hex << n;
if (numeric_limits<long>::digits + 1 == 32) VERIFY ( strbuf.str() == expect );
VERIFY( strbuf.str() == "37777777777 ffffffff" );
else return test;
VERIFY( strbuf.str() == "1777777777777777777777 " }
"ffffffffffffffff" );
strbuf.str(str_blank);
o << showpos << hex << showbase << 11; int
VERIFY( strbuf.str() == "0xb" ); test03()
{
short s = -1;
int i = -1;
long l = -1;
bool test = true;
VERIFY(test); test &= test03_check (s);
test &= test03_check (i);
test &= test03_check (l);
return 0; return 0;
} }
...@@ -350,12 +343,15 @@ test04() ...@@ -350,12 +343,15 @@ test04()
{ {
stringbuf strbuf1, strbuf2; stringbuf strbuf1, strbuf2;
ostream o1(&strbuf1), o2(&strbuf2); ostream o1(&strbuf1), o2(&strbuf2);
bool test = true;
o1 << hex << showbase << setw(6) << internal << 0xff; o1 << hex << showbase << setw(6) << internal << 0xff;
VERIFY( strbuf1.str() == "0x ff" ); VERIFY( strbuf1.str() == "0x ff" );
// ... vs internal-adjusted const char*-type objects // ... vs internal-adjusted const char*-type objects
o2 << hex << showbase << setw(6) << internal << "0xff"; o2 << hex << showbase << setw(6) << internal << "0xff";
VERIFY( strbuf2.str() == " 0xff" ); VERIFY( strbuf2.str() == " 0xff" );
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment