f1 = Fraction.getFraction(Integer.MIN_VALUE, 5); f2 = Fraction.getFraction(1,5); try { f = f1.subtract(f2); fail("expecting ArithmeticException but got: " + f.toString()); } catch (ArithmeticException ex) {}  try { f= Fraction.getFraction(Integer.MIN_VALUE, 1); f = f.subtract(Fraction.ONE); fail("expecting ArithmeticException"); } catch (ArithmeticException ex) {}  try { f= Fraction.getFraction(Integer.MAX_VALUE, 1); f = f.subtract(Fraction.ONE.negate()); fail("expecting ArithmeticException"); } catch (ArithmeticException ex) {}  f1 = Fraction.getFraction(3,327680); f2 = Fraction.getFraction(2,59049); try { f = f1.subtract(f2); fail("expecting ArithmeticException but got: " + f.toString()); } catch (ArithmeticException ex) {}
    public void testSubtract() {        Fraction f = null;        Fraction f1 = null;        Fraction f2 = null;                f1 = Fraction.getFraction(3, 5);        f2 = Fraction.getFraction(1, 5);        f = f1.subtract(f2);        assertEquals(2, f.getNumerator());        assertEquals(5, f.getDenominator());                f1 = Fraction.getFraction(7, 5);        f2 = Fraction.getFraction(2, 5);        f = f1.subtract(f2);        assertEquals(1, f.getNumerator());        assertEquals(1, f.getDenominator());                f1 = Fraction.getFraction(3, 5);        f2 = Fraction.getFraction(3, 5);        f = f1.subtract(f2);        assertEquals(0, f.getNumerator());        assertEquals(1, f.getDenominator());                f1 = Fraction.getFraction(3, 5);        f2 = Fraction.getFraction(-4, 5);        f = f1.subtract(f2);        assertEquals(7, f.getNumerator());        assertEquals(5, f.getDenominator());                f1 = Fraction.getFraction(0, 5);        f2 = Fraction.getFraction(4, 5);        f = f1.subtract(f2);        assertEquals(-4, f.getNumerator());        assertEquals(5, f.getDenominator());                f1 = Fraction.getFraction(0, 5);        f2 = Fraction.getFraction(-4, 5);        f = f1.subtract(f2);        assertEquals(4, f.getNumerator());        assertEquals(5, f.getDenominator());                f1 = Fraction.getFraction(3, 5);        f2 = Fraction.getFraction(1, 2);        f = f1.subtract(f2);        assertEquals(1, f.getNumerator());        assertEquals(10, f.getDenominator());                f1 = Fraction.getFraction(0, 5);        f2 = Fraction.getFraction(1, 5);        f = f2.subtract(f1);        assertSame(f2, f);                try {            f.subtract(null);            fail("expecting IllegalArgumentException");        } catch (IllegalArgumentException ex) {}                try {            f1 = Fraction.getFraction(1, Integer.MAX_VALUE);            f2 = Fraction.getFraction(1, Integer.MAX_VALUE - 1);            f = f1.subtract(f2);            fail("expecting ArithmeticException");  //should overflow        } catch (ArithmeticException ex) {}                }