public final class LazyAssert extends Object
| Modifier | Constructor and Description |
|---|---|
private |
LazyAssert() |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertArrayEquals(boolean[] expecteds,
boolean[] actuals)
Asserts that two boolean arrays are equal.
|
static void |
assertArrayEquals(byte[] expecteds,
byte[] actuals)
Asserts that two byte arrays are equal.
|
static void |
assertArrayEquals(char[] expecteds,
char[] actuals)
Asserts that two char arrays are equal.
|
static void |
assertArrayEquals(double[] expecteds,
double[] actuals,
double delta)
Asserts that two double arrays are equal.
|
static void |
assertArrayEquals(float[] expecteds,
float[] actuals,
float delta)
Asserts that two float arrays are equal.
|
static void |
assertArrayEquals(int[] expecteds,
int[] actuals)
Asserts that two int arrays are equal.
|
static void |
assertArrayEquals(long[] expecteds,
long[] actuals)
Asserts that two long arrays are equal.
|
static void |
assertArrayEquals(Object[] expecteds,
Object[] actuals)
Asserts that two object arrays are equal.
|
static void |
assertArrayEquals(short[] expecteds,
short[] actuals)
Asserts that two short arrays are equal.
|
static void |
assertArrayEquals(String message,
boolean[] expecteds,
boolean[] actuals)
Asserts that two boolean arrays are equal.
|
static void |
assertArrayEquals(String message,
byte[] expecteds,
byte[] actuals)
Asserts that two byte arrays are equal.
|
static void |
assertArrayEquals(String message,
char[] expecteds,
char[] actuals)
Asserts that two char arrays are equal.
|
static void |
assertArrayEquals(String message,
double[] expecteds,
double[] actuals,
double delta)
Asserts that two double arrays are equal.
|
static void |
assertArrayEquals(String message,
float[] expecteds,
float[] actuals,
float delta)
Asserts that two float arrays are equal.
|
static void |
assertArrayEquals(String message,
int[] expecteds,
int[] actuals)
Asserts that two int arrays are equal.
|
static void |
assertArrayEquals(String message,
long[] expecteds,
long[] actuals)
Asserts that two long arrays are equal.
|
static void |
assertArrayEquals(String message,
Object[] expecteds,
Object[] actuals)
Asserts that two object arrays are equal.
|
static void |
assertArrayEquals(String message,
short[] expecteds,
short[] actuals)
Asserts that two short arrays are equal.
|
static void |
assertEquals(double expected,
double actual,
double delta)
Asserts that two doubles are equal to within a positive delta.
|
static void |
assertEquals(float expected,
float actual,
float delta)
Asserts that two floats are equal to within a positive delta.
|
static void |
assertEquals(long expected,
long actual)
Asserts that two longs are equal.
|
static void |
assertEquals(Object[] expecteds,
Object[] actuals)
Deprecated.
use assertArrayEquals
|
static void |
assertEquals(Object expected,
Object actual)
Asserts that two objects are equal.
|
static void |
assertEquals(String message,
double expected,
double actual,
double delta)
Asserts that two doubles are equal to within a positive delta.
|
static void |
assertEquals(String message,
float expected,
float actual,
float delta)
Asserts that two floats are equal to within a positive delta.
|
static void |
assertEquals(String message,
long expected,
long actual)
Asserts that two longs are equal.
|
static void |
assertEquals(String message,
Object[] expecteds,
Object[] actuals)
Deprecated.
use assertArrayEquals
|
static void |
assertEquals(String message,
Object expected,
Object actual)
Asserts that two objects are equal.
|
static void |
assertFalse(boolean condition)
Asserts that a condition is false.
|
static void |
assertFalse(String message,
boolean condition)
Asserts that a condition is false.
|
static void |
assertNotEquals(double unexpected,
double actual,
double delta)
Asserts that two doubles are not equal to within a positive delta.
|
static void |
assertNotEquals(float unexpected,
float actual,
float delta)
Asserts that two floats are not equal to within a positive delta.
|
static void |
assertNotEquals(long unexpected,
long actual)
Asserts that two longs are not equals.
|
static void |
assertNotEquals(Object unexpected,
Object actual)
Asserts that two objects are not equals.
|
static void |
assertNotEquals(String message,
double unexpected,
double actual,
double delta)
Asserts that two doubles are not equal to within a positive delta.
|
static void |
assertNotEquals(String message,
float unexpected,
float actual,
float delta)
Asserts that two floats are not equal to within a positive delta.
|
static void |
assertNotEquals(String message,
long unexpected,
long actual)
Asserts that two longs are not equals.
|
static void |
assertNotEquals(String message,
Object unexpected,
Object actual)
Asserts that two objects are not equals.
|
static void |
assertNotNull(Object object)
Asserts that an object isn't null.
|
static void |
assertNotNull(String message,
Object object)
Asserts that an object isn't null.
|
static void |
assertNotSame(Object unexpected,
Object actual)
Asserts that two objects do not refer to the same object.
|
static void |
assertNotSame(String message,
Object unexpected,
Object actual)
Asserts that two objects do not refer to the same object.
|
static void |
assertNull(Object object)
Asserts that an object is null.
|
static void |
assertNull(String message,
Object object)
Asserts that an object is null.
|
static void |
assertSame(Object expected,
Object actual)
Asserts that two objects refer to the same object.
|
static void |
assertSame(String message,
Object expected,
Object actual)
Asserts that two objects refer to the same object.
|
static <T> void |
assertThat(String reason,
T actual,
org.hamcrest.Matcher<? super T> matcher)
Asserts that
actual satisfies the condition specified by
matcher. |
static <T> void |
assertThat(T actual,
org.hamcrest.Matcher<? super T> matcher)
Asserts that
actual satisfies the condition specified by
matcher. |
static void |
assertTrue(boolean condition)
Asserts that a condition is true.
|
static void |
assertTrue(String message,
boolean condition)
Asserts that a condition is true.
|
private static boolean |
doubleIsDifferent(double d1,
double d2,
double delta) |
private static boolean |
equalsRegardingNull(Object expected,
Object actual) |
static void |
fail()
Fails a test with no message.
|
static void |
fail(String message)
Fails a test with the given message.
|
private static void |
failEquals(String message,
Object actual) |
private static void |
failNotEquals(String message,
Object expected,
Object actual) |
private static void |
failNotNull(String message,
Object actual) |
private static void |
failNotSame(String message,
Object expected,
Object actual) |
private static void |
failSame(String message) |
private static boolean |
floatIsDifferent(float f1,
float f2,
float delta) |
(package private) static String |
format(String message,
Object expected,
Object actual) |
private static String |
formatClassAndValue(Object value,
String valueString) |
private static void |
internalArrayEquals(String message,
Object expecteds,
Object actuals)
Asserts that two object arrays are equal.
|
private static boolean |
isEquals(Object expected,
Object actual) |
public static void assertTrue(String message, boolean condition)
LazyAssertionError with the given message.message - the identifying message for the LazyAssertionError (null
okay)condition - condition to be checkedpublic static void assertTrue(boolean condition)
LazyAssertionError without a message.condition - condition to be checkedpublic static void assertFalse(String message, boolean condition)
LazyAssertionError with the given message.message - the identifying message for the LazyAssertionError (null
okay)condition - condition to be checkedpublic static void assertFalse(boolean condition)
LazyAssertionError without a message.condition - condition to be checkedpublic static void fail(String message)
message - the identifying message for the LazyAssertionError (null
okay)LazyAssertionErrorpublic static void fail()
public static void assertEquals(String message, Object expected, Object actual)
LazyAssertionError is thrown with the given message. If
expected and actual are null,
they are considered equal.message - the identifying message for the LazyAssertionError (null
okay)expected - expected valueactual - actual valuepublic static void assertEquals(Object expected, Object actual)
LazyAssertionError without a message is thrown. If
expected and actual are null,
they are considered equal.expected - expected valueactual - the value to check against expectedpublic static void assertNotEquals(String message, Object unexpected, Object actual)
LazyAssertionError is thrown with the given message. If
unexpected and actual are null,
they are considered equal.message - the identifying message for the LazyAssertionError (null
okay)unexpected - unexpected value to checkactual - the value to check against unexpectedpublic static void assertNotEquals(Object unexpected, Object actual)
LazyAssertionError without a message is thrown. If
unexpected and actual are null,
they are considered equal.unexpected - unexpected value to checkactual - the value to check against unexpectedpublic static void assertNotEquals(String message, long unexpected, long actual)
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)unexpected - unexpected value to checkactual - the value to check against unexpectedpublic static void assertNotEquals(long unexpected,
long actual)
LazyAssertionError without a message is thrown.unexpected - unexpected value to checkactual - the value to check against unexpectedpublic static void assertNotEquals(String message, double unexpected, double actual, double delta)
LazyAssertionError is thrown with the given
message. If the unexpected value is infinity then the delta value is
ignored. NaNs are considered equal:
assertNotEquals(Double.NaN, Double.NaN, *) failsmessage - the identifying message for the LazyAssertionError (null
okay)unexpected - unexpected valueactual - the value to check against unexpecteddelta - the maximum delta between unexpected and
actual for which both numbers are still
considered equal.public static void assertNotEquals(double unexpected,
double actual,
double delta)
LazyAssertionError is thrown. If the unexpected
value is infinity then the delta value is ignored.NaNs are considered
equal: assertNotEquals(Double.NaN, Double.NaN, *) failsunexpected - unexpected valueactual - the value to check against unexpecteddelta - the maximum delta between unexpected and
actual for which both numbers are still
considered equal.public static void assertNotEquals(float unexpected,
float actual,
float delta)
LazyAssertionError is thrown. If the unexpected
value is infinity then the delta value is ignored.NaNs are considered
equal: assertNotEquals(Float.NaN, Float.NaN, *) failsunexpected - unexpected valueactual - the value to check against unexpecteddelta - the maximum delta between unexpected and
actual for which both numbers are still
considered equal.public static void assertArrayEquals(String message, Object[] expecteds, Object[] actuals) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message. If
expecteds and actuals are null,
they are considered equal.message - the identifying message for the LazyAssertionError (null
okay)expecteds - Object array or array of arrays (multi-dimensional array) with
expected values.actuals - Object array or array of arrays (multi-dimensional array) with
actual valuesorg.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(Object[] expecteds, Object[] actuals)
LazyAssertionError is thrown. If expected and
actual are null, they are considered
equal.expecteds - Object array or array of arrays (multi-dimensional array) with
expected valuesactuals - Object array or array of arrays (multi-dimensional array) with
actual valuespublic static void assertArrayEquals(String message, boolean[] expecteds, boolean[] actuals) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message. If
expecteds and actuals are null,
they are considered equal.message - the identifying message for the LazyAssertionError (null
okay)expecteds - boolean array with expected values.actuals - boolean array with expected values.org.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(boolean[] expecteds,
boolean[] actuals)
LazyAssertionError is thrown. If expected and
actual are null, they are considered
equal.expecteds - boolean array with expected values.actuals - boolean array with expected values.public static void assertArrayEquals(String message, byte[] expecteds, byte[] actuals) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expecteds - byte array with expected values.actuals - byte array with actual valuesorg.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(byte[] expecteds,
byte[] actuals)
LazyAssertionError is thrown.expecteds - byte array with expected values.actuals - byte array with actual valuespublic static void assertArrayEquals(String message, char[] expecteds, char[] actuals) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expecteds - char array with expected values.actuals - char array with actual valuesorg.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(char[] expecteds,
char[] actuals)
LazyAssertionError is thrown.expecteds - char array with expected values.actuals - char array with actual valuespublic static void assertArrayEquals(String message, short[] expecteds, short[] actuals) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expecteds - short array with expected values.actuals - short array with actual valuesorg.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(short[] expecteds,
short[] actuals)
LazyAssertionError is thrown.expecteds - short array with expected values.actuals - short array with actual valuespublic static void assertArrayEquals(String message, int[] expecteds, int[] actuals) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expecteds - int array with expected values.actuals - int array with actual valuesorg.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(int[] expecteds,
int[] actuals)
LazyAssertionError is thrown.expecteds - int array with expected values.actuals - int array with actual valuespublic static void assertArrayEquals(String message, long[] expecteds, long[] actuals) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expecteds - long array with expected values.actuals - long array with actual valuesorg.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(long[] expecteds,
long[] actuals)
LazyAssertionError is thrown.expecteds - long array with expected values.actuals - long array with actual valuespublic static void assertArrayEquals(String message, double[] expecteds, double[] actuals, double delta) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expecteds - double array with expected values.actuals - double array with actual valuesdelta - the maximum delta between expecteds[i] and
actuals[i] for which both numbers are still
considered equal.org.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(double[] expecteds,
double[] actuals,
double delta)
LazyAssertionError is thrown.expecteds - double array with expected values.actuals - double array with actual valuesdelta - the maximum delta between expecteds[i] and
actuals[i] for which both numbers are still
considered equal.public static void assertArrayEquals(String message, float[] expecteds, float[] actuals, float delta) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expecteds - float array with expected values.actuals - float array with actual valuesdelta - the maximum delta between expecteds[i] and
actuals[i] for which both numbers are still
considered equal.org.junit.internal.ArrayComparisonFailurepublic static void assertArrayEquals(float[] expecteds,
float[] actuals,
float delta)
LazyAssertionError is thrown.expecteds - float array with expected values.actuals - float array with actual valuesdelta - the maximum delta between expecteds[i] and
actuals[i] for which both numbers are still
considered equal.private static void internalArrayEquals(String message, Object expecteds, Object actuals) throws org.junit.internal.ArrayComparisonFailure
LazyAssertionError is thrown with the given message. If
expecteds and actuals are null,
they are considered equal.message - the identifying message for the LazyAssertionError (null
okay)expecteds - Object array or array of arrays (multi-dimensional array) with
expected values.actuals - Object array or array of arrays (multi-dimensional array) with
actual valuesorg.junit.internal.ArrayComparisonFailurepublic static void assertEquals(String message, double expected, double actual, double delta)
LazyAssertionError is thrown with the given
message. If the expected value is infinity then the delta value is
ignored. NaNs are considered equal:
assertEquals(Double.NaN, Double.NaN, *) passesmessage - the identifying message for the LazyAssertionError (null
okay)expected - expected valueactual - the value to check against expecteddelta - the maximum delta between expected and
actual for which both numbers are still
considered equal.public static void assertEquals(String message, float expected, float actual, float delta)
LazyAssertionError is thrown with the given
message. If the expected value is infinity then the delta value is
ignored. NaNs are considered equal:
assertEquals(Float.NaN, Float.NaN, *) passesmessage - the identifying message for the LazyAssertionError (null
okay)expected - expected valueactual - the value to check against expecteddelta - the maximum delta between expected and
actual for which both numbers are still
considered equal.public static void assertNotEquals(String message, float unexpected, float actual, float delta)
LazyAssertionError is thrown with the given
message. If the unexpected value is infinity then the delta value is
ignored. NaNs are considered equal:
assertNotEquals(Float.NaN, Float.NaN, *) failsmessage - the identifying message for the LazyAssertionError (null
okay)unexpected - unexpected valueactual - the value to check against unexpecteddelta - the maximum delta between unexpected and
actual for which both numbers are still
considered equal.private static boolean doubleIsDifferent(double d1,
double d2,
double delta)
private static boolean floatIsDifferent(float f1,
float f2,
float delta)
public static void assertEquals(long expected,
long actual)
LazyAssertionError is thrown.expected - expected long value.actual - actual long valuepublic static void assertEquals(String message, long expected, long actual)
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expected - long expected value.actual - long actual valuepublic static void assertEquals(double expected,
double actual,
double delta)
LazyAssertionError is thrown. If the expected
value is infinity then the delta value is ignored.NaNs are considered
equal: assertEquals(Double.NaN, Double.NaN, *) passesexpected - expected valueactual - the value to check against expecteddelta - the maximum delta between expected and
actual for which both numbers are still
considered equal.public static void assertEquals(float expected,
float actual,
float delta)
LazyAssertionError is thrown. If the expected
value is infinity then the delta value is ignored. NaNs are considered
equal: assertEquals(Float.NaN, Float.NaN, *) passesexpected - expected valueactual - the value to check against expecteddelta - the maximum delta between expected and
actual for which both numbers are still
considered equal.public static void assertNotNull(String message, Object object)
LazyAssertionError is
thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)object - Object to check or nullpublic static void assertNotNull(Object object)
LazyAssertionError is
thrown.object - Object to check or nullpublic static void assertNull(String message, Object object)
LazyAssertionError
is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)object - Object to check or nullpublic static void assertNull(Object object)
LazyAssertionError is
thrown.object - Object to check or nullpublic static void assertSame(String message, Object expected, Object actual)
LazyAssertionError is thrown with the given message.message - the identifying message for the LazyAssertionError (null
okay)expected - the expected objectactual - the object to compare to expectedpublic static void assertSame(Object expected, Object actual)
LazyAssertionError without a message is thrown.expected - the expected objectactual - the object to compare to expectedpublic static void assertNotSame(String message, Object unexpected, Object actual)
LazyAssertionError is thrown with the
given message.message - the identifying message for the LazyAssertionError (null
okay)unexpected - the object you don't expectactual - the object to compare to unexpectedpublic static void assertNotSame(Object unexpected, Object actual)
LazyAssertionError without a message is
thrown.unexpected - the object you don't expectactual - the object to compare to unexpectedprivate static void failSame(String message)
@Deprecated public static void assertEquals(String message, Object[] expecteds, Object[] actuals)
LazyAssertionError is thrown with the given message. If
expecteds and actuals are null,
they are considered equal.message - the identifying message for the LazyAssertionError (null
okay)expecteds - Object array or array of arrays (multi-dimensional array) with
expected values.actuals - Object array or array of arrays (multi-dimensional array) with
actual values@Deprecated public static void assertEquals(Object[] expecteds, Object[] actuals)
LazyAssertionError is thrown. If expected and
actual are null, they are considered
equal.expecteds - Object array or array of arrays (multi-dimensional array) with
expected valuesactuals - Object array or array of arrays (multi-dimensional array) with
actual valuespublic static <T> void assertThat(T actual,
org.hamcrest.Matcher<? super T> matcher)
actual satisfies the condition specified by
matcher. If not, an LazyAssertionError is thrown with
information about the matcher and failing value. Example:
assertThat(0, is(1)); // fails:
// failure message:
// expected: is <1>
// got value: <0>
assertThat(0, is(not(1))) // passes
org.hamcrest.Matcher does not currently document the meaning
of its type parameter T. This method assumes that a matcher
typed as Matcher<T> can be meaningfully applied only
to values that could be assigned to a variable of type T.T - the static type accepted by the matcher (this can flag obvious
compile-time problems such as assertThat(1, is("a"))actual - the computed value being comparedmatcher - an expression, built of Matchers, specifying allowed
valuesCoreMatchers,
MatcherAssertpublic static <T> void assertThat(String reason, T actual, org.hamcrest.Matcher<? super T> matcher)
actual satisfies the condition specified by
matcher. If not, an LazyAssertionError is thrown with
the reason and information about the matcher and failing value. Example:
assertThat("Help! Integers don't work", 0, is(1)); // fails:
// failure message:
// Help! Integers don't work
// expected: is <1>
// got value: <0>
assertThat("Zero is one", 0, is(not(1))) // passes
org.hamcrest.Matcher does not currently document the meaning
of its type parameter T. This method assumes that a matcher
typed as Matcher<T> can be meaningfully applied only
to values that could be assigned to a variable of type T.T - the static type accepted by the matcher (this can flag obvious
compile-time problems such as assertThat(1, is("a"))reason - additional information about the erroractual - the computed value being comparedmatcher - an expression, built of Matchers, specifying allowed
valuesCoreMatchers,
MatcherAssertCopyright © 2013-2017. All Rights Reserved.