Commit 1ce6245d authored by Rob Pike's avatar Rob Pike

throughout: fix broken calls to Printf etc.

I have written a tool to verify Printf calls, and although it's not
ready to be reviewed yet it's already uncovered a spate of problems
in the repository.  I'm sending this CL to break the changes into
pieces; as the tool improves it will find more, I'm sure.

R=rsc
CC=golang-dev
https://golang.org/cl/3427043
parent ab7884da
...@@ -111,7 +111,7 @@ func readTestZip(t *testing.T, zt ZipTest) { ...@@ -111,7 +111,7 @@ func readTestZip(t *testing.T, zt ZipTest) {
var b bytes.Buffer var b bytes.Buffer
_, err = io.Copy(&b, r) _, err = io.Copy(&b, r)
if err != ChecksumError { if err != ChecksumError {
t.Errorf("%s: copy error=%v, want %v", err, ChecksumError) t.Errorf("%s: copy error=%v, want %v", z.File[0].Name, err, ChecksumError)
} }
} }
...@@ -144,7 +144,7 @@ func readTestFile(t *testing.T, ft ZipTestFile, f *File) { ...@@ -144,7 +144,7 @@ func readTestFile(t *testing.T, ft ZipTestFile, f *File) {
} }
for i, b := range b.Bytes() { for i, b := range b.Bytes() {
if b != c[i] { if b != c[i] {
t.Errorf("%s: content[%d]=%q want %q", i, b, c[i]) t.Errorf("%s: content[%d]=%q want %q", f.Name, i, b, c[i])
return return
} }
} }
......
...@@ -94,7 +94,7 @@ func testFunZZ(t *testing.T, msg string, f funZZ, a argZZ) { ...@@ -94,7 +94,7 @@ func testFunZZ(t *testing.T, msg string, f funZZ, a argZZ) {
var z Int var z Int
f(&z, a.x, a.y) f(&z, a.x, a.y)
if !isNormalized(&z) { if !isNormalized(&z) {
t.Errorf("msg: %v is not normalized", z, msg) t.Errorf("%s%v is not normalized", z, msg)
} }
if (&z).Cmp(a.z) != 0 { if (&z).Cmp(a.z) != 0 {
t.Errorf("%s%+v\n\tgot z = %v; want %v", msg, a, &z, a.z) t.Errorf("%s%+v\n\tgot z = %v; want %v", msg, a, &z, a.z)
......
...@@ -397,9 +397,9 @@ func TestWriter(t *testing.T) { ...@@ -397,9 +397,9 @@ func TestWriter(t *testing.T) {
} }
for l := 0; l < len(written); l++ { for l := 0; l < len(written); l++ {
if written[i] != data[i] { if written[i] != data[i] {
t.Errorf("%s: wrong bytes written") t.Errorf("wrong bytes written")
t.Errorf("want=%s", data[0:len(written)]) t.Errorf("want=%q", data[0:len(written)])
t.Errorf("have=%s", written) t.Errorf("have=%q", written)
} }
} }
} }
......
...@@ -165,7 +165,7 @@ func TestBasicOperations(t *testing.T) { ...@@ -165,7 +165,7 @@ func TestBasicOperations(t *testing.T) {
t.Error("ReadByte unexpected eof") t.Error("ReadByte unexpected eof")
} }
if c != data[1] { if c != data[1] {
t.Error("ReadByte wrong value c=%v", c) t.Errorf("ReadByte wrong value c=%v", c)
} }
c, err = buf.ReadByte() c, err = buf.ReadByte()
if err == nil { if err == nil {
......
...@@ -127,59 +127,59 @@ func TestIntInsertDeleteClear(t *testing.T) { ...@@ -127,59 +127,59 @@ func TestIntInsertDeleteClear(t *testing.T) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: A) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: A) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: A) wrong len() %d (expected %d)", a, len(a), i)
} }
a.Insert(0, int2IntValue(val(i))) a.Insert(0, int2IntValue(val(i)))
if elem2IntValue(a.Last()) != int2IntValue(val(0)) { if elem2IntValue(a.Last()) != int2IntValue(val(0)) {
t.Error("T%: B", a) t.Errorf("%T: B", a)
} }
} }
for i := n - 1; i >= 0; i-- { for i := n - 1; i >= 0; i-- {
if elem2IntValue(a.Last()) != int2IntValue(val(0)) { if elem2IntValue(a.Last()) != int2IntValue(val(0)) {
t.Error("T%: C", a) t.Errorf("%T: C", a)
} }
if elem2IntValue(a.At(0)) != int2IntValue(val(i)) { if elem2IntValue(a.At(0)) != int2IntValue(val(i)) {
t.Error("T%: D", a) t.Errorf("%T: D", a)
} }
if elem2IntValue(a[0]) != int2IntValue(val(i)) { if elem2IntValue(a[0]) != int2IntValue(val(i)) {
t.Error("T%: D2", a) t.Errorf("%T: D2", a)
} }
a.Delete(0) a.Delete(0)
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: E) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: E) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: E) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: E) wrong len() %d (expected %d)", a, len(a), i)
} }
} }
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: F) wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: F) wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: F) wrong len() %d (expected 0)", a, len(a))
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
a.Push(int2IntValue(val(i))) a.Push(int2IntValue(val(i)))
if a.Len() != i+1 { if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1) t.Errorf("%T: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
} }
if len(a) != i+1 { if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1) t.Errorf("%T: G) wrong len() %d (expected %d)", a, len(a), i+1)
} }
if elem2IntValue(a.Last()) != int2IntValue(val(i)) { if elem2IntValue(a.Last()) != int2IntValue(val(i)) {
t.Error("T%: H", a) t.Errorf("%T: H", a)
} }
} }
a.Resize(0, 0) a.Resize(0, 0)
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: I wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: I wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: I wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: I wrong len() %d (expected 0)", a, len(a))
} }
const m = 5 const m = 5
...@@ -189,21 +189,21 @@ func TestIntInsertDeleteClear(t *testing.T) { ...@@ -189,21 +189,21 @@ func TestIntInsertDeleteClear(t *testing.T) {
x := val(i) x := val(i)
a.Push(int2IntValue(x)) a.Push(int2IntValue(x))
if elem2IntValue(a.Pop()) != int2IntValue(x) { if elem2IntValue(a.Pop()) != int2IntValue(x) {
t.Error("T%: J", a) t.Errorf("%T: J", a)
} }
if a.Len() != j+1 { if a.Len() != j+1 {
t.Errorf("T%: K) wrong Len() %d (expected %d)", a, a.Len(), j+1) t.Errorf("%T: K) wrong Len() %d (expected %d)", a, a.Len(), j+1)
} }
if len(a) != j+1 { if len(a) != j+1 {
t.Errorf("T%: K) wrong len() %d (expected %d)", a, len(a), j+1) t.Errorf("%T: K) wrong len() %d (expected %d)", a, len(a), j+1)
} }
} }
} }
if a.Len() != m { if a.Len() != m {
t.Errorf("T%: L) wrong Len() %d (expected %d)", a, a.Len(), m) t.Errorf("%T: L) wrong Len() %d (expected %d)", a, a.Len(), m)
} }
if len(a) != m { if len(a) != m {
t.Errorf("T%: L) wrong len() %d (expected %d)", a, len(a), m) t.Errorf("%T: L) wrong len() %d (expected %d)", a, len(a), m)
} }
} }
...@@ -211,14 +211,14 @@ func TestIntInsertDeleteClear(t *testing.T) { ...@@ -211,14 +211,14 @@ func TestIntInsertDeleteClear(t *testing.T) {
func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) { func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) {
for k := i; k < j; k++ { for k := i; k < j; k++ {
if elem2IntValue(x.At(k)) != int2IntValue(elt) { if elem2IntValue(x.At(k)) != int2IntValue(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt)) t.Errorf("%T: M) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt))
} }
} }
s := x.Slice(i, j) s := x.Slice(i, j)
for k, n := 0, j-i; k < n; k++ { for k, n := 0, j-i; k < n; k++ {
if elem2IntValue(s.At(k)) != int2IntValue(elt) { if elem2IntValue(s.At(k)) != int2IntValue(elt) {
t.Errorf("T%: N) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt)) t.Errorf("%T: N) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt))
} }
} }
} }
...@@ -227,10 +227,10 @@ func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) { ...@@ -227,10 +227,10 @@ func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) {
func verify_patternInt(t *testing.T, x *IntVector, a, b, c int) { func verify_patternInt(t *testing.T, x *IntVector, a, b, c int) {
n := a + b + c n := a + b + c
if x.Len() != n { if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n) t.Errorf("%T: O) wrong Len() %d (expected %d)", x, x.Len(), n)
} }
if len(*x) != n { if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n) t.Errorf("%T: O) wrong len() %d (expected %d)", x, len(*x), n)
} }
verify_sliceInt(t, x, 0, 0, a) verify_sliceInt(t, x, 0, 0, a)
verify_sliceInt(t, x, 1, a, a+b) verify_sliceInt(t, x, 1, a, a+b)
......
...@@ -127,59 +127,59 @@ func TestStrInsertDeleteClear(t *testing.T) { ...@@ -127,59 +127,59 @@ func TestStrInsertDeleteClear(t *testing.T) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: A) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: A) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: A) wrong len() %d (expected %d)", a, len(a), i)
} }
a.Insert(0, int2StrValue(val(i))) a.Insert(0, int2StrValue(val(i)))
if elem2StrValue(a.Last()) != int2StrValue(val(0)) { if elem2StrValue(a.Last()) != int2StrValue(val(0)) {
t.Error("T%: B", a) t.Errorf("%T: B", a)
} }
} }
for i := n - 1; i >= 0; i-- { for i := n - 1; i >= 0; i-- {
if elem2StrValue(a.Last()) != int2StrValue(val(0)) { if elem2StrValue(a.Last()) != int2StrValue(val(0)) {
t.Error("T%: C", a) t.Errorf("%T: C", a)
} }
if elem2StrValue(a.At(0)) != int2StrValue(val(i)) { if elem2StrValue(a.At(0)) != int2StrValue(val(i)) {
t.Error("T%: D", a) t.Errorf("%T: D", a)
} }
if elem2StrValue(a[0]) != int2StrValue(val(i)) { if elem2StrValue(a[0]) != int2StrValue(val(i)) {
t.Error("T%: D2", a) t.Errorf("%T: D2", a)
} }
a.Delete(0) a.Delete(0)
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: E) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: E) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: E) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: E) wrong len() %d (expected %d)", a, len(a), i)
} }
} }
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: F) wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: F) wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: F) wrong len() %d (expected 0)", a, len(a))
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
a.Push(int2StrValue(val(i))) a.Push(int2StrValue(val(i)))
if a.Len() != i+1 { if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1) t.Errorf("%T: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
} }
if len(a) != i+1 { if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1) t.Errorf("%T: G) wrong len() %d (expected %d)", a, len(a), i+1)
} }
if elem2StrValue(a.Last()) != int2StrValue(val(i)) { if elem2StrValue(a.Last()) != int2StrValue(val(i)) {
t.Error("T%: H", a) t.Errorf("%T: H", a)
} }
} }
a.Resize(0, 0) a.Resize(0, 0)
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: I wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: I wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: I wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: I wrong len() %d (expected 0)", a, len(a))
} }
const m = 5 const m = 5
...@@ -189,21 +189,21 @@ func TestStrInsertDeleteClear(t *testing.T) { ...@@ -189,21 +189,21 @@ func TestStrInsertDeleteClear(t *testing.T) {
x := val(i) x := val(i)
a.Push(int2StrValue(x)) a.Push(int2StrValue(x))
if elem2StrValue(a.Pop()) != int2StrValue(x) { if elem2StrValue(a.Pop()) != int2StrValue(x) {
t.Error("T%: J", a) t.Errorf("%T: J", a)
} }
if a.Len() != j+1 { if a.Len() != j+1 {
t.Errorf("T%: K) wrong Len() %d (expected %d)", a, a.Len(), j+1) t.Errorf("%T: K) wrong Len() %d (expected %d)", a, a.Len(), j+1)
} }
if len(a) != j+1 { if len(a) != j+1 {
t.Errorf("T%: K) wrong len() %d (expected %d)", a, len(a), j+1) t.Errorf("%T: K) wrong len() %d (expected %d)", a, len(a), j+1)
} }
} }
} }
if a.Len() != m { if a.Len() != m {
t.Errorf("T%: L) wrong Len() %d (expected %d)", a, a.Len(), m) t.Errorf("%T: L) wrong Len() %d (expected %d)", a, a.Len(), m)
} }
if len(a) != m { if len(a) != m {
t.Errorf("T%: L) wrong len() %d (expected %d)", a, len(a), m) t.Errorf("%T: L) wrong len() %d (expected %d)", a, len(a), m)
} }
} }
...@@ -211,14 +211,14 @@ func TestStrInsertDeleteClear(t *testing.T) { ...@@ -211,14 +211,14 @@ func TestStrInsertDeleteClear(t *testing.T) {
func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) { func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) {
for k := i; k < j; k++ { for k := i; k < j; k++ {
if elem2StrValue(x.At(k)) != int2StrValue(elt) { if elem2StrValue(x.At(k)) != int2StrValue(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt)) t.Errorf("%T: M) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt))
} }
} }
s := x.Slice(i, j) s := x.Slice(i, j)
for k, n := 0, j-i; k < n; k++ { for k, n := 0, j-i; k < n; k++ {
if elem2StrValue(s.At(k)) != int2StrValue(elt) { if elem2StrValue(s.At(k)) != int2StrValue(elt) {
t.Errorf("T%: N) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt)) t.Errorf("%T: N) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt))
} }
} }
} }
...@@ -227,10 +227,10 @@ func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) { ...@@ -227,10 +227,10 @@ func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) {
func verify_patternStr(t *testing.T, x *StringVector, a, b, c int) { func verify_patternStr(t *testing.T, x *StringVector, a, b, c int) {
n := a + b + c n := a + b + c
if x.Len() != n { if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n) t.Errorf("%T: O) wrong Len() %d (expected %d)", x, x.Len(), n)
} }
if len(*x) != n { if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n) t.Errorf("%T: O) wrong len() %d (expected %d)", x, len(*x), n)
} }
verify_sliceStr(t, x, 0, 0, a) verify_sliceStr(t, x, 0, 0, a)
verify_sliceStr(t, x, 1, a, a+b) verify_sliceStr(t, x, 1, a, a+b)
......
...@@ -127,59 +127,59 @@ func TestInsertDeleteClear(t *testing.T) { ...@@ -127,59 +127,59 @@ func TestInsertDeleteClear(t *testing.T) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: A) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: A) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: A) wrong len() %d (expected %d)", a, len(a), i)
} }
a.Insert(0, int2Value(val(i))) a.Insert(0, int2Value(val(i)))
if elem2Value(a.Last()) != int2Value(val(0)) { if elem2Value(a.Last()) != int2Value(val(0)) {
t.Error("T%: B", a) t.Errorf("%T: B", a)
} }
} }
for i := n - 1; i >= 0; i-- { for i := n - 1; i >= 0; i-- {
if elem2Value(a.Last()) != int2Value(val(0)) { if elem2Value(a.Last()) != int2Value(val(0)) {
t.Error("T%: C", a) t.Errorf("%T: C", a)
} }
if elem2Value(a.At(0)) != int2Value(val(i)) { if elem2Value(a.At(0)) != int2Value(val(i)) {
t.Error("T%: D", a) t.Errorf("%T: D", a)
} }
if elem2Value(a[0]) != int2Value(val(i)) { if elem2Value(a[0]) != int2Value(val(i)) {
t.Error("T%: D2", a) t.Errorf("%T: D2", a)
} }
a.Delete(0) a.Delete(0)
if a.Len() != i { if a.Len() != i {
t.Errorf("T%: E) wrong Len() %d (expected %d)", a, a.Len(), i) t.Errorf("%T: E) wrong Len() %d (expected %d)", a, a.Len(), i)
} }
if len(a) != i { if len(a) != i {
t.Errorf("T%: E) wrong len() %d (expected %d)", a, len(a), i) t.Errorf("%T: E) wrong len() %d (expected %d)", a, len(a), i)
} }
} }
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: F) wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: F) wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: F) wrong len() %d (expected 0)", a, len(a))
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
a.Push(int2Value(val(i))) a.Push(int2Value(val(i)))
if a.Len() != i+1 { if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1) t.Errorf("%T: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
} }
if len(a) != i+1 { if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1) t.Errorf("%T: G) wrong len() %d (expected %d)", a, len(a), i+1)
} }
if elem2Value(a.Last()) != int2Value(val(i)) { if elem2Value(a.Last()) != int2Value(val(i)) {
t.Error("T%: H", a) t.Errorf("%T: H", a)
} }
} }
a.Resize(0, 0) a.Resize(0, 0)
if a.Len() != 0 { if a.Len() != 0 {
t.Errorf("T%: I wrong Len() %d (expected 0)", a, a.Len()) t.Errorf("%T: I wrong Len() %d (expected 0)", a, a.Len())
} }
if len(a) != 0 { if len(a) != 0 {
t.Errorf("T%: I wrong len() %d (expected 0)", a, len(a)) t.Errorf("%T: I wrong len() %d (expected 0)", a, len(a))
} }
const m = 5 const m = 5
...@@ -189,21 +189,21 @@ func TestInsertDeleteClear(t *testing.T) { ...@@ -189,21 +189,21 @@ func TestInsertDeleteClear(t *testing.T) {
x := val(i) x := val(i)
a.Push(int2Value(x)) a.Push(int2Value(x))
if elem2Value(a.Pop()) != int2Value(x) { if elem2Value(a.Pop()) != int2Value(x) {
t.Error("T%: J", a) t.Errorf("%T: J", a)
} }
if a.Len() != j+1 { if a.Len() != j+1 {
t.Errorf("T%: K) wrong Len() %d (expected %d)", a, a.Len(), j+1) t.Errorf("%T: K) wrong Len() %d (expected %d)", a, a.Len(), j+1)
} }
if len(a) != j+1 { if len(a) != j+1 {
t.Errorf("T%: K) wrong len() %d (expected %d)", a, len(a), j+1) t.Errorf("%T: K) wrong len() %d (expected %d)", a, len(a), j+1)
} }
} }
} }
if a.Len() != m { if a.Len() != m {
t.Errorf("T%: L) wrong Len() %d (expected %d)", a, a.Len(), m) t.Errorf("%T: L) wrong Len() %d (expected %d)", a, a.Len(), m)
} }
if len(a) != m { if len(a) != m {
t.Errorf("T%: L) wrong len() %d (expected %d)", a, len(a), m) t.Errorf("%T: L) wrong len() %d (expected %d)", a, len(a), m)
} }
} }
...@@ -211,14 +211,14 @@ func TestInsertDeleteClear(t *testing.T) { ...@@ -211,14 +211,14 @@ func TestInsertDeleteClear(t *testing.T) {
func verify_slice(t *testing.T, x *Vector, elt, i, j int) { func verify_slice(t *testing.T, x *Vector, elt, i, j int) {
for k := i; k < j; k++ { for k := i; k < j; k++ {
if elem2Value(x.At(k)) != int2Value(elt) { if elem2Value(x.At(k)) != int2Value(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt)) t.Errorf("%T: M) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt))
} }
} }
s := x.Slice(i, j) s := x.Slice(i, j)
for k, n := 0, j-i; k < n; k++ { for k, n := 0, j-i; k < n; k++ {
if elem2Value(s.At(k)) != int2Value(elt) { if elem2Value(s.At(k)) != int2Value(elt) {
t.Errorf("T%: N) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt)) t.Errorf("%T: N) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt))
} }
} }
} }
...@@ -227,10 +227,10 @@ func verify_slice(t *testing.T, x *Vector, elt, i, j int) { ...@@ -227,10 +227,10 @@ func verify_slice(t *testing.T, x *Vector, elt, i, j int) {
func verify_pattern(t *testing.T, x *Vector, a, b, c int) { func verify_pattern(t *testing.T, x *Vector, a, b, c int) {
n := a + b + c n := a + b + c
if x.Len() != n { if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n) t.Errorf("%T: O) wrong Len() %d (expected %d)", x, x.Len(), n)
} }
if len(*x) != n { if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n) t.Errorf("%T: O) wrong len() %d (expected %d)", x, len(*x), n)
} }
verify_slice(t, x, 0, 0, a) verify_slice(t, x, 0, 0, a)
verify_slice(t, x, 1, a, a+b) verify_slice(t, x, 1, a, a+b)
......
...@@ -290,7 +290,7 @@ func TestBaseMult(t *testing.T) { ...@@ -290,7 +290,7 @@ func TestBaseMult(t *testing.T) {
for i, e := range p224BaseMultTests { for i, e := range p224BaseMultTests {
k, ok := new(big.Int).SetString(e.k, 10) k, ok := new(big.Int).SetString(e.k, 10)
if !ok { if !ok {
t.Errorf("%d: bad value for k: %s", e.k) t.Errorf("%d: bad value for k: %s", i, e.k)
} }
x, y := p224.ScalarBaseMult(k.Bytes()) x, y := p224.ScalarBaseMult(k.Bytes())
if fmt.Sprintf("%x", x) != e.x || fmt.Sprintf("%x", y) != e.y { if fmt.Sprintf("%x", x) != e.x || fmt.Sprintf("%x", y) != e.y {
......
...@@ -532,7 +532,7 @@ func TestScanMultiple(t *testing.T) { ...@@ -532,7 +532,7 @@ func TestScanMultiple(t *testing.T) {
t.Errorf("Sscan count error: expected 1: got %d", n) t.Errorf("Sscan count error: expected 1: got %d", n)
} }
if err == nil { if err == nil {
t.Errorf("Sscan expected error; got none", err) t.Errorf("Sscan expected error; got none: %s", err)
} }
if s != "asdf" { if s != "asdf" {
t.Errorf("Sscan wrong values: got %q expected \"asdf\"", s) t.Errorf("Sscan wrong values: got %q expected \"asdf\"", s)
...@@ -547,7 +547,7 @@ func TestScanEmpty(t *testing.T) { ...@@ -547,7 +547,7 @@ func TestScanEmpty(t *testing.T) {
t.Errorf("Sscan count error: expected 1: got %d", n) t.Errorf("Sscan count error: expected 1: got %d", n)
} }
if err == nil { if err == nil {
t.Errorf("Sscan <one item> expected error; got none") t.Error("Sscan <one item> expected error; got none")
} }
if s1 != "abc" { if s1 != "abc" {
t.Errorf("Sscan wrong values: got %q expected \"abc\"", s1) t.Errorf("Sscan wrong values: got %q expected \"abc\"", s1)
...@@ -557,7 +557,7 @@ func TestScanEmpty(t *testing.T) { ...@@ -557,7 +557,7 @@ func TestScanEmpty(t *testing.T) {
t.Errorf("Sscan count error: expected 0: got %d", n) t.Errorf("Sscan count error: expected 0: got %d", n)
} }
if err == nil { if err == nil {
t.Errorf("Sscan <empty> expected error; got none") t.Error("Sscan <empty> expected error; got none")
} }
// Quoted empty string is OK. // Quoted empty string is OK.
n, err = Sscanf(`""`, "%q", &s1) n, err = Sscanf(`""`, "%q", &s1)
......
...@@ -829,7 +829,7 @@ func TestNesting(t *testing.T) { ...@@ -829,7 +829,7 @@ func TestNesting(t *testing.T) {
dec := NewDecoder(b) dec := NewDecoder(b)
err := dec.Decode(&drt) err := dec.Decode(&drt)
if err != nil { if err != nil {
t.Errorf("decoder error:", err) t.Error("decoder error:", err)
} }
if drt.a != rt.a { if drt.a != rt.a {
t.Errorf("nesting: encode expected %v got %v", *rt, drt) t.Errorf("nesting: encode expected %v got %v", *rt, drt)
...@@ -1196,7 +1196,7 @@ func TestInterface(t *testing.T) { ...@@ -1196,7 +1196,7 @@ func TestInterface(t *testing.T) {
} }
continue continue
if v1.Square() != v2.Square() { if v1.Square() != v2.Square() {
t.Errorf("item %d inconsistent values: %v %v", v1, v2) t.Errorf("item %d inconsistent values: %v %v", i, v1, v2)
} }
} }
} }
......
...@@ -138,7 +138,7 @@ func TestNextValueBig(t *testing.T) { ...@@ -138,7 +138,7 @@ func TestNextValueBig(t *testing.T) {
var scan scanner var scan scanner
item, rest, err := nextValue(jsonBig, &scan) item, rest, err := nextValue(jsonBig, &scan)
if err != nil { if err != nil {
t.Fatalf("nextValue: ", err) t.Fatalf("nextValue: %s", err)
} }
if len(item) != len(jsonBig) || &item[0] != &jsonBig[0] { if len(item) != len(jsonBig) || &item[0] != &jsonBig[0] {
t.Errorf("invalid item: %d %d", len(item), len(jsonBig)) t.Errorf("invalid item: %d %d", len(item), len(jsonBig))
...@@ -149,7 +149,7 @@ func TestNextValueBig(t *testing.T) { ...@@ -149,7 +149,7 @@ func TestNextValueBig(t *testing.T) {
item, rest, err = nextValue(append(jsonBig, []byte("HELLO WORLD")...), &scan) item, rest, err = nextValue(append(jsonBig, []byte("HELLO WORLD")...), &scan)
if err != nil { if err != nil {
t.Fatalf("nextValue extra: ", err) t.Fatalf("nextValue extra: %s", err)
} }
if len(item) != len(jsonBig) { if len(item) != len(jsonBig) {
t.Errorf("invalid item: %d %d", len(item), len(jsonBig)) t.Errorf("invalid item: %d %d", len(item), len(jsonBig))
......
...@@ -71,10 +71,10 @@ func TestDecoder(t *testing.T) { ...@@ -71,10 +71,10 @@ func TestDecoder(t *testing.T) {
} }
} }
if !reflect.DeepEqual(out, streamTest[0:i]) { if !reflect.DeepEqual(out, streamTest[0:i]) {
t.Errorf("decoding %d items: mismatch") t.Errorf("decoding %d items: mismatch", i)
for j := range out { for j := range out {
if !reflect.DeepEqual(out[j], streamTest[j]) { if !reflect.DeepEqual(out[j], streamTest[j]) {
t.Errorf("#%d: have %v want %v", out[j], streamTest[j]) t.Errorf("#%d: have %v want %v", j, out[j], streamTest[j])
} }
} }
break break
......
...@@ -79,7 +79,7 @@ func importReceive(imp *Importer, t *testing.T, done chan bool) { ...@@ -79,7 +79,7 @@ func importReceive(imp *Importer, t *testing.T, done chan bool) {
break break
} }
if v != 23+i { if v != 23+i {
t.Errorf("importReceive: bad value: expected %%d+%d=%d; got %+d", base, i, base+i, v) t.Errorf("importReceive: bad value: expected %d+%d=%d; got %+d", base, i, base+i, v)
} }
} }
if done != nil { if done != nil {
......
...@@ -165,7 +165,7 @@ func testReaddirnames(dir string, contents []string, t *testing.T) { ...@@ -165,7 +165,7 @@ func testReaddirnames(dir string, contents []string, t *testing.T) {
} }
s, err2 := file.Readdirnames(-1) s, err2 := file.Readdirnames(-1)
if err2 != nil { if err2 != nil {
t.Fatalf("readdirnames %q failed: %v", err2) t.Fatalf("readdirnames %q failed: %v", dir, err2)
} }
for _, m := range contents { for _, m := range contents {
found := false found := false
...@@ -264,7 +264,7 @@ func TestReaddirnamesOneAtATime(t *testing.T) { ...@@ -264,7 +264,7 @@ func TestReaddirnamesOneAtATime(t *testing.T) {
small := smallReaddirnames(file1, len(all)+100, t) // +100 in case we screw up small := smallReaddirnames(file1, len(all)+100, t) // +100 in case we screw up
for i, n := range all { for i, n := range all {
if small[i] != n { if small[i] != n {
t.Errorf("small read %q %q mismatch: %v", small[i], n) t.Errorf("small read %q mismatch: %v", small[i], n)
} }
} }
} }
...@@ -348,7 +348,7 @@ func TestSymLink(t *testing.T) { ...@@ -348,7 +348,7 @@ func TestSymLink(t *testing.T) {
t.Fatalf("stat %q failed: %v", from, err) t.Fatalf("stat %q failed: %v", from, err)
} }
if !fromstat.FollowedSymlink { if !fromstat.FollowedSymlink {
t.Fatalf("stat %q did not follow symlink") t.Fatalf("stat %q did not follow symlink", from)
} }
s, err := Readlink(from) s, err := Readlink(from)
if err != nil { if err != nil {
......
...@@ -35,7 +35,7 @@ func TestMkdirAll(t *testing.T) { ...@@ -35,7 +35,7 @@ func TestMkdirAll(t *testing.T) {
// Can't make directory named after file. // Can't make directory named after file.
err = MkdirAll(fpath, 0777) err = MkdirAll(fpath, 0777)
if err == nil { if err == nil {
t.Fatalf("MkdirAll %q: no error") t.Fatalf("MkdirAll %q: no error", fpath)
} }
perr, ok := err.(*PathError) perr, ok := err.(*PathError)
if !ok { if !ok {
...@@ -49,7 +49,7 @@ func TestMkdirAll(t *testing.T) { ...@@ -49,7 +49,7 @@ func TestMkdirAll(t *testing.T) {
ffpath := fpath + "/subdir" ffpath := fpath + "/subdir"
err = MkdirAll(ffpath, 0777) err = MkdirAll(ffpath, 0777)
if err == nil { if err == nil {
t.Fatalf("MkdirAll %q: no error") t.Fatalf("MkdirAll %q: no error", ffpath)
} }
perr, ok = err.(*PathError) perr, ok = err.(*PathError)
if !ok { if !ok {
...@@ -135,7 +135,7 @@ func TestRemoveAll(t *testing.T) { ...@@ -135,7 +135,7 @@ func TestRemoveAll(t *testing.T) {
if err == nil { if err == nil {
t.Errorf("Can lstat %q after supposed RemoveAll", path) t.Errorf("Can lstat %q after supposed RemoveAll", path)
} }
t.Fatalf("RemoveAll %q succeeded with chmod 0 subdirectory", path, err) t.Fatalf("RemoveAll %q succeeded with chmod 0 subdirectory: err %s", path, err)
} }
perr, ok := err.(*PathError) perr, ok := err.(*PathError)
if !ok { if !ok {
......
...@@ -257,7 +257,7 @@ func TestWalk(t *testing.T) { ...@@ -257,7 +257,7 @@ func TestWalk(t *testing.T) {
errors := make(chan os.Error, 64) errors := make(chan os.Error, 64)
Walk(tree.name, v, errors) Walk(tree.name, v, errors)
if err, ok := <-errors; ok { if err, ok := <-errors; ok {
t.Errorf("no error expected, found: s", err) t.Error("no error expected, found: s", err)
} }
checkMarks(t) checkMarks(t)
......
...@@ -873,7 +873,7 @@ func TestMap(t *testing.T) { ...@@ -873,7 +873,7 @@ func TestMap(t *testing.T) {
// Check that value lookup is correct. // Check that value lookup is correct.
vv := mv.Elem(NewValue(k)) vv := mv.Elem(NewValue(k))
if vi := vv.(*IntValue).Get(); vi != int64(v) { if vi := vv.(*IntValue).Get(); vi != int64(v) {
t.Errorf("Key %q: have value %d, want %d", vi, v) t.Errorf("Key %q: have value %d, want %d", k, vi, v)
} }
// Copy into new map. // Copy into new map.
......
...@@ -46,7 +46,7 @@ func TestAtob(t *testing.T) { ...@@ -46,7 +46,7 @@ func TestAtob(t *testing.T) {
} }
} else { } else {
if e != nil { if e != nil {
t.Errorf("%s: expected no error but got %s", test.in, test.err, e) t.Errorf("%s: expected no error but got %s", test.in, e)
} }
if b != test.out { if b != test.out {
t.Errorf("%s: expected %t but got %t", test.in, test.out, b) t.Errorf("%s: expected %t but got %t", test.in, test.out, b)
......
...@@ -47,7 +47,7 @@ func TestNew(t *testing.T) { ...@@ -47,7 +47,7 @@ func TestNew(t *testing.T) {
func TestNewLogger(t *testing.T) { func TestNewLogger(t *testing.T) {
f := NewLogger(LOG_INFO, 0) f := NewLogger(LOG_INFO, 0)
if f == nil { if f == nil {
t.Errorf("NewLogger() failed") t.Error("NewLogger() failed")
} }
} }
......
...@@ -31,7 +31,7 @@ func TestTicker(t *testing.T) { ...@@ -31,7 +31,7 @@ func TestTicker(t *testing.T) {
Sleep(2 * Delta) Sleep(2 * Delta)
_, received := <-ticker.C _, received := <-ticker.C
if received { if received {
t.Fatalf("Ticker did not shut down") t.Fatal("Ticker did not shut down")
} }
} }
......
...@@ -329,7 +329,7 @@ func printCategories() { ...@@ -329,7 +329,7 @@ func printCategories() {
for k, _ := range category { for k, _ := range category {
fmt.Printf("\t%q: %s,\n", k, k) fmt.Printf("\t%q: %s,\n", k, k)
} }
fmt.Printf("}\n\n") fmt.Print("}\n\n")
} }
decl := make(sort.StringArray, len(list)) decl := make(sort.StringArray, len(list))
...@@ -377,7 +377,7 @@ func printCategories() { ...@@ -377,7 +377,7 @@ func printCategories() {
for _, d := range decl { for _, d := range decl {
fmt.Print(d) fmt.Print(d)
} }
fmt.Println(")\n") fmt.Print(")\n\n")
} }
type Op func(code int) bool type Op func(code int) bool
...@@ -597,7 +597,7 @@ func printScriptOrProperty(doProps bool) { ...@@ -597,7 +597,7 @@ func printScriptOrProperty(doProps bool) {
for k, _ := range table { for k, _ := range table {
fmt.Printf("\t%q: %s,\n", k, k) fmt.Printf("\t%q: %s,\n", k, k)
} }
fmt.Printf("}\n\n") fmt.Print("}\n\n")
} }
decl := make(sort.StringArray, len(list)) decl := make(sort.StringArray, len(list))
...@@ -618,14 +618,14 @@ func printScriptOrProperty(doProps bool) { ...@@ -618,14 +618,14 @@ func printScriptOrProperty(doProps bool) {
for _, s := range ranges { for _, s := range ranges {
fmt.Printf(format, s.Lo, s.Hi, s.Stride) fmt.Printf(format, s.Lo, s.Hi, s.Stride)
} }
fmt.Printf("}\n\n") fmt.Print("}\n\n")
} }
decl.Sort() decl.Sort()
fmt.Println("var (") fmt.Println("var (")
for _, d := range decl { for _, d := range decl {
fmt.Print(d) fmt.Print(d)
} }
fmt.Println(")\n") fmt.Print(")\n\n")
} }
const ( const (
...@@ -792,7 +792,7 @@ func printCases() { ...@@ -792,7 +792,7 @@ func printCases() {
} }
prevState = state prevState = state
} }
fmt.Printf("}\n") fmt.Print("}\n")
} }
func printCaseRange(lo, hi *caseState) { func printCaseRange(lo, hi *caseState) {
......
...@@ -15,7 +15,7 @@ func TestScanForwards(t *testing.T) { ...@@ -15,7 +15,7 @@ func TestScanForwards(t *testing.T) {
runes := []int(s) runes := []int(s)
str := NewString(s) str := NewString(s)
if str.RuneCount() != len(runes) { if str.RuneCount() != len(runes) {
t.Error("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) t.Errorf("%s: expected %d runes; got %d", s, len(runes), str.RuneCount())
break break
} }
for i, expect := range runes { for i, expect := range runes {
...@@ -32,7 +32,7 @@ func TestScanBackwards(t *testing.T) { ...@@ -32,7 +32,7 @@ func TestScanBackwards(t *testing.T) {
runes := []int(s) runes := []int(s)
str := NewString(s) str := NewString(s)
if str.RuneCount() != len(runes) { if str.RuneCount() != len(runes) {
t.Error("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) t.Errorf("%s: expected %d runes; got %d", s, len(runes), str.RuneCount())
break break
} }
for i := len(runes) - 1; i >= 0; i-- { for i := len(runes) - 1; i >= 0; i-- {
...@@ -55,7 +55,7 @@ func TestRandomAccess(t *testing.T) { ...@@ -55,7 +55,7 @@ func TestRandomAccess(t *testing.T) {
runes := []int(s) runes := []int(s)
str := NewString(s) str := NewString(s)
if str.RuneCount() != len(runes) { if str.RuneCount() != len(runes) {
t.Error("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) t.Errorf("%s: expected %d runes; got %d", s, len(runes), str.RuneCount())
break break
} }
for j := 0; j < randCount; j++ { for j := 0; j < randCount; j++ {
...@@ -77,7 +77,7 @@ func TestRandomSliceAccess(t *testing.T) { ...@@ -77,7 +77,7 @@ func TestRandomSliceAccess(t *testing.T) {
runes := []int(s) runes := []int(s)
str := NewString(s) str := NewString(s)
if str.RuneCount() != len(runes) { if str.RuneCount() != len(runes) {
t.Error("%s: expected %d runes; got %d", s, len(runes), str.RuneCount()) t.Errorf("%s: expected %d runes; got %d", s, len(runes), str.RuneCount())
break break
} }
for k := 0; k < randCount; k++ { for k := 0; k < randCount; k++ {
......
...@@ -166,7 +166,7 @@ func TestIntConversion(t *testing.T) { ...@@ -166,7 +166,7 @@ func TestIntConversion(t *testing.T) {
for _, ts := range testStrings { for _, ts := range testStrings {
runes := []int(ts) runes := []int(ts)
if RuneCountInString(ts) != len(runes) { if RuneCountInString(ts) != len(runes) {
t.Error("%q: expected %d runes; got %d", ts, len(runes), RuneCountInString(ts)) t.Errorf("%q: expected %d runes; got %d", ts, len(runes), RuneCountInString(ts))
break break
} }
i := 0 i := 0
......
...@@ -155,7 +155,7 @@ func TestHTTP(t *testing.T) { ...@@ -155,7 +155,7 @@ func TestHTTP(t *testing.T) {
// specification, the server should abort the WebSocket connection. // specification, the server should abort the WebSocket connection.
_, _, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr)) _, _, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr))
if err == nil { if err == nil {
t.Errorf("Get: unexpected success") t.Error("Get: unexpected success")
return return
} }
urlerr, ok := err.(*http.URLError) urlerr, ok := err.(*http.URLError)
......
...@@ -301,7 +301,7 @@ func TestIssue569(t *testing.T) { ...@@ -301,7 +301,7 @@ func TestIssue569(t *testing.T) {
err := Unmarshal(buf, &i) err := Unmarshal(buf, &i)
if err != nil || i.Field_a != "abcd" { if err != nil || i.Field_a != "abcd" {
t.Fatalf("Expecting abcd") t.Fatal("Expecting abcd")
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment