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); } }