2010-06-17 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / tests / pack-bug.cs
blob26ec30a3e15ea62704599f4f4742bae3a0d1d97c
1 using System;
2 using System.Collections;
3 using System.Runtime.InteropServices;
4 // bug #77788
6 [StructLayout(LayoutKind.Sequential , Pack = 1)]
7 struct Bogus {
8 public byte b;
9 public string str;
11 public Bogus (int a) {
12 b = (byte)a;
13 str = "hello-" + a.ToString ();
17 class T {
19 static void test (Bogus[] arr) {
20 for (int i = 0; i < 256; ++i) {
21 if (arr [i].b != (byte)i)
22 throw new Exception ("wrong b at " + i);
23 if (arr [i].str != "hello-" + i.ToString ())
24 throw new Exception ("wrong str at " + i);
27 static void Main () {
28 Bogus[] arr = new Bogus [256];
29 int i;
30 for (i = 0; i < 256; ++i) {
31 arr [i] = new Bogus (i);
33 test (arr);
34 for (i = 0; i < 10000; ++i) {
35 ArrayList l = new ArrayList ();
36 l.Add (i);
39 GC.Collect ();
40 test (arr);