aboutsummaryrefslogtreecommitdiff
path: root/src/bytes/bytes_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2018-09-26 20:19:11 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-09-26 20:51:23 +0000
commitebdc0b8d68e04ad383088c8b3ab963de4a9b5c5d (patch)
treec6ccca03228b99d0042fd0d18ac91c9380355d40 /src/bytes/bytes_test.go
parent5a8c11ce3e7a87485defafb78c7bcf14f9d7b5a2 (diff)
downloadgo-ebdc0b8d68e04ad383088c8b3ab963de4a9b5c5d.tar.xz
bytes, strings: add ReplaceAll
Credit to Harald Nordgren for the proposal in https://golang.org/cl/137456 and #27864. Fixes #27864 Change-Id: I80546683b0623124fe4627a71af88add2f6c1c27 Reviewed-on: https://go-review.googlesource.com/137855 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/bytes/bytes_test.go')
-rw-r--r--src/bytes/bytes_test.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go
index 55a22bae22..f4c0ffd2a9 100644
--- a/src/bytes/bytes_test.go
+++ b/src/bytes/bytes_test.go
@@ -1362,6 +1362,12 @@ func TestReplace(t *testing.T) {
if cap(in) == cap(out) && &in[:1][0] == &out[:1][0] {
t.Errorf("Replace(%q, %q, %q, %d) didn't copy", tt.in, tt.old, tt.new, tt.n)
}
+ if tt.n == -1 {
+ out := ReplaceAll(in, []byte(tt.old), []byte(tt.new))
+ if s := string(out); s != tt.out {
+ t.Errorf("ReplaceAll(%q, %q, %q) = %q, want %q", tt.in, tt.old, tt.new, s, tt.out)
+ }
+ }
}
}