Bump external/ikdasm to master.
[mono-project.git] / mono / tests / bug-705140.cs
blobc1ebb91741297bec63a1ce5f05565269727c8b8e
1 using System;
4 namespace BufferTest
6 class Test
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));
14 else
15 return i;
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)
22 array [i] = 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) + " ");
30 Console.WriteLine ();
31 Console.WriteLine ("got");
32 for (byte j = 0; j < TotalLength; ++j)
33 Console.Write ("" + array [j] + " ");
34 Console.WriteLine ();
35 return false;
38 return true;
41 public static int Main (string[] args)
43 bool failed = false;
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))
49 failed = true;
54 return failed ? 1 : 0;