Package org.assertj.core.internal
Class Numbers<NUMBER extends Number & Comparable<NUMBER>>
- java.lang.Object
-
- org.assertj.core.internal.Comparables
-
- org.assertj.core.internal.Numbers<NUMBER>
-
- Direct Known Subclasses:
BigDecimals,BigIntegers,Bytes,Integers,Longs,RealNumbers,Shorts
public abstract class Numbers<NUMBER extends Number & Comparable<NUMBER>> extends Comparables
Base class of reusable assertions for numbers.- Author:
- Drummond Dawson, Joel Costigliola, Nicolas François
-
-
Field Summary
-
Fields inherited from class org.assertj.core.internal.Comparables
failures
-
-
Constructor Summary
Constructors Constructor Description Numbers()Numbers(ComparisonStrategy comparisonStrategy)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract NUMBERabsDiff(NUMBER actual, NUMBER other)protected booleanareEqual(NUMBER value, NUMBER other)voidassertIsBetween(AssertionInfo info, NUMBER actual, NUMBER start, NUMBER end)Asserts that the actual value is in [start, end] range (start included, end included).voidassertIsCloseTo(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.voidassertIsCloseToPercentage(AssertionInfo info, NUMBER actual, NUMBER other, Percentage percentage)Asserts that the actual value is close to the an offset expressed as an percentage value.voidassertIsNegative(AssertionInfo info, NUMBER actual)Asserts that the actual value is negative.voidassertIsNotCloseTo(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.voidassertIsNotCloseToPercentage(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.voidassertIsNotNegative(AssertionInfo info, NUMBER actual)Asserts that the actual value is not negative.voidassertIsNotPositive(AssertionInfo info, NUMBER actual)Asserts that the actual value is not positive.voidassertIsNotZero(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).voidassertIsOne(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).voidassertIsPositive(AssertionInfo info, NUMBER actual)Asserts that the actual value is positive.voidassertIsStrictlyBetween(AssertionInfo info, NUMBER actual, NUMBER start, NUMBER end)Asserts that the actual value is in ]start, end[ range (start excluded, end excluded).voidassertIsZero(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 booleanisGreaterThan(NUMBER value, NUMBER other)protected booleanisGreaterThanOrEqualTo(NUMBER value, NUMBER other)protected abstract NUMBERone()protected abstract NUMBERzero()-
Methods inherited from class org.assertj.core.internal.Comparables
areEqual, assertEqual, assertEqualByComparison, assertGreaterThan, assertGreaterThanOrEqualTo, assertIsBetween, assertLessThan, assertLessThanOrEqualTo, assertNotEqual, assertNotEqualByComparison, assertNotNull, checkBoundsValidity, equals, getComparator, hashCode, resetFailures, setFailures, toString
-
-
-
-
Constructor Detail
-
Numbers
public Numbers()
-
Numbers
public Numbers(ComparisonStrategy comparisonStrategy)
-
-
Method Detail
-
zero
protected abstract NUMBER zero()
-
one
protected abstract NUMBER one()
-
assertIsZero
public 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).- Parameters:
info- contains information about the assertion.actual- the actual value.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the actual value is not equal to zero.
-
assertIsNotZero
public 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).- Parameters:
info- contains information about the assertion.actual- the actual value.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the actual value is equal to zero.
-
assertIsOne
public 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).- Parameters:
info- contains information about the assertion.actual- the actual value.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the actual value is not equal to one.
-
assertIsNegative
public void assertIsNegative(AssertionInfo info, NUMBER actual)
Asserts that the actual value is negative.- Parameters:
info- contains information about the assertion.actual- the actual value.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the actual value is not negative: it is either equal to or greater than zero.
-
assertIsPositive
public void assertIsPositive(AssertionInfo info, NUMBER actual)
Asserts that the actual value is positive.- Parameters:
info- contains information about the assertion.actual- the actual value.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the actual value is not positive: it is either equal to or less than zero.
-
assertIsNotNegative
public void assertIsNotNegative(AssertionInfo info, NUMBER actual)
Asserts that the actual value is not negative.- Parameters:
info- contains information about the assertion.actual- the actual value.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the actual value is negative.
-
assertIsNotPositive
public void assertIsNotPositive(AssertionInfo info, NUMBER actual)
Asserts that the actual value is not positive.- Parameters:
info- contains information about the assertion.actual- the actual value.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the actual value is positive.
-
assertIsBetween
public void assertIsBetween(AssertionInfo info, NUMBER actual, NUMBER start, NUMBER end)
Asserts that the actual value is in [start, end] range (start included, end included).- Parameters:
info- contains information about the assertion.actual- the actual value.start- range start valueend- range end value- Throws:
AssertionError- if the actual value isnull.AssertionError- if the actual value is positive.NullPointerException- if start value isnull.NullPointerException- if end value isnull.AssertionError- if the actual value is not in [start, end] range.
-
assertIsStrictlyBetween
public void assertIsStrictlyBetween(AssertionInfo info, NUMBER actual, NUMBER start, NUMBER end)
Asserts that the actual value is in ]start, end[ range (start excluded, end excluded).- Parameters:
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.- Throws:
AssertionError- if the actual value isnull.NullPointerException- if start value isnull.NullPointerException- if end value isnull.AssertionError- if the actual value is not in ]start, end[ range.
-
assertIsCloseTo
public 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.It does not rely on the custom comparisonStrategy (if one is set) because using an offset is already a specific comparison strategy.
- Parameters:
info- contains information about the assertion.actual- the actual value.expected- the value to compare actual too.offset- the given positive offset.
-
assertIsNotCloseTo
public 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.- Parameters:
info- contains information about the assertion.actual- the actual value.expected- the value to compare actual too.offset- the given positive offset.
-
assertIsCloseToPercentage
public 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.- Parameters:
info- contains information about the assertion.actual- the actual value.other- the expected value.percentage- the given positive percentage.
-
assertIsNotCloseToPercentage
public 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.- Parameters:
info- contains information about the assertion.actual- the actual value.other- the expected value.percentage- the given positive percentage.
-
-