tests: fix prints
- delete unnecessary newlines
- make sure formatted prints call the formatting routines
R=adg
CC=golang-dev
https://golang.org/cl/2225046
diff --git a/src/pkg/bytes/buffer_test.go b/src/pkg/bytes/buffer_test.go
index bc696f4..53086a4 100644
--- a/src/pkg/bytes/buffer_test.go
+++ b/src/pkg/bytes/buffer_test.go
@@ -30,19 +30,19 @@
bytes := buf.Bytes()
str := buf.String()
if buf.Len() != len(bytes) {
- t.Errorf("%s: buf.Len() == %d, len(buf.Bytes()) == %d\n", testname, buf.Len(), len(bytes))
+ t.Errorf("%s: buf.Len() == %d, len(buf.Bytes()) == %d", testname, buf.Len(), len(bytes))
}
if buf.Len() != len(str) {
- t.Errorf("%s: buf.Len() == %d, len(buf.String()) == %d\n", testname, buf.Len(), len(str))
+ t.Errorf("%s: buf.Len() == %d, len(buf.String()) == %d", testname, buf.Len(), len(str))
}
if buf.Len() != len(s) {
- t.Errorf("%s: buf.Len() == %d, len(s) == %d\n", testname, buf.Len(), len(s))
+ t.Errorf("%s: buf.Len() == %d, len(s) == %d", testname, buf.Len(), len(s))
}
if string(bytes) != s {
- t.Errorf("%s: string(buf.Bytes()) == %q, s == %q\n", testname, string(bytes), s)
+ t.Errorf("%s: string(buf.Bytes()) == %q, s == %q", testname, string(bytes), s)
}
}
@@ -55,10 +55,10 @@
for ; n > 0; n-- {
m, err := buf.WriteString(fus)
if m != len(fus) {
- t.Errorf(testname+" (fill 2): m == %d, expected %d\n", m, len(fus))
+ t.Errorf(testname+" (fill 2): m == %d, expected %d", m, len(fus))
}
if err != nil {
- t.Errorf(testname+" (fill 3): err should always be nil, found err == %s\n", err)
+ t.Errorf(testname+" (fill 3): err should always be nil, found err == %s", err)
}
s += fus
check(t, testname+" (fill 4)", buf, s)
@@ -75,10 +75,10 @@
for ; n > 0; n-- {
m, err := buf.Write(fub)
if m != len(fub) {
- t.Errorf(testname+" (fill 2): m == %d, expected %d\n", m, len(fub))
+ t.Errorf(testname+" (fill 2): m == %d, expected %d", m, len(fub))
}
if err != nil {
- t.Errorf(testname+" (fill 3): err should always be nil, found err == %s\n", err)
+ t.Errorf(testname+" (fill 3): err should always be nil, found err == %s", err)
}
s += string(fub)
check(t, testname+" (fill 4)", buf, s)
@@ -110,7 +110,7 @@
break
}
if err != nil {
- t.Errorf(testname+" (empty 2): err should always be nil, found err == %s\n", err)
+ t.Errorf(testname+" (empty 2): err should always be nil, found err == %s", err)
}
s = s[n:]
check(t, testname+" (empty 3)", buf, s)
@@ -134,10 +134,10 @@
n, err := buf.Write(Bytes(data[0:1]))
if n != 1 {
- t.Errorf("wrote 1 byte, but n == %d\n", n)
+ t.Errorf("wrote 1 byte, but n == %d", n)
}
if err != nil {
- t.Errorf("err should always be nil, but err == %s\n", err)
+ t.Errorf("err should always be nil, but err == %s", err)
}
check(t, "TestBasicOperations (4)", &buf, "a")
@@ -146,7 +146,7 @@
n, err = buf.Write(Bytes(data[2:26]))
if n != 24 {
- t.Errorf("wrote 25 bytes, but n == %d\n", n)
+ t.Errorf("wrote 25 bytes, but n == %d", n)
}
check(t, "TestBasicOperations (6)", &buf, string(data[0:26]))
@@ -162,14 +162,14 @@
buf.WriteByte(data[1])
c, err := buf.ReadByte()
if err != nil {
- t.Errorf("ReadByte unexpected eof\n")
+ t.Error("ReadByte unexpected eof")
}
if c != data[1] {
- t.Errorf("ReadByte wrong value c=%v\n", c)
+ t.Error("ReadByte wrong value c=%v", c)
}
c, err = buf.ReadByte()
if err == nil {
- t.Errorf("ReadByte unexpected not eof\n")
+ t.Error("ReadByte unexpected not eof")
}
}
}
@@ -238,7 +238,7 @@
func TestNil(t *testing.T) {
var b *Buffer
if b.String() != "<nil>" {
- t.Error("expcted <nil>; got %q", b.String())
+ t.Errorf("expcted <nil>; got %q", b.String())
}
}