| // Copyright 2012 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func TestForwardCopy(t *testing.T) { |
| {0, 9, 0, 9, "012345678"}, |
| for _, tc := range testCases { |
| b := []byte("0123456789") |
| forwardCopy(b, tc.dst0, tc.src0, n) |
| got := string(b[tc.dst0 : tc.dst0+n]) |
| t.Errorf("dst=b[%d:%d], src=b[%d:%d]: got %q, want %q", |
| tc.dst0, tc.dst1, tc.src0, tc.src1, got, tc.want) |
| // Check that the bytes outside of dst[:n] were not modified. |
| if i >= tc.dst0 && i < tc.dst0+n { |
| t.Errorf("dst=b[%d:%d], src=b[%d:%d]: copy overrun at b[%d]: got '%c', want '%c'", |
| tc.dst0, tc.dst1, tc.src0, tc.src1, i, x, '0'+i) |