os: improve Readdir test coverage, fix Readdir(0) on EOF

Adds tests for Readdir and Readdirnames with different n
values.  No good way to inject faults during full reads,
though.

Also fixes bug report from fshahriar:
Readdir(0) wasn't behaving like Readdir(-1).

R=rsc, fshahriar
CC=golang-dev
https://golang.org/cl/4529092
This commit is contained in:
Brad Fitzpatrick 2011-05-27 12:14:48 -07:00
parent 0b204e4625
commit 0e865ab8e7
2 changed files with 66 additions and 1 deletions

View file

@ -32,7 +32,7 @@ func (f *File) Readdirnames(n int) (names []string, err Error) {
f.dirinfo.buf = make([]byte, blockSize)
}
d := f.dirinfo
wantAll := n < 0
wantAll := n <= 0
size := n
if size < 0 {