Skip to content

Commit a70ae43

Browse files
author
TheRealHaui
committed
Added some Unit Tests to increase test code coverage
1 parent ae68a78 commit a70ae43

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

other/fischer_yates_shuffle.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212

1313
def fisher_yates_shuffle(data: list) -> list[Any]:
14+
"""
15+
>>> import random
16+
>>> from unittest.mock import patch
17+
>>> with patch('random.randint', side_effect=[0, 3, 1, 2, 2, 0, 3, 1]):
18+
... fisher_yates_shuffle(["python", "says", "hello", "!"])
19+
['says', 'python', '!', 'hello']
20+
"""
1421
for _ in range(len(data)):
1522
a = random.randint(0, len(data) - 1)
1623
b = random.randint(0, len(data) - 1)

scheduling/multi_level_feedback_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def calculate_completion_time(self, queue: list[Process]) -> list[int]:
100100
>>> P4 = Process("P4", 0, 24)
101101
>>> mlfq = MLFQ(3, [17, 25], deque([P1, P2, P3, P4]), 0)
102102
>>> _ = mlfq.multi_level_feedback_queue()
103-
>>> mlfq.calculate_turnaround_time([P1, P2, P3, P4])
103+
>>> mlfq.calculate_completion_time([P1, P2, P3, P4])
104104
[136, 34, 162, 125]
105105
"""
106106
completion_times = []

strings/min_cost_string_conversion.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]:
8585
>>> y = len(ops[0]) - 1
8686
>>> assemble_transformation(ops, x, y)
8787
['Cc', 'Rau', 'Ct']
88+
>>> assemble_transformation(ops, x, y-1)
89+
['Cc', 'Da', 'Rtu']
8890
8991
>>> ops1 = [['0']]
9092
>>> x1 = len(ops1) - 1

0 commit comments

Comments
 (0)