]> Cypherpunks repositories - gostls13.git/commitdiff
throughout: fix broken calls to Printf etc.
authorRob Pike <r@golang.org>
Tue, 7 Dec 2010 21:42:54 +0000 (16:42 -0500)
committerRob Pike <r@golang.org>
Tue, 7 Dec 2010 21:42:54 +0000 (16:42 -0500)
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

25 files changed:
src/pkg/archive/zip/reader_test.go
src/pkg/big/int_test.go
src/pkg/bufio/bufio_test.go
src/pkg/bytes/buffer_test.go
src/pkg/container/vector/intvector_test.go
src/pkg/container/vector/stringvector_test.go
src/pkg/container/vector/vector_test.go
src/pkg/crypto/elliptic/elliptic_test.go
src/pkg/fmt/scan_test.go
src/pkg/gob/codec_test.go
src/pkg/json/scanner_test.go
src/pkg/json/stream_test.go
src/pkg/netchan/netchan_test.go
src/pkg/os/os_test.go
src/pkg/os/path_test.go
src/pkg/path/path_test.go
src/pkg/reflect/all_test.go
src/pkg/strconv/atob_test.go
src/pkg/syslog/syslog_test.go
src/pkg/time/tick_test.go
src/pkg/unicode/maketables.go
src/pkg/utf8/string_test.go
src/pkg/utf8/utf8_test.go
src/pkg/websocket/websocket_test.go
src/pkg/xml/xml_test.go

index 8e1fbbfa512a420c5208a5a77bdc21cd87d41870..3c24f1467cf8e71b5775a9c40a54954d958ba8d3 100644 (file)
@@ -111,7 +111,7 @@ func readTestZip(t *testing.T, zt ZipTest) {
        var b bytes.Buffer
        _, err = io.Copy(&b, r)
        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) {
        }
        for i, b := range b.Bytes() {
                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
                }
        }
index 818d0c6dbc66c38bc493a5c569ea423bb80f1f10..fc981e1da46c4fab2ff04e0d61a3e3082f8539a4 100755 (executable)
@@ -94,7 +94,7 @@ func testFunZZ(t *testing.T, msg string, f funZZ, a argZZ) {
        var z Int
        f(&z, a.x, a.y)
        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 {
                t.Errorf("%s%+v\n\tgot z = %v; want %v", msg, a, &z, a.z)
index d84d18768e6365f7b37ad5bed03f5102895d905c..059ca6dd223d91ea2a6d42bd989ccb9e1db580e3 100644 (file)
@@ -397,9 +397,9 @@ func TestWriter(t *testing.T) {
                        }
                        for l := 0; l < len(written); l++ {
                                if written[i] != data[i] {
-                                       t.Errorf("%s: wrong bytes written")
-                                       t.Errorf("want=%s", data[0:len(written)])
-                                       t.Errorf("have=%s", written)
+                                       t.Errorf("wrong bytes written")
+                                       t.Errorf("want=%q", data[0:len(written)])
+                                       t.Errorf("have=%q", written)
                                }
                        }
                }
index ef42d430cbb1b4017f3bc32c3d2cb35336577b31..509793d24a8293331ffcc297d6493a42d8c0ca85 100644 (file)
@@ -165,7 +165,7 @@ func TestBasicOperations(t *testing.T) {
                        t.Error("ReadByte unexpected eof")
                }
                if c != data[1] {
-                       t.Error("ReadByte wrong value c=%v", c)
+                       t.Errorf("ReadByte wrong value c=%v", c)
                }
                c, err = buf.ReadByte()
                if err == nil {
index fcc7403b36d1bd73b3313ac1025f1d0a2a3bfcce..1e38a1982f6620b285ec0b4ebd041fea78ef73a3 100644 (file)
@@ -127,59 +127,59 @@ func TestIntInsertDeleteClear(t *testing.T) {
 
        for i := 0; i < n; 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 {
-                       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)))
                if elem2IntValue(a.Last()) != int2IntValue(val(0)) {
-                       t.Error("T%: B", a)
+                       t.Errorf("%T: B", a)
                }
        }
        for i := n - 1; i >= 0; i-- {
                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)) {
-                       t.Error("T%: D", a)
+                       t.Errorf("%T: D", a)
                }
                if elem2IntValue(a[0]) != int2IntValue(val(i)) {
-                       t.Error("T%: D2", a)
+                       t.Errorf("%T: D2", a)
                }
                a.Delete(0)
                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 {
-                       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 {
-               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 {
-               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++ {
                a.Push(int2IntValue(val(i)))
                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 {
-                       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)) {
-                       t.Error("T%: H", a)
+                       t.Errorf("%T: H", a)
                }
        }
        a.Resize(0, 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 {
-               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
@@ -189,21 +189,21 @@ func TestIntInsertDeleteClear(t *testing.T) {
                        x := val(i)
                        a.Push(int2IntValue(x))
                        if elem2IntValue(a.Pop()) != int2IntValue(x) {
-                               t.Error("T%: J", a)
+                               t.Errorf("%T: J", a)
                        }
                        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 {
-                               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 {
-               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 {
-               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) {
 func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) {
        for k := i; k < j; k++ {
                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)
        for k, n := 0, j-i; k < n; k++ {
                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) {
 func verify_patternInt(t *testing.T, x *IntVector, a, b, c int) {
        n := a + b + c
        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 {
-               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, 1, a, a+b)
index 2f3f082bdc481ad0ed23afd25754561b344e47da..776ae26dea13ac8fa6a240520a2551dbfda384e8 100644 (file)
@@ -127,59 +127,59 @@ func TestStrInsertDeleteClear(t *testing.T) {
 
        for i := 0; i < n; 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 {
-                       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)))
                if elem2StrValue(a.Last()) != int2StrValue(val(0)) {
-                       t.Error("T%: B", a)
+                       t.Errorf("%T: B", a)
                }
        }
        for i := n - 1; i >= 0; i-- {
                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)) {
-                       t.Error("T%: D", a)
+                       t.Errorf("%T: D", a)
                }
                if elem2StrValue(a[0]) != int2StrValue(val(i)) {
-                       t.Error("T%: D2", a)
+                       t.Errorf("%T: D2", a)
                }
                a.Delete(0)
                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 {
-                       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 {
-               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 {
-               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++ {
                a.Push(int2StrValue(val(i)))
                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 {
-                       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)) {
-                       t.Error("T%: H", a)
+                       t.Errorf("%T: H", a)
                }
        }
        a.Resize(0, 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 {
-               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
@@ -189,21 +189,21 @@ func TestStrInsertDeleteClear(t *testing.T) {
                        x := val(i)
                        a.Push(int2StrValue(x))
                        if elem2StrValue(a.Pop()) != int2StrValue(x) {
-                               t.Error("T%: J", a)
+                               t.Errorf("%T: J", a)
                        }
                        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 {
-                               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 {
-               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 {
-               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) {
 func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) {
        for k := i; k < j; k++ {
                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)
        for k, n := 0, j-i; k < n; k++ {
                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) {
 func verify_patternStr(t *testing.T, x *StringVector, a, b, c int) {
        n := a + b + c
        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 {
-               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, 1, a, a+b)
index 986dff2da7779257e49235803f68582dd97bb225..a9c4ceb55acebcf7b74dd5be7fb71bcadc7c5539 100644 (file)
@@ -127,59 +127,59 @@ func TestInsertDeleteClear(t *testing.T) {
 
        for i := 0; i < n; 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 {
-                       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)))
                if elem2Value(a.Last()) != int2Value(val(0)) {
-                       t.Error("T%: B", a)
+                       t.Errorf("%T: B", a)
                }
        }
        for i := n - 1; i >= 0; i-- {
                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)) {
-                       t.Error("T%: D", a)
+                       t.Errorf("%T: D", a)
                }
                if elem2Value(a[0]) != int2Value(val(i)) {
-                       t.Error("T%: D2", a)
+                       t.Errorf("%T: D2", a)
                }
                a.Delete(0)
                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 {
-                       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 {
-               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 {
-               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++ {
                a.Push(int2Value(val(i)))
                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 {
-                       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)) {
-                       t.Error("T%: H", a)
+                       t.Errorf("%T: H", a)
                }
        }
        a.Resize(0, 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 {
-               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
@@ -189,21 +189,21 @@ func TestInsertDeleteClear(t *testing.T) {
                        x := val(i)
                        a.Push(int2Value(x))
                        if elem2Value(a.Pop()) != int2Value(x) {
-                               t.Error("T%: J", a)
+                               t.Errorf("%T: J", a)
                        }
                        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 {
-                               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 {
-               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 {
-               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) {
 func verify_slice(t *testing.T, x *Vector, elt, i, j int) {
        for k := i; k < j; k++ {
                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)
        for k, n := 0, j-i; k < n; k++ {
                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) {
 func verify_pattern(t *testing.T, x *Vector, a, b, c int) {
        n := a + b + c
        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 {
-               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, 1, a, a+b)
index a04b1fa1064c1cc8a305590845cbeaaf98d52fda..25c2071ca382b7e08430cdfae8c78cfe6f54bc9a 100644 (file)
@@ -290,7 +290,7 @@ func TestBaseMult(t *testing.T) {
        for i, e := range p224BaseMultTests {
                k, ok := new(big.Int).SetString(e.k, 10)
                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())
                if fmt.Sprintf("%x", x) != e.x || fmt.Sprintf("%x", y) != e.y {
index 7a0baae2455cf55fcdaf77d56cddadcfa5addff1..fe5ee1d6175d6e4c6956f34add9718df28a6f32a 100644 (file)
@@ -532,7 +532,7 @@ func TestScanMultiple(t *testing.T) {
                t.Errorf("Sscan count error: expected 1: got %d", n)
        }
        if err == nil {
-               t.Errorf("Sscan expected error; got none", err)
+               t.Errorf("Sscan expected error; got none: %s", err)
        }
        if s != "asdf" {
                t.Errorf("Sscan wrong values: got %q expected \"asdf\"", s)
@@ -547,7 +547,7 @@ func TestScanEmpty(t *testing.T) {
                t.Errorf("Sscan count error: expected 1: got %d", n)
        }
        if err == nil {
-               t.Errorf("Sscan <one item> expected error; got none")
+               t.Error("Sscan <one item> expected error; got none")
        }
        if s1 != "abc" {
                t.Errorf("Sscan wrong values: got %q expected \"abc\"", s1)
@@ -557,7 +557,7 @@ func TestScanEmpty(t *testing.T) {
                t.Errorf("Sscan count error: expected 0: got %d", n)
        }
        if err == nil {
-               t.Errorf("Sscan <empty> expected error; got none")
+               t.Error("Sscan <empty> expected error; got none")
        }
        // Quoted empty string is OK.
        n, err = Sscanf(`""`, "%q", &s1)
index a95cfa9929b3492d520c8b707c8cfa92ef3d099d..3fe5fe2b00f83cb0f6e868304357fc768c6d63c9 100644 (file)
@@ -829,7 +829,7 @@ func TestNesting(t *testing.T) {
        dec := NewDecoder(b)
        err := dec.Decode(&drt)
        if err != nil {
-               t.Errorf("decoder error:", err)
+               t.Error("decoder error:", err)
        }
        if drt.a != rt.a {
                t.Errorf("nesting: encode expected %v got %v", *rt, drt)
@@ -1196,7 +1196,7 @@ func TestInterface(t *testing.T) {
                        }
                        continue
                        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)
                        }
                }
        }
index b90f5811b7ea67dcf9bb1f2198de3513de558f28..2dc8ff87fb42a522d631f346163403b18797df69 100644 (file)
@@ -138,7 +138,7 @@ func TestNextValueBig(t *testing.T) {
        var scan scanner
        item, rest, err := nextValue(jsonBig, &scan)
        if err != nil {
-               t.Fatalf("nextValue: ", err)
+               t.Fatalf("nextValue: %s", err)
        }
        if len(item) != len(jsonBig) || &item[0] != &jsonBig[0] {
                t.Errorf("invalid item: %d %d", len(item), len(jsonBig))
@@ -149,7 +149,7 @@ func TestNextValueBig(t *testing.T) {
 
        item, rest, err = nextValue(append(jsonBig, []byte("HELLO WORLD")...), &scan)
        if err != nil {
-               t.Fatalf("nextValue extra: ", err)
+               t.Fatalf("nextValue extra: %s", err)
        }
        if len(item) != len(jsonBig) {
                t.Errorf("invalid item: %d %d", len(item), len(jsonBig))
index ab90b754e1331ca63fec24a908f5a0d67c172527..c83cfe3a93711d1e76877ed1805df2f6bf09d3e0 100644 (file)
@@ -71,10 +71,10 @@ func TestDecoder(t *testing.T) {
                        }
                }
                if !reflect.DeepEqual(out, streamTest[0:i]) {
-                       t.Errorf("decoding %d items: mismatch")
+                       t.Errorf("decoding %d items: mismatch", i)
                        for j := range out {
                                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
index 707111a09418ca9e5a9573aad014fd17a71c7b26..766c4c474011063172caebfa2ac81e9888ad86dd 100644 (file)
@@ -79,7 +79,7 @@ func importReceive(imp *Importer, t *testing.T, done chan bool) {
                        break
                }
                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 {
index 0bbb686e18253e2e7f49269a5020ba0cf0217cf3..d60a52f850363116eba44c41cf71f24963ca1ea6 100644 (file)
@@ -165,7 +165,7 @@ func testReaddirnames(dir string, contents []string, t *testing.T) {
        }
        s, err2 := file.Readdirnames(-1)
        if err2 != nil {
-               t.Fatalf("readdirnames %q failed: %v", err2)
+               t.Fatalf("readdirnames %q failed: %v", dir, err2)
        }
        for _, m := range contents {
                found := false
@@ -264,7 +264,7 @@ func TestReaddirnamesOneAtATime(t *testing.T) {
        small := smallReaddirnames(file1, len(all)+100, t) // +100 in case we screw up
        for i, n := range all {
                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) {
                t.Fatalf("stat %q failed: %v", from, err)
        }
        if !fromstat.FollowedSymlink {
-               t.Fatalf("stat %q did not follow symlink")
+               t.Fatalf("stat %q did not follow symlink", from)
        }
        s, err := Readlink(from)
        if err != nil {
index 9bc92ae0278cc8226764fd8f7da847a8609133ce..c662882a05ef7197c41be61363c78ee00e3f977a 100644 (file)
@@ -35,7 +35,7 @@ func TestMkdirAll(t *testing.T) {
        // Can't make directory named after file.
        err = MkdirAll(fpath, 0777)
        if err == nil {
-               t.Fatalf("MkdirAll %q: no error")
+               t.Fatalf("MkdirAll %q: no error", fpath)
        }
        perr, ok := err.(*PathError)
        if !ok {
@@ -49,7 +49,7 @@ func TestMkdirAll(t *testing.T) {
        ffpath := fpath + "/subdir"
        err = MkdirAll(ffpath, 0777)
        if err == nil {
-               t.Fatalf("MkdirAll %q: no error")
+               t.Fatalf("MkdirAll %q: no error", ffpath)
        }
        perr, ok = err.(*PathError)
        if !ok {
@@ -135,7 +135,7 @@ func TestRemoveAll(t *testing.T) {
                        if err == nil {
                                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)
                if !ok {
index e00ac097298136e58dda5be13b2afd116f458fbb..971f32eb7ac414423b35b9fdb2eef28065ed2093 100644 (file)
@@ -257,7 +257,7 @@ func TestWalk(t *testing.T) {
        errors := make(chan os.Error, 64)
        Walk(tree.name, v, errors)
        if err, ok := <-errors; ok {
-               t.Errorf("no error expected, found: s", err)
+               t.Error("no error expected, found: s", err)
        }
        checkMarks(t)
 
index 25e429a9d45615b70e0eb38dc5a8bf42e5011c30..e745ab8afb6ef65da776635cd3f7e11ea6be3229 100644 (file)
@@ -873,7 +873,7 @@ func TestMap(t *testing.T) {
                // Check that value lookup is correct.
                vv := mv.Elem(NewValue(k))
                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.
index 7a95456214d8a582cd0237411794961d4be80b23..497df5b18d80bbc3c32c7101f38fb539701d5979 100644 (file)
@@ -46,7 +46,7 @@ func TestAtob(t *testing.T) {
                        }
                } else {
                        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 {
                                t.Errorf("%s: expected %t but got %t", test.in, test.out, b)
index eeae1022ce64ec13cc6f73a13ab56e7acbe62f72..063ab71b44649a0dbbd84f2bf592095b9aade392 100644 (file)
@@ -47,7 +47,7 @@ func TestNew(t *testing.T) {
 func TestNewLogger(t *testing.T) {
        f := NewLogger(LOG_INFO, 0)
        if f == nil {
-               t.Errorf("NewLogger() failed")
+               t.Error("NewLogger() failed")
        }
 }
 
index d089a9b98ca1739e1524fd863ee5f1a9ac53a831..2a63a0f2b3bd5343d8447623662bf34736a74aec 100644 (file)
@@ -31,7 +31,7 @@ func TestTicker(t *testing.T) {
        Sleep(2 * Delta)
        _, received := <-ticker.C
        if received {
-               t.Fatalf("Ticker did not shut down")
+               t.Fatal("Ticker did not shut down")
        }
 }
 
index 4c6d83f3e69453d53c3b513cdbd9e99e6064d7c6..c8e7eb442008edfd93fd3f473865c24ae9aa2081 100644 (file)
@@ -329,7 +329,7 @@ func printCategories() {
                for k, _ := range category {
                        fmt.Printf("\t%q: %s,\n", k, k)
                }
-               fmt.Printf("}\n\n")
+               fmt.Print("}\n\n")
        }
 
        decl := make(sort.StringArray, len(list))
@@ -377,7 +377,7 @@ func printCategories() {
        for _, d := range decl {
                fmt.Print(d)
        }
-       fmt.Println(")\n")
+       fmt.Print(")\n\n")
 }
 
 type Op func(code int) bool
@@ -597,7 +597,7 @@ func printScriptOrProperty(doProps bool) {
                for k, _ := range table {
                        fmt.Printf("\t%q: %s,\n", k, k)
                }
-               fmt.Printf("}\n\n")
+               fmt.Print("}\n\n")
        }
 
        decl := make(sort.StringArray, len(list))
@@ -618,14 +618,14 @@ func printScriptOrProperty(doProps bool) {
                for _, s := range ranges {
                        fmt.Printf(format, s.Lo, s.Hi, s.Stride)
                }
-               fmt.Printf("}\n\n")
+               fmt.Print("}\n\n")
        }
        decl.Sort()
        fmt.Println("var (")
        for _, d := range decl {
                fmt.Print(d)
        }
-       fmt.Println(")\n")
+       fmt.Print(")\n\n")
 }
 
 const (
@@ -792,7 +792,7 @@ func printCases() {
                }
                prevState = state
        }
-       fmt.Printf("}\n")
+       fmt.Print("}\n")
 }
 
 func printCaseRange(lo, hi *caseState) {
index 0733b061c16b6041e37898ea24b3004b026fb85f..9dd847247306de6209e69d77c967c3da719367fc 100644 (file)
@@ -15,7 +15,7 @@ func TestScanForwards(t *testing.T) {
                runes := []int(s)
                str := NewString(s)
                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
                }
                for i, expect := range runes {
@@ -32,7 +32,7 @@ func TestScanBackwards(t *testing.T) {
                runes := []int(s)
                str := NewString(s)
                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
                }
                for i := len(runes) - 1; i >= 0; i-- {
@@ -55,7 +55,7 @@ func TestRandomAccess(t *testing.T) {
                runes := []int(s)
                str := NewString(s)
                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
                }
                for j := 0; j < randCount; j++ {
@@ -77,7 +77,7 @@ func TestRandomSliceAccess(t *testing.T) {
                runes := []int(s)
                str := NewString(s)
                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
                }
                for k := 0; k < randCount; k++ {
index 59896aa656d426fce8a06095ed210057a0f55013..7a1db93e550d7f5510836c7c15ba511f7fee20c4 100644 (file)
@@ -166,7 +166,7 @@ func TestIntConversion(t *testing.T) {
        for _, ts := range testStrings {
                runes := []int(ts)
                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
                }
                i := 0
index c66c114589d95135ff3ac000a178fe518b4a71d0..cc4b9dc1898be6cf9c0bb18948badce99848e120 100644 (file)
@@ -155,7 +155,7 @@ func TestHTTP(t *testing.T) {
        // specification, the server should abort the WebSocket connection.
        _, _, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr))
        if err == nil {
-               t.Errorf("Get: unexpected success")
+               t.Error("Get: unexpected success")
                return
        }
        urlerr, ok := err.(*http.URLError)
index 00688969f26d0cfb2b7168b19c4bdca870b35e40..2c73fcc803ed88125e995284d9f5a1c9f0458930 100644 (file)
@@ -301,7 +301,7 @@ func TestIssue569(t *testing.T) {
        err := Unmarshal(buf, &i)
 
        if err != nil || i.Field_a != "abcd" {
-               t.Fatalf("Expecting abcd")
+               t.Fatal("Expecting abcd")
        }
 }