Skip to content

Commit 337eb8a

Browse files
committed
Add tests, in CountFriendsPairing.java
1 parent 0d68b65 commit 337eb8a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.thealgorithms.dynamicprogramming;
2+
3+
import static org.junit.jupiter.api.Assertions.assertFalse;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
5+
6+
import org.junit.jupiter.api.Test;
7+
8+
public class CountFriendsPairingTest {
9+
10+
@Test
11+
void testSmallCase() {
12+
int n = 5;
13+
int[] expectedGolombSequence = {1, 2, 2, 3, 3};
14+
15+
assertTrue(CountFriendsPairing.countFriendsPairing(n, expectedGolombSequence));
16+
}
17+
18+
@Test
19+
void testMismatchSequence() {
20+
int n = 5;
21+
int[] wrongSequence = {1, 2, 2, 2, 3}; // An incorrect sequence
22+
23+
assertFalse(CountFriendsPairing.countFriendsPairing(n, wrongSequence));
24+
}
25+
26+
@Test
27+
void testLargerCase() {
28+
int n = 10;
29+
int[] expectedGolombSequence = {1, 2, 2, 3, 3, 4, 4, 4, 5, 5};
30+
31+
assertTrue(CountFriendsPairing.countFriendsPairing(n, expectedGolombSequence));
32+
}
33+
34+
@Test
35+
void testEdgeCaseSingleElement() {
36+
int n = 1;
37+
int[] expectedGolombSequence = {1};
38+
39+
assertTrue(CountFriendsPairing.countFriendsPairing(n, expectedGolombSequence));
40+
}
41+
42+
@Test
43+
void testEmptySequence() {
44+
int n = 0;
45+
int[] emptySequence = {};
46+
47+
// Test the case where n is 0 (should handle this gracefully)
48+
assertTrue(CountFriendsPairing.countFriendsPairing(n, emptySequence));
49+
}
50+
}

0 commit comments

Comments
 (0)