-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathPowerOfTwoTest.java
29 lines (24 loc) · 960 Bytes
/
PowerOfTwoTest.java
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
27
28
29
package by.andd3dfx.numeric;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class PowerOfTwoTest {
@Test
public void testIsPowerOfTwo() {
assertTrue(PowerOfTwo.isPowerOfTwo(2));
assertTrue(PowerOfTwo.isPowerOfTwo(1));
assertFalse(PowerOfTwo.isPowerOfTwo(0));
assertFalse(PowerOfTwo.isPowerOfTwo(-1));
assertTrue(PowerOfTwo.isPowerOfTwo(16));
assertFalse(PowerOfTwo.isPowerOfTwo(34));
}
@Test
public void testIsPowerOfTwo_usingLog() {
assertTrue(PowerOfTwo.isPowerOfTwo_usingLog(2));
assertTrue(PowerOfTwo.isPowerOfTwo_usingLog(1));
assertFalse(PowerOfTwo.isPowerOfTwo_usingLog(0));
assertFalse(PowerOfTwo.isPowerOfTwo_usingLog(-1));
assertTrue(PowerOfTwo.isPowerOfTwo_usingLog(16));
assertFalse(PowerOfTwo.isPowerOfTwo_usingLog(34));
}
}