aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/strings/replace_test.go
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2013-11-01 11:18:49 +1100
committerAndrew Gerrand <adg@golang.org>2013-11-01 11:18:49 +1100
commitefb3af3d5c33dbdbad0fc52e95680843bb77ee72 (patch)
tree7bea6509151a4cd32294f6c1deeaeb6c1821f478 /src/pkg/strings/replace_test.go
parent7191e085990417cb17e51a61470debdea6297b5a (diff)
downloadgo-efb3af3d5c33dbdbad0fc52e95680843bb77ee72.tar.xz
[release-branch.go1.2] strings: fix Replacer bug with prefix matches
««« CL 16880043 / 0eb6508d3e88 strings: fix Replacer bug with prefix matches singleStringReplacer had a bug where if a string was replaced at the beginning and no output had yet been produced into the temp buffer before matching ended, an invalid nil check (used as a proxy for having matched anything) meant it always returned its input. Fixes #6659 R=golang-dev, r CC=golang-dev https://golang.org/cl/16880043 »»» R=golang-dev CC=golang-dev https://golang.org/cl/20570044
Diffstat (limited to 'src/pkg/strings/replace_test.go')
-rw-r--r--src/pkg/strings/replace_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pkg/strings/replace_test.go b/src/pkg/strings/replace_test.go
index d33dea95b0..82e4b6ef08 100644
--- a/src/pkg/strings/replace_test.go
+++ b/src/pkg/strings/replace_test.go
@@ -261,10 +261,21 @@ func TestReplacer(t *testing.T) {
testCases = append(testCases,
testCase{abcMatcher, "", ""},
testCase{abcMatcher, "ab", "ab"},
+ testCase{abcMatcher, "abc", "[match]"},
testCase{abcMatcher, "abcd", "[match]d"},
testCase{abcMatcher, "cabcabcdabca", "c[match][match]d[match]a"},
)
+ // Issue 6659 cases (more single string replacer)
+
+ noHello := NewReplacer("Hello", "")
+ testCases = append(testCases,
+ testCase{noHello, "Hello", ""},
+ testCase{noHello, "Hellox", "x"},
+ testCase{noHello, "xHello", "x"},
+ testCase{noHello, "xHellox", "xx"},
+ )
+
// No-arg test cases.
nop := NewReplacer()