forked from mirror/afero
Add a test for the EOF behaviour of Read.
This commit is contained in:
parent
139e50e29a
commit
56a1f83590
|
@ -0,0 +1,27 @@
|
|||
package afero
|
||||
|
||||
import (
|
||||
"io"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMemFileRead(t *testing.T) {
|
||||
f := MemFileCreate("testfile")
|
||||
f.WriteString("abcd")
|
||||
f.Seek(0, 0)
|
||||
b := make([]byte, 8)
|
||||
n, err := f.Read(b)
|
||||
if n != 4 {
|
||||
t.Errorf("didn't read all bytes: %v %v %v", n, err, b)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("err is not nil: %v %v %v", n, err, b)
|
||||
}
|
||||
n, err = f.Read(b)
|
||||
if n != 0 {
|
||||
t.Errorf("read more bytes: %v %v %v", n, err, b)
|
||||
}
|
||||
if err != io.EOF {
|
||||
t.Errorf("error is not EOF: %v %v %v", n, err, b)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue