/**
 * CS-12J  Asg5
 * SizerTest.java
 * Purpose: Unit test of the Sizer class.
 *
 * @version 1.1 9/29/04
 * @author Ed Parrish
 */
public final class SizerTest {
    private static int numErrors;

    /**
     * Private constructor to prevent instantiating this utility class.
     */
    private SizerTest() { }

    /**
     * The main method begins execution of the tests.
     *
     * @param args not used
     */
    public static void main(final String[] args) {
        testCalcHatSize();
        testCalcJacketSize();
        testCalcWaistSize();
        if (numErrors == 0) {
            System.out.println("*** All tests passed ***");
        }
    }

    /**
     * Convenience method to test for assertions.
     *
     * @param condition The test condition that must be true to pass.
     * @param message The reason for the failure.
     */
    public static void assertTrue(boolean condition, String message) {
        if (!condition) {
            //throw new RuntimeException(message);
            System.out.println("Error: " + message);
            numErrors++;
        }
    }

    /**
     * Test method: double calcHatSize(int height, int weight)
     */
    public static void testCalcHatSize() {
        System.out.println("Testing calcHatSize");
        final int height = 73;
        final int weight = 175;
        final double hatSize = 6.952055;
        double result = Sizer.calcHatSize(height, weight);
        assertTrue(Math.abs(result - hatSize) < .001,
            "Wrong hat size calculated: " + result);
    }

    /**
     * Test method: double calcJacketSize(int height, int weight, int age)
     */
    public static void testCalcJacketSize() {
        System.out.println("Testing calcJacketSize");
        final int age = 39;
        final int height = 73;
        final int weight = 175;
        final double jacketSize = 44.357639;
        double result = Sizer.calcJacketSize(height, weight, age);
        assertTrue(Math.abs(result - jacketSize) < .001,
            "Wrong jacket size calculated: " + result);
    }

    /**
     * Test method: double calcWaistSize(int weight, int age)
     */
    public static void testCalcWaistSize() {
        System.out.println("Testing calcWaistSize");
        final int age = 39;
        final int weight = 175;
        final double waistSize = 31.20175438596491;
        double result = Sizer.calcWaistSize(weight, age);
        assertTrue(Math.abs(result - waistSize) < .001,
            "Wrong waist size calculated: " + result);
    }
}

