-
Notifications
You must be signed in to change notification settings - Fork 19.7k
/
Copy pathAutomorphicNumberTest.java
27 lines (23 loc) · 1.07 KB
/
AutomorphicNumberTest.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
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;
public class AutomorphicNumberTest {
@Test
void testAutomorphicNumber() {
int[] trueTestCases = {0, 1, 25, 625, 12890625};
int[] falseTestCases = {-5, 2, 26, 1234};
for (Integer n : trueTestCases) {
assertTrue(AutomorphicNumber.isAutomorphic(n));
assertTrue(AutomorphicNumber.isAutomorphic2(n));
assertTrue(AutomorphicNumber.isAutomorphic3(String.valueOf(n)));
}
for (Integer n : 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
}
}