-
Notifications
You must be signed in to change notification settings - Fork 21.1k
Expand file tree
/
Copy pathArmstrongNumberTest.java
More file actions
37 lines (31 loc) · 1.2 KB
/
ArmstrongNumberTest.java
File metadata and controls
37 lines (31 loc) · 1.2 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
37
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 ArmstrongNumberTest {
@Test
void testArmstrongNumbers() {
// Test known Armstrong numbers
assertTrue(ArmstrongNumber.isArmstrong(0));
assertTrue(ArmstrongNumber.isArmstrong(1));
assertTrue(ArmstrongNumber.isArmstrong(153));
assertTrue(ArmstrongNumber.isArmstrong(370));
assertTrue(ArmstrongNumber.isArmstrong(371));
assertTrue(ArmstrongNumber.isArmstrong(407));
assertTrue(ArmstrongNumber.isArmstrong(1634));
}
@Test
void testNonArmstrongNumbers() {
// Test numbers that are not Armstrong numbers
assertFalse(ArmstrongNumber.isArmstrong(10));
assertFalse(ArmstrongNumber.isArmstrong(100));
assertFalse(ArmstrongNumber.isArmstrong(152));
assertFalse(ArmstrongNumber.isArmstrong(200));
}
@Test
void testNegativeNumbers() {
// Negative numbers cannot be Armstrong numbers
assertFalse(ArmstrongNumber.isArmstrong(-1));
assertFalse(ArmstrongNumber.isArmstrong(-153));
}
}