1
0
mirror of https://github.com/golang/go synced 2024-11-21 18:34:44 -07:00

fmt.Printf: write tests for %T.

Fix a bug that caused it to ignore field widths.

R=rsc
CC=golang-dev
https://golang.org/cl/1704041
This commit is contained in:
Rob Pike 2010-06-14 17:42:31 -07:00
parent d482c163be
commit 177746ba31
2 changed files with 7 additions and 1 deletions

View File

@ -314,6 +314,12 @@ var fmttests = []fmtTest{
fmtTest{"%v", renamedComplex64(3 + 4i), "(3+4i)"}, fmtTest{"%v", renamedComplex64(3 + 4i), "(3+4i)"},
fmtTest{"%v", renamedComplex128(4 - 3i), "(4-3i)"}, fmtTest{"%v", renamedComplex128(4 - 3i), "(4-3i)"},
// %T
fmtTest{"%T", (4 - 3i), "complex"},
fmtTest{"%T", renamedComplex128(4 - 3i), "fmt_test.renamedComplex128"},
fmtTest{"%T", intVal, "int"},
fmtTest{"%6T", &intVal, " *int"},
// erroneous things // erroneous things
fmtTest{"%d", "hello", "%d(string=hello)"}, fmtTest{"%d", "hello", "%d(string=hello)"},
fmtTest{"no args", "hello", "no args?(extra string=hello)"}, fmtTest{"no args", "hello", "no args?(extra string=hello)"},

View File

@ -959,7 +959,7 @@ func (p *pp) doPrintf(format string, a []interface{}) {
p.buf.Write(nilAngleBytes) p.buf.Write(nilAngleBytes)
break break
} }
p.buf.WriteString(reflect.Typeof(field).String()) p.printField(reflect.Typeof(field).String(), 's', false, false, 0)
continue continue
} }