2005-06-03 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / tests / fixed-buffer-exe.cs
1 // Compiler options: -unsafe -r:fixed-buffer-dll.dll
2
3 using System;
4
5 public unsafe struct TestNew {
6         private fixed char test_1 [128];
7         public fixed bool test2 [4];
8         
9         public fixed int T [2];
10         public fixed bool test20 [4], test21 [40];
11         
12         private int foo, foo2;
13         public void SetTest () {
14                 fixed (char* c = test_1) {
15                         *c = 'g';
16                 }
17         }
18 }
19
20 public class C {
21         unsafe static int Test () {
22                 TestNew tt = new TestNew ();
23                 tt.SetTest ();
24                 tt.test2 [2] = false;
25                 tt.T [1] = 5544;
26                 if (tt.T [1] != 5544)
27                         return 2;
28         
29                 ExternalStruct es = new ExternalStruct ();
30                 es.double_buffer [1] = 999999.8888;
31                 es.double_buffer [0] = es.double_buffer [1];
32
33                 // Attributes test
34                 if (Attribute.GetCustomAttribute (typeof (TestNew).GetField ("test2"), typeof (System.Runtime.CompilerServices.FixedBufferAttribute)) == null)
35                         return 3;
36
37                 
38                 if (typeof (TestNew).GetNestedTypes ().Length != 5)
39                         return 5;
40
41                 foreach (Type t in typeof (TestNew).GetNestedTypes ()) {
42                         if (Attribute.GetCustomAttribute (t, typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute)) == null)
43                                 return 4;
44                 }
45
46                 Console.WriteLine ("OK");
47                 return 0;
48         }
49     
50         public static int Main () {
51                 return Test ();
52         }
53 }