mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
bytes.Copy
R=rsc DELTA=38 (38 added, 0 deleted, 0 changed) OCL=29895 CL=29895
This commit is contained in:
parent
78933226f1
commit
52e5d061c7
4 changed files with 38 additions and 0 deletions
|
|
@ -128,3 +128,30 @@ func TestSplit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
type CopyTest struct {
|
||||
a string;
|
||||
b string;
|
||||
res string;
|
||||
}
|
||||
var copytests = []CopyTest {
|
||||
CopyTest{ "", "", "" },
|
||||
CopyTest{ "a", "", "a" },
|
||||
CopyTest{ "a", "a", "a" },
|
||||
CopyTest{ "a", "b", "b" },
|
||||
CopyTest{ "xyz", "abc", "abc" },
|
||||
CopyTest{ "wxyz", "abc", "abcz" },
|
||||
}
|
||||
|
||||
func TestCopy(t *testing.T) {
|
||||
for i := 0; i < len(copytests); i++ {
|
||||
tt := copytests[i];
|
||||
dst := io.StringBytes(tt.a);
|
||||
Copy(dst, io.StringBytes(tt.b));
|
||||
result := string(dst);
|
||||
if result != tt.res {
|
||||
t.Errorf(`Copy("%s", "%s") = "%s"; want "%s"`, tt.a, tt.b, result, tt.res);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue