Skip to content

Commit bc501e8

Browse files
committed
Update array unit tests
Updated for clarity
1 parent 37cde7c commit bc501e8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/test/java/org/scijava/convert/ConvertServiceTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public void testPrimitives() {
134134
*/
135135
@Test
136136
public void testArrays() {
137+
// Test that each primitive [] is compatible in either direciton with its
138+
// paired PrimitiveArray
137139
testIntechangeable(int[].class, IntArray.class);
138140
testIntechangeable(long[].class, LongArray.class);
139141
testIntechangeable(double[].class, DoubleArray.class);
@@ -142,18 +144,22 @@ public void testArrays() {
142144
testIntechangeable(char[].class, CharArray.class);
143145
testIntechangeable(boolean[].class, BoolArray.class);
144146

145-
assertTrue(convertService.supports(List.class, int[].class));
146-
assertTrue(convertService.supports(List.class, long[].class));
147-
assertTrue(convertService.supports(List.class, double[].class));
148-
assertTrue(convertService.supports(List.class, float[].class));
149-
assertTrue(convertService.supports(List.class, short[].class));
150-
assertTrue(convertService.supports(List.class, char[].class));
151-
assertTrue(convertService.supports(List.class, boolean[].class));
147+
// Test that primitive [] can not be convertied to mismatched PrimitiveArray
148+
assertFalse(convertService.supports(int[].class, LongArray.class));
152149

150+
// Test that lists can be converted to any primitive []
153151
final List<Integer> list = new ArrayList<Integer>();
154-
155152
for (int i=0; i<100; i++) list.add((int) (10000 * Math.random()));
156153

154+
assertTrue(convertService.supports(list, int[].class));
155+
assertTrue(convertService.supports(list, long[].class));
156+
assertTrue(convertService.supports(list, double[].class));
157+
assertTrue(convertService.supports(list, float[].class));
158+
assertTrue(convertService.supports(list, short[].class));
159+
assertTrue(convertService.supports(list, char[].class));
160+
assertTrue(convertService.supports(list, boolean[].class));
161+
162+
// Verify PrimitiveArray conversion
157163
final int[] primitives = convertService.convert(list, int[].class);
158164

159165
final IntArray intArray = convertService.convert(primitives, IntArray.class);

0 commit comments

Comments
 (0)