From: Hiroshi Ioka Date: Tue, 20 Sep 2016 10:43:34 +0000 (+0900) Subject: path/filepath: simplify TestToNorm X-Git-Tag: go1.8beta1~863 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ad50408fe7d9edfc7a1d9791e7391df132bc58b2;p=gostls13.git path/filepath: simplify TestToNorm Change-Id: I8a176ed9c7f59ebdfd39c1e2b88905f977179982 Reviewed-on: https://go-review.googlesource.com/31119 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go index 2be200cb7d..7bfa6e42a0 100644 --- a/src/path/filepath/path_windows_test.go +++ b/src/path/filepath/path_windows_test.go @@ -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)