From: Leon Klingele Date: Sun, 3 Feb 2019 16:07:39 +0000 (+0000) Subject: bytes: clean up a test X-Git-Tag: go1.13beta1~1366 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=97f81572c4a97b6539f0a7b3ca3089daf3d6b4c3;p=gostls13.git bytes: clean up a test Change-Id: Iaa0e1721996b582bba9509c083755e1f125abb6b GitHub-Last-Rev: c9b13ec0cdc2b22aafa54706dc6df6113a11712b GitHub-Pull-Request: golang/go#29996 Reviewed-on: https://go-review.googlesource.com/c/160420 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/bytes/buffer_test.go b/src/bytes/buffer_test.go index 6e9d6952a5..7626d277d4 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) } } }