]> Cypherpunks repositories - gostls13.git/commitdiff
os: improve Readdir and Readdirnames test coverage
authorShawn Smith <shawn.p.smith@gmail.com>
Wed, 1 Jan 2014 05:40:52 +0000 (16:40 +1100)
committerDave Cheney <dave@cheney.net>
Wed, 1 Jan 2014 05:40:52 +0000 (16:40 +1100)
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46450043

src/pkg/os/os_test.go

index 414e4e6243a54c8f3e1c93dde4888bb324e74102..14ecd958750a7f2a14764d3e2659ae896446bbb2 100644 (file)
@@ -252,11 +252,25 @@ func TestReaddirnames(t *testing.T) {
        testReaddirnames(sysdir.name, sysdir.files, t)
 }
 
+func TestReaddirnamesNilFile(t *testing.T) {
+       var f *File
+       if fi, err := f.Readdirnames(1); fi != nil || err != ErrInvalid {
+               t.Errorf("Readdirnames should fail when f is nil: %v, %v", fi, err)
+       }
+}
+
 func TestReaddir(t *testing.T) {
        testReaddir(".", dot, t)
        testReaddir(sysdir.name, sysdir.files, t)
 }
 
+func TestReaddirNilFile(t *testing.T) {
+       var f *File
+       if fi, err := f.Readdir(1); fi != nil || err != ErrInvalid {
+               t.Errorf("Readdir should fail when f is nil: %v, %v", fi, err)
+       }
+}
+
 // Read the directory one entry at a time.
 func smallReaddirnames(file *File, length int, t *testing.T) []string {
        names := make([]string, length)