|
36 | 36 | import static org.junit.Assert.assertTrue;
|
37 | 37 |
|
38 | 38 | import java.util.ArrayList;
|
| 39 | +import java.util.Arrays; |
39 | 40 | import java.util.Iterator;
|
40 | 41 | import java.util.List;
|
41 | 42 |
|
@@ -209,15 +210,25 @@ public void testToString() {
|
209 | 210 | objectIndex.add(new Integer(5));
|
210 | 211 | objectIndex.add(new Float(2.5f));
|
211 | 212 | objectIndex.add(new Integer(3));
|
212 |
| - final String[] expected = |
213 |
| - { "java.io.Serializable: {5, 2.5, 3}", |
214 |
| - "java.lang.Comparable: {5, 2.5, 3}", "java.lang.Float: {2.5}", |
215 |
| - "java.lang.Integer: {5, 3}", "java.lang.Number: {5, 2.5, 3}", |
216 |
| - "java.lang.Object: {5, 2.5, 3}", |
217 |
| - "org.scijava.object.ObjectIndex$All: {5, 2.5, 3}" }; |
| 213 | + |
| 214 | + final List<String> expected = new ArrayList<>(); |
| 215 | + expected.addAll(Arrays.asList( |
| 216 | + "java.io.Serializable: {5, 2.5, 3}", |
| 217 | + "java.lang.Comparable: {5, 2.5, 3}", "java.lang.Float: {2.5}", |
| 218 | + "java.lang.Integer: {5, 3}", "java.lang.Number: {5, 2.5, 3}", |
| 219 | + "java.lang.Object: {5, 2.5, 3}" |
| 220 | + )); |
| 221 | + final String[] javaVersion = System.getProperty("java.version").split("\\."); |
| 222 | + final int majorVersion = Integer.parseInt(javaVersion[0]); |
| 223 | + if (majorVersion >= 12) { |
| 224 | + expected.add("java.lang.constant.Constable: {5, 2.5, 3}"); |
| 225 | + expected.add("java.lang.constant.ConstantDesc: {5, 2.5, 3}"); |
| 226 | + } |
| 227 | + expected.add("org.scijava.object.ObjectIndex$All: {5, 2.5, 3}"); |
| 228 | + |
218 | 229 | final String[] actual =
|
219 | 230 | objectIndex.toString().split(System.getProperty("line.separator"));
|
220 |
| - assertArrayEquals(expected, actual); |
| 231 | + assertArrayEquals(expected.toArray(), actual); |
221 | 232 | }
|
222 | 233 |
|
223 | 234 | }
|
0 commit comments