コード例 #1
0
 private static void testValidExpression(double expected, String expression) {
   try {
     double result = CalculationEngineFactory.defaultEngine().calculate(expression);
     assertEquals(expected, result);
   } catch (CalculationException e) {
     Assert.fail("Exception happened " + e);
   }
 }
コード例 #2
0
 private static void testInvalidExpression(String expression) {
   try {
     CalculationEngineFactory.defaultEngine().calculate(expression);
     Assert.fail("Successfully evaluate " + expression);
   } catch (CalculationException e) {
     Log.d("Test", "Successfully fail");
   }
 }
コード例 #3
0
 @Test
 public void testDivisionByZero3() {
   try {
     double result = CalculationEngineFactory.defaultEngine().calculate("(10-10)/(10-10)");
     Assert.assertTrue(Double.isNaN(result));
   } catch (CalculationException e) {
     Log.d("Test", "Valid Failure");
   }
 }
コード例 #4
0
 @Test
 public void testDivisionByZero2() {
   try {
     double result = CalculationEngineFactory.defaultEngine().calculate("1/(10-10)");
     Assert.assertEquals(Double.POSITIVE_INFINITY, result);
   } catch (CalculationException e) {
     Log.d("Test", "Valid Failure");
   }
 }