LEFT | RIGHT |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // This file contains tests for the printf checker. | 5 // This file contains tests for the printf checker. |
6 | 6 |
7 package testdata | 7 package testdata |
8 | 8 |
9 import ( | 9 import ( |
10 "fmt" | 10 "fmt" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 fmt.Printf("%q %q %q %q", 3, i, 'x', r) | 72 fmt.Printf("%q %q %q %q", 3, i, 'x', r) |
73 fmt.Printf("%s %s %s", "hi", s, []byte{65}) | 73 fmt.Printf("%s %s %s", "hi", s, []byte{65}) |
74 fmt.Printf("%t %t", true, b) | 74 fmt.Printf("%t %t", true, b) |
75 fmt.Printf("%T %T", 3, i) | 75 fmt.Printf("%T %T", 3, i) |
76 fmt.Printf("%U %U", 3, i) | 76 fmt.Printf("%U %U", 3, i) |
77 fmt.Printf("%v %v", 3, i) | 77 fmt.Printf("%v %v", 3, i) |
78 fmt.Printf("%x %x %x %x", 3, i, "hi", s) | 78 fmt.Printf("%x %x %x %x", 3, i, "hi", s) |
79 fmt.Printf("%X %X %X %X", 3, i, "hi", s) | 79 fmt.Printf("%X %X %X %X", 3, i, "hi", s) |
80 fmt.Printf("%.*s %d %g", 3, "hi", 23, 2.3) | 80 fmt.Printf("%.*s %d %g", 3, "hi", 23, 2.3) |
81 fmt.Printf("%s", &stringerv) | 81 fmt.Printf("%s", &stringerv) |
82 » fmt.Printf("%T", stringerv) | 82 » fmt.Printf("%T", &stringerv) |
83 fmt.Printf("%*%", 2) // Ridiculous but allowed. | 83 fmt.Printf("%*%", 2) // Ridiculous but allowed. |
84 | 84 |
85 fmt.Printf("%g", 1+2i) | 85 fmt.Printf("%g", 1+2i) |
86 // Some bad format/argTypes | 86 // Some bad format/argTypes |
87 fmt.Printf("%b", "hi") // ERROR "arg .hi. for printf
verb %b of wrong type" | 87 fmt.Printf("%b", "hi") // ERROR "arg .hi. for printf
verb %b of wrong type" |
88 fmt.Printf("%b", c) // ERROR "arg c for printf ve
rb %b of wrong type" | 88 fmt.Printf("%b", c) // ERROR "arg c for printf ve
rb %b of wrong type" |
89 fmt.Printf("%b", 1+2i) // ERROR "arg 1 \+ 2i for pri
ntf verb %b of wrong type" | 89 fmt.Printf("%b", 1+2i) // ERROR "arg 1 \+ 2i for pri
ntf verb %b of wrong type" |
90 fmt.Printf("%c", 2.3) // ERROR "arg 2.3 for printf
verb %c of wrong type" | 90 fmt.Printf("%c", 2.3) // ERROR "arg 2.3 for printf
verb %c of wrong type" |
91 fmt.Printf("%d", 2.3) // ERROR "arg 2.3 for printf
verb %d of wrong type" | 91 fmt.Printf("%d", 2.3) // ERROR "arg 2.3 for printf
verb %d of wrong type" |
92 fmt.Printf("%e", "hi") // ERROR "arg .hi. for printf
verb %e of wrong type" | 92 fmt.Printf("%e", "hi") // ERROR "arg .hi. for printf
verb %e of wrong type" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return "string" | 191 return "string" |
192 } | 192 } |
193 | 193 |
194 func (*stringer) Warn(int, ...interface{}) string { | 194 func (*stringer) Warn(int, ...interface{}) string { |
195 return "warn" | 195 return "warn" |
196 } | 196 } |
197 | 197 |
198 func (*stringer) Warnf(int, string, ...interface{}) string { | 198 func (*stringer) Warnf(int, string, ...interface{}) string { |
199 return "warnf" | 199 return "warnf" |
200 } | 200 } |
LEFT | RIGHT |