2002-06-24 Dietmar Maurer <dietmar@ximian.com>
[mono.git] / mono / tests / marshal1.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 public class Test {
5
6         public static int Main () {
7                 byte [] bytesrc = new byte [20];
8                 byte [] bytedest = new byte [20];
9
10                 IntPtr dest = Marshal.AllocHGlobal (1024);
11
12                 foreach (byte b in bytesrc)
13                         b = 0;
14                 
15                 bytesrc [2] = 2;
16                 bytesrc [11] = 11;              
17                 Marshal.Copy (bytesrc, 2, dest, 10);
18
19                 if (Marshal.ReadByte (dest, 0) != 2)
20                         return 1;
21                 if (Marshal.ReadByte (dest, 9) != 11)
22                         return 1;
23
24                 Marshal.Copy (dest, bytedest, 2, 10);
25
26                 if (bytedest [2] != 2)
27                         return 1;
28                 if (bytedest [11] != 11)
29                         return 1;               
30
31                 return 0;
32         }
33 }
34