-
Notifications
You must be signed in to change notification settings - Fork 19.7k
/
Copy pathLookSchedulingTest.java
68 lines (50 loc) · 2.42 KB
/
LookSchedulingTest.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
63
64
65
66
67
68
package com.thealgorithms.scheduling.diskscheduling;
import static java.util.Collections.emptyList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
public class LookSchedulingTest {
@Test
public void testLookSchedulingMovingUp() {
LookScheduling lookScheduling = new LookScheduling(50, true, 200);
List<Integer> requests = Arrays.asList(55, 58, 39, 18, 90, 160, 150);
List<Integer> expected = Arrays.asList(55, 58, 90, 150, 160, 39, 18);
List<Integer> result = lookScheduling.execute(requests);
assertEquals(expected, result);
}
@Test
public void testLookSchedulingMovingDown() {
LookScheduling lookScheduling = new LookScheduling(50, false, 200);
List<Integer> requests = Arrays.asList(55, 58, 39, 18, 90, 160, 150);
List<Integer> expected = Arrays.asList(39, 18, 55, 58, 90, 150, 160);
List<Integer> result = lookScheduling.execute(requests);
assertEquals(expected, result);
}
@Test
public void testLookSchedulingEmptyRequests() {
LookScheduling lookScheduling = new LookScheduling(50, true, 200);
List<Integer> requests = emptyList();
List<Integer> expected = emptyList();
List<Integer> result = lookScheduling.execute(requests);
assertEquals(expected, result);
}
@Test
public void testLookSchedulingCurrentPosition() {
LookScheduling lookScheduling = new LookScheduling(50, true, 200);
// Testing current position remains unchanged after scheduling.
assertEquals(50, lookScheduling.getCurrentPosition());
}
@Test
public void testLookSchedulingPrintStatus() {
LookScheduling lookScheduling = new LookScheduling(50, true, 200);
List<Integer> requests = Arrays.asList(55, 58, 39, 18, 90, 160, 150);
List<Integer> result = lookScheduling.execute(requests);
List<Integer> expectedOrder = Arrays.asList(55, 58, 90, 150, 160, 39, 18);
assertEquals(expectedOrder, result);
System.out.println("Final LookScheduling Position: " + lookScheduling.getCurrentPosition());
System.out.println("LookScheduling Moving Up: " + lookScheduling.isMovingUp());
System.out.println("Farthest Position Reached: " + lookScheduling.getFarthestPosition());
System.out.println("Request Order: " + result);
}
}