diff --git a/src/bytes/buffer_test.go b/src/bytes/buffer_test.go index 6e9d6952a51a58..7626d277d4f489 100644 --- a/src/bytes/buffer_test.go +++ b/src/bytes/buffer_test.go @@ -131,11 +131,8 @@ func TestBasicOperations(t *testing.T) { check(t, "TestBasicOperations (3)", &buf, "") n, err := buf.Write(testBytes[0:1]) - if n != 1 { - t.Errorf("wrote 1 byte, but n == %d", n) - } - if err != nil { - t.Errorf("err should always be nil, but err == %s", err) + if want := 1; err != nil || n != want { + t.Errorf("Write: got (%d, %v), want (%d, %v)", n, err, want, nil) } check(t, "TestBasicOperations (4)", &buf, "a") @@ -143,8 +140,8 @@ func TestBasicOperations(t *testing.T) { check(t, "TestBasicOperations (5)", &buf, "ab") n, err = buf.Write(testBytes[2:26]) - if n != 24 { - t.Errorf("wrote 24 bytes, but n == %d", n) + if want := 24; err != nil || n != want { + t.Errorf("Write: got (%d, %v), want (%d, %v)", n, err, want, nil) } check(t, "TestBasicOperations (6)", &buf, testString[0:26]) @@ -159,15 +156,12 @@ func TestBasicOperations(t *testing.T) { buf.WriteByte(testString[1]) c, err := buf.ReadByte() - if err != nil { - t.Error("ReadByte unexpected eof") - } - if c != testString[1] { - t.Errorf("ReadByte wrong value c=%v", c) + if want := testString[1]; err != nil || c != want { + t.Errorf("ReadByte: got (%q, %v), want (%q, %v)", c, err, want, nil) } c, err = buf.ReadByte() - if err == nil { - t.Error("ReadByte unexpected not eof") + if err != io.EOF { + t.Errorf("ReadByte: got (%q, %v), want (%q, %v)", c, err, byte(0), io.EOF) } } }