/** * Creates a matcher of {@link Comparable} object that matches when the examined object is * greater than or equal to the specified value, as reported by the <code>compareTo</code> method * of the <b>examined</b> object. * <p/> * For example: * <pre>assertThat(1, greaterThanOrEqualTo(1))</pre> * * @param value * the value which, when passed to the compareTo method of the examined object, should return greater * than or equal to zero */ public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> greaterThanOrEqualTo(T value) { return org.hamcrest.number.OrderingComparison.<T>greaterThanOrEqualTo(value); }
/** * Creates a matcher of {@link Comparable} object that matches when the examined object is * greater than or equal to the specified value, as reported by the <code>compareTo</code> method * of the <b>examined</b> object. * For example: * <pre>assertThat(1, greaterThanOrEqualTo(1))</pre> * * @param value the value which, when passed to the compareTo method of the examined object, should return greater * than or equal to zero */ public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> greaterThanOrEqualTo(T value) { return org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo(value); }
public void testComparesBigDecimalsWithDifferentScalesCorrectlyForIssue20() { assertThat(new BigDecimal("10.0"), greaterThanOrEqualTo(new BigDecimal("10"))); assertThat(new BigDecimal(10), greaterThanOrEqualTo(new BigDecimal("10.0"))); assertThat(new BigDecimal("2"), comparesEqualTo(new BigDecimal("2.000"))); }
public void testComparesBigDecimalsWithDifferentScalesCorrectlyForIssue20() { assertThat(new BigDecimal("10.0"), greaterThanOrEqualTo(new BigDecimal("10"))); assertThat(new BigDecimal(10), greaterThanOrEqualTo(new BigDecimal("10.0"))); assertThat(new BigDecimal("2"), comparesEqualTo(new BigDecimal("2.000"))); }
public void testAllowsForInclusiveComparisons() { assertThat("less", 1, lessThanOrEqualTo(1)); assertThat("greater", 1, greaterThanOrEqualTo(1)); }
public void testAllowsForInclusiveComparisons() { assertThat("less", 1, lessThanOrEqualTo(1)); assertThat("greater", 1, greaterThanOrEqualTo(1)); }
@Test public void testSocketUtil() { int port = SocketUtil.findOpenPort(0); Assert.assertThat("Port is greater than the maximum port 0xffff", port, OrderingComparison.lessThanOrEqualTo(MAX_PORT)); Assert.assertThat("Port is less than minimum port 0", port, OrderingComparison.greaterThanOrEqualTo(0)); }
public void testDescription() { assertDescription("a value greater than <1>", greaterThan(1)); assertDescription("a value equal to or greater than <1>", greaterThanOrEqualTo(1)); assertDescription("a value equal to <1>", comparesEqualTo(1)); assertDescription("a value less than or equal to <1>", lessThanOrEqualTo(1)); assertDescription("a value less than <1>", lessThan(1)); }
public void testDescription() { assertDescription("a value greater than <1>", greaterThan(1)); assertDescription("a value equal to or greater than <1>", greaterThanOrEqualTo(1)); assertDescription("a value equal to <1>", comparesEqualTo(1)); assertDescription("a value less than or equal to <1>", lessThanOrEqualTo(1)); assertDescription("a value less than <1>", lessThan(1)); }
@Property public void shouldHold(double d) { assertThat(d, greaterThanOrEqualTo(RangeAttributes.minDouble())); assertThat(d, lessThan(RangeAttributes.maxDouble())); } }
@Property public void shouldHold(Double d) { assertThat(d, greaterThanOrEqualTo(RangeAttributes.minDouble())); assertThat(d, lessThan(RangeAttributes.maxDouble())); } }
@Property public void shouldHold(Float f) { assertThat(f, greaterThanOrEqualTo(RangeAttributes.minFloat())); assertThat(f, lessThan(RangeAttributes.maxFloat())); } }
@Property public void shouldHold(@InRange(min = "-2.71") Double d) { assertThat(d, greaterThanOrEqualTo(-2.71)); assertThat(d, lessThan(RangeAttributes.maxDouble())); } }
@Property public void shouldHold(@InRange(maxFloat = 3.14F) float f) { assertThat(f, greaterThanOrEqualTo(RangeAttributes.minFloat())); assertThat(f, lessThanOrEqualTo(3.14F)); } }
@Property public void shouldHold(@InRange(min = "-2.71") Float f) { assertThat(f, greaterThanOrEqualTo(-2.71F)); assertThat(f, lessThan(RangeAttributes.maxFloat())); } }
@Property public void shouldHold(@InRange(max = "3.14") Double d) { assertThat(d, greaterThanOrEqualTo(RangeAttributes.minDouble())); assertThat(d, lessThan(3.14)); } }
@Property public void shouldHold(@InRange(minFloat = -2.71F) float f) { assertThat(f, greaterThanOrEqualTo(-2.71F)); assertThat(f, lessThan(RangeAttributes.maxFloat())); } }
@Property public void shouldHold(@InRange(maxDouble = 3.14) double d) { assertThat(d, greaterThanOrEqualTo(RangeAttributes.minDouble())); assertThat(d, lessThan(3.14)); } }
@Property public void shouldHold(@InRange(minDouble = -2.71) double d) { assertThat(d, greaterThanOrEqualTo(-2.71)); assertThat(d, lessThan(RangeAttributes.maxDouble())); } }
@Property public void shouldHold(@InRange(max = "3.14") Float f) { assertThat(f, greaterThanOrEqualTo(RangeAttributes.minFloat())); assertThat(f, lessThanOrEqualTo(3.14F)); } }