mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 14:34:05 +08:00
Add count set bits algorithm (#3262)
This commit is contained in:
15
src/test/java/com/thealgorithms/others/countSetBitsTest.java
Normal file
15
src/test/java/com/thealgorithms/others/countSetBitsTest.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.thealgorithms.others;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user