From ad50408fe7d9edfc7a1d9791e7391df132bc58b2 Mon Sep 17 00:00:00 2001 From: Hiroshi Ioka Date: Tue, 20 Sep 2016 19:43:34 +0900 Subject: [PATCH] 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 --- src/path/filepath/path_windows_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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)