diff --git a/memfile_test.go b/memfile_test.go new file mode 100644 index 0000000..b77ae8e --- /dev/null +++ b/memfile_test.go @@ -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) + } +}