-
Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathActivitySelectionTest.java
44 lines (33 loc) · 1.24 KB
/
ActivitySelectionTest.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
package com.thealgorithms.greedyalgorithms;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
public class ActivitySelectionTest {
@Test
public void testActivitySelection() {
int[] start = {1, 3, 0, 5, 8, 5};
int[] end = {2, 4, 6, 7, 9, 9};
ArrayList<Integer> result = ActivitySelection.activitySelection(start, end);
ArrayList<Integer> expected = new ArrayList<>(Arrays.asList(0, 1, 3, 4));
assertEquals(expected, result);
}
@Test
public void testSingleActivity() {
int[] start = {1};
int[] end = {2};
ArrayList<Integer> result = ActivitySelection.activitySelection(start, end);
List<Integer> expected = singletonList(0);
assertEquals(expected, result);
}
@Test
public void testNoOverlap() {
int[] start = {1, 2, 3};
int[] end = {2, 3, 4};
ArrayList<Integer> result = ActivitySelection.activitySelection(start, end);
ArrayList<Integer> expected = new ArrayList<>(Arrays.asList(0, 1, 2));
assertEquals(expected, result);
}
}