diff options
| author | Rob Pike <r@golang.org> | 2011-12-22 13:58:58 -0800 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2011-12-22 13:58:58 -0800 |
| commit | dd1a34bdae65c8126fc9b36debd856f7a6e47b86 (patch) | |
| tree | 4f91991660efca8bc05c0cf070f67802ab4c5055 /src/pkg/path/filepath/path_test.go | |
| parent | ddf67af01b49789974201c930a7b13993219c164 (diff) | |
| download | go-dd1a34bdae65c8126fc9b36debd856f7a6e47b86.tar.xz | |
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
Diffstat (limited to 'src/pkg/path/filepath/path_test.go')
| -rw-r--r-- | src/pkg/path/filepath/path_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
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 |
