2003-08-22 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / tests / unsafe-6.cs
1 //
2 // This tests excercises the compound assignment when the left side
3 // is an dereference operator.
4 //
5 using System;
6 namespace TestCase {
7         public unsafe class Test {
8                 static int Main(string[] args) {
9                         uint[] uArr = {0, 200};
10                         uint[] uArr2 = {0, 200};
11
12                         fixed (uint* u = uArr, u2 = uArr2) {
13                                 if (DoOp (u) != 100)
14                                         return 1;
15
16                                 if (uArr [0] != 100)
17                                         return 2;
18
19                                 if (uArr [1] != 200)
20                                         return 3;
21
22                                 if (DoOp2 (u2) != 100)
23                                         return 4;
24
25                                 if (uArr2 [0] != 100)
26                                         return 5;
27
28                                 if (uArr2 [1] != 200)
29                                         return 6;
30                         }
31
32                         return 0;
33                 }
34
35                 private static uint DoOp (uint *u) {
36                         return *(u) += 100;
37                 }
38
39                 private static uint DoOp2 (uint *u) {
40                         *(u) += 100;
41                         return *u;
42                 }
43
44         }
45 }
46