forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerOfFourTest.java
More file actions
36 lines (30 loc) · 1.1 KB
/
PowerOfFourTest.java
File metadata and controls
36 lines (30 loc) · 1.1 KB
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
30
31
32
33
34
35
36
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
class PowerOfFourTest {
@Test
void testPowersOfFour() {
assertTrue(PowerOfFour.isPowerOfFour(1));
assertTrue(PowerOfFour.isPowerOfFour(4));
assertTrue(PowerOfFour.isPowerOfFour(16));
assertTrue(PowerOfFour.isPowerOfFour(64));
assertTrue(PowerOfFour.isPowerOfFour(256));
assertTrue(PowerOfFour.isPowerOfFour(1024));
}
@Test
void testNonPowersOfFour() {
assertFalse(PowerOfFour.isPowerOfFour(2));
assertFalse(PowerOfFour.isPowerOfFour(3));
assertFalse(PowerOfFour.isPowerOfFour(5));
assertFalse(PowerOfFour.isPowerOfFour(8));
assertFalse(PowerOfFour.isPowerOfFour(15));
assertFalse(PowerOfFour.isPowerOfFour(32));
}
@Test
void testEdgeCases() {
assertFalse(PowerOfFour.isPowerOfFour(0));
assertFalse(PowerOfFour.isPowerOfFour(-1));
assertFalse(PowerOfFour.isPowerOfFour(-4));
}
}