-
Notifications
You must be signed in to change notification settings - Fork 21k
Expand file tree
/
Copy pathAbundantNumberTest.java
More file actions
31 lines (26 loc) · 1.08 KB
/
AbundantNumberTest.java
File metadata and controls
31 lines (26 loc) · 1.08 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
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
class AbundantNumberTest {
@ParameterizedTest
@CsvSource({"12", "66", "222", "444", "888", "2424"})
void abundantNumbersTest(int n) {
assertTrue(AbundantNumber.isAbundant(n));
assertTrue(AbundantNumber.isAbundantNumber(n));
}
@ParameterizedTest
@CsvSource({"1", "2", "6", "111", "333", "2222"})
void nonAbundantNumbersTest(int n) {
assertFalse(AbundantNumber.isAbundant(n));
assertFalse(AbundantNumber.isAbundantNumber(n));
}
@ParameterizedTest
@CsvSource({"0", "-1"})
void throwsNegativeNumbersNotAllowed(int n) {
assertThrows(IllegalArgumentException.class, () -> AbundantNumber.isAbundant(n));
assertThrows(IllegalArgumentException.class, () -> AbundantNumber.isAbundantNumber(n));
}
}