diff --git a/libcxx/test/std/utilities/format/format.functions/format_tests.h b/libcxx/test/std/utilities/format/format.functions/format_tests.h --- a/libcxx/test/std/utilities/format/format.functions/format_tests.h +++ b/libcxx/test/std/utilities/format/format.functions/format_tests.h @@ -86,15 +86,16 @@ template auto format(status s, basic_format_context& ctx) -> decltype(ctx.out()) { const char* names[] = {"foo", "bar", "foobar"}; - char buffer[6]; - const char* begin; - const char* end; + char buffer[7]; + const char* begin = names[0]; + const char* end = names[0]; switch (type) { case 0: begin = buffer; buffer[0] = '0'; buffer[1] = 'x'; end = std::to_chars(&buffer[2], std::end(buffer), static_cast(s), 16).ptr; + buffer[6] = '\0'; break; case 1: @@ -102,7 +103,9 @@ buffer[0] = '0'; buffer[1] = 'X'; end = std::to_chars(&buffer[2], std::end(buffer), static_cast(s), 16).ptr; - std::transform(static_cast(&buffer[2]), end, &buffer[2], [](char c) { return std::toupper(c); }); + std::transform(static_cast(&buffer[2]), end, &buffer[2], [](char c) { + return static_cast(std::toupper(c)); }); + buffer[6] = '\0'; break; case 2: @@ -991,8 +994,8 @@ template void format_test_floating_point_hex_lower_case(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // Test whether the hexadecimal letters are the proper case. // The precision is too large for float, so two tests are used. @@ -1021,9 +1024,15 @@ check.template operator()<"answer is '{:^<6a}'">(SV("answer is 'nan^^^'"), nan_pos); check.template operator()<"answer is '{:^^6a}'">(SV("answer is '^nan^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7a}'">(SV("answer is '000-nan'"), nan_neg); check.template operator()<"answer is '{:0<7a}'">(SV("answer is '-nan000'"), nan_neg); check.template operator()<"answer is '{:0^7a}'">(SV("answer is '0-nan00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12a}'">(SV("answer is '000-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:0<12a}'">(SV("answer is '-nan(ind)000'"), nan_neg); + check.template operator()<"answer is '{:0^12a}'">(SV("answer is '0-nan(ind)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>07a}'">(SV("answer is ' 1p-2'"), F(0.25)); @@ -1057,10 +1066,17 @@ check.template operator()<"answer is '{:+a}'">(SV("answer is '+nan'"), nan_pos); check.template operator()<"answer is '{: a}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:a}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:-a}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:+a}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{: a}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:a}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-a}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+a}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: a}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** alternate form *** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -1075,7 +1091,11 @@ check.template operator()<"answer is '{:#a}'">(SV("answer is '-inf'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#a}'">(SV("answer is 'nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#a}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:#a}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:04a}'">(SV("answer is '1p-5'"), 0.03125); @@ -1102,10 +1122,17 @@ check.template operator()<"answer is '{:+010a}'">(SV("answer is ' +nan'"), nan_pos); check.template operator()<"answer is '{: 010a}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010a}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:-010a}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:+010a}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{: 010a}'">(SV("answer is ' -nan'"), nan_neg); +#else + check.template operator()<"answer is '{:010a}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-010a}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+010a}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: 010a}'">(SV("answer is ' -nan(ind)'"), nan_neg); +#endif // *** precision *** // See format_test_floating_point_hex_lower_case_precision @@ -1116,8 +1143,8 @@ template void format_test_floating_point_hex_upper_case(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // Test whether the hexadecimal letters are the proper case. // The precision is too large for float, so two tests are used. @@ -1146,9 +1173,15 @@ check.template operator()<"answer is '{:^<6A}'">(SV("answer is 'NAN^^^'"), nan_pos); check.template operator()<"answer is '{:^^6A}'">(SV("answer is '^NAN^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7A}'">(SV("answer is '000-NAN'"), nan_neg); check.template operator()<"answer is '{:0<7A}'">(SV("answer is '-NAN000'"), nan_neg); check.template operator()<"answer is '{:0^7A}'">(SV("answer is '0-NAN00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12A}'">(SV("answer is '000-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:0<12A}'">(SV("answer is '-NAN(IND)000'"), nan_neg); + check.template operator()<"answer is '{:0^12A}'">(SV("answer is '0-NAN(IND)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>07A}'">(SV("answer is ' 1P-2'"), F(0.25)); @@ -1182,10 +1215,17 @@ check.template operator()<"answer is '{:+A}'">(SV("answer is '+NAN'"), nan_pos); check.template operator()<"answer is '{: A}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:A}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:-A}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:+A}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{: A}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:A}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-A}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+A}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: A}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** alternate form *** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -1200,7 +1240,11 @@ check.template operator()<"answer is '{:#A}'">(SV("answer is '-INF'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#A}'">(SV("answer is 'NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#A}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:#A}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:04A}'">(SV("answer is '1P-5'"), 0.03125); @@ -1227,10 +1271,17 @@ check.template operator()<"answer is '{:+010A}'">(SV("answer is ' +NAN'"), nan_pos); check.template operator()<"answer is '{: 010A}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010A}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:-010A}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:+010A}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{: 010A}'">(SV("answer is ' -NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:010A}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-010A}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+010A}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: 010A}'">(SV("answer is ' -NAN(IND)'"), nan_neg); +#endif // *** precision *** // See format_test_floating_point_hex_upper_case_precision @@ -1241,8 +1292,8 @@ template void format_test_floating_point_hex_lower_case_precision(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:14.6a}'">(SV("answer is ' 1.000000p-2'"), F(0.25)); @@ -1266,9 +1317,15 @@ check.template operator()<"answer is '{:^<6.6a}'">(SV("answer is 'nan^^^'"), nan_pos); check.template operator()<"answer is '{:^^6.6a}'">(SV("answer is '^nan^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7.6a}'">(SV("answer is '000-nan'"), nan_neg); check.template operator()<"answer is '{:0<7.6a}'">(SV("answer is '-nan000'"), nan_neg); check.template operator()<"answer is '{:0^7.6a}'">(SV("answer is '0-nan00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12.11a}'">(SV("answer is '000-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:0<12.11a}'">(SV("answer is '-nan(ind)000'"), nan_neg); + check.template operator()<"answer is '{:0^12.11a}'">(SV("answer is '0-nan(ind)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>014.6a}'">(SV("answer is ' 1.000000p-2'"), F(0.25)); @@ -1302,10 +1359,17 @@ check.template operator()<"answer is '{:+.6a}'">(SV("answer is '+nan'"), nan_pos); check.template operator()<"answer is '{: .6a}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:.6a}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:-.6a}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:+.6a}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{: .6a}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:.6a}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-.6a}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+.6a}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: .6a}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** alternate form *** check.template operator()<"answer is '{:#.6a}'">(SV("answer is '1.400000p+1'"), F(2.5)); @@ -1314,7 +1378,11 @@ check.template operator()<"answer is '{:#.6a}'">(SV("answer is '-inf'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#.6a}'">(SV("answer is 'nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#.6a}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:#.6a}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:011.6a}'">(SV("answer is '1.000000p-5'"), 0.03125); @@ -1344,10 +1412,17 @@ check.template operator()<"answer is '{:+010.6a}'">(SV("answer is ' +nan'"), nan_pos); check.template operator()<"answer is '{: 010.6a}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010.6a}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:-010.6a}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:+010.6a}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{: 010.6a}'">(SV("answer is ' -nan'"), nan_neg); +#else + check.template operator()<"answer is '{:010.6a}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-010.6a}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+010.6a}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: 010.6a}'">(SV("answer is ' -nan(ind)'"), nan_neg); +#endif // *** locale-specific form *** // See locale-specific_form.pass.cpp @@ -1355,8 +1430,8 @@ template void format_test_floating_point_hex_upper_case_precision(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:14.6A}'">(SV("answer is ' 1.000000P-2'"), F(0.25)); @@ -1380,9 +1455,15 @@ check.template operator()<"answer is '{:^<6.6A}'">(SV("answer is 'NAN^^^'"), nan_pos); check.template operator()<"answer is '{:^^6.6A}'">(SV("answer is '^NAN^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7.6A}'">(SV("answer is '000-NAN'"), nan_neg); check.template operator()<"answer is '{:0<7.6A}'">(SV("answer is '-NAN000'"), nan_neg); check.template operator()<"answer is '{:0^7.6A}'">(SV("answer is '0-NAN00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12.11A}'">(SV("answer is '000-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:0<12.11A}'">(SV("answer is '-NAN(IND)000'"), nan_neg); + check.template operator()<"answer is '{:0^12.11A}'">(SV("answer is '0-NAN(IND)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>014.6A}'">(SV("answer is ' 1.000000P-2'"), F(0.25)); @@ -1416,10 +1497,17 @@ check.template operator()<"answer is '{:+.6A}'">(SV("answer is '+NAN'"), nan_pos); check.template operator()<"answer is '{: .6A}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:.6A}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:-.6A}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:+.6A}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{: .6A}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:.6A}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-.6A}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+.6A}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: .6A}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** alternate form *** check.template operator()<"answer is '{:#.6A}'">(SV("answer is '1.400000P+1'"), F(2.5)); @@ -1428,7 +1516,11 @@ check.template operator()<"answer is '{:#.6A}'">(SV("answer is '-INF'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#.6A}'">(SV("answer is 'NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#.6A}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:#.6A}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:011.6A}'">(SV("answer is '1.000000P-5'"), 0.03125); @@ -1458,10 +1550,17 @@ check.template operator()<"answer is '{:+010.6A}'">(SV("answer is ' +NAN'"), nan_pos); check.template operator()<"answer is '{: 010.6A}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010.6A}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:-010.6A}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:+010.6A}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{: 010.6A}'">(SV("answer is ' -NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:010.6A}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-010.6A}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+010.6A}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: 010.6A}'">(SV("answer is ' -NAN(IND)'"), nan_neg); +#endif // *** locale-specific form *** // See locale-specific_form.pass.cpp @@ -1469,8 +1568,8 @@ template void format_test_floating_point_scientific_lower_case(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:15e}'">(SV("answer is ' 2.500000e-01'"), F(0.25)); @@ -1494,9 +1593,15 @@ check.template operator()<"answer is '{:^<6e}'">(SV("answer is 'nan^^^'"), nan_pos); check.template operator()<"answer is '{:^^6e}'">(SV("answer is '^nan^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7e}'">(SV("answer is '000-nan'"), nan_neg); check.template operator()<"answer is '{:0<7e}'">(SV("answer is '-nan000'"), nan_neg); check.template operator()<"answer is '{:0^7e}'">(SV("answer is '0-nan00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12e}'">(SV("answer is '000-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:0<12e}'">(SV("answer is '-nan(ind)000'"), nan_neg); + check.template operator()<"answer is '{:0^12e}'">(SV("answer is '0-nan(ind)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>015e}'">(SV("answer is ' 2.500000e-01'"), F(0.25)); @@ -1530,10 +1635,17 @@ check.template operator()<"answer is '{:+e}'">(SV("answer is '+nan'"), nan_pos); check.template operator()<"answer is '{: e}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:e}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:-e}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:+e}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{: e}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:e}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-e}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+e}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: e}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** alternate form ** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -1547,7 +1659,11 @@ check.template operator()<"answer is '{:#e}'">(SV("answer is '-inf'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#e}'">(SV("answer is 'nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#e}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:#e}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:07e}'">(SV("answer is '3.125000e-02'"), 0.03125); @@ -1575,10 +1691,17 @@ check.template operator()<"answer is '{:+010e}'">(SV("answer is ' +nan'"), nan_pos); check.template operator()<"answer is '{: 010e}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010e}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:-010e}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:+010e}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{: 010e}'">(SV("answer is ' -nan'"), nan_neg); +#else + check.template operator()<"answer is '{:010e}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-010e}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+010e}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: 010e}'">(SV("answer is ' -nan(ind)'"), nan_neg); +#endif // *** precision *** check.template operator()<"answer is '{:.0e}'">(SV("answer is '3e-02'"), 0.03125); @@ -1592,8 +1715,8 @@ template void format_test_floating_point_scientific_upper_case(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:15E}'">(SV("answer is ' 2.500000E-01'"), F(0.25)); @@ -1617,9 +1740,15 @@ check.template operator()<"answer is '{:^<6E}'">(SV("answer is 'NAN^^^'"), nan_pos); check.template operator()<"answer is '{:^^6E}'">(SV("answer is '^NAN^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7E}'">(SV("answer is '000-NAN'"), nan_neg); check.template operator()<"answer is '{:0<7E}'">(SV("answer is '-NAN000'"), nan_neg); check.template operator()<"answer is '{:0^7E}'">(SV("answer is '0-NAN00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12E}'">(SV("answer is '000-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:0<12E}'">(SV("answer is '-NAN(IND)000'"), nan_neg); + check.template operator()<"answer is '{:0^12E}'">(SV("answer is '0-NAN(IND)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>015E}'">(SV("answer is ' 2.500000E-01'"), F(0.25)); @@ -1653,10 +1782,17 @@ check.template operator()<"answer is '{:+E}'">(SV("answer is '+NAN'"), nan_pos); check.template operator()<"answer is '{: E}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:E}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:-E}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:+E}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{: E}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:E}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-E}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+E}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: E}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** alternate form ** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -1670,7 +1806,11 @@ check.template operator()<"answer is '{:#E}'">(SV("answer is '-INF'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#E}'">(SV("answer is 'NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#E}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:#E}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:07E}'">(SV("answer is '3.125000E-02'"), 0.03125); @@ -1698,10 +1838,17 @@ check.template operator()<"answer is '{:+010E}'">(SV("answer is ' +NAN'"), nan_pos); check.template operator()<"answer is '{: 010E}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010E}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:-010E}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:+010E}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{: 010E}'">(SV("answer is ' -NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:010E}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-010E}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+010E}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: 010E}'">(SV("answer is ' -NAN(IND)'"), nan_neg); +#endif // *** precision *** check.template operator()<"answer is '{:.0E}'">(SV("answer is '3E-02'"), 0.03125); @@ -1715,8 +1862,8 @@ template void format_test_floating_point_fixed_lower_case(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:11f}'">(SV("answer is ' 0.250000'"), F(0.25)); @@ -1740,9 +1887,15 @@ check.template operator()<"answer is '{:^<6f}'">(SV("answer is 'nan^^^'"), nan_pos); check.template operator()<"answer is '{:^^6f}'">(SV("answer is '^nan^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7f}'">(SV("answer is '000-nan'"), nan_neg); check.template operator()<"answer is '{:0<7f}'">(SV("answer is '-nan000'"), nan_neg); check.template operator()<"answer is '{:0^7f}'">(SV("answer is '0-nan00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12f}'">(SV("answer is '000-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:0<12f}'">(SV("answer is '-nan(ind)000'"), nan_neg); + check.template operator()<"answer is '{:0^12f}'">(SV("answer is '0-nan(ind)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>011f}'">(SV("answer is ' 0.250000'"), F(0.25)); @@ -1776,10 +1929,17 @@ check.template operator()<"answer is '{:+f}'">(SV("answer is '+nan'"), nan_pos); check.template operator()<"answer is '{: f}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:f}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:-f}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:+f}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{: f}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:f}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-f}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+f}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: f}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** alternate form ** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -1793,7 +1953,11 @@ check.template operator()<"answer is '{:#f}'">(SV("answer is '-inf'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#f}'">(SV("answer is 'nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#f}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:#f}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:07f}'">(SV("answer is '0.031250'"), 0.03125); @@ -1821,10 +1985,17 @@ check.template operator()<"answer is '{:+010f}'">(SV("answer is ' +nan'"), nan_pos); check.template operator()<"answer is '{: 010f}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010f}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:-010f}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:+010f}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{: 010f}'">(SV("answer is ' -nan'"), nan_neg); +#else + check.template operator()<"answer is '{:010f}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-010f}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+010f}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: 010f}'">(SV("answer is ' -nan(ind)'"), nan_neg); +#endif // *** precision *** check.template operator()<"answer is '{:.0f}'">(SV("answer is '0'"), 0.03125); @@ -1838,8 +2009,8 @@ template void format_test_floating_point_fixed_upper_case(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:11F}'">(SV("answer is ' 0.250000'"), F(0.25)); @@ -1863,9 +2034,15 @@ check.template operator()<"answer is '{:^<6F}'">(SV("answer is 'NAN^^^'"), nan_pos); check.template operator()<"answer is '{:^^6F}'">(SV("answer is '^NAN^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7F}'">(SV("answer is '000-NAN'"), nan_neg); check.template operator()<"answer is '{:0<7F}'">(SV("answer is '-NAN000'"), nan_neg); check.template operator()<"answer is '{:0^7F}'">(SV("answer is '0-NAN00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12F}'">(SV("answer is '000-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:0<12F}'">(SV("answer is '-NAN(IND)000'"), nan_neg); + check.template operator()<"answer is '{:0^12F}'">(SV("answer is '0-NAN(IND)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>011F}'">(SV("answer is ' 0.250000'"), F(0.25)); @@ -1899,10 +2076,17 @@ check.template operator()<"answer is '{:+F}'">(SV("answer is '+NAN'"), nan_pos); check.template operator()<"answer is '{: F}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:F}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:-F}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:+F}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{: F}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:F}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-F}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+F}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: F}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** alternate form ** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -1916,7 +2100,11 @@ check.template operator()<"answer is '{:#F}'">(SV("answer is '-INF'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#F}'">(SV("answer is 'NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#F}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:#F}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:07F}'">(SV("answer is '0.031250'"), 0.03125); @@ -1944,10 +2132,17 @@ check.template operator()<"answer is '{:+010F}'">(SV("answer is ' +NAN'"), nan_pos); check.template operator()<"answer is '{: 010F}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010F}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:-010F}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:+010F}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{: 010F}'">(SV("answer is ' -NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:010F}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-010F}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+010F}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: 010F}'">(SV("answer is ' -NAN(IND)'"), nan_neg); +#endif // *** precision *** check.template operator()<"answer is '{:.0F}'">(SV("answer is '0'"), 0.03125); @@ -1961,8 +2156,8 @@ template void format_test_floating_point_general_lower_case(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:7g}'">(SV("answer is ' 0.25'"), F(0.25)); @@ -1986,9 +2181,15 @@ check.template operator()<"answer is '{:^<6g}'">(SV("answer is 'nan^^^'"), nan_pos); check.template operator()<"answer is '{:^^6g}'">(SV("answer is '^nan^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7g}'">(SV("answer is '000-nan'"), nan_neg); check.template operator()<"answer is '{:0<7g}'">(SV("answer is '-nan000'"), nan_neg); check.template operator()<"answer is '{:0^7g}'">(SV("answer is '0-nan00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12g}'">(SV("answer is '000-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:0<12g}'">(SV("answer is '-nan(ind)000'"), nan_neg); + check.template operator()<"answer is '{:0^12g}'">(SV("answer is '0-nan(ind)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>07g}'">(SV("answer is ' 0.25'"), F(0.25)); @@ -2022,10 +2223,17 @@ check.template operator()<"answer is '{:+g}'">(SV("answer is '+nan'"), nan_pos); check.template operator()<"answer is '{: g}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:g}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:-g}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:+g}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{: g}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:g}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-g}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+g}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: g}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** alternate form ** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -2039,7 +2247,11 @@ check.template operator()<"answer is '{:#g}'">(SV("answer is '-inf'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#g}'">(SV("answer is 'nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#g}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:#g}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:06g}'">(SV("answer is '0.03125'"), 0.03125); @@ -2067,10 +2279,17 @@ check.template operator()<"answer is '{:+010g}'">(SV("answer is ' +nan'"), nan_pos); check.template operator()<"answer is '{: 010g}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010g}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:-010g}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:+010g}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{: 010g}'">(SV("answer is ' -nan'"), nan_neg); +#else + check.template operator()<"answer is '{:010g}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-010g}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+010g}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: 010g}'">(SV("answer is ' -nan(ind)'"), nan_neg); +#endif // *** precision *** check.template operator()<"answer is '{:.0g}'">(SV("answer is '0.03'"), 0.03125); @@ -2087,8 +2306,8 @@ template void format_test_floating_point_general_upper_case(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:7G}'">(SV("answer is ' 0.25'"), F(0.25)); @@ -2112,9 +2331,15 @@ check.template operator()<"answer is '{:^<6G}'">(SV("answer is 'NAN^^^'"), nan_pos); check.template operator()<"answer is '{:^^6G}'">(SV("answer is '^NAN^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7G}'">(SV("answer is '000-NAN'"), nan_neg); check.template operator()<"answer is '{:0<7G}'">(SV("answer is '-NAN000'"), nan_neg); check.template operator()<"answer is '{:0^7G}'">(SV("answer is '0-NAN00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12G}'">(SV("answer is '000-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:0<12G}'">(SV("answer is '-NAN(IND)000'"), nan_neg); + check.template operator()<"answer is '{:0^12G}'">(SV("answer is '0-NAN(IND)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>07G}'">(SV("answer is ' 0.25'"), F(0.25)); @@ -2148,10 +2373,17 @@ check.template operator()<"answer is '{:+G}'">(SV("answer is '+NAN'"), nan_pos); check.template operator()<"answer is '{: G}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:G}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:-G}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{:+G}'">(SV("answer is '-NAN'"), nan_neg); check.template operator()<"answer is '{: G}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:G}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-G}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+G}'">(SV("answer is '-NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: G}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** alternate form ** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -2165,7 +2397,11 @@ check.template operator()<"answer is '{:#G}'">(SV("answer is '-INF'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#G}'">(SV("answer is 'NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#G}'">(SV("answer is '-NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:#G}'">(SV("answer is '-NAN(IND)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:06G}'">(SV("answer is '0.03125'"), 0.03125); @@ -2193,10 +2429,17 @@ check.template operator()<"answer is '{:+010G}'">(SV("answer is ' +NAN'"), nan_pos); check.template operator()<"answer is '{: 010G}'">(SV("answer is ' NAN'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010G}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:-010G}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{:+010G}'">(SV("answer is ' -NAN'"), nan_neg); check.template operator()<"answer is '{: 010G}'">(SV("answer is ' -NAN'"), nan_neg); +#else + check.template operator()<"answer is '{:010G}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:-010G}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{:+010G}'">(SV("answer is ' -NAN(IND)'"), nan_neg); + check.template operator()<"answer is '{: 010G}'">(SV("answer is ' -NAN(IND)'"), nan_neg); +#endif // *** precision *** check.template operator()<"answer is '{:.0G}'">(SV("answer is '0.03'"), 0.03125); @@ -2213,8 +2456,8 @@ template void format_test_floating_point_default(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:7}'">(SV("answer is ' 0.25'"), F(0.25)); @@ -2238,9 +2481,15 @@ check.template operator()<"answer is '{:^<6}'">(SV("answer is 'nan^^^'"), nan_pos); check.template operator()<"answer is '{:^^6}'">(SV("answer is '^nan^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7}'">(SV("answer is '000-nan'"), nan_neg); check.template operator()<"answer is '{:0<7}'">(SV("answer is '-nan000'"), nan_neg); check.template operator()<"answer is '{:0^7}'">(SV("answer is '0-nan00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12}'">(SV("answer is '000-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:0<12}'">(SV("answer is '-nan(ind)000'"), nan_neg); + check.template operator()<"answer is '{:0^12}'">(SV("answer is '0-nan(ind)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>07}'">(SV("answer is ' 0.25'"), F(0.25)); @@ -2274,10 +2523,17 @@ check.template operator()<"answer is '{:+}'">(SV("answer is '+nan'"), nan_pos); check.template operator()<"answer is '{: }'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:-}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:+}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{: }'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: }'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** alternate form *** check.template operator()<"answer is '{:#}'">(SV("answer is '0.'"), F(0)); @@ -2287,7 +2543,11 @@ check.template operator()<"answer is '{:#}'">(SV("answer is '-inf'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#}'">(SV("answer is 'nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:#}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:07}'">(SV("answer is '0.03125'"), 0.03125); @@ -2315,10 +2575,17 @@ check.template operator()<"answer is '{:+010}'">(SV("answer is ' +nan'"), nan_pos); check.template operator()<"answer is '{: 010}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:-010}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:+010}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{: 010}'">(SV("answer is ' -nan'"), nan_neg); +#else + check.template operator()<"answer is '{:010}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-010}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+010}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: 010}'">(SV("answer is ' -nan(ind)'"), nan_neg); +#endif // *** precision *** // See format_test_floating_point_default_precision @@ -2330,8 +2597,8 @@ template void format_test_floating_point_default_precision(TestFunction check) { - auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" - auto nan_neg = std::copysign(nan_pos, -1.0); // "-nan" + auto nan_pos = std::numeric_limits::quiet_NaN(); // "nan" + auto nan_neg = std::copysign(nan_pos, static_cast(-1.0)); // "-nan" // *** align-fill & width *** check.template operator()<"answer is '{:7.6}'">(SV("answer is ' 0.25'"), F(0.25)); @@ -2355,9 +2622,15 @@ check.template operator()<"answer is '{:^<6.6}'">(SV("answer is 'nan^^^'"), nan_pos); check.template operator()<"answer is '{:^^6.6}'">(SV("answer is '^nan^^'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:0>7.6}'">(SV("answer is '000-nan'"), nan_neg); check.template operator()<"answer is '{:0<7.6}'">(SV("answer is '-nan000'"), nan_neg); check.template operator()<"answer is '{:0^7.6}'">(SV("answer is '0-nan00'"), nan_neg); +#else + check.template operator()<"answer is '{:0>12.6}'">(SV("answer is '000-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:0<12.6}'">(SV("answer is '-nan(ind)000'"), nan_neg); + check.template operator()<"answer is '{:0^12.6}'">(SV("answer is '0-nan(ind)00'"), nan_neg); +#endif // Test whether zero padding is ignored check.template operator()<"answer is '{:>07.6}'">(SV("answer is ' 0.25'"), F(0.25)); @@ -2391,10 +2664,17 @@ check.template operator()<"answer is '{:+.6}'">(SV("answer is '+nan'"), nan_pos); check.template operator()<"answer is '{: .6}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:.6}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:-.6}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{:+.6}'">(SV("answer is '-nan'"), nan_neg); check.template operator()<"answer is '{: .6}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:.6}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-.6}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+.6}'">(SV("answer is '-nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: .6}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** alternate form ** // When precision is zero there's no decimal point except when the alternate form is specified. @@ -2408,7 +2688,11 @@ check.template operator()<"answer is '{:#.6}'">(SV("answer is '-inf'"), -std::numeric_limits::infinity()); check.template operator()<"answer is '{:#.6}'">(SV("answer is 'nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:#.6}'">(SV("answer is '-nan'"), nan_neg); +#else + check.template operator()<"answer is '{:#.6}'">(SV("answer is '-nan(ind)'"), nan_neg); +#endif // *** zero-padding & width *** check.template operator()<"answer is '{:06.6}'">(SV("answer is '0.03125'"), 0.03125); @@ -2436,10 +2720,17 @@ check.template operator()<"answer is '{:+010.6}'">(SV("answer is ' +nan'"), nan_pos); check.template operator()<"answer is '{: 010.6}'">(SV("answer is ' nan'"), nan_pos); +#ifndef _MSVC_STL_VERSION check.template operator()<"answer is '{:010.6}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:-010.6}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{:+010.6}'">(SV("answer is ' -nan'"), nan_neg); check.template operator()<"answer is '{: 010.6}'">(SV("answer is ' -nan'"), nan_neg); +#else + check.template operator()<"answer is '{:010.6}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:-010.6}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{:+010.6}'">(SV("answer is ' -nan(ind)'"), nan_neg); + check.template operator()<"answer is '{: 010.6}'">(SV("answer is ' -nan(ind)'"), nan_neg); +#endif // *** precision *** check.template operator()<"answer is '{:.0}'">(SV("answer is '0.03'"), 0.03125);