-
Notifications
You must be signed in to change notification settings - Fork 21.2k
Expand file tree
/
Copy pathFriendlyNumberTest.java
More file actions
33 lines (27 loc) · 1.01 KB
/
Copy pathFriendlyNumberTest.java
File metadata and controls
33 lines (27 loc) · 1.01 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
package com.thealgorithms.maths;
// author: Vraj Prajapati @Rosander0
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class FriendlyNumberTest {
@Test
public void testFriendlyNumbers() {
// 6 and 28 are friendly (abundancy index = 2)
assertTrue(FriendlyNumber.areFriendly(6, 28));
// Every number is friendly with itself
assertTrue(FriendlyNumber.areFriendly(6, 6));
assertTrue(FriendlyNumber.areFriendly(1, 1));
}
@Test
public void testNonFriendlyNumbers() {
assertFalse(FriendlyNumber.areFriendly(6, 10));
assertFalse(FriendlyNumber.areFriendly(10, 15));
assertFalse(FriendlyNumber.areFriendly(4, 9));
}
@Test
public void testInvalidInputs() {
assertFalse(FriendlyNumber.areFriendly(0, 6));
assertFalse(FriendlyNumber.areFriendly(-1, 6));
assertFalse(FriendlyNumber.areFriendly(6, -1));
}
}