From: YongHao Hu Subject: msvcp90/tests: Add more tests to ostream_print_complex_float. Message-Id: <54C73432.30208@gmail.com> Date: Tue, 27 Jan 2015 14:46:10 +0800 --- dlls/msvcp90/tests/ios.c | 81 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 10 deletions(-) diff --git a/dlls/msvcp90/tests/ios.c b/dlls/msvcp90/tests/ios.c index af5a2f0..eecabe7 100644 --- a/dlls/msvcp90/tests/ios.c +++ b/dlls/msvcp90/tests/ios.c @@ -2129,22 +2129,83 @@ static void test_istream_read_double(void) static void test_ostream_print_complex_float(void) { - static const char complex_float_str[] = "(3.14,1.57)"; - basic_stringstream_char ss; basic_string_char pstr; const char *str; - complex_float val = {3.14, 1.57}; + locale lcl, retlcl; + int i; + struct _test_print_complex_float { + complex_float val; + const char *lcl; + streamsize prec; /* set to -1 for default */ + IOSB_fmtflags fmtfl; /* FMTFLAG_scientific, FMTFLAG_fixed */ + const char *str; + } tests[] = { + /* simple cases */ + { {0.123,-4.5}, NULL, -1, 0, "(0.123,-4.5)" }, + { {0.123,-4.5}, NULL, 6, 0, "(0.123,-4.5)" }, + { {0.123,-4.5}, NULL, 0, 0, "(0.123,-4.5)" }, + + /*{ fixed format */ + { {0.123,-4.5}, NULL, 0, FMTFLAG_fixed, "(0,-5)" }, + { {0.123,-4.5}, NULL, -1, FMTFLAG_fixed, "(0.123000,-4.500000)" }, + { {0.123,-4.5}, NULL, 6, FMTFLAG_fixed, "(0.123000,-4.500000)" }, + + /*{ scientific format */ + { {123456.789,-4.5678}, NULL, -1, FMTFLAG_scientific, "(1.234568e+005,-4.567800e+000)" }, + { {123456.789,-4.5678}, NULL, 0, FMTFLAG_scientific, "(1.234568e+005,-4.567800e+000)" }, + { {123456.789,-4.5678}, NULL, 9, FMTFLAG_scientific, "(1.234567891e+005,-4.567800045e+000)" }, + { {123456.789,-4.5678}, "German", 9, FMTFLAG_scientific, "(1,234567891e+005,-4,567800045e+000)" }, + + /*{ different locales */ + { {0.123,-4.5}, "C", -1, 0, "(0.123,-4.5)" }, + { {0.123,-4.5}, "English", -1, 0, "(0.123,-4.5)" }, + { {0.123,-4.5}, "German", -1, 0, "(0,123,-4,5)" }, + + { {123456.789,-4.5678}, "C", -1, 0, "(123457,-4.5678)" }, + { {123456.789,-4.5678}, "English", -1, 0, "(123,457,-4.5678)" }, + { {123456.789,-4.5678}, "German", -1, 0, "(123.457,-4,5678)" }, + + /*{ signs and exponents */ + { { 1.0e-9,-4.1e-3}, NULL, -1, 0, "(1e-009,-0.0041)" }, + { { 1.0e-9,-4.1e-3}, NULL, 9, 0, "(9.99999972e-010,-0.00410000002)" }, + { {-1.0e9,-4.1e-3}, NULL, -1, 0, "(-1e+009,-0.0041)" }, + { {-1.0e9,-4.1e-3}, NULL, 9, 0, "(-1e+009,-0.00410000002)" }, + + { { 1.0e-9,0}, NULL, 0, FMTFLAG_fixed, "(0,0)" }, + { { 1.0e-9,0}, NULL, 6, FMTFLAG_fixed, "(0.000000,0.000000)" }, + { { 1.0e-9,0}, NULL, 9, FMTFLAG_fixed, "(0.000000001,0.000000000)" }, + { {-1.0e9, 0}, NULL, 0, FMTFLAG_fixed, "(-1000000000,0)" }, + { {-1.0e9, 0}, NULL, 6, FMTFLAG_fixed, "(-1000000000.000000,0.000000)" }, + + { {-1.23456789e9,2.3456789e9}, NULL, 0, 0, "(-1.23457e+009,2.34568e+009)" }, + { {-1.23456789e9,2.3456789e9}, NULL, 0, FMTFLAG_fixed, "(-1234567936,2345678848)" }, + { {-1.23456789e9,2.3456789e9}, NULL, 6, FMTFLAG_fixed, "(-1234567936.000000,2345678848.000000)" }, + { {-1.23456789e-9,2.3456789e9}, NULL, 6, FMTFLAG_fixed, "(-0.000000,2345678848.000000)" }, + { {-1.23456789e-9,2.3456789e9}, NULL, 9, FMTFLAG_fixed, "(-0.000000001,2345678848.000000000)" } + }; - call_func1(p_basic_stringstream_char_ctor, &ss); - p_basic_ostream_char_print_complex_float(&ss.base.base2, &val); + for(i=0; i