bytes: clean up a test

This commit is contained in:
Leon Klingele 2019-02-03 17:05:21 +01:00
parent 56c9f8e8cf
commit c9b13ec0cd
No known key found for this signature in database
GPG Key ID: 0C8AF48831EEC211
1 changed files with 8 additions and 14 deletions

View File

@ -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)
}
}
}