#include #include #include //------------------------------------------------------------------------------ void ostreamBool() { char buf[40]; obufstream ob(buf, sizeof(buf)); bool f = false; bool t = true; ob << t << ',' << f << ',' << setw(2) << t << ',' << left << setw(2) << f; testVerifyStr(buf, "1,0, 1,0 "); ob.init(buf, sizeof(buf)); ob << boolalpha << t << ',' << f << ',' << setw(5) << t; ob << ',' << right << setw(6) << f; testVerifyStr(buf, "true,false,true , false"); } //------------------------------------------------------------------------------ void ostreamChar() { char buf[40]; obufstream ob(buf, sizeof(buf)); char c = 'c'; signed char sc = 's'; unsigned char uc = 'u'; ob <<'l' << c << sc << uc; ob.put('p'); testVerifyStr(buf, "lcsup"); ob.init(buf, sizeof(buf)); ob << 's' << setw(2) << 'r' << 'n' << left << setw(2) << 'l'; ob << 'm' << right << setw(2) << 'e'; testVerifyStr(buf, "s rnl m e"); ob.init(buf, sizeof(buf)); ob << setfill('f') << setw(5) << 'r'; testVerifyStr(buf, "ffffr"); } //------------------------------------------------------------------------------ void ostreamFloat() { char buf[50]; obufstream ob(buf, sizeof(buf)); float f = 9.87654; double d = -123.4567; ob << f <<','; ob << internal << setw(10) << d << ','; ob << setfill('0') << setw(10) << d; testVerifyStr(buf, "9.88,- 123.46,-000123.46"); ob.init(buf, sizeof(buf)); ob << setw(10) << left << d << ',' << showpos << -d << ','; ob << setprecision(0) << d; testVerifyStr(buf, "-123.46000,+123.46,-123"); ob.init(buf, sizeof(buf)); ob << showpoint << d << noshowpoint << ',' << d << ','; ob << setprecision(4) << f << ',' << setprecision(2) << noshowpos << f; testVerifyStr(buf, "-123.,-123,+9.8765,9.88"); } //------------------------------------------------------------------------------ void ostreamNumber() { char buf[50]; obufstream ob(buf, sizeof(buf)); short s = 1; short signed ss = 2; short unsigned su = 3; int i = 4; int signed is = 5; int unsigned iu = 6; long l = 7; long signed ls = 8; long unsigned lu = 9; ob << s << ss << su << i << is << iu << l <