diff options
Diffstat (limited to 'src/pkg/fmt/fmt_test.go')
-rw-r--r-- | src/pkg/fmt/fmt_test.go | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/src/pkg/fmt/fmt_test.go b/src/pkg/fmt/fmt_test.go index 0aafe6d99..3f085b722 100644 --- a/src/pkg/fmt/fmt_test.go +++ b/src/pkg/fmt/fmt_test.go @@ -28,10 +28,8 @@ type ( renamedUintptr uintptr renamedString string renamedBytes []byte - renamedFloat float renamedFloat32 float32 renamedFloat64 float64 - renamedComplex complex renamedComplex64 complex64 renamedComplex128 complex128 ) @@ -224,31 +222,31 @@ var fmttests = []struct { {"%b", 7, "111"}, {"%b", b64, "1111111111111111111111111111111111111111111111111111111111111111"}, {"%b", -6, "-110"}, - {"%e", float64(1), "1.000000e+00"}, - {"%e", float64(1234.5678e3), "1.234568e+06"}, - {"%e", float64(1234.5678e-8), "1.234568e-05"}, - {"%e", float64(-7), "-7.000000e+00"}, - {"%e", float64(-1e-9), "-1.000000e-09"}, - {"%f", float64(1234.5678e3), "1234567.800000"}, - {"%f", float64(1234.5678e-8), "0.000012"}, - {"%f", float64(-7), "-7.000000"}, - {"%f", float64(-1e-9), "-0.000000"}, - {"%g", float64(1234.5678e3), "1.2345678e+06"}, + {"%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"}, + {"%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", float64(1234.5678e-8), "1.2345678e-05"}, - {"%g", float64(-7), "-7"}, - {"%g", float64(-1e-9), "-1e-09"}, + {"%g", 1234.5678e-8, "1.2345678e-05"}, + {"%g", -7.0, "-7"}, + {"%g", -1e-9, "-1e-09"}, {"%g", float32(-1e-9), "-1e-09"}, - {"%E", float64(1), "1.000000E+00"}, - {"%E", float64(1234.5678e3), "1.234568E+06"}, - {"%E", float64(1234.5678e-8), "1.234568E-05"}, - {"%E", float64(-7), "-7.000000E+00"}, - {"%E", float64(-1e-9), "-1.000000E-09"}, - {"%G", float64(1234.5678e3), "1.2345678E+06"}, + {"%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", float64(1234.5678e-8), "1.2345678E-05"}, - {"%G", float64(-7), "-7"}, - {"%G", float64(-1e-9), "-1E-09"}, + {"%G", 1234.5678e-8, "1.2345678E-05"}, + {"%G", -7.0, "-7"}, + {"%G", -1e-9, "-1E-09"}, {"%G", float32(-1e-9), "-1E-09"}, {"%c", 'x', "x"}, {"%c", 0xe4, "รค"}, @@ -273,15 +271,15 @@ var fmttests = []struct { {"%20e", 1.2345e3, " 1.234500e+03"}, {"%20e", 1.2345e-3, " 1.234500e-03"}, {"%20.8e", 1.2345e3, " 1.23450000e+03"}, - {"%20f", float64(1.23456789e3), " 1234.567890"}, - {"%20f", float64(1.23456789e-3), " 0.001235"}, - {"%20f", float64(12345678901.23456789), " 12345678901.234568"}, - {"%-20f", float64(1.23456789e3), "1234.567890 "}, - {"%20.8f", float64(1.23456789e3), " 1234.56789000"}, - {"%20.8f", float64(1.23456789e-3), " 0.00123457"}, - {"%g", float64(1.23456789e3), "1234.56789"}, - {"%g", float64(1.23456789e-3), "0.00123456789"}, - {"%g", float64(1.23456789e20), "1.23456789e+20"}, + {"%20f", 1.23456789e3, " 1234.567890"}, + {"%20f", 1.23456789e-3, " 0.001235"}, + {"%20f", 12345678901.23456789, " 12345678901.234568"}, + {"%-20f", 1.23456789e3, "1234.567890 "}, + {"%20.8f", 1.23456789e3, " 1234.56789000"}, + {"%20.8f", 1.23456789e-3, " 0.00123457"}, + {"%g", 1.23456789e3, "1234.56789"}, + {"%g", 1.23456789e-3, "0.00123456789"}, + {"%g", 1.23456789e20, "1.23456789e+20"}, {"%20e", math.Inf(1), " +Inf"}, {"%-20f", math.Inf(-1), "-Inf "}, {"%20g", math.NaN(), " NaN"}, @@ -346,10 +344,8 @@ var fmttests = []struct { {"%x", renamedString("thing"), "7468696e67"}, {"%d", renamedBytes([]byte{1, 2, 15}), `[1 2 15]`}, {"%q", renamedBytes([]byte("hello")), `"hello"`}, - {"%v", renamedFloat(11), "11"}, {"%v", renamedFloat32(22), "22"}, {"%v", renamedFloat64(33), "33"}, - {"%v", renamedComplex(7 + .2i), "(7+0.2i)"}, {"%v", renamedComplex64(3 + 4i), "(3+4i)"}, {"%v", renamedComplex128(4 - 3i), "(4-3i)"}, @@ -363,7 +359,7 @@ var fmttests = []struct { {"%#v", S{F(7), G(8)}, "fmt_test.S{f:<v=F(7)>, g:GoString(8)}"}, // %T - {"%T", (4 - 3i), "complex"}, + {"%T", (4 - 3i), "complex128"}, {"%T", renamedComplex128(4 - 3i), "fmt_test.renamedComplex128"}, {"%T", intVal, "int"}, {"%6T", &intVal, " *int"}, |