From: W. Trevor King Date: Fri, 7 Oct 2011 07:44:18 +0000 (-0400) Subject: Update ArrayFuncsTest.java to JUnit-4. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b9edd6a86e66d354b0c1d010125246d8359cbb37;p=fits.git Update ArrayFuncsTest.java to JUnit-4. --- diff --git a/src/nom/tam/util/test/ArrayFuncsTest.java b/src/nom/tam/util/test/ArrayFuncsTest.java index df5efb0..7ad8e51 100644 --- a/src/nom/tam/util/test/ArrayFuncsTest.java +++ b/src/nom/tam/util/test/ArrayFuncsTest.java @@ -6,6 +6,12 @@ */ package nom.tam.util.test; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertNotSame; import junit.framework.*; import java.lang.reflect.*; import java.util.Arrays; @@ -15,21 +21,12 @@ import nom.tam.util.ArrayFuncs; * * @author Thomas McGlynn */ -public class ArrayFuncsTest extends TestCase { - - public ArrayFuncsTest(String testName) { - super(testName); - } - - protected void setUp() throws Exception { - } - - protected void tearDown() throws Exception { - } +public class ArrayFuncsTest { /** * Test of computeSize method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testComputeSize() { System.out.println("computeSize"); @@ -58,6 +55,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of nElements method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testNElements() { System.out.println("nElements"); @@ -72,6 +70,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of deepClone method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testDeepClone() { int[][] test = {{0, 1}, {2, 3}, {4, 5}}; int[][] result = (int[][]) nom.tam.util.ArrayFuncs.deepClone(test); @@ -96,6 +95,7 @@ public class ArrayFuncsTest extends TestCase { } public boolean equals(Object x) { + System.out.println("checking equality"); return (x instanceof CloneTest) && (((CloneTest) x).value == this.value); } @@ -104,6 +104,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of genericClone method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testGenericClone() { System.out.println("genericClone"); @@ -126,6 +127,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of copyArray method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testCopyArray() { System.out.println("copyArray"); @@ -138,6 +140,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of getDimensions method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testGetDimensions() { System.out.println("getDimensions"); @@ -157,6 +160,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of getBaseArray method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testGetBaseArray() { int[][][] test = new int[2][3][4]; @@ -169,6 +173,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of getBaseClass method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testGetBaseClass() { System.out.println("getBaseClass"); @@ -179,6 +184,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of getBaseLength method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testGetBaseLength() { assertEquals(ArrayFuncs.getBaseLength(new int[2][3]), 4); @@ -195,6 +201,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of generateArray method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testGenerateArray() { System.out.println("generateArray"); @@ -213,6 +220,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of testPattern method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testTestPattern() { System.out.println("testPattern"); @@ -229,6 +237,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of flatten method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testFlatten() { System.out.println("flatten"); @@ -241,6 +250,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of curl method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testCurl() { System.out.println("curl"); @@ -259,6 +269,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of mimicArray method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testMimicArray() { System.out.println("mimicArray"); @@ -273,6 +284,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of convertArray method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testConvertArray() { System.out.println("convertArray"); @@ -286,7 +298,7 @@ public class ArrayFuncsTest extends TestCase { newType = int.class; int[][] ires = (int[][]) ArrayFuncs.convertArray(array, newType, true); - assertEquals(array, ires); + assertSame(array, ires); ires = (int[][]) ArrayFuncs.convertArray(array, newType, false); assertNotSame(array, ires); @@ -296,6 +308,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of copyInto method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testCopyInto() { System.out.println("copyInto"); @@ -304,13 +317,14 @@ public class ArrayFuncsTest extends TestCase { ArrayFuncs.copyInto(x, y); - assertEquals((double) x[0][0], y[0][0]); - assertEquals((double) x[1][2], y[1][2]); + assertEquals((double) x[0][0], y[0][0], 0.01); + assertEquals((double) x[1][2], y[1][2], 0.01); } /** * Test of arrayEquals method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testArrayEquals() { System.out.println("arrayEquals"); @@ -331,6 +345,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of doubleArrayEquals method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testDoubleArrayEquals() { double x[] = {1, 2, 3}; @@ -349,6 +364,7 @@ public class ArrayFuncsTest extends TestCase { /** * Test of floatArrayEquals method, of class nom.tam.util.ArrayFuncs. */ + @Test public void testFloatArrayEquals() { float x[] = {1f, 2f, 3f}; float y[] = {1f, 2f, 3f};