test/testlibrary/com/oracle/java/testlibrary/Asserts.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/test/testlibrary/com/oracle/java/testlibrary/Asserts.java Wed Nov 26 19:11:59 2014
--- new/test/testlibrary/com/oracle/java/testlibrary/Asserts.java Wed Nov 26 19:11:59 2014
*** 66,77 ****
--- 66,76 ----
* Calls {@link #assertLessThan(T, T, String)} with a default message.
*
* @see #assertLessThan(T, T, String)
*/
public static <T extends Comparable<T>> void assertLessThan(T lhs, T rhs) {
! String msg = "Expected that " + format(lhs) + " < " + format(rhs);
assertLessThan(lhs, rhs, msg);
! assertLessThan(lhs, rhs, null);
}
/**
* Asserts that {@code lhs} is less than {@code rhs}.
*
*** 79,89 ****
--- 78,88 ----
* @param rhs The right hand side of the comparison.
* @param msg A description of the assumption.
* @throws RuntimeException if the assertion isn't valid.
*/
public static <T extends Comparable<T>>void assertLessThan(T lhs, T rhs, String msg) {
! assertTrue(compare(lhs, rhs, msg) < 0, getMessage(lhs, rhs, "<", msg));
}
/**
* Shorthand for {@link #assertLessThanOrEqual(T, T)}.
*
*** 106,117 ****
--- 105,115 ----
* Calls {@link #assertLessThanOrEqual(T, T, String)} with a default message.
*
* @see #assertLessThanOrEqual(T, T, String)
*/
public static <T extends Comparable<T>> void assertLessThanOrEqual(T lhs, T rhs) {
! String msg = "Expected that " + format(lhs) + " <= " + format(rhs);
assertLessThanOrEqual(lhs, rhs, msg);
! assertLessThanOrEqual(lhs, rhs, null);
}
/**
* Asserts that {@code lhs} is less than or equal to {@code rhs}.
*
*** 119,129 ****
--- 117,127 ----
* @param rhs The right hand side of the comparison.
* @param msg A description of the assumption.
* @throws RuntimeException if the assertion isn't valid.
*/
public static <T extends Comparable<T>> void assertLessThanOrEqual(T lhs, T rhs, String msg) {
! assertTrue(compare(lhs, rhs, msg) <= 0, getMessage(lhs, rhs, "<=", msg));
}
/**
* Shorthand for {@link #assertEquals(T, T)}.
*
*** 146,157 ****
--- 144,154 ----
* Calls {@link #assertEquals(T, T, String)} with a default message.
*
* @see #assertEquals(T, T, String)
*/
public static void assertEquals(Object lhs, Object rhs) {
! String msg = "Expected " + format(lhs) + " to equal " + format(rhs);
assertEquals(lhs, rhs, msg);
! assertEquals(lhs, rhs, null);
}
/**
* Asserts that {@code lhs} is equal to {@code rhs}.
*
*** 164,174 ****
--- 161,171 ----
if (lhs == null) {
if (rhs != null) {
error(msg);
}
} else {
! assertTrue(lhs.equals(rhs), getMessage(lhs, rhs, "==", msg));
}
}
/**
* Shorthand for {@link #assertGreaterThanOrEqual(T, T)}.
*** 192,203 ****
--- 189,199 ----
* Calls {@link #assertGreaterThanOrEqual(T, T, String)} with a default message.
*
* @see #assertGreaterThanOrEqual(T, T, String)
*/
public static <T extends Comparable<T>> void assertGreaterThanOrEqual(T lhs, T rhs) {
! String msg = "Expected that " + format(lhs) + " >= " + format(rhs);
assertGreaterThanOrEqual(lhs, rhs, msg);
! assertGreaterThanOrEqual(lhs, rhs, null);
}
/**
* Asserts that {@code lhs} is greater than or equal to {@code rhs}.
*
*** 205,215 ****
--- 201,211 ----
* @param rhs The right hand side of the comparison.
* @param msg A description of the assumption.
* @throws RuntimeException if the assertion isn't valid.
*/
public static <T extends Comparable<T>> void assertGreaterThanOrEqual(T lhs, T rhs, String msg) {
! assertTrue(compare(lhs, rhs, msg) >= 0, getMessage(lhs, rhs, ">=", msg));
}
/**
* Shorthand for {@link #assertGreaterThan(T, T)}.
*
*** 232,243 ****
--- 228,238 ----
* Calls {@link #assertGreaterThan(T, T, String)} with a default message.
*
* @see #assertGreaterThan(T, T, String)
*/
public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs) {
! String msg = "Expected that " + format(lhs) + " > " + format(rhs);
assertGreaterThan(lhs, rhs, msg);
! assertGreaterThan(lhs, rhs, null);
}
/**
* Asserts that {@code lhs} is greater than {@code rhs}.
*
*** 245,255 ****
--- 240,250 ----
* @param rhs The right hand side of the comparison.
* @param msg A description of the assumption.
* @throws RuntimeException if the assertion isn't valid.
*/
public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs, String msg) {
! assertTrue(compare(lhs, rhs, msg) > 0, getMessage(lhs, rhs, ">", msg));
}
/**
* Shorthand for {@link #assertNotEquals(T, T)}.
*
*** 272,283 ****
--- 267,277 ----
* Calls {@link #assertNotEquals(T, T, String)} with a default message.
*
* @see #assertNotEquals(T, T, String)
*/
public static void assertNotEquals(Object lhs, Object rhs) {
! String msg = "Expected " + format(lhs) + " to not equal " + format(rhs);
assertNotEquals(lhs, rhs, msg);
! assertNotEquals(lhs, rhs, null);
}
/**
* Asserts that {@code lhs} is not equal to {@code rhs}.
*
*** 290,300 ****
--- 284,294 ----
if (lhs == null) {
if (rhs == null) {
error(msg);
}
} else {
! assertFalse(lhs.equals(rhs), getMessage(lhs, rhs,"!=", msg));
}
}
/**
* Calls {@link #assertNull(Object, String)} with a default message.
*** 448,453 ****
--- 442,450 ----
private static void error(String msg) {
throw new RuntimeException(msg);
}
+ private static String getMessage(Object lhs, Object rhs, String op, String msg) {
+ return (msg == null ? "" : msg + " ") + "Expected that " + format(lhs) + " " + op + " " + format(rhs);
+ }
}
test/testlibrary/com/oracle/java/testlibrary/Asserts.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File