1 16 17 package org.apache.commons.math.util; 18 19 import java.math.BigDecimal ; 20 21 import org.apache.commons.math.MathException; 22 import junit.framework.TestCase; 23 24 27 public class DefaultTransformerTest extends TestCase { 28 31 public void testTransformDouble() throws Exception { 32 double expected = 1.0; 33 Double input = new Double (expected); 34 DefaultTransformer t = new DefaultTransformer(); 35 assertEquals(expected, t.transform(input), 1.0e-4); 36 } 37 38 41 public void testTransformNull(){ 42 DefaultTransformer t = new DefaultTransformer(); 43 try { 44 t.transform(null); 45 fail("Expection MathException"); 46 } catch (MathException e) { 47 } 49 } 50 51 54 public void testTransformInteger() throws Exception { 55 double expected = 1.0; 56 Integer input = new Integer (1); 57 DefaultTransformer t = new DefaultTransformer(); 58 assertEquals(expected, t.transform(input), 1.0e-4); 59 } 60 61 64 public void testTransformBigDecimal() throws Exception { 65 double expected = 1.0; 66 BigDecimal input = new BigDecimal ("1.0"); 67 DefaultTransformer t = new DefaultTransformer(); 68 assertEquals(expected, t.transform(input), 1.0e-4); 69 } 70 71 74 public void testTransformString() throws Exception { 75 double expected = 1.0; 76 String input = "1.0"; 77 DefaultTransformer t = new DefaultTransformer(); 78 assertEquals(expected, t.transform(input), 1.0e-4); 79 } 80 81 84 public void testTransformObject(){ 85 Boolean input = Boolean.TRUE; 86 DefaultTransformer t = new DefaultTransformer(); 87 try { 88 t.transform(input); 89 fail("Expecting MathException"); 90 } catch (MathException e) { 91 } 93 } 94 } 95 | Popular Tags |