@@ -0,0 +1,2618 @@
+package net.imagej.convert;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.Arrays;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0Aimport org.junit.runners.Parameterized.Parameter;%0Aimport org.junit.runners.Parameterized.Parameters;%0Aimport org.scijava.Context;%0Aimport org.scijava.convert.ConvertService;%0A%0Aimport net.imglib2.type.numeric.NumericType;%0Aimport net.imglib2.type.numeric.integer.IntType;%0Aimport net.imglib2.type.numeric.integer.LongType;%0Aimport net.imglib2.type.numeric.integer.UnsignedByteType;%0Aimport net.imglib2.type.numeric.real.DoubleType;%0Aimport net.imglib2.type.numeric.real.FloatType;%0Aimport net.imglib2.type.operators.ValueEquals;%0A%0A@RunWith(Parameterized.class)%0Apublic class NumberAndTypeConversionTest %7B%0A%09%0A%09@Parameters(name=%22Type conversion test %7Bindex%7D: %7B0%7D %3C=%3E %7B1%7D%22)%0A%09public static Iterable%3CObject%5B%5D%3E data() %7B%0A%09%09return Arrays.asList(new Object%5B%5D%5B%5D %7B%0A%09%09%09%09%7Bnew Double(Double.POSITIVE_INFINITY), new DoubleType(Double.POSITIVE_INFINITY)%7D,%0A%09%09%09%09%7Bnew Float(Float.NEGATIVE_INFINITY), new FloatType(Float.NEGATIVE_INFINITY)%7D,%0A%09%09%09%09%7Bnew Integer(Integer.MAX_VALUE), new IntType(Integer.MAX_VALUE)%7D,%0A%09%09%09%09%7Bnew Long(Long.MAX_VALUE), new LongType(Long.MAX_VALUE)%7D,%0A%09%09%09%09%7Bnew Integer(255), new UnsignedByteType(255)%7D%0A%09%09%09%7D);%0A%09%7D%0A%0A%09@Parameter(0)%0A%09public Object number;%0A%0A%09@Parameter(1)%0A%09public Object numericType;%0A%0A%09private ConvertService convertService;%0A%0A%09@Before%0A%09public void setUp() %7B%0A%09%09final Context ctx = new Context();%0A%09%09convertService = ctx.getService(ConvertService.class);%0A%09%7D%0A%0A%09@After%0A%09public void tearDown() %7B%0A%09%09convertService.getContext().dispose();%0A%09%09convertService = null;%0A%09%7D%0A%0A%09/**%0A%09 * Test conversion from %7B@link Number%7D to %7B@link NumericType%7D%0A%09 */%0A%09@SuppressWarnings(%7B %22rawtypes%22, %22unchecked%22 %7D)%0A%09@Test%0A%09public void testNumberToNumericType() %7B%0A%09%09assertTrue(%22Conversion support from number to numeric type%22, convertService.supports(number, numericType.getClass()));%0A%09%09ValueEquals converted = (ValueEquals) convertService.convert(number, numericType.getClass());%0A%09%09assertTrue(%22Converted type value equality%22, converted.valueEquals(numericType));%0A%09%7D%0A%0A%09/**%0A%09 * Test conversion from %7B@link Number%7D to %7B@link NumericType%7D%0A%09 */%0A%09@Test%0A%09public void testNumericTypeToNumber() %7B%0A%09%09assertTrue(%22Conversion support from numeric type to number%22, convertService.supports(numericType, number.getClass()));%0A%09%09Number converted = (Number) convertService.convert(numericType, number.getClass());%0A%09%09assertEquals(%22Converted value equality%22, number, converted);%0A%09%7D%0A%7D%0A

Add tests for various number/numeric type conversions