forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountSetBitsTest.java
More file actions
26 lines (21 loc) · 760 Bytes
/
CountSetBitsTest.java
File metadata and controls
26 lines (21 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.thealgorithms.bitmanipulation;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class CountSetBitsTest {
@Test
void testSetBits() {
CountSetBits csb = new CountSetBits();
assertEquals(1L, csb.countSetBits(16));
assertEquals(4, csb.countSetBits(15));
assertEquals(5, csb.countSetBits(10000));
assertEquals(5, csb.countSetBits(31));
}
@Test
void testSetBitsLookupApproach() {
CountSetBits csb = new CountSetBits();
assertEquals(1L, csb.lookupApproach(16));
assertEquals(4, csb.lookupApproach(15));
assertEquals(5, csb.lookupApproach(10000));
assertEquals(5, csb.lookupApproach(31));
}
}