Commit 97f81572 authored by Leon Klingele's avatar Leon Klingele Committed by Brad Fitzpatrick

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 <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 068a832a
......@@ -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)
}
}
}
......
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