summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/JobQueueTest.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/JobQueueTest.java b/src/test/JobQueueTest.java
new file mode 100644
index 0000000..e0e8a29
--- /dev/null
+++ b/src/test/JobQueueTest.java
@@ -0,0 +1,33 @@
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class JobQueueTest {
+ @Test
+ void test() {
+ int numWorkers = 2;
+ int[] jobs = {1, 2, 3, 4, 5};
+ JobQueue jobQueue = new JobQueue();
+ jobQueue.numWorkers = numWorkers;
+ jobQueue.jobs = jobs;
+ jobQueue.assignJobsImproved();
+ assertEquals(5, jobQueue.assignedWorker.length);
+ assertEquals(5, jobQueue.startTime.length);
+ assertArrayEquals(new int[]{0, 1, 0, 1, 0}, jobQueue.assignedWorker);
+ assertArrayEquals(new long[]{0, 0, 1, 2, 4}, jobQueue.startTime);
+ }
+
+ @Test
+ void test1() {
+ int numWorkers = 4;
+ int[] jobs = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+ JobQueue jobQueue = new JobQueue();
+ jobQueue.numWorkers = numWorkers;
+ jobQueue.jobs = jobs;
+ jobQueue.assignJobsImproved();
+ assertEquals(20, jobQueue.assignedWorker.length);
+ assertEquals(20, jobQueue.startTime.length);
+ assertArrayEquals(new int[]{0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3}, jobQueue.assignedWorker);
+ assertArrayEquals(new long[]{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4}, jobQueue.startTime);
+ }
+} \ No newline at end of file