Skip to content

Commit

Permalink
fixed test_sjf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkushSinghGandhi authored Apr 9, 2024
1 parent 1dcfffe commit 4e49f5f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/test_sjf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ def test_sjf_scheduler():
Process("P2", arrival_time=1, burst_time=3, priority=2),
Process("P3", arrival_time=2, burst_time=7, priority=3)
]

# Initialize the SJF scheduler
scheduler = SJFScheduler()

# Schedule the processes
scheduling_output = scheduler.schedule(processes)


# Sort processes by arrival time for consistent comparison
processes.sort(key=lambda x: x.arrival_time)

# Verify the scheduling output
expected_output = """Process ID\tArrival Time\tBurst Time\tWaiting Time\tTurnaround Time
P1\t\t0\t\t5\t\t3\t\t8
P2\t\t1\t\t3\t\t0\t\t3
P3\t\t2\t\t7\t\t6\t\t13
Average Waiting Time: 3.0
Average Turnaround Time: 8.0
"""
print("Actual Output:")
print(scheduling_output)
print("Expected Output:")
print(expected_output)

assert scheduling_output.strip() == expected_output.strip()

0 comments on commit 4e49f5f

Please sign in to comment.