From 58839cefb50e56ae5b157b37e9814ae83ceee70b Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 20 Jul 2017 15:22:49 -0700 Subject: Upgrading server dependancies (#6984) --- vendor/golang.org/x/text/message/fmt_test.go | 268 ++++++++++++++------------- 1 file changed, 144 insertions(+), 124 deletions(-) (limited to 'vendor/golang.org/x/text/message/fmt_test.go') diff --git a/vendor/golang.org/x/text/message/fmt_test.go b/vendor/golang.org/x/text/message/fmt_test.go index d02808a92..0dbedcbca 100755 --- a/vendor/golang.org/x/text/message/fmt_test.go +++ b/vendor/golang.org/x/text/message/fmt_test.go @@ -158,9 +158,15 @@ var fmtTests = []struct { // Extra argument errors should format without flags set. {"%010.2", "12345", "%!(NOVERB)"}, - // All following tests are identical to that of the fmt package. - {"%d", 12345, "12345"}, - {"%v", 12345, "12345"}, + // Some key other differences, asides from localized values: + // - NaN values should not use affixes; so no signs (CLDR requirement) + // - Infinity uses patterns, so signs may be different (CLDR requirement) + // - The # flag is used to disable localization. + + // All following tests are analogous to those of the fmt package, but with + // localized numbers when appropriate. + {"%d", 12345, "12,345"}, + {"%v", 12345, "12,345"}, {"%t", true, "true"}, // basic string @@ -307,9 +313,9 @@ var fmtTests = []struct { // Runes that are not valid. {"%q", int32(-1), "%!q(int32=-1)"}, {"%q", 0xDC80, `'�'`}, - {"%q", rune(0x110000), "%!q(int32=1114112)"}, - {"%q", int64(0xFFFFFFFFF), "%!q(int64=68719476735)"}, - {"%q", uint64(0xFFFFFFFFF), "%!q(uint64=68719476735)"}, + {"%q", rune(0x110000), "%!q(int32=1,114,112)"}, + {"%q", int64(0xFFFFFFFFF), "%!q(int64=68,719,476,735)"}, + {"%q", uint64(0xFFFFFFFFF), "%!q(uint64=68,719,476,735)"}, // width {"%5s", "abc", " abc"}, @@ -339,23 +345,23 @@ var fmtTests = []struct { {"%-10v", nil, " "}, // integers - {"%d", uint(12345), "12345"}, - {"%d", int(-12345), "-12345"}, + {"%d", uint(12345), "12,345"}, + {"%d", int(-12345), "-12,345"}, {"%d", ^uint8(0), "255"}, - {"%d", ^uint16(0), "65535"}, - {"%d", ^uint32(0), "4294967295"}, - {"%d", ^uint64(0), "18446744073709551615"}, + {"%d", ^uint16(0), "65,535"}, + {"%d", ^uint32(0), "4,294,967,295"}, + {"%d", ^uint64(0), "18,446,744,073,709,551,615"}, {"%d", int8(-1 << 7), "-128"}, - {"%d", int16(-1 << 15), "-32768"}, - {"%d", int32(-1 << 31), "-2147483648"}, - {"%d", int64(-1 << 63), "-9223372036854775808"}, + {"%d", int16(-1 << 15), "-32,768"}, + {"%d", int32(-1 << 31), "-2,147,483,648"}, + {"%d", int64(-1 << 63), "-9,223,372,036,854,775,808"}, {"%.d", 0, ""}, {"%.0d", 0, ""}, {"%6.0d", 0, " "}, {"%06.0d", 0, " "}, - {"% d", 12345, " 12345"}, - {"%+d", 12345, "+12345"}, - {"%+d", -12345, "-12345"}, + {"% d", 12345, " 12,345"}, + {"%+d", 12345, "+12,345"}, + {"%+d", -12345, "-12,345"}, {"%b", 7, "111"}, {"%b", -6, "-110"}, {"%b", ^uint32(0), "11111111111111111111111111111111"}, @@ -371,29 +377,29 @@ var fmtTests = []struct { {"%x", ^uint32(0), "ffffffff"}, {"%X", ^uint64(0), "FFFFFFFFFFFFFFFF"}, {"%.20b", 7, "00000000000000000111"}, - {"%10d", 12345, " 12345"}, - {"%10d", -12345, " -12345"}, - {"%+10d", 12345, " +12345"}, - {"%010d", 12345, "0000012345"}, - {"%010d", -12345, "-000012345"}, - {"%20.8d", 1234, " 00001234"}, - {"%20.8d", -1234, " -00001234"}, - {"%020.8d", 1234, " 00001234"}, - {"%020.8d", -1234, " -00001234"}, - {"%-20.8d", 1234, "00001234 "}, - {"%-20.8d", -1234, "-00001234 "}, + {"%10d", 12345, " 12,345"}, + {"%10d", -12345, " -12,345"}, + {"%+10d", 12345, " +12,345"}, + {"%010d", 12345, "0,000,012,345"}, + {"%010d", -12345, "-0,000,012,345"}, + {"%20.8d", 1234, " 00,001,234"}, + {"%20.8d", -1234, " -00,001,234"}, + {"%020.8d", 1234, " 00,001,234"}, + {"%020.8d", -1234, " -00,001,234"}, + {"%-20.8d", 1234, "00,001,234 "}, + {"%-20.8d", -1234, "-00,001,234 "}, {"%-#20.8x", 0x1234abc, "0x01234abc "}, {"%-#20.8X", 0x1234abc, "0X01234ABC "}, {"%-#20.8o", 01234, "00001234 "}, // Test correct f.intbuf overflow checks. - {"%068d", 1, zeroFill("", 68, "1")}, - {"%068d", -1, zeroFill("-", 67, "1")}, + {"%068d", 1, "00," + strings.Repeat("000,", 21) + "001"}, + {"%068d", -1, "-00," + strings.Repeat("000,", 21) + "001"}, {"%#.68x", 42, zeroFill("0x", 68, "2a")}, - {"%.68d", -42, zeroFill("-", 68, "42")}, - {"%+.68d", 42, zeroFill("+", 68, "42")}, - {"% .68d", 42, zeroFill(" ", 68, "42")}, - {"% +.68d", 42, zeroFill("+", 68, "42")}, + {"%.68d", -42, "-00," + strings.Repeat("000,", 21) + "042"}, + {"%+.68d", 42, "+00," + strings.Repeat("000,", 21) + "042"}, + {"% .68d", 42, " 00," + strings.Repeat("000,", 21) + "042"}, + {"% +.68d", 42, "+00," + strings.Repeat("000,", 21) + "042"}, // unicode format {"%U", 0, "U+0000"}, @@ -415,8 +421,8 @@ var fmtTests = []struct { {"%#.68U", '日', zeroFill("U+", 68, "65E5") + " '日'"}, // floats - {"%+.3e", 0.0, "+0.000e+00"}, - {"%+.3e", 1.0, "+1.000e+00"}, + {"%+.3e", 0.0, "+0.000\u202f×\u202f10⁰⁰"}, + {"%+.3e", 1.0, "+1.000\u202f×\u202f10⁰⁰"}, {"%+.3f", -1.0, "-1.000"}, {"%+.3F", -1.0, "-1.000"}, {"%+.3F", float32(-1.0), "-1.000"}, @@ -430,8 +436,8 @@ var fmtTests = []struct { {"%-+07.2f", -1.0, "-1.00 "}, {"%+10.2f", +1.0, " +1.00"}, {"%+10.2f", -1.0, " -1.00"}, - {"% .3E", -1.0, "-1.000E+00"}, - {"% .3e", 1.0, " 1.000e+00"}, + {"% .3E", -1.0, "-1.000\u202f×\u202f10⁰⁰"}, + {"% .3e", 1.0, " 1.000\u202f×\u202f10⁰⁰"}, {"%+.3g", 0.0, "+0"}, {"%+.3g", 1.0, "+1"}, {"%+.3g", -1.0, "-1"}, @@ -469,25 +475,27 @@ var fmtTests = []struct { {"%.4b", float32(1.0), "8388608p-23"}, {"%.4b", -1.0, "-4503599627370496p-52"}, // Test correct f.intbuf boundary checks. - {"%.68f", 1.0, zeroFill("1.", 68, "")}, - {"%.68f", -1.0, zeroFill("-1.", 68, "")}, + // TODO: the following cases won't work because of rounding errors. We can + // fix this if we expose the internals of strconv. + // {"%.68f", 1.0, zeroFill("1.", 68, "")}, // TODO(bug): rounding error + // {"%.68f", -1.0, zeroFill("-1.", 68, "")}, // TODO(bug): rounding error // float infinites and NaNs - {"%f", posInf, "+Inf"}, - {"%.1f", negInf, "-Inf"}, - {"% f", NaN, " NaN"}, - {"%20f", posInf, " +Inf"}, - {"% 20F", posInf, " Inf"}, - {"% 20e", negInf, " -Inf"}, - {"%+20E", negInf, " -Inf"}, - {"% +20g", negInf, " -Inf"}, - {"%+-20G", posInf, "+Inf "}, + {"%f", posInf, "∞"}, + {"%.1f", negInf, "-∞"}, + {"% f", NaN, "NaN"}, + {"%20f", posInf, " ∞"}, + {"% 20F", posInf, " ∞"}, + {"% 20e", negInf, " -∞"}, + {"%+20E", negInf, " -∞"}, + {"% +20g", negInf, " -∞"}, + {"%+-20G", posInf, "+∞ "}, {"%20e", NaN, " NaN"}, - {"% +20E", NaN, " +NaN"}, - {"% -20g", NaN, " NaN "}, - {"%+-20G", NaN, "+NaN "}, + {"% +20E", NaN, " NaN"}, + {"% -20g", NaN, "NaN "}, + {"%+-20G", NaN, "NaN "}, // Zero padding does not apply to infinities and NaN. - {"%+020e", posInf, " +Inf"}, - {"%-020f", negInf, "-Inf "}, + {"%+020e", posInf, " +∞"}, + {"%-020f", negInf, "-∞ "}, {"%-020E", NaN, "NaN "}, // complex values @@ -495,24 +503,24 @@ var fmtTests = []struct { {"% .f", 0i, "( 0+0i)"}, {"%+.f", 0i, "(+0+0i)"}, {"% +.f", 0i, "(+0+0i)"}, - {"%+.3e", 0i, "(+0.000e+00+0.000e+00i)"}, + {"%+.3e", 0i, "(+0.000\u202f×\u202f10⁰⁰+0.000\u202f×\u202f10⁰⁰i)"}, {"%+.3f", 0i, "(+0.000+0.000i)"}, {"%+.3g", 0i, "(+0+0i)"}, - {"%+.3e", 1 + 2i, "(+1.000e+00+2.000e+00i)"}, + {"%+.3e", 1 + 2i, "(+1.000\u202f×\u202f10⁰⁰+2.000\u202f×\u202f10⁰⁰i)"}, {"%+.3f", 1 + 2i, "(+1.000+2.000i)"}, {"%+.3g", 1 + 2i, "(+1+2i)"}, - {"%.3e", 0i, "(0.000e+00+0.000e+00i)"}, + {"%.3e", 0i, "(0.000\u202f×\u202f10⁰⁰+0.000\u202f×\u202f10⁰⁰i)"}, {"%.3f", 0i, "(0.000+0.000i)"}, {"%.3F", 0i, "(0.000+0.000i)"}, {"%.3F", complex64(0i), "(0.000+0.000i)"}, {"%.3g", 0i, "(0+0i)"}, - {"%.3e", 1 + 2i, "(1.000e+00+2.000e+00i)"}, + {"%.3e", 1 + 2i, "(1.000\u202f×\u202f10⁰⁰+2.000\u202f×\u202f10⁰⁰i)"}, {"%.3f", 1 + 2i, "(1.000+2.000i)"}, {"%.3g", 1 + 2i, "(1+2i)"}, - {"%.3e", -1 - 2i, "(-1.000e+00-2.000e+00i)"}, + {"%.3e", -1 - 2i, "(-1.000\u202f×\u202f10⁰⁰-2.000\u202f×\u202f10⁰⁰i)"}, {"%.3f", -1 - 2i, "(-1.000-2.000i)"}, {"%.3g", -1 - 2i, "(-1-2i)"}, - {"% .3E", -1 - 2i, "(-1.000E+00-2.000E+00i)"}, + {"% .3E", -1 - 2i, "(-1.000\u202f×\u202f10⁰⁰-2.000\u202f×\u202f10⁰⁰i)"}, {"%+.3g", 1 + 2i, "(+1+2i)"}, {"%+.3g", complex64(1 + 2i), "(+1+2i)"}, {"%#g", 1 + 2i, "(1.00000+2.00000i)"}, @@ -537,70 +545,70 @@ var fmtTests = []struct { {"%.4b", 1 + 2i, "(4503599627370496p-52+4503599627370496p-51i)"}, {"%.4b", complex64(1 + 2i), "(8388608p-23+8388608p-22i)"}, // complex infinites and NaNs - {"%f", complex(posInf, posInf), "(+Inf+Infi)"}, - {"%f", complex(negInf, negInf), "(-Inf-Infi)"}, + {"%f", complex(posInf, posInf), "(∞+∞i)"}, + {"%f", complex(negInf, negInf), "(-∞-∞i)"}, {"%f", complex(NaN, NaN), "(NaN+NaNi)"}, - {"%.1f", complex(posInf, posInf), "(+Inf+Infi)"}, - {"% f", complex(posInf, posInf), "( Inf+Infi)"}, - {"% f", complex(negInf, negInf), "(-Inf-Infi)"}, - {"% f", complex(NaN, NaN), "( NaN+NaNi)"}, - {"%8e", complex(posInf, posInf), "( +Inf +Infi)"}, - {"% 8E", complex(posInf, posInf), "( Inf +Infi)"}, - {"%+8f", complex(negInf, negInf), "( -Inf -Infi)"}, - {"% +8g", complex(negInf, negInf), "( -Inf -Infi)"}, - {"% -8G", complex(NaN, NaN), "( NaN +NaN i)"}, + {"%.1f", complex(posInf, posInf), "(∞+∞i)"}, + {"% f", complex(posInf, posInf), "( ∞+∞i)"}, + {"% f", complex(negInf, negInf), "(-∞-∞i)"}, + {"% f", complex(NaN, NaN), "(NaN+NaNi)"}, + {"%8e", complex(posInf, posInf), "( ∞ +∞i)"}, + {"% 8E", complex(posInf, posInf), "( ∞ +∞i)"}, + {"%+8f", complex(negInf, negInf), "( -∞ -∞i)"}, + {"% +8g", complex(negInf, negInf), "( -∞ -∞i)"}, // TODO(g) + {"% -8G", complex(NaN, NaN), "(NaN +NaN i)"}, {"%+-8b", complex(NaN, NaN), "(+NaN +NaN i)"}, // Zero padding does not apply to infinities and NaN. - {"%08f", complex(posInf, posInf), "( +Inf +Infi)"}, - {"%-08g", complex(negInf, negInf), "(-Inf -Inf i)"}, + {"%08f", complex(posInf, posInf), "( ∞ +∞i)"}, + {"%-08g", complex(negInf, negInf), "(-∞ -∞ i)"}, {"%-08G", complex(NaN, NaN), "(NaN +NaN i)"}, // old test/fmt_test.go - {"%e", 1.0, "1.000000e+00"}, - {"%e", 1234.5678e3, "1.234568e+06"}, - {"%e", 1234.5678e-8, "1.234568e-05"}, - {"%e", -7.0, "-7.000000e+00"}, - {"%e", -1e-9, "-1.000000e-09"}, - {"%f", 1234.5678e3, "1234567.800000"}, + {"%e", 1.0, "1.000000\u202f×\u202f10⁰⁰"}, + {"%e", 1234.5678e3, "1.234570\u202f×\u202f10⁰⁶"}, + {"%e", 1234.5678e-8, "1.234570\u202f×\u202f10⁻⁰⁵"}, + {"%e", -7.0, "-7.000000\u202f×\u202f10⁰⁰"}, + {"%e", -1e-9, "-1.000000\u202f×\u202f10⁻⁰⁹"}, + {"%f", 1234.5678e3, "1,234,567.800000"}, {"%f", 1234.5678e-8, "0.000012"}, {"%f", -7.0, "-7.000000"}, {"%f", -1e-9, "-0.000000"}, - {"%g", 1234.5678e3, "1.2345678e+06"}, - {"%g", float32(1234.5678e3), "1.2345678e+06"}, - {"%g", 1234.5678e-8, "1.2345678e-05"}, + {"%g", 1234.5678e3, "1.2345678\u202f×\u202f10⁰⁶"}, + {"%g", float32(1234.5678e3), "1.2345678\u202f×\u202f10⁰⁶"}, + {"%g", 1234.5678e-8, "1.2345678\u202f×\u202f10⁻⁰⁵"}, {"%g", -7.0, "-7"}, - {"%g", -1e-9, "-1e-09"}, - {"%g", float32(-1e-9), "-1e-09"}, - {"%E", 1.0, "1.000000E+00"}, - {"%E", 1234.5678e3, "1.234568E+06"}, - {"%E", 1234.5678e-8, "1.234568E-05"}, - {"%E", -7.0, "-7.000000E+00"}, - {"%E", -1e-9, "-1.000000E-09"}, - {"%G", 1234.5678e3, "1.2345678E+06"}, - {"%G", float32(1234.5678e3), "1.2345678E+06"}, - {"%G", 1234.5678e-8, "1.2345678E-05"}, + {"%g", -1e-9, "-1\u202f×\u202f10⁻⁰⁹"}, + {"%g", float32(-1e-9), "-1\u202f×\u202f10⁻⁰⁹"}, + {"%E", 1.0, "1.000000\u202f×\u202f10⁰⁰"}, + {"%E", 1234.5678e3, "1.234570\u202f×\u202f10⁰⁶"}, + {"%E", 1234.5678e-8, "1.234570\u202f×\u202f10⁻⁰⁵"}, + {"%E", -7.0, "-7.000000\u202f×\u202f10⁰⁰"}, + {"%E", -1e-9, "-1.000000\u202f×\u202f10⁻⁰⁹"}, + {"%G", 1234.5678e3, "1.2345678\u202f×\u202f10⁰⁶"}, + {"%G", float32(1234.5678e3), "1.2345678\u202f×\u202f10⁰⁶"}, + {"%G", 1234.5678e-8, "1.2345678\u202f×\u202f10⁻⁰⁵"}, {"%G", -7.0, "-7"}, - {"%G", -1e-9, "-1E-09"}, - {"%G", float32(-1e-9), "-1E-09"}, + {"%G", -1e-9, "-1\u202f×\u202f10⁻⁰⁹"}, + {"%G", float32(-1e-9), "-1\u202f×\u202f10⁻⁰⁹"}, {"%20.5s", "qwertyuiop", " qwert"}, {"%.5s", "qwertyuiop", "qwert"}, {"%-20.5s", "qwertyuiop", "qwert "}, {"%20c", 'x', " x"}, {"%-20c", 'x', "x "}, - {"%20.6e", 1.2345e3, " 1.234500e+03"}, - {"%20.6e", 1.2345e-3, " 1.234500e-03"}, - {"%20e", 1.2345e3, " 1.234500e+03"}, - {"%20e", 1.2345e-3, " 1.234500e-03"}, - {"%20.8e", 1.2345e3, " 1.23450000e+03"}, - {"%20f", 1.23456789e3, " 1234.567890"}, + {"%20.6e", 1.2345e3, " 1.234500\u202f×\u202f10⁰³"}, + {"%20.6e", 1.2345e-3, " 1.234500\u202f×\u202f10⁻⁰³"}, + {"%20e", 1.2345e3, " 1.234500\u202f×\u202f10⁰³"}, + {"%20e", 1.2345e-3, " 1.234500\u202f×\u202f10⁻⁰³"}, + {"%20.8e", 1.2345e3, " 1.23450000\u202f×\u202f10⁰³"}, + {"%20f", 1.23456789e3, " 1,234.567890"}, {"%20f", 1.23456789e-3, " 0.001235"}, - {"%20f", 12345678901.23456789, " 12345678901.234568"}, - {"%-20f", 1.23456789e3, "1234.567890 "}, - {"%20.8f", 1.23456789e3, " 1234.56789000"}, + {"%20f", 12345678901.23456789, "12,345,678,901.234568"}, + {"%-20f", 1.23456789e3, "1,234.567890 "}, + {"%20.8f", 1.23456789e3, " 1,234.56789000"}, {"%20.8f", 1.23456789e-3, " 0.00123457"}, - {"%g", 1.23456789e3, "1234.56789"}, + {"%g", 1.23456789e3, "1,234.56789"}, {"%g", 1.23456789e-3, "0.00123456789"}, - {"%g", 1.23456789e20, "1.23456789e+20"}, + {"%g", 1.23456789e20, "1.23456789\u202f×\u202f10²⁰"}, // arrays {"%v", array, "[1 2 3 4 5]"}, @@ -930,8 +938,11 @@ var fmtTests = []struct { {"%+7.2f", -1.0, " -1.00"}, {"% +7.2f", 1.0, " +1.00"}, {"% +7.2f", -1.0, " -1.00"}, - {"%07.2f", 1.0, "0001.00"}, - {"%07.2f", -1.0, "-001.00"}, + // Padding with 0's indicates minimum number of integer digits minus the + // period, if present, and minus the sign if it is fixed. + // TODO: consider making this number the number of significant digits. + {"%07.2f", 1.0, "0,001.00"}, + {"%07.2f", -1.0, "-0,001.00"}, {"% 07.2f", 1.0, " 001.00"}, {"% 07.2f", -1.0, "-001.00"}, {"%+07.2f", 1.0, "+001.00"}, @@ -949,13 +960,13 @@ var fmtTests = []struct { // float and complex formatting should not change the padding width // for other elements. See issue 14642. - {"%06v", []interface{}{+10.0, 10}, "[000010 000010]"}, - {"%06v", []interface{}{-10.0, 10}, "[-00010 000010]"}, - {"%06v", []interface{}{+10.0 + 10i, 10}, "[(000010+00010i) 000010]"}, - {"%06v", []interface{}{-10.0 + 10i, 10}, "[(-00010+00010i) 000010]"}, + {"%06v", []interface{}{+10.0, 10}, "[000,010 000,010]"}, + {"%06v", []interface{}{-10.0, 10}, "[-000,010 000,010]"}, + {"%06v", []interface{}{+10.0 + 10i, 10}, "[(000,010+00,010i) 000,010]"}, + {"%06v", []interface{}{-10.0 + 10i, 10}, "[(-000,010+00,010i) 000,010]"}, // integer formatting should not alter padding for other elements. - {"%03.6v", []interface{}{1, 2.0, "x"}, "[000001 002 00x]"}, + {"%03.6v", []interface{}{1, 2.0, "x"}, "[000,001 002 00x]"}, {"%03.0v", []interface{}{0, 2.0, "x"}, "[ 002 000]"}, // Complex fmt used to leave the plus flag set for future entries in the array @@ -971,10 +982,11 @@ var fmtTests = []struct { {"%+10.2f", -104.66 + 440.51i, "( -104.66 +440.51i)"}, {"%+10.2f", +104.66 - 440.51i, "( +104.66 -440.51i)"}, {"%+10.2f", -104.66 - 440.51i, "( -104.66 -440.51i)"}, - {"%+010.2f", +104.66 + 440.51i, "(+000104.66+000440.51i)"}, - {"%+010.2f", -104.66 + 440.51i, "(-000104.66+000440.51i)"}, - {"%+010.2f", +104.66 - 440.51i, "(+000104.66-000440.51i)"}, - {"%+010.2f", -104.66 - 440.51i, "(-000104.66-000440.51i)"}, + {"%010.2f", +104.66 + 440.51i, "(0,000,104.66+000,440.51i)"}, + {"%+010.2f", +104.66 + 440.51i, "(+000,104.66+000,440.51i)"}, + {"%+010.2f", -104.66 + 440.51i, "(-000,104.66+000,440.51i)"}, + {"%+010.2f", +104.66 - 440.51i, "(+000,104.66-000,440.51i)"}, + {"%+010.2f", -104.66 - 440.51i, "(-000,104.66-000,440.51i)"}, // []T where type T is a byte with a Stringer method. {"%v", byteStringerSlice, "[X X X X X]"}, @@ -1043,7 +1055,7 @@ func zeroFill(prefix string, width int, suffix string) string { func TestSprintf(t *testing.T) { p := NewPrinter(language.Und) for _, tt := range fmtTests { - t.Run(fmt.Sprint(tt.fmt, tt.val), func(t *testing.T) { + t.Run(fmt.Sprint(tt.fmt, "/", tt.val), func(t *testing.T) { s := p.Sprintf(tt.fmt, tt.val) i := strings.Index(tt.out, "PTR") if i >= 0 && i < len(s) { @@ -1126,6 +1138,14 @@ func TestComplexFormatting(t *testing.T) { for _, imagValue := range values { one := p.Sprintf(realFmt, complex(realValue, imagValue)) two := p.Sprintf("("+realFmt+imagFmt+"i)", realValue, imagValue) + if math.IsNaN(imagValue) { + p := len(two) - len("NaNi)") - 1 + if two[p] == ' ' { + two = two[:p] + "+" + two[p+1:] + } else { + two = two[:p+1] + "+" + two[p+1:] + } + } if one != two { t.Error(f, one, two) } @@ -1626,14 +1646,14 @@ var startests = []struct { {"%-*d", args(4, 42), "42 "}, {"%*d", args(-4, 42), "42 "}, {"%-*d", args(-4, 42), "42 "}, - {"%.*d", args(4, 42), "0042"}, - {"%*.*d", args(8, 4, 42), " 0042"}, - {"%0*d", args(4, 42), "0042"}, + {"%.*d", args(4, 42), "0,042"}, + {"%*.*d", args(8, 4, 42), " 0,042"}, + {"%0*d", args(4, 42), "0,042"}, // Some non-int types for width. (Issue 10732). - {"%0*d", args(uint(4), 42), "0042"}, - {"%0*d", args(uint64(4), 42), "0042"}, - {"%0*d", args('\x04', 42), "0042"}, - {"%0*d", args(uintptr(4), 42), "0042"}, + {"%0*d", args(uint(4), 42), "0,042"}, + {"%0*d", args(uint64(4), 42), "0,042"}, + {"%0*d", args('\x04', 42), "0,042"}, + {"%0*d", args(uintptr(4), 42), "0,042"}, // erroneous {"%*d", args(nil, 42), "%!(BADWIDTH)42"}, -- cgit v1.2.3-1-g7c22