Fixed match assertion that didn't run any assert with object of different types that don't extend Number

This commit is contained in:
Luca Cavanna 2014-01-04 11:11:36 +01:00
parent 623e4a0fc8
commit 7166ab6b6f
1 changed files with 3 additions and 3 deletions

View File

@ -45,12 +45,12 @@ public class MatchAssertion extends Assertion {
logger.trace("assert that [{}] matches [{}]", actualValue, expectedValue);
if (!actualValue.getClass().equals(expectedValue.getClass())) {
if (actualValue instanceof Number && expectedValue instanceof Number) {
//Double 1.0 is equals to Integer 1
//Double 1.0 is equal to Integer 1
assertThat(errorMessage(), ((Number) actualValue).doubleValue(), equalTo(((Number) expectedValue).doubleValue()));
return;
}
} else {
assertThat(errorMessage(), actualValue, equalTo(expectedValue));
}
assertThat(errorMessage(), actualValue, equalTo(expectedValue));
}
private String errorMessage() {