Methods Summary |
---|
public static void | assertEquals(java.lang.String message, java.lang.String expected, java.lang.String actual)Asserts that two Strings are equal.
if (expected == null && actual == null)
return;
if (expected != null && expected.equals(actual))
return;
throw new ComparisonFailure(message, expected, actual);
|
public static void | assertEquals(java.lang.String expected, java.lang.String actual)Asserts that two Strings are equal.
assertEquals(null, expected, actual);
|
public static void | assertEquals(java.lang.String message, double expected, double actual, double delta)Asserts that two doubles are equal concerning a delta. If they are not
an AssertionFailedError is thrown with the given message. If the expected
value is infinity then the delta value is ignored.
// handle infinity specially since subtracting to infinite values gives NaN and the
// the following test fails
if (Double.isInfinite(expected)) {
if (!(expected == actual))
failNotEquals(message, new Double(expected), new Double(actual));
} else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false
failNotEquals(message, new Double(expected), new Double(actual));
|
public static void | assertEquals(double expected, double actual, double delta)Asserts that two doubles are equal concerning a delta. If the expected
value is infinity then the delta value is ignored.
assertEquals(null, expected, actual, delta);
|
public static void | assertEquals(java.lang.String message, float expected, float actual, float delta)Asserts that two floats are equal concerning a delta. If they are not
an AssertionFailedError is thrown with the given message. If the expected
value is infinity then the delta value is ignored.
// handle infinity specially since subtracting to infinite values gives NaN and the
// the following test fails
if (Float.isInfinite(expected)) {
if (!(expected == actual))
failNotEquals(message, new Float(expected), new Float(actual));
} else if (!(Math.abs(expected-actual) <= delta))
failNotEquals(message, new Float(expected), new Float(actual));
|
public static void | assertEquals(float expected, float actual, float delta)Asserts that two floats are equal concerning a delta. If the expected
value is infinity then the delta value is ignored.
assertEquals(null, expected, actual, delta);
|
public static void | assertEquals(java.lang.String message, long expected, long actual)Asserts that two longs are equal. If they are not
an AssertionFailedError is thrown with the given message.
assertEquals(message, new Long(expected), new Long(actual));
|
public static void | assertEquals(long expected, long actual)Asserts that two longs are equal.
assertEquals(null, expected, actual);
|
public static void | assertEquals(java.lang.String message, boolean expected, boolean actual)Asserts that two booleans are equal. If they are not
an AssertionFailedError is thrown with the given message.
assertEquals(message, new Boolean(expected), new Boolean(actual));
|
public static void | assertEquals(boolean expected, boolean actual)Asserts that two booleans are equal.
assertEquals(null, expected, actual);
|
public static void | assertEquals(java.lang.String message, byte expected, byte actual)Asserts that two bytes are equal. If they are not
an AssertionFailedError is thrown with the given message.
assertEquals(message, new Byte(expected), new Byte(actual));
|
public static void | assertEquals(byte expected, byte actual)Asserts that two bytes are equal.
assertEquals(null, expected, actual);
|
public static void | assertEquals(java.lang.String message, char expected, char actual)Asserts that two chars are equal. If they are not
an AssertionFailedError is thrown with the given message.
assertEquals(message, new Character(expected), new Character(actual));
|
public static void | assertEquals(char expected, char actual)Asserts that two chars are equal.
assertEquals(null, expected, actual);
|
public static void | assertEquals(java.lang.String message, short expected, short actual)Asserts that two shorts are equal. If they are not
an AssertionFailedError is thrown with the given message.
assertEquals(message, new Short(expected), new Short(actual));
|
public static void | assertEquals(short expected, short actual)Asserts that two shorts are equal.
assertEquals(null, expected, actual);
|
public static void | assertEquals(java.lang.String message, int expected, int actual)Asserts that two ints are equal. If they are not
an AssertionFailedError is thrown with the given message.
assertEquals(message, new Integer(expected), new Integer(actual));
|
public static void | assertEquals(int expected, int actual)Asserts that two ints are equal.
assertEquals(null, expected, actual);
|
public static void | assertEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual)Asserts that two objects are equal. If they are not
an AssertionFailedError is thrown with the given message.
if (expected == null && actual == null)
return;
if (expected != null && expected.equals(actual))
return;
failNotEquals(message, expected, actual);
|
public static void | assertEquals(java.lang.Object expected, java.lang.Object actual)Asserts that two objects are equal. If they are not
an AssertionFailedError is thrown.
assertEquals(null, expected, actual);
|
public static void | assertFalse(java.lang.String message, boolean condition)Asserts that a condition is false. If it isn't it throws
an AssertionFailedError with the given message.
assertTrue(message, !condition);
|
public static void | assertFalse(boolean condition)Asserts that a condition is false. If it isn't it throws
an AssertionFailedError.
assertFalse(null, condition);
|
public static void | assertNotNull(java.lang.Object object)Asserts that an object isn't null.
assertNotNull(null, object);
|
public static void | assertNotNull(java.lang.String message, java.lang.Object object)Asserts that an object isn't null. If it is
an AssertionFailedError is thrown with the given message.
assertTrue(message, object != null);
|
public static void | assertNotSame(java.lang.String message, java.lang.Object expected, java.lang.Object actual)Asserts that two objects refer to the same object. If they are not
an AssertionFailedError is thrown with the given message.
if (expected == actual)
failSame(message);
|
public static void | assertNotSame(java.lang.Object expected, java.lang.Object actual)Asserts that two objects refer to the same object. If they are not
the same an AssertionFailedError is thrown.
assertNotSame(null, expected, actual);
|
public static void | assertNull(java.lang.Object object)Asserts that an object is null.
assertNull(null, object);
|
public static void | assertNull(java.lang.String message, java.lang.Object object)Asserts that an object is null. If it is not
an AssertionFailedError is thrown with the given message.
assertTrue(message, object == null);
|
public static void | assertSame(java.lang.String message, java.lang.Object expected, java.lang.Object actual)Asserts that two objects refer to the same object. If they are not
an AssertionFailedError is thrown with the given message.
if (expected == actual)
return;
failNotSame(message, expected, actual);
|
public static void | assertSame(java.lang.Object expected, java.lang.Object actual)Asserts that two objects refer to the same object. If they are not
the same an AssertionFailedError is thrown.
assertSame(null, expected, actual);
|
public static void | assertTrue(java.lang.String message, boolean condition)Asserts that a condition is true. If it isn't it throws
an AssertionFailedError with the given message.
if (!condition)
fail(message);
|
public static void | assertTrue(boolean condition)Asserts that a condition is true. If it isn't it throws
an AssertionFailedError.
assertTrue(null, condition);
|
public static void | fail(java.lang.String message)Fails a test with the given message.
throw new AssertionFailedError(message);
|
public static void | fail()Fails a test with no message.
fail(null);
|
private static void | failNotEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
fail(format(message, expected, actual));
|
private static void | failNotSame(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
String formatted= "";
if (message != null)
formatted= message+" ";
fail(formatted+"expected same:<"+expected+"> was not:<"+actual+">");
|
private static void | failSame(java.lang.String message)
String formatted= "";
if (message != null)
formatted= message+" ";
fail(formatted+"expected not same");
|
static java.lang.String | format(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
String formatted= "";
if (message != null)
formatted= message+" ";
return formatted+"expected:<"+expected+"> but was:<"+actual+">";
|