public class SimpleFractionTest {

    public static void main(String[] args) {
        testNumeratorDenominatorConstructor();
    }

    private static void testNumeratorDenominatorConstructor() {

        Fraction f;   // value produced by the constructor
        int n;        // convenience varible for the numerator value
        int d;        // convenience varible for the denominator value

        // Test Case 1: check the boundary case of a zero numerator "0/1".
        f = new Fraction(0,1);
        if ((n = f.getNumerator()) != 0 && (d = f.getDenominator()) != 1) {
            System.out.println("Got " + n + "/" + d + ", expected 0/1");
        }

        // Test Case 2: check a simple case the doesn't need reduction.
        f = new Fraction(1,2);
        if ((n = f.getNumerator()) != 1 && (d = f.getDenominator()) != 2) {
            System.out.println("Got " + n + "/" + d + ", expected 1/2");
        }

        // Test Case 3: check a case that needs some reduction.
        f = new Fraction(4,8);
        if ((n = f.getNumerator()) != 1 && (d = f.getDenominator()) != 2) {
            System.out.println("Got " + n + "/" + d + ", expected 1/2");
        }

    }

}