Java Assert assertComparison(T actual, T expected)

Here you can find the source of assertComparison(T actual, T expected)

Description

assert the equality of two generic objects using compareTo() operator

License

Apache License

Parameter

Parameter Description
T the type of comparable objects
actual specify a object to be compared
expected specify a object to be expected

Return

true if equal according to compareTo()

Declaration

public static <T extends Comparable<T>> boolean assertComparison(T actual, T expected) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**// w  ww .j  a v a2  s. c  o m
     * assert the equality of two generic objects using compareTo() operator
     *
     * @param <T> the type of comparable objects
     *
     * @param actual
     *          specify a object to be compared
     *
     * @param expected
     *          specify a object to be expected
     *
     * @return true if equal according to compareTo()
     */
    public static <T extends Comparable<T>> boolean assertComparison(T actual, T expected) {
        boolean ret = false;
        if ((expected == null) && (actual == null)) {
            ret = true;
        } else if (expected != null) {
            ret = expected.compareTo(actual) == 0;
        }
        return ret;
    }
}

Related

  1. assertCheckStrAndQuery(String str, String query)
  2. assertClassDoesNotExist(String className)
  3. assertClassExists(String className)
  4. assertColor(int color)
  5. assertComparison(T actual, T expected)
  6. assertCond(boolean b)
  7. assertCondition(boolean condition, String message)
  8. assertCondition(boolean condition, String msg)
  9. assertContains(final String string, final String content)