]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils/testcases/org/simantics/utils/strings/TestAlphanumComparator.java
Don't run branch in branch-release if branch is not given
[simantics/platform.git] / bundles / org.simantics.utils / testcases / org / simantics / utils / strings / TestAlphanumComparator.java
1 package org.simantics.utils.strings;
2
3 import java.util.Arrays;
4
5 import org.junit.Test;
6
7
8 public class TestAlphanumComparator {
9
10     String[] test = {
11             "20X Radonius Prime",
12             "Xiph Xlater 10000",
13             "40X Radonius",
14             "20X Radonius",
15             "Xiph Xlater 5000",
16             "Allegia 6R Clasteron",
17             "200X Radonius",
18             "10X Radonius",
19             "Allegia 50B Clasteron",
20             "Allegia 50 Clasteron",
21             "30X Radonius",
22             "Allegia 51 Clasteron",
23             "Alpha 2A",
24             "1000X Radonius Maximus",
25             "Alpha 2A-8000",
26             "Allegia 500 Clasteron",
27             "Alpha 2A-900",
28             "Callisto Morphamax 600",
29             "Alpha 2",
30             "Callisto Morphamax",
31             "Callisto Morphamax 500",
32             "Xiph Xlater 58",
33             "Callisto Morphamax 6000 SE",
34             "Xiph Xlater 500",
35             "Alpha 100",
36             "Xiph Xlater 5",
37             "Callisto Morphamax 6000 SE2",
38             "Callisto Morphamax 7000",
39             "Callisto Morphamax 700",
40             "Xiph Xlater 40",
41             "Xiph Xlater 50",
42             "Callisto Morphamax 5000",
43             "Alpha 200",
44             "Xiph Xlater 300",
45             "Xiph Xlater 2000",
46     };
47
48     String[] expected = {
49             "10X Radonius",
50             "20X Radonius",
51             "20X Radonius Prime",
52             "30X Radonius",
53             "40X Radonius",
54             "200X Radonius",
55             "1000X Radonius Maximus",
56             "Allegia 6R Clasteron",
57             "Allegia 50 Clasteron",
58             "Allegia 50B Clasteron",
59             "Allegia 51 Clasteron",
60             "Allegia 500 Clasteron",
61             "Alpha 2",
62             "Alpha 2A",
63             "Alpha 2A-900",
64             "Alpha 2A-8000",
65             "Alpha 100",
66             "Alpha 200",
67             "Callisto Morphamax",
68             "Callisto Morphamax 500",
69             "Callisto Morphamax 600",
70             "Callisto Morphamax 700",
71             "Callisto Morphamax 5000",
72             "Callisto Morphamax 6000 SE",
73             "Callisto Morphamax 6000 SE2",
74             "Callisto Morphamax 7000",
75             "Xiph Xlater 5",
76             "Xiph Xlater 40",
77             "Xiph Xlater 50",
78             "Xiph Xlater 58",
79             "Xiph Xlater 300",
80             "Xiph Xlater 500",
81             "Xiph Xlater 2000",
82             "Xiph Xlater 5000",
83             "Xiph Xlater 10000",
84     };
85
86     @Test
87     public void testCaseSensitiveSort() {
88         Arrays.sort(test, AlphanumComparator.COMPARATOR);
89         for (int i = 0; i < test.length; ++i) {
90             if (!test[i].equals(expected[i])) {
91                 throw new RuntimeException("Sorting did not match expected result:\n  result: " + Arrays.toString(test) + "\n  expected: " + Arrays.toString(expected));
92             }
93         }
94     }
95
96     String[] test2 = {
97             "AlleGia 50 clAsTeron",
98             "ALLEgia 500 ClastERON",
99             "AlleGia 51 Clasteron",
100             "Allegia 6R CLASTERON",
101             "Allegia 50B Clasteron",
102     };
103
104     String[] expected2 = {
105             "Allegia 6R CLASTERON",
106             "AlleGia 50 clAsTeron",
107             "Allegia 50B Clasteron",
108             "AlleGia 51 Clasteron",
109             "ALLEgia 500 ClastERON",
110     };
111
112     @Test
113     public void testCaseInsensitiveSort() {
114         Arrays.sort(test2, AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);
115         for (int i = 0; i < test2.length; ++i) {
116             if (!test2[i].equals(expected2[i])) {
117                 throw new RuntimeException("Sorting did not match expected result:\n  result: " + Arrays.toString(test2) + "\n  expected: " + Arrays.toString(expected2));
118             }
119         }
120     }
121
122 }