- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathPowerOfTwoOrNotTest.java
24 lines (20 loc) · 811 Bytes
/
PowerOfTwoOrNotTest.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
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertFalse;
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
importorg.junit.jupiter.api.Test;
publicclassPowerOfTwoOrNotTest {
@Test
publicvoidtestPowerOfTwoOrNotForPowersOfTwo() {
finalvarpowersOfTwo = newint[] {1, 2, 4, 8, 16, 32, 64};
for (finalvarn : powersOfTwo) {
assertTrue(PowerOfTwoOrNot.checkIfPowerOfTwoOrNot(n));
}
}
@Test
publicvoidtestPowerOfTwoOrNotForNotPowersOfTwo() {
finalvarnotPowersOfTwo = newint[] {-16, -8, -6, -5, -4, -3, -2, -1, 0, 3, 5, 6, 7, 9, 10, 11, 33, 63, 65, 1000, 9999};
for (finalvarn : notPowersOfTwo) {
assertFalse(PowerOfTwoOrNot.checkIfPowerOfTwoOrNot(n));
}
}
}