Skip to content

Commit

Permalink
ObjectIndexTest: make tests pass with OpenJDK 12
Browse files Browse the repository at this point in the history
Closes #474.
  • Loading branch information
ctrueden committed Nov 4, 2023
1 parent 41f3136 commit 4133ac7
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/test/java/org/scijava/object/ObjectIndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

Expand Down Expand Up @@ -209,15 +210,25 @@ public void testToString() {
objectIndex.add(new Integer(5));
objectIndex.add(new Float(2.5f));
objectIndex.add(new Integer(3));
final String[] expected =
{ "java.io.Serializable: {5, 2.5, 3}",
"java.lang.Comparable: {5, 2.5, 3}", "java.lang.Float: {2.5}",
"java.lang.Integer: {5, 3}", "java.lang.Number: {5, 2.5, 3}",
"java.lang.Object: {5, 2.5, 3}",
"org.scijava.object.ObjectIndex$All: {5, 2.5, 3}" };

final List<String> expected = new ArrayList<>();
expected.addAll(Arrays.asList(
"java.io.Serializable: {5, 2.5, 3}",
"java.lang.Comparable: {5, 2.5, 3}", "java.lang.Float: {2.5}",
"java.lang.Integer: {5, 3}", "java.lang.Number: {5, 2.5, 3}",
"java.lang.Object: {5, 2.5, 3}"
));
final String[] javaVersion = System.getProperty("java.version").split("\\.");
final int majorVersion = Integer.parseInt(javaVersion[0]);
if (majorVersion >= 12) {
expected.add("java.lang.constant.Constable: {5, 2.5, 3}");
expected.add("java.lang.constant.ConstantDesc: {5, 2.5, 3}");
}
expected.add("org.scijava.object.ObjectIndex$All: {5, 2.5, 3}");

final String[] actual =
objectIndex.toString().split(System.getProperty("line.separator"));
assertArrayEquals(expected, actual);
assertArrayEquals(expected.toArray(), actual);
}

}

0 comments on commit 4133ac7

Please sign in to comment.