]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: simplify TestToNorm
authorHiroshi Ioka <hirochachacha@gmail.com>
Tue, 20 Sep 2016 10:43:34 +0000 (19:43 +0900)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 16 Oct 2016 09:21:57 +0000 (09:21 +0000)
Change-Id: I8a176ed9c7f59ebdfd39c1e2b88905f977179982
Reviewed-on: https://go-review.googlesource.com/31119
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/path/filepath/path_windows_test.go

index 2be200cb7d1a8c01e5062ae0d0c16662eb6feee8..7bfa6e42a0eec76a0649c3f2ce309db20079801e 100644 (file)
@@ -383,10 +383,12 @@ func TestToNorm(t *testing.T) {
        tmpVol := filepath.VolumeName(tmp)
        tmpNoVol := tmp[len(tmpVol):]
 
+       replacer := strings.NewReplacer("{{tmp}}", tmp, "{{tmpvol}}", tmpVol, "{{tmpnovol}}", tmpNoVol)
+
        for _, test := range testsDir {
-               wd := strings.Replace(strings.Replace(strings.Replace(test.wd, "{{tmp}}", tmp, -1), "{{tmpvol}}", tmpVol, -1), "{{tmpnovol}}", tmpNoVol, -1)
-               arg := strings.Replace(strings.Replace(strings.Replace(test.arg, "{{tmp}}", tmp, -1), "{{tmpvol}}", tmpVol, -1), "{{tmpnovol}}", tmpNoVol, -1)
-               want := strings.Replace(strings.Replace(strings.Replace(test.want, "{{tmp}}", tmp, -1), "{{tmpvol}}", tmpVol, -1), "{{tmpnovol}}", tmpNoVol, -1)
+               wd := replacer.Replace(test.wd)
+               arg := replacer.Replace(test.arg)
+               want := replacer.Replace(test.want)
 
                if test.wd == "." {
                        err := os.Chdir(cwd)