fmtTest{"%#v", make(chan int), "(chan int)(PTR)"},
fmtTest{"%#v", uint64(1<<64 - 1), "0xffffffffffffffff"},
fmtTest{"%#v", 1000000000, "1000000000"},
+
+ // erroneous things
+ fmtTest{"%d", "hello", "%d(string=hello)"},
+ fmtTest{"no args", "hello", "no args?(extra string=hello)"},
+ fmtTest{"%s", nil, "%s(<nil>)"},
}
func TestSprintf(t *testing.T) {
}
func getString(a interface{}) (val string, ok bool) {
+ if a == nil {
+ return "<nil>", ok
+ }
// Is it a regular string or []byte type?
switch s := a.(type) {
case string:
p.buf.WriteByte('%')
p.add(c)
p.buf.WriteByte('(')
- p.buf.WriteString(reflect.Typeof(field).String())
- p.buf.WriteByte('=')
+ if field != nil {
+ p.buf.WriteString(reflect.Typeof(field).String())
+ p.buf.WriteByte('=')
+ }
p.printField(field, false, false, 0)
p.buf.WriteByte(')')
}