Bael 1580 2 (#3787)
* BAEL-1580: Changing hamcrest dependency. * BAEL-1580: Adding test scope. * BAEL-1580: Adding comparesEqualTo and notANumber matchers.
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
9667f061ab
commit
bce01cfff5
+27
-1
@@ -6,8 +6,15 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.closeTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.comparesEqualTo;
|
||||
import static org.hamcrest.Matchers.notANumber;
|
||||
|
||||
public class HamcrestNumberUnitTest {
|
||||
|
||||
@@ -43,6 +50,19 @@ public class HamcrestNumberUnitTest {
|
||||
assertThat(actual, is(not(closeTo(operand, error))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void given5_whenComparesEqualTo5_thenCorrect() {
|
||||
Integer five = 5;
|
||||
assertThat(five, comparesEqualTo(five));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void given5_whenNotComparesEqualTo7_thenCorrect() {
|
||||
Integer seven = 7;
|
||||
Integer five = 5;
|
||||
assertThat(five, not(comparesEqualTo(seven)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void given7_whenGreaterThan5_thenCorrect() {
|
||||
Integer seven = 7;
|
||||
@@ -149,4 +169,10 @@ public class HamcrestNumberUnitTest {
|
||||
else return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNaN_whenIsNotANumber_thenCorrect() {
|
||||
double zero = 0d;
|
||||
assertThat(zero / zero, is(notANumber()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user