List of utility methods to do Assert
void | assertSame(Object targetObject0, Object targetObject1) assert Same System.out.println(targetObject0 == targetObject1); |
void | assertSameClazz(Object object, Object defaults) assert Same Clazz if (!object.getClass().equals(defaults.getClass())) { throw new RuntimeException("Objects must have the same class: " + object.getClass().getName() + " != " + defaults.getClass().getName()); |
void | assertSameObject(Object obj1, Object obj2) Checks object memory equality if (obj1 != obj2) { throw new AssertionError("Objects are not the same"); |
void | assertSameSize(double[][] newLogPhi, double[][] logPhi) assert Same Size assert (newLogPhi.length == logPhi.length); for (int k = 0; k < logPhi.length; k++) { assert (newLogPhi[k].length == logPhi[k].length); |
void | assertSorted(final int[] values) assert Sorted int previousValue = values[0]; for (int i = 0; i < values.length; i++) { if (previousValue > values[i]) { String message = String.format("%d at index %d is smaller than its previous value %d", values[i], i, previousValue); throw new AssertionError(message); |
String[] | assertSplit(final String text, final int length) assert Split return assertSplit(text, length, "'" + text + "' must have at least " + length + " parts delimited by '.' or '::'."); |
void | assertSquare(double[]... d) assert Square if (d.length > 2) { for (int i = 0; i < d.length; i++) { assertSquare(d[i]); } else { int firstLength = d[0].length; for (int i = 1; i < d.length; i++) { assert d[i].length == firstLength; ... |
void | assertState(boolean expression) assert State if (!expression) { throw new IllegalStateException(); |
void | assertStringMatch(String first, String second) assert String Match Exception ex = new Exception(first + "!=" + second); if (first == null && second != null) throw ex; if (second != null && first.equals(second) == false) throw ex; |
void | assertStringNotEmpty(String str, String name) Check if the given string is empty (trimmed). if (str != null && str.trim().length() == 0) { throw new IllegalArgumentException(name + " should not be empty (trimmed)."); |