From ace0391bbf5684f78e4a5d2ef660803af9057ecd Mon Sep 17 00:00:00 2001 From: brighttsekumah46-coder Date: Thu, 17 Sep 2026 13:45:20 +0000 Subject: [PATCH] Add unit tests for comparable items and TypeError in slowsort --- tests/test_sorts.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_sorts.py b/tests/test_sorts.py index 2c9b79aa4bfe..a74fa2b3cecc 100644 --- a/tests/test_sorts.py +++ b/tests/test_sorts.py @@ -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) \ No newline at end of file