2007-03-19 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mcs / tests / gtest-166.cs
blobccfa38d0aecaa1572ebf8d2bc4f44c2eedaba93d
1 // Compiler options: -unsafe -r:gtest-166-lib.dll
3 // Fixed buffers tests
5 using System;
7 public unsafe struct TestNew {
8 private fixed char test_1 [128];
9 public fixed bool test2 [4];
11 public fixed int T [2];
12 public fixed bool test20 [4], test21 [40];
14 private int foo, foo2;
15 public void SetTest () {
16 fixed (char* c = test_1) {
17 *c = 'g';
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;
31 ExternalStruct es = new ExternalStruct ();
32 es.double_buffer [1] = 999999.8888;
33 es.double_buffer [0] = es.double_buffer [1];
35 // Attributes test
36 if (Attribute.GetCustomAttribute (typeof (TestNew).GetField ("test2"), typeof (System.Runtime.CompilerServices.FixedBufferAttribute)) == null)
37 return 3;
40 if (typeof (TestNew).GetNestedTypes ().Length != 5)
41 return 5;
43 foreach (Type t in typeof (TestNew).GetNestedTypes ()) {
44 if (Attribute.GetCustomAttribute (t, typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute)) == null)
45 return 4;
48 Console.WriteLine ("OK");
49 return 0;
52 public static int Main () {
53 return Test ();