package math; import jmunit.framework.cldc11.*; public class ArithmeticTest extends TestCase { private double[] pi_vars; /** * Test of getInstance method, of class math.Arithmetic. */ public void testgetInstance() throws AssertionFailedException { System.out.println("getInstance"); math.Arithmetic instance = Arithmetic.getInstance(); math.Arithmetic expectedResult = Arithmetic.getInstance(); math.Arithmetic result = instance.getInstance(); assertEquals(expectedResult, result); } /** * Test of add method, of class math.Arithmetic. */ public void testadd() throws AssertionFailedException { System.out.println("add"); math.Arithmetic instance = Arithmetic.getInstance(); for (int a=0;a<=10;a++) for (int b=0;b<=10;b++) { int expectedResult = a+b; int result = instance.add(a,b); assertEquals(expectedResult, result); } } /** * Test of substract method, of class math.Arithmetic. */ public void testsubstract() throws AssertionFailedException { System.out.println("substract"); math.Arithmetic instance = Arithmetic.getInstance(); for (int a=0;a<=10;a++) for (int b=0;b<=10;b++) { int expectedResult = a-b; int result = instance.substract(a,b); assertEquals(expectedResult, result); } } /** * Test of multiply method, of class math.Arithmetic. */ public void testmultiply() throws AssertionFailedException { System.out.println("multiply"); math.Arithmetic instance = Arithmetic.getInstance(); for (int a=0;a<=10;a++) for (int b=0;b<=10;b++) { int expectedResult = a*b; int result = instance.multiply(a,b); assertEquals(expectedResult, result); } } /** * Test of divide method, of class math.Arithmetic. */ public void testdivide() throws AssertionFailedException { System.out.println("divide"); math.Arithmetic instance = Arithmetic.getInstance(); for (int a=1;a<=10;a++) for (int b=1;b<=10;b++) { double expectedResult = a/b; /* In order to make this not fail we must cast each * variable before the divide operation * * double expectedResult = (double) a/(double) b; */ double result = instance.divide(a,b); assertEquals(expectedResult, result); } } /** * Test of sin method, of class math.Arithmetic. */ public void testsin() throws AssertionFailedException { System.out.println("sin"); math.Arithmetic instance = math.Arithmetic.getInstance(); for (int i=0;i