2010-03-26 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / tests / string-compare.cs
blob3cb82cfdcfabdea1062dafcc4ca153ad9987b8cd
1 using System;
3 namespace T {
4 struct datum {
5 public string a;
6 public string b;
7 public int result;
9 public datum (string A, string B, int r) {
10 a = A;
11 b = B;
12 result =r;
15 public bool match () {
16 int r = String.Compare (a, b);
17 switch (result) {
18 case -1:
19 if (r < 0) return true;
20 break;
21 case 0:
22 if (r == 0) return true;
23 break;
24 case 1:
25 if (r > 0) return true;
26 break;
27 default:
28 return false;
30 return false;
33 public class test {
34 public static int Main() {
35 datum[] data = {
36 new datum ("a", "b", -1),
37 new datum ("a", "a", 0),
38 new datum ("b", "a", 1),
39 new datum ("ba", "b", 1),
40 new datum ("b", "ba", -1),
42 int i;
43 for (i = 0; i < data.Length; ++i) {
44 if (!data[i].match())
45 return i+1;
47 return 0;