Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 21.3k
Expand file tree
/
Copy pathAutomorphicNumberTest.java
More file actions
Latest commit
27 lines (23 loc) · 1.07 KB
/
Copy pathAutomorphicNumberTest.java
File metadata and controls
27 lines (23 loc) · 1.07 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
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertFalse;
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
importorg.junit.jupiter.api.Test;
publicclassAutomorphicNumberTest {
@Test
voidtestAutomorphicNumber() {
int[] trueTestCases = {0, 1, 25, 625, 12890625};
int[] falseTestCases = {-5, 2, 26, 1234};
for (Integern : trueTestCases) {
assertTrue(AutomorphicNumber.isAutomorphic(n));
assertTrue(AutomorphicNumber.isAutomorphic2(n));
assertTrue(AutomorphicNumber.isAutomorphic3(String.valueOf(n)));
}
for (Integern : falseTestCases) {
assertFalse(AutomorphicNumber.isAutomorphic(n));
assertFalse(AutomorphicNumber.isAutomorphic2(n));
assertFalse(AutomorphicNumber.isAutomorphic3(String.valueOf(n)));
}
assertTrue(AutomorphicNumber.isAutomorphic3("59918212890625")); // Special case for BigInteger
assertFalse(AutomorphicNumber.isAutomorphic3("12345678912345")); // Special case for BigInteger
}
}