-
Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathScanSchedulingTest.java
55 lines (43 loc) · 2.02 KB
/
ScanSchedulingTest.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
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 ScanSchedulingTest {
@Test
public void testScanSchedulingMovingUp() {
ScanScheduling scanScheduling = new ScanScheduling(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, 199, 39, 18);
List<Integer> result = scanScheduling.execute(requests);
assertEquals(expected, result);
}
@Test
public void testScanSchedulingMovingDown() {
ScanScheduling scanScheduling = new ScanScheduling(50, false, 200);
List<Integer> requests = Arrays.asList(55, 58, 39, 18, 90, 160, 150);
List<Integer> expected = Arrays.asList(39, 18, 0, 55, 58, 90, 150, 160);
List<Integer> result = scanScheduling.execute(requests);
assertEquals(expected, result);
}
@Test
public void testScanSchedulingEmptyRequests() {
ScanScheduling scanScheduling = new ScanScheduling(50, true, 200);
List<Integer> requests = emptyList();
List<Integer> expected = emptyList();
List<Integer> result = scanScheduling.execute(requests);
assertEquals(expected, result);
}
@Test
public void testScanScheduling() {
ScanScheduling scanScheduling = new ScanScheduling(50, true, 200);
List<Integer> requests = Arrays.asList(55, 58, 39, 18, 90, 160, 150);
List<Integer> result = scanScheduling.execute(requests);
List<Integer> expectedOrder = Arrays.asList(55, 58, 90, 150, 160, 199, 39, 18);
assertEquals(expectedOrder, result);
System.out.println("Final Head Position: " + scanScheduling.getHeadPosition());
System.out.println("Head Moving Up: " + scanScheduling.isMovingUp());
System.out.println("Request Order: " + result);
}
}