Package com.helger.base.mock
Class CommonsAssert
java.lang.Object
com.helger.base.mock.CommonsAssert
Extensions for the default JUnit assertions.
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final float -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertEquals(boolean x, boolean y) Assert that two boolean values are equal.static voidassertEquals(boolean x, @NonNull Boolean y) Assert that a boolean primitive and a Boolean object are equal.static voidassertEquals(double @Nullable [] x, double @Nullable [] y) Assert that two double arrays are element-wise equal within the allowed rounding difference.static voidassertEquals(double x, double y) Assert that two double values are equal within the allowed rounding difference.static voidassertEquals(double x, @NonNull Double y) Assert that a double primitive and a Double object are equal within the allowed rounding difference.static voidassertEquals(float @Nullable [] x, float @Nullable [] y) Assert that two float arrays are element-wise equal within the allowed rounding difference.static voidassertEquals(float x, float y) Assert that two float values are equal within the allowed rounding difference.static voidassertEquals(float x, @NonNull Float y) Assert that a float primitive and a Float object are equal within the allowed rounding difference.static <T> voidassertEquals(@Nullable T x, @Nullable T y) Like JUnit assertEquals but usingEqualsHelper.static voidassertEquals(@Nullable String sUserMsg, boolean x, boolean y) Assert that two boolean values are equal, with a custom message.static voidassertEquals(@Nullable String sUserMsg, double x, double y) Assert that two double values are equal within the allowed rounding difference, with a custom message.static voidassertEquals(@Nullable String sUserMsg, float x, float y) Assert that two float values are equal within the allowed rounding difference, with a custom message.static <T> voidassertEquals(@Nullable String sUserMsg, @Nullable T x, @Nullable T y) Like JUnit assertEquals but usingEqualsHelper.static voidassertNotEquals(boolean x, boolean y) Assert that two boolean values are not equal.static voidassertNotEquals(boolean x, @NonNull Boolean y) Assert that a boolean primitive and a Boolean object are not equal.static <T> voidassertNotEquals(@Nullable T x, @Nullable T y) Like JUnit assertNotEquals but usingEqualsHelper.static voidassertNotEquals(@Nullable String sUserMsg, boolean x, boolean y) Assert that two boolean values are not equal, with a custom message.static <T> voidassertNotEquals(@Nullable String sUserMsg, @Nullable T x, @Nullable T y) Like JUnit assertNotEquals but usingEqualsHelper.static voidfail()Unconditionally fail with a default message.static voidUnconditionally fail with the provided message.
-
Field Details
-
FLOAT_ALLOWED_ROUNDING_DIFFERENCE
public static final float FLOAT_ALLOWED_ROUNDING_DIFFERENCE- See Also:
-
DOUBLE_ALLOWED_ROUNDING_DIFFERENCE
public static final double DOUBLE_ALLOWED_ROUNDING_DIFFERENCE- See Also:
-
-
Constructor Details
-
CommonsAssert
protected CommonsAssert()
-
-
Method Details
-
fail
public static void fail()Unconditionally fail with a default message. -
fail
Unconditionally fail with the provided message.- Parameters:
sMsg- The failure message. May not benull.
-
assertEquals
public static void assertEquals(boolean x, boolean y) Assert that two boolean values are equal.- Parameters:
x- First value.y- Second value.
-
assertEquals
Assert that a boolean primitive and a Boolean object are equal.- Parameters:
x- First value.y- Second value. May not benull.
-
assertNotEquals
public static void assertNotEquals(boolean x, boolean y) Assert that two boolean values are not equal.- Parameters:
x- First value.y- Second value.
-
assertNotEquals
Assert that a boolean primitive and a Boolean object are not equal.- Parameters:
x- First value.y- Second value. May not benull.
-
assertNotEquals
Assert that two boolean values are not equal, with a custom message.- Parameters:
sUserMsg- Optional user message. May benull.x- First value.y- Second value.
-
assertEquals
Assert that two boolean values are equal, with a custom message.- Parameters:
sUserMsg- Optional user message. May benull.x- First value.y- Second value.
-
assertEquals
public static void assertEquals(double x, double y) Assert that two double values are equal within the allowed rounding difference.- Parameters:
x- First value.y- Second value.
-
assertEquals
Assert that a double primitive and a Double object are equal within the allowed rounding difference.- Parameters:
x- First value.y- Second value. May not benull.
-
assertEquals
Assert that two double values are equal within the allowed rounding difference, with a custom message.- Parameters:
sUserMsg- Optional user message. May benull.x- First value.y- Second value.
-
assertEquals
public static void assertEquals(float x, float y) Assert that two float values are equal within the allowed rounding difference.- Parameters:
x- First value.y- Second value.
-
assertEquals
Assert that a float primitive and a Float object are equal within the allowed rounding difference.- Parameters:
x- First value.y- Second value. May not benull.
-
assertEquals
Assert that two float values are equal within the allowed rounding difference, with a custom message.- Parameters:
sUserMsg- Optional user message. May benull.x- First value.y- Second value.
-
assertEquals
public static <T> void assertEquals(@Nullable T x, @Nullable T y) Like JUnit assertEquals but usingEqualsHelper.- Type Parameters:
T- data type to compare- Parameters:
x- Fist object. May benully- Second object. May benull.
-
assertEquals
Like JUnit assertEquals but usingEqualsHelper.- Type Parameters:
T- data type to compare- Parameters:
sUserMsg- Optional user message. May benull.x- Fist object. May benully- Second object. May benull.
-
assertNotEquals
public static <T> void assertNotEquals(@Nullable T x, @Nullable T y) Like JUnit assertNotEquals but usingEqualsHelper.- Type Parameters:
T- data type to compare- Parameters:
x- Fist object. May benully- Second object. May benull.
-
assertNotEquals
Like JUnit assertNotEquals but usingEqualsHelper.- Type Parameters:
T- data type to compare- Parameters:
sUserMsg- Optional user message. May benull.x- Fist object. May benully- Second object. May benull.
-
assertEquals
public static void assertEquals(float @Nullable [] x, float @Nullable [] y) Assert that two float arrays are element-wise equal within the allowed rounding difference.- Parameters:
x- First array. May benull.y- Second array. May benull.
-
assertEquals
public static void assertEquals(double @Nullable [] x, double @Nullable [] y) Assert that two double arrays are element-wise equal within the allowed rounding difference.- Parameters:
x- First array. May benull.y- Second array. May benull.
-