-
Notifications
You must be signed in to change notification settings - Fork 19.4k
/
GangSchedulingTest.java
52 lines (43 loc) · 1.62 KB
/
GangSchedulingTest.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
package com.thealgorithms.scheduling;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class GangSchedulingTest {
private GangScheduling scheduler;
@BeforeEach
public void setup() {
scheduler = new GangScheduling();
}
@Test
public void testAddGangAndTask() {
scheduler.addGang("Gang1");
scheduler.addTaskToGang("Gang1", "Task1");
Map<String, List<String>> expected = Map.of("Gang1", List.of("Task1"));
assertEquals(expected, scheduler.getGangSchedules());
}
@Test
public void testMultipleGangs() {
scheduler.addGang("Gang1");
scheduler.addGang("Gang2");
scheduler.addTaskToGang("Gang1", "Task1");
scheduler.addTaskToGang("Gang2", "Task2");
Map<String, List<String>> expected = Map.of("Gang1", List.of("Task1"), "Gang2", List.of("Task2"));
assertEquals(expected, scheduler.getGangSchedules());
}
@Test
public void testGangWithMultipleTasks() {
scheduler.addGang("Gang1");
scheduler.addTaskToGang("Gang1", "Task1");
scheduler.addTaskToGang("Gang1", "Task2");
Map<String, List<String>> expected = Map.of("Gang1", List.of("Task1", "Task2"));
assertEquals(expected, scheduler.getGangSchedules());
}
@Test
public void testEmptyGangSchedule() {
scheduler.addGang("Gang1");
Map<String, List<String>> expected = Map.of("Gang1", List.of());
assertEquals(expected, scheduler.getGangSchedules());
}
}