Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / invoke-string-ctors.cs
1 using System;
2 using System.Reflection;
3
4 class T {
5
6         const int count = 10000;
7         static int Main () {
8                 int res, i;
9                 for (i = 0; i < count; ++i) {
10                         res = run ();
11                         if (res != 0)
12                                 return res;
13                 }
14                 return 0;
15         }
16
17         static unsafe int run () {
18                 char[] val = new char[] {'h', 'e', 'l', 'l', 'o'};
19                 string a;
20
21                 a = (string)Activator.CreateInstance (typeof (string), new object[] {'a', 5});
22                 if (a != "aaaaa") {
23                         return 1;
24                 }
25                 a = (string)Activator.CreateInstance (typeof (string), new object[] {val});
26                 if (a != "hello") {
27                         return 2;
28                 }
29                 a = (string)Activator.CreateInstance (typeof (string), new object[] {val, 0, 3});
30                 if (a != "hel") {
31                         return 3;
32                 }
33                 /*
34                  * The other ctors use pointers: maybe something like this is supposed to work some day.
35                 fixed (char *c = val) {
36                         a = (string)Activator.CreateInstance (typeof (string), new object[] {Pointer.Box (c, typeof (char*))});
37                         if (a != "hello") {
38                                 return 4;
39                         }
40                 }*/
41                 return 0;
42         }
43 }
44