2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / gtest-166.cs
blob022b823ade2c716a68a7c21c3ea8592a610a8028
1 // Compiler options: -unsafe -r:gtest-166-lib.dll
3 // Fixed buffers tests
5 using System;
6 using System.Runtime.InteropServices;
8 //[module: DefaultCharSet (CharSet.Ansi)]
10 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
11 public unsafe struct TestNew {
12 private fixed char test_1 [128];
13 public fixed bool test2 [4];
15 public fixed int T [2];
16 public fixed bool test20 [4], test21 [40];
18 private int foo, foo2;
19 public void SetTest () {
20 fixed (char* c = test_1) {
21 *c = 'g';
26 struct Struct2 {
27 public unsafe fixed byte Pad[64];
30 public class C {
31 unsafe static int Test () {
32 TestNew tt = new TestNew ();
33 tt.SetTest ();
34 tt.test2 [2] = false;
35 tt.T [1] = 5544;
36 if (tt.T [1] != 5544)
37 return 2;
39 ExternalStruct es = new ExternalStruct ();
40 es.double_buffer [1] = 999999.8888;
41 es.double_buffer [0] = es.double_buffer [1];
43 // Attributes test
44 if (Attribute.GetCustomAttribute (typeof (TestNew).GetField ("test2"), typeof (System.Runtime.CompilerServices.FixedBufferAttribute)) == null)
45 return 3;
48 if (typeof (TestNew).GetNestedTypes ().Length != 5)
49 return 5;
51 foreach (Type t in typeof (TestNew).GetNestedTypes ()) {
52 if (Attribute.GetCustomAttribute (t, typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute)) == null)
53 return 40;
55 if (Attribute.GetCustomAttribute (t, typeof (System.Runtime.CompilerServices.UnsafeValueTypeAttribute)) == null)
56 return 41;
58 if (!t.IsUnicodeClass)
59 return 42;
62 Console.WriteLine ("OK");
63 return 0;
66 public static int Main () {
67 return Test ();