Skip to content

Commit 4410bd5

Browse files
committed
added a test (pytest) to Bubble_Sort
1 parent f3dabfe commit 4410bd5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Bubble_Sort.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ def main():
4444

4545
sort.bubbleSortRecursive()
4646
print("Sorted array :\n", sort)
47+
48+
# Tests ('pip install pytest'; run with 'pytest Bubble_Sort.py')
49+
def test_result_in_order():
50+
array = [64, 34, 25, 12, 22, 11, 90]
51+
sort = bubbleSort(array)
52+
sort.bubbleSortRecursive()
53+
for i in range(sort.length-1):
54+
assert sort.array[i] < sort.array[i+1]
4755

4856

4957
if __name__ == "__main__":

0 commit comments

Comments
 (0)