Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class CalcControllerTest {
@Test
public void result() {
CalcController c = new CalcController(new Calculator() {
@Override
public double process(String expression) {
if (expression.equals("1 + 1")) {
return 2;
}
if (expression.equals("+")) {
throw new CalculatorException("Invalid expression: +");
}
throw new CalculatorException("Unexpected input: "+ expression);
}
});
assertEquals("2.0", c.result("1 + 1"));
assertEquals("Invalid expression: +", c.result("+"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.