Skip to content

Instantly share code, notes, and snippets.

@jonbodner
Created February 25, 2019 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonbodner/07e819c68103f79b5585e4cfbc8326b2 to your computer and use it in GitHub Desktop.
Save jonbodner/07e819c68103f79b5585e4cfbc8326b2 to your computer and use it in GitHub Desktop.
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