@Test(expected = MalformedExpressionException.class) public void evalExceptOnNoArguments() throws MalformedExpressionException { String operationExpression = "-"; PostfixEvaluator testPostfix = new PostfixEvaluator(operationExpression); try { testPostfix.eval(); } catch (Exception e) { throw e; } }
/** * Create a PostfixEvaluator on the given sequence of operations, and return the results of * eval(), or catches an exception thrown by eval(). * * @param operationExpression the sequence of operations to perform, written in RPN or postfix * notation. * @return the results of running PostfixEvaluator.eval() on the operationExpression. */ private double evalTest(String operationExpression) { PostfixEvaluator testPostfix = new PostfixEvaluator(operationExpression); double evalResult = 0; try { evalResult = testPostfix.eval(); } catch (Exception e) { System.out.println("Unexpected exception occurred. Details:"); System.out.println("\t" + e.getClass()); System.out.println("\t" + e.getMessage()); } return evalResult; }