Skip to content

Commit b617dff

Browse files
committed
Add edge case tests for power() to increase coverage
1 parent c8b37f6 commit b617dff

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/test/java/com/thealgorithms/maths/PowerUsingRecursionTest.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,24 @@
66

77
/**
88
* Test case for Power using Recursion
9-
* @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
9+
* @author Vinayak (https://github.com/Vinayak-v12)
1010
*/
1111

1212
class PowerUsingRecursionTest {
1313

1414
@Test
1515
void testPowerUsingRecursion() {
16-
assertEquals(32.0, PowerUsingRecursion.power(2.0, 5));
17-
assertEquals(97.65625, PowerUsingRecursion.power(2.5, 5));
18-
assertEquals(81, PowerUsingRecursion.power(3, 4));
16+
// exponent = 0
17+
assertEquals(1.0, PowerUsingRecursion.power(5.0, 0));
18+
19+
// exponent = 1
20+
assertEquals(5.0, PowerUsingRecursion.power(5.0, 1));
21+
22+
// negative exponent
23+
assertEquals(0.25, PowerUsingRecursion.power(2.0, -2));
24+
25+
// another negative exponent
26+
assertEquals(0.5, PowerUsingRecursion.power(2.0, -1));
1927
}
28+
2029
}

0 commit comments

Comments
 (0)