Skip to content

Commit 5fc6418

Browse files
Removed clearLowestSetBit(int n) from the file
1 parent b74a362 commit 5fc6418

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

src/test/java/com/thealgorithms/bitmanipulation/LowestSetBitTest.java

+10-25
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,23 @@ public class LowestSetBitTest {
1010
@Test
1111
public void testIsolateLowestSetBit() {
1212
// Test with regular positive numbers
13-
assertEquals(1, lowestSetBit.isolateLowestSetBit(5)); // 5 in binary is 101, the lowest set bit is 1
14-
assertEquals(2, lowestSetBit.isolateLowestSetBit(6)); // 6 in binary is 110, the lowest set bit is 2
15-
assertEquals(4, lowestSetBit.isolateLowestSetBit(12)); // 12 in binary is 1100, the lowest set bit is 4
13+
assertEquals(1, lowestSetBit.isolateLowestSetBit(5));
14+
assertEquals(2, lowestSetBit.isolateLowestSetBit(6));
15+
assertEquals(4, lowestSetBit.isolateLowestSetBit(12));
1616

1717
// Test with powers of two
18-
assertEquals(1, lowestSetBit.isolateLowestSetBit(1)); // 1 in binary is 1, the lowest set bit is 1
19-
assertEquals(2, lowestSetBit.isolateLowestSetBit(2)); // 2 in binary is 10, the lowest set bit is 2
20-
assertEquals(4, lowestSetBit.isolateLowestSetBit(4)); // 4 in binary is 100, the lowest set bit is 4
18+
assertEquals(1, lowestSetBit.isolateLowestSetBit(1));
19+
assertEquals(2, lowestSetBit.isolateLowestSetBit(2));
20+
assertEquals(4, lowestSetBit.isolateLowestSetBit(4));
2121

2222
// Test with negative numbers
23-
assertEquals(1, lowestSetBit.isolateLowestSetBit(-5)); // -5 in binary (two's complement) still has 1 as the lowest set bit
24-
assertEquals(2, lowestSetBit.isolateLowestSetBit(-6)); // -6 in binary has 2 as the lowest set bit
23+
assertEquals(1, lowestSetBit.isolateLowestSetBit(-5));
24+
assertEquals(2, lowestSetBit.isolateLowestSetBit(-6));
2525

2626
// Test with zero
27-
assertEquals(0, lowestSetBit.isolateLowestSetBit(0)); // Edge case: 0 should return 0
27+
assertEquals(0, lowestSetBit.isolateLowestSetBit(0));
2828

2929
// Test with number having all bits set
30-
assertEquals(1, lowestSetBit.isolateLowestSetBit(-1)); // -1 in two's complement has all bits set, lowest set bit is 1
31-
}
32-
33-
@Test
34-
public void testClearLowestSetBit() {
35-
// Test with positive numbers
36-
assertEquals(4, lowestSetBit.clearLowestSetBit(5)); // 5 in binary is 101, clearing lowest set bit gives 100 (which is 4)
37-
assertEquals(4, lowestSetBit.clearLowestSetBit(6)); // 6 in binary is 110, clearing lowest set bit gives 100 (which is 4)
38-
assertEquals(8, lowestSetBit.clearLowestSetBit(12)); // 12 in binary is 1100, clearing lowest set bit gives 1000 (which is 8)
39-
40-
// Test with negative numbers
41-
assertEquals(-6, lowestSetBit.clearLowestSetBit(-5)); // -5 in binary, clearing lowest set bit should give -6
42-
assertEquals(-8, lowestSetBit.clearLowestSetBit(-6)); // -6 in binary, clearing lowest set bit should give -8
43-
44-
// Test with zero
45-
assertEquals(0, lowestSetBit.clearLowestSetBit(0)); // Edge case: 0 should return 0
30+
assertEquals(1, lowestSetBit.isolateLowestSetBit(-1));
4631
}
4732
}

0 commit comments

Comments
 (0)