diff options
author | Russ Cox <rsc@golang.org> | 2009-06-24 15:35:35 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-06-24 15:35:35 -0700 |
commit | dfb87f8c51fe464d263cff5dfde93c8d1c9964e9 (patch) | |
tree | e2d71892ab2cb3612167f91d17e4022b5b1a8bcd /src/pkg/bytes/bytes_test.go | |
parent | d61c2b2d31f0d692d0eba8101a7b7faf6b127778 (diff) | |
download | golang-dfb87f8c51fe464d263cff5dfde93c8d1c9964e9.tar.gz |
make bytes.Copy both src- and dst- limited
and return the number of bytes copied.
R=r
DELTA=18 (6 added, 0 deleted, 12 changed)
OCL=30693
CL=30712
Diffstat (limited to 'src/pkg/bytes/bytes_test.go')
-rw-r--r-- | src/pkg/bytes/bytes_test.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/pkg/bytes/bytes_test.go b/src/pkg/bytes/bytes_test.go index 4e7cdfad6..3fbe21c30 100644 --- a/src/pkg/bytes/bytes_test.go +++ b/src/pkg/bytes/bytes_test.go @@ -132,25 +132,27 @@ func TestSplit(t *testing.T) { type CopyTest struct { a string; b string; + n int; 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" }, + 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 := io.StringBytes(tt.a); - Copy(dst, io.StringBytes(tt.b)); + n := 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); + 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; } } |