Skip to content

Commit

Permalink
Add tests for the RerollOnce expressions using the new RunDataMockFor…
Browse files Browse the repository at this point in the history
…Testing and specified sequence of die rolls.

RPTools/dicelib#27
  • Loading branch information
selquest committed Apr 25, 2020
1 parent 2ad1dc9 commit b721cd0
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ public void testEvaluate_KeepWithMockRunData() throws ParserException {
assertEquals(new BigDecimal(17), result.getValue());
}

public void testEvaluate_RerollOnceAndKeepWithMockRunData() throws ParserException {
int[] rolls = {4, 2, 1}; // the 2 will be re-rolled, and the 1 will be kept
RunDataMockForTesting mockRD = new RunDataMockForTesting(new Result(""), rolls);
RunData.setCurrent(mockRD);
Result result = new ExpressionParser().evaluate("2d6rk3");
assertEquals(new BigDecimal(5), result.getValue());
}

public void testEvaluate_RerollOnceAndChooseWithMockRunData() throws ParserException {
int[] rolls = {4, 2, 1}; // the 2 will be re-rolled, but still kept as it is higher than the 1
RunDataMockForTesting mockRD = new RunDataMockForTesting(new Result(""), rolls);
RunData.setCurrent(mockRD);
Result result = new ExpressionParser().evaluate("2d6rc3");
assertEquals(new BigDecimal(6), result.getValue());
}

public void testEvaluate_CountSuccessesWithMockRunData() throws ParserException {
int[] rolls = {6, 2, 5, 4, 1, 6}; // count the 5 and 6s
setUpMockRunData(rolls);
Expand Down

0 comments on commit b721cd0

Please sign in to comment.