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