mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
remove bytes.Copy
replace all calls with calls to copy use copy in regexp and bytes.Buffer R=rsc CC=golang-dev https://golang.org/cl/157073
This commit is contained in:
parent
093493c6a5
commit
e70cedfaec
22 changed files with 147 additions and 218 deletions
|
|
@ -172,36 +172,6 @@ func TestSplitAfter(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
type CopyTest struct {
|
||||
a string;
|
||||
b string;
|
||||
n int;
|
||||
res string;
|
||||
}
|
||||
|
||||
var copytests = []CopyTest{
|
||||
CopyTest{"", "", 0, ""},
|
||||
CopyTest{"a", "", 0, "a"},
|
||||
CopyTest{"a", "a", 1, "a"},
|
||||
CopyTest{"a", "b", 1, "b"},
|
||||
CopyTest{"xyz", "abc", 3, "abc"},
|
||||
CopyTest{"wxyz", "abc", 3, "abcz"},
|
||||
CopyTest{"xyz", "abcd", 3, "abc"},
|
||||
}
|
||||
|
||||
func TestCopy(t *testing.T) {
|
||||
for i := 0; i < len(copytests); i++ {
|
||||
tt := copytests[i];
|
||||
dst := strings.Bytes(tt.a);
|
||||
n := Copy(dst, strings.Bytes(tt.b));
|
||||
result := string(dst);
|
||||
if result != tt.res || n != tt.n {
|
||||
t.Errorf(`Copy(%q, %q) = %d, %q; want %d, %q`, tt.a, tt.b, n, result, tt.n, tt.res);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test case for any function which accepts and returns a byte array.
|
||||
// For ease of creation, we write the byte arrays as strings.
|
||||
type StringTest struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue