Further updates to the makefile
[mono.git] / mcs / tests / test-120.cs
1 //
2 // This tests checks that the compiler catches the special attributes
3 // for in a struct for CharSet, and turns the right bit on the TypeAttribute
4 //
5 using System;
6 using System.Reflection;
7 using System.Runtime.InteropServices;
8
9 [StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Unicode)]
10 struct MyUnicode
11 {
12         [FieldOffset(0)] public float fh_float;
13         [FieldOffset(0)] public int fh_int;
14 }
15
16 [StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Ansi)]
17 struct MyAnsi
18 {
19         [FieldOffset(0)] public float fh_float;
20         [FieldOffset(0)] public int fh_int;
21 }
22 [StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Auto)]
23 struct MyAuto
24 {
25         [FieldOffset(0)] public float fh_float;
26         [FieldOffset(0)] public int fh_int;
27 }
28
29 class test
30 {
31         
32         static int Main ()
33         {
34                 Type t = typeof (MyUnicode);
35
36                 if ((t.Attributes & TypeAttributes.UnicodeClass) != TypeAttributes.UnicodeClass){
37                         Console.WriteLine ("Class MyUnicode does not have Unicode bit set");
38                         return 1;
39                 }
40
41                 t = typeof (MyAuto);
42                 if ((t.Attributes & TypeAttributes.AutoClass) != TypeAttributes.AutoClass){
43                         Console.WriteLine ("Class MyAuto does not have Auto bit set");
44                         return 2;
45                 }
46
47                 t = typeof (MyAnsi);
48
49                 if ((t.Attributes & TypeAttributes.AnsiClass) != TypeAttributes.AnsiClass){
50                         Console.WriteLine ("Class MyUnicode does not have Ansi bit set");
51                         return 3;
52                 }
53
54                 return 0;
55         }
56 }