8 const byte TotalLength
= 32;
10 public static byte Expected (byte dest
, byte src
, int len
, byte i
)
12 if (i
>= dest
&& i
< dest
+ len
)
13 return (byte) (src
+ (i
- dest
));
18 public static bool TestMove (byte dest
, byte src
, int len
)
20 byte[] array
= new byte [TotalLength
];
21 for (byte i
= 0; i
< TotalLength
; ++i
)
23 Buffer
.BlockCopy (array
, src
, array
, dest
, len
);
24 for (byte i
= 0; i
< TotalLength
; ++i
)
26 if (array
[i
] != Expected (dest
, src
, len
, i
)) {
27 Console
.WriteLine ("when copying " + len
+ " from " + src
+ " to " + dest
+ ": expected ");
28 for (byte j
= 0; j
< TotalLength
; ++j
)
29 Console
.Write ("" + Expected (dest
, src
, len
, j
) + " ");
31 Console
.WriteLine ("got");
32 for (byte j
= 0; j
< TotalLength
; ++j
)
33 Console
.Write ("" + array
[j
] + " ");
41 public static int Main (string[] args
)
44 for (byte i
= 0; i
< TotalLength
; ++i
) {
45 for (byte j
= 0; j
< TotalLength
; ++j
) {
46 byte max
= (byte) (TotalLength
- Math
.Max (i
, j
));
47 for (byte l
= 0; l
< max
; ++l
) {
48 if (!TestMove (i
, j
, l
))
54 return failed
? 1 : 0;