Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jonbodner
Created February 25, 2019 20:06
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/ec77588c7d936b675297e0214a471aae to your computer and use it in GitHub Desktop.
Save jonbodner/ec77588c7d936b675297e0214a471aae to your computer and use it in GitHub Desktop.
@Parameters(name = "{index}: CalculatorTest({0})={1}, throws {2}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{"1 + 1", 2, null},
{"1 + 1 + 1", 3, null},
{"1–1", 0, null},
{"1 * 1", 1, null},
{"1 / 1", 1, null},
{"( 1 + 1 )", 2, null},
{"+", 0, new CalculatorException("Invalid expression: +")},
{"1 1", 0, new CalculatorException("Invalid expression: 1 1")},
{"1 / 1 * 1 ", 1, null},
{"( 1–1 )", 0, null},
{"( 1 + 1–1 * 1 / 1 )", 1, null},
{"( 1 + 1 * 1 )", 2, null},
{"1 ( 1", 0, new CalculatorException("Invalid expression: 1 ( 1")},
{"1 + + 1", 0, new CalculatorException("Invalid expression: 1 + + 1")}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment