-
Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathKrishnamurthyNumberTest.java
62 lines (53 loc) · 1.69 KB
/
KrishnamurthyNumberTest.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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;
/**
* Unit tests for the KrishnamurthyNumber class.
*/
public class KrishnamurthyNumberTest {
/**
* Test the isKrishnamurthy method with a known Krishnamurthy number.
*/
@Test
public void testIsKrishnamurthyTrue() {
assertTrue(KrishnamurthyNumber.isKrishnamurthy(145));
}
/**
* Test the isKrishnamurthy method with a number that is not a Krishnamurthy number.
*/
@Test
public void testIsKrishnamurthyFalse() {
assertFalse(KrishnamurthyNumber.isKrishnamurthy(123));
}
/**
* Test the isKrishnamurthy method with zero.
*/
@Test
public void testIsKrishnamurthyZero() {
assertFalse(KrishnamurthyNumber.isKrishnamurthy(0));
}
/**
* Test the isKrishnamurthy method with a negative number.
*/
@Test
public void testIsKrishnamurthyNegative() {
assertFalse(KrishnamurthyNumber.isKrishnamurthy(-145));
}
/**
* Test the isKrishnamurthy method with a single-digit Krishnamurthy number.
*/
@Test
public void testIsKrishnamurthySingleDigitTrue() {
assertTrue(KrishnamurthyNumber.isKrishnamurthy(1));
assertTrue(KrishnamurthyNumber.isKrishnamurthy(2));
}
/**
* Test the isKrishnamurthy method with a single-digit number that is not a Krishnamurthy number.
*/
@Test
public void testIsKrishnamurthySingleDigitFalse() {
assertFalse(KrishnamurthyNumber.isKrishnamurthy(3));
assertFalse(KrishnamurthyNumber.isKrishnamurthy(4));
}
}