@Test public void test7() throws Throwable { Rational rational0 = new Rational((-1706L), 1409L); try { rational0.pow((-1)); fail("Expecting exception: NumberFormatException"); } catch (NumberFormatException e) { // // Cannot create a Rational object with zero as the denominator // } }
/** * OVERVIEW: The test case "test7" covers around 6.0% (low percentage) of statements in "Rational" */ @Test public void test7() throws Throwable { // The test case instantiates a "Rational" with numerator equal to -1L, // and denominator equal to -1L. // The execution of this constructor implicitly covers the following 1 // conditions: // - the condition " denominator equals to 0L" is FALSE; Rational rational0 = new Rational((-1L), (-1L)); // The test case declares an object of the class "Rational" whose value // is the power of "rational0" Rational rational1 = rational0.pow(3404); // Then, it tests: // 1) whether the integer value of "rational1" is equal to 1; assertEquals(1, rational1.intValue()); // 2) whether the short value of "rational1" is equal to 1; assertEquals(1, rational1.shortValue()); }