From c0efcac6a97588f7013b7ec09dd56cb780bdce64 Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Fri, 20 Jul 2012 16:04:22 -0300 Subject: bytes: make Join return a new buffer on len(a) == 1 Fixes #3844. R=golang-dev, r CC=golang-dev https://golang.org/cl/6432054 --- src/pkg/bytes/bytes_test.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/pkg/bytes/bytes_test.go') diff --git a/src/pkg/bytes/bytes_test.go b/src/pkg/bytes/bytes_test.go index 000f235176..0e2ef504cf 100644 --- a/src/pkg/bytes/bytes_test.go +++ b/src/pkg/bytes/bytes_test.go @@ -490,6 +490,12 @@ func TestSplit(t *testing.T) { t.Errorf("Split disagrees withSplitN(%q, %q, %d) = %v; want %v", tt.s, tt.sep, tt.n, b, a) } } + if len(a) > 0 { + in, out := a[0], s + if cap(in) == cap(out) && &in[:1][0] == &out[:1][0] { + t.Errorf("Join(%#v, %q) didn't copy", a, tt.sep) + } + } } } -- cgit v1.3