Java Assert Equal assertEquals(float a1, float a2)

Here you can find the source of assertEquals(float a1, float a2)

Description

Ensure that the two values given are equal, if not fail the test

License

Open Source License

Parameter

Parameter Description
a1 The first value to compare
a2 The second value to compare

Declaration

public static void assertEquals(float a1, float a2) 

Method Source Code

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

public class Main {
    /**//from  w ww  . jav  a  2 s .  c o m
     * Ensure that the two values given are equal, if not fail the test
     * 
     * @param a1
     *            The first value to compare
     * @param a2
     *            The second value to compare
     */
    public static void assertEquals(float a1, float a2) {
        if (a1 != a2) {
            throw new RuntimeException("TEST FAILS: " + a1 + " should be " + a2);
        }
    }

    /**
     * Ensure that the two values given are equal, if not fail the test
     * 
     * @param a1
     *            The first value to compare
     * @param a2
     *            The second value to compare
     */
    public static void assertEquals(int a1, int a2) {
        if (a1 != a2) {
            throw new RuntimeException("TEST FAILS: " + a1 + " should be " + a2);
        }
    }

    /**
     * Ensure that the two values given are equal, if not fail the test
     * 
     * @param a1
     *            The first value to compare
     * @param a2
     *            The second value to compare
     */
    public static void assertEquals(Object a1, Object a2) {
        if (!a1.equals(a2)) {
            throw new RuntimeException("TEST FAILS: " + a1 + " should be " + a2);
        }
    }
}

Related

  1. assertEquality(Object original, Object equal, Object... notEqual)
  2. assertEquals(double x, double y)
  3. assertEquals(double x, double y)
  4. assertEquals(final int expected, final int actual)
  5. assertEquals(final Object actual, final Object expected, final String name)
  6. assertEquals(int a, int b)
  7. assertEquals(int i1, int i2)
  8. assertEquals(Integer a, Integer b)
  9. assertEquals(Object a, Object b, String msg)