-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bubble sort #26
bubble sort #26
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,40 @@ def test_mergesort_empty(): | |
|
||
|
||
def test_bubble_sort(): | ||
# Stub for basic bubble sort tests, see issue #9 | ||
pass | ||
# Test even-sized list: | ||
l = [3, 2, 1, 5, 4, 6] | ||
res = lws.bubble_sort(l) | ||
assert res == [1, 2, 3, 4, 5, 6] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This list of tests is good. One way one can write it more compact is for example |
||
|
||
# Test odd-sized list: | ||
l = [5, 4, 3, 2, 1] | ||
res = lws.bubble_sort(l) | ||
assert res == [1, 2, 3, 4, 5] | ||
|
||
# Test already sorted list: | ||
l = [1, 2, 3, 4, 5] | ||
res = lws.bubble_sort(l) | ||
assert res == [1, 2, 3, 4, 5] | ||
|
||
# Test list with duplicate elements: | ||
l = [4, 2, 3, 2, 1, 3] | ||
res = lws.bubble_sort(l) | ||
assert res == [1, 2, 2, 3, 3, 4] | ||
|
||
# Test list with all identical elements: | ||
l = [7, 7, 7, 7] | ||
res = lws.bubble_sort(l) | ||
assert res == [7, 7, 7, 7] | ||
|
||
# Test empty list: | ||
l = [] | ||
res = lws.bubble_sort(l) | ||
assert res == [] | ||
|
||
# Test single-element list: | ||
l = [1] | ||
res = lws.bubble_sort(l) | ||
assert res == [1] | ||
|
||
|
||
def test_selection_sort(): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would need some documentation of course. At least for public facing functions.