Skip to content

Commit ef9bb19

Browse files
committed
Formatted the code manually
1 parent fae3497 commit ef9bb19

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,15 @@
77

88
public class BinaryPowTest {
99

10-
// --- Existing Tests (from your provided code) ---
1110
@Test
1211
@DisplayName("Original tests for common cases")
1312
void testBinPow() {
14-
assertEquals(4, BinaryPow.binPow(2, 2)); // No 'L' needed for int literals
13+
assertEquals(4, BinaryPow.binPow(2, 2));
1514
assertEquals(256, BinaryPow.binPow(4, 4));
1615
assertEquals(729, BinaryPow.binPow(9, 3));
1716
assertEquals(262144, BinaryPow.binPow(8, 6));
1817
}
1918

20-
// --- New Comprehensive Tests (integrated and adjusted for binPow(int, int)) ---
21-
2219
@Test
2320
@DisplayName("binPow(2, 3) should return 8")
2421
void testBinPow_basicCase1() {
@@ -37,19 +34,16 @@ void testBinPow_basicCase3() {
3734
assertEquals(10000, BinaryPow.binPow(10, 4));
3835
}
3936

40-
// --- Edge Cases and Special Values ---
41-
4237
@Test
4338
@DisplayName("binPow(base, 0) should return 1 for non-zero base")
4439
void testBinPow_exponentZero() {
4540
assertEquals(1, BinaryPow.binPow(5, 0));
4641
assertEquals(1, BinaryPow.binPow(1, 0));
4742
assertEquals(1, BinaryPow.binPow(-10, 0));
48-
// Removed Long.MAX_VALUE as it exceeds int range
4943
}
5044

5145
@Test
52-
@DisplayName("binPow(0, 0) should return 1 (as per common convention for this algorithm)")
46+
@DisplayName("binPow(0, 0) should return 1 (as per convention)")
5347
void testBinPow_zeroToThePowerOfZero() {
5448
assertEquals(1, BinaryPow.binPow(0, 0));
5549
}
@@ -107,8 +101,6 @@ void testBinPow_negativeBaseOddExponent() {
107101
assertEquals(-243, BinaryPow.binPow(-3, 5));
108102
}
109103

110-
// --- Exception Handling for Negative Exponent ---
111-
112104
@Test
113105
@DisplayName("Should throw IllegalArgumentException for negative exponent")
114106
void testBinPow_negativeExponentThrowsException() {
@@ -118,19 +110,15 @@ void testBinPow_negativeExponentThrowsException() {
118110
assertThrows(IllegalArgumentException.class, () -> BinaryPow.binPow(1, -2));
119111
}
120112

121-
// --- Large Number Tests (within int range, careful with potential overflow) ---
122-
123113
@Test
124-
@DisplayName("binPow(2, 30) should return 1073741824 (fits in int)")
114+
@DisplayName("binPow(2, 30) should return 1073741824")
125115
void testBinPow_largeExponentFitsInInt() {
126-
// 2^30 = 1,073,741,824, which fits within Integer.MAX_VALUE (2,147,483,647)
127116
assertEquals(1073741824, BinaryPow.binPow(2, 30));
128117
}
129118

130119
@Test
131-
@DisplayName("binPow(7, 10) should return 282475249 (fits in int)")
120+
@DisplayName("binPow(7, 10) should return 282475249")
132121
void testBinPow_anotherLargeExponentFitsInInt() {
133-
// 7^10 = 282,475,249, which fits within Integer.MAX_VALUE
134122
assertEquals(282475249, BinaryPow.binPow(7, 10));
135123
}
136-
}
124+
}

0 commit comments

Comments
 (0)