From dd1a34bdae65c8126fc9b36debd856f7a6e47b86 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Thu, 22 Dec 2011 13:58:58 -0800 Subject: path/filepath: Dir There was Base but not Dir, so fill in the gap. R=n13m3y3r, r, rsc, gustavo CC=golang-dev https://golang.org/cl/5503067 --- src/pkg/path/filepath/path_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/pkg/path/filepath/path_test.go') diff --git a/src/pkg/path/filepath/path_test.go b/src/pkg/path/filepath/path_test.go index 67d8858fc3..49a7135b4a 100644 --- a/src/pkg/path/filepath/path_test.go +++ b/src/pkg/path/filepath/path_test.go @@ -431,6 +431,29 @@ func TestBase(t *testing.T) { } } +var dirtests = []PathTest{ + {"", "."}, + {".", "."}, + {"/.", "/"}, + {"/", "/"}, + {"////", "/"}, + {"/foo", "/"}, + {"x/", "x"}, + {"abc", "."}, + {"abc/def", "abc"}, + {"a/b/.x", "a/b"}, + {"a/b/c.", "a/b"}, + {"a/b/c.x", "a/b"}, +} + +func TestDir(t *testing.T) { + for _, test := range dirtests { + if s := filepath.ToSlash(filepath.Dir(test.path)); s != test.result { + t.Errorf("Dir(%q) = %q, want %q", test.path, s, test.result) + } + } +} + type IsAbsTest struct { path string isAbs bool -- cgit v1.3