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
This commit is contained in:
Gustavo Niemeyer 2012-07-20 16:04:22 -03:00
parent 7bf8355dc7
commit c0efcac6a9
2 changed files with 11 additions and 6 deletions

View file

@ -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)
}
}
}
}