public abstract class Numbers<NUMBER extends Number & Comparable<NUMBER>> extends Comparables
Constructor and Description |
---|
Numbers() |
Numbers(ComparisonStrategy comparisonStrategy) |
Modifier and Type | Method and Description |
---|---|
protected abstract NUMBER |
absDiff(NUMBER actual,
NUMBER other) |
protected boolean |
areEqual(NUMBER value,
NUMBER other) |
void |
assertIsBetween(AssertionInfo info,
NUMBER actual,
NUMBER start,
NUMBER end)
Asserts that the actual value is in [start, end] range (start included, end included).
|
void |
assertIsCloseTo(AssertionInfo info,
NUMBER actual,
NUMBER expected,
Offset<NUMBER> offset)
Asserts that the actual value is close to the expected one by less than the given offset.
|
void |
assertIsCloseToPercentage(AssertionInfo info,
NUMBER actual,
NUMBER other,
Percentage percentage)
Asserts that the actual value is close to the an offset expressed as an percentage value.
|
void |
assertIsNegative(AssertionInfo info,
NUMBER actual)
Asserts that the actual value is negative.
|
void |
assertIsNotCloseTo(AssertionInfo info,
NUMBER actual,
NUMBER expected,
Offset<NUMBER> offset)
Asserts that the actual value is not close to the expected one by less than the given offset.
|
void |
assertIsNotCloseToPercentage(AssertionInfo info,
NUMBER actual,
NUMBER other,
Percentage percentage)
Asserts that the actual value is not close to the an offset expressed as an percentage value.
|
void |
assertIsNotNegative(AssertionInfo info,
NUMBER actual)
Asserts that the actual value is not negative.
|
void |
assertIsNotPositive(AssertionInfo info,
NUMBER actual)
Asserts that the actual value is not positive.
|
void |
assertIsNotZero(AssertionInfo info,
NUMBER actual)
Asserts that the actual value is not equal to zero.
It does not rely on the custom comparisonStrategy (if one is set). |
void |
assertIsOne(AssertionInfo info,
NUMBER actual)
Asserts that the actual value is equal to one.
It does not rely on the custom comparisonStrategy (if one is set). |
void |
assertIsPositive(AssertionInfo info,
NUMBER actual)
Asserts that the actual value is positive.
|
void |
assertIsStrictlyBetween(AssertionInfo info,
NUMBER actual,
NUMBER start,
NUMBER end)
Asserts that the actual value is in ]start, end[ range (start excluded, end excluded).
|
void |
assertIsZero(AssertionInfo info,
NUMBER actual)
Asserts that the actual value is equal to zero.
It does not rely on the custom comparisonStrategy (if one is set). |
protected abstract boolean |
isGreaterThan(NUMBER value,
NUMBER other) |
protected boolean |
isGreaterThanOrEqualTo(NUMBER value,
NUMBER other) |
protected abstract NUMBER |
one() |
protected abstract NUMBER |
zero() |
areEqual, assertEqual, assertEqualByComparison, assertGreaterThan, assertGreaterThanOrEqualTo, assertIsBetween, assertLessThan, assertLessThanOrEqualTo, assertNotEqual, assertNotEqualByComparison, assertNotNull, checkBoundsValidity, equals, getComparator, hashCode, toString
public Numbers()
public Numbers(ComparisonStrategy comparisonStrategy)
protected abstract NUMBER zero()
protected abstract NUMBER one()
public void assertIsZero(AssertionInfo info, NUMBER actual)
info
- contains information about the assertion.actual
- the actual value.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is not equal to zero.public void assertIsNotZero(AssertionInfo info, NUMBER actual)
info
- contains information about the assertion.actual
- the actual value.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is equal to zero.public void assertIsOne(AssertionInfo info, NUMBER actual)
info
- contains information about the assertion.actual
- the actual value.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is not equal to one.public void assertIsNegative(AssertionInfo info, NUMBER actual)
info
- contains information about the assertion.actual
- the actual value.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is not negative: it is either equal to or greater than zero.public void assertIsPositive(AssertionInfo info, NUMBER actual)
info
- contains information about the assertion.actual
- the actual value.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is not positive: it is either equal to or less than zero.public void assertIsNotNegative(AssertionInfo info, NUMBER actual)
info
- contains information about the assertion.actual
- the actual value.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is negative.public void assertIsNotPositive(AssertionInfo info, NUMBER actual)
info
- contains information about the assertion.actual
- the actual value.AssertionError
- if the actual value is null
.AssertionError
- if the actual value is positive.public void assertIsBetween(AssertionInfo info, NUMBER actual, NUMBER start, NUMBER end)
info
- contains information about the assertion.actual
- the actual value.start
- range start valueend
- range end valueAssertionError
- if the actual value is null
.AssertionError
- if the actual value is positive.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.AssertionError
- if the actual value is not in [start, end] range.public void assertIsStrictlyBetween(AssertionInfo info, NUMBER actual, NUMBER start, NUMBER end)
info
- contains information about the assertion.actual
- the actual value.start
- the start value (exclusive), expected not to be null.end
- the end value (exclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.AssertionError
- if the actual value is not in ]start, end[ range.public void assertIsCloseTo(AssertionInfo info, NUMBER actual, NUMBER expected, Offset<NUMBER> offset)
It does not rely on the custom comparisonStrategy (if one is set) because using an offset is already a specific comparison strategy.
info
- contains information about the assertion.actual
- the actual value.expected
- the value to compare actual too.offset
- the given positive offset.public void assertIsNotCloseTo(AssertionInfo info, NUMBER actual, NUMBER expected, Offset<NUMBER> offset)
info
- contains information about the assertion.actual
- the actual value.expected
- the value to compare actual too.offset
- the given positive offset.public void assertIsCloseToPercentage(AssertionInfo info, NUMBER actual, NUMBER other, Percentage percentage)
info
- contains information about the assertion.actual
- the actual value.other
- the expected value.percentage
- the given positive percentage.public void assertIsNotCloseToPercentage(AssertionInfo info, NUMBER actual, NUMBER other, Percentage percentage)
info
- contains information about the assertion.actual
- the actual value.other
- the expected value.percentage
- the given positive percentage.Copyright © 2014–2019 AssertJ. All rights reserved.