Skip to content

Instantly share code, notes, and snippets.

@CDRussell
Created July 21, 2015 10:59
Show Gist options
  • Save CDRussell/72ad9191046063e6d3f4 to your computer and use it in GitHub Desktop.
Save CDRussell/72ad9191046063e6d3f4 to your computer and use it in GitHub Desktop.
Asserts two BigDecimals are equal. Will fail if compareTo() returns a non-zero result.
public static void assertEqualsBigDecimal(BigDecimal expected, BigDecimal actual) {
int result = expected.compareTo(actual);
if(result < 0) {
fail(String.format("Expected is less than actual; {expected=%s, actual=%s}", expected.toPlainString(), actual.toPlainString()));
} else if (result > 0) {
fail(String.format("Expected is greater than actual; {expected=%s, actual=%s}", expected.toPlainString(), actual.toPlainString()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment