Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/test_sorts.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,23 @@ def test_sort_matches_builtin(sort, case) -> None:
def test_sort_rejects_non_comparable_items(sort) -> None:
with pytest.raises(TypeError):
sort([1, "a"])
import pytest
from sorts.slowsort import slowsort


def test_slowsort_comparable_types():
# Test with strings
words = ["banana", "apple", "cherry", "date"]
slowsort(words)
assert words == ["apple", "banana", "cherry", "date"]

# Test with floats and negative numbers
floats = [3.14, -1.0, 2.5, 0.0]
slowsort(floats)
assert floats == [-1.0, 0.0, 2.5, 3.14]


def test_slowsort_type_error_on_incomparable():
mixed = [1, "a"]
with pytest.raises(TypeError):
slowsort(mixed)