diff options
| author | Benny Siegert <bsiegert@gmail.com> | 2010-11-30 17:17:45 -0800 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2010-11-30 17:17:45 -0800 |
| commit | b06dc26a58df0a79e6be3004484809ffd2c60d74 (patch) | |
| tree | ad513997489aa9d89cf5442e2eb9b409bafd84ad /src/pkg/path/path_test.go | |
| parent | 555feea117532a5c033478997e1ce9b77b4f8eea (diff) | |
| download | go-b06dc26a58df0a79e6be3004484809ffd2c60d74.tar.xz | |
path: Windows support for Split
Make Split work on backslashes as well as on slashes under Windows
and support the "C:filename" special case. Also add corresponding
tests.
R=r, rsc, PeterGo, r2, brainman
CC=golang-dev
https://golang.org/cl/3008041
Diffstat (limited to 'src/pkg/path/path_test.go')
| -rw-r--r-- | src/pkg/path/path_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pkg/path/path_test.go b/src/pkg/path/path_test.go index 2bbb9244aa..e00ac09729 100644 --- a/src/pkg/path/path_test.go +++ b/src/pkg/path/path_test.go @@ -6,6 +6,7 @@ package path import ( "os" + "runtime" "testing" ) @@ -83,7 +84,18 @@ var splittests = []SplitTest{ {"/", "/", ""}, } +var winsplittests = []SplitTest{ + {`C:\Windows\System32`, `C:\Windows\`, `System32`}, + {`C:\Windows\`, `C:\Windows\`, ``}, + {`C:\Windows`, `C:\`, `Windows`}, + {`C:Windows`, `C:`, `Windows`}, + {`\\?\c:\`, `\\?\c:\`, ``}, +} + func TestSplit(t *testing.T) { + if runtime.GOOS == "windows" { + splittests = append(splittests, winsplittests...) + } for _, test := range splittests { if d, f := Split(test.path); d != test.dir || f != test.file { t.Errorf("Split(%q) = %q, %q, want %q, %q", test.path, d, f, test.dir, test.file) |
