2010-06-17 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / tests / invoke-string-ctors.cs
blobf132d04257f307aa9ca3a6727ecabd9ae6303c25
1 using System;
2 using System.Reflection;
4 class T {
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;
14 return 0;
17 static unsafe int run () {
18 char[] val = new char[] {'h', 'e', 'l', 'l', 'o'};
19 string a;
21 a = (string)Activator.CreateInstance (typeof (string), new object[] {'a', 5});
22 if (a != "aaaaa") {
23 return 1;
25 a = (string)Activator.CreateInstance (typeof (string), new object[] {val});
26 if (a != "hello") {
27 return 2;
29 a = (string)Activator.CreateInstance (typeof (string), new object[] {val, 0, 3});
30 if (a != "hel") {
31 return 3;
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;
40 }*/
41 return 0;