Skip to content

Commit 32f65f2

Browse files
committed
test_sorts with dataclasses and namedtuples
1 parent 9e1cf59 commit 32f65f2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/test_sorts.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
0/1/2, ``bitonic_sort`` needs a power-of-two length, ``topological_sort`` works
1414
on a graph, and ``stalin_sort``/``wiggle_sort`` deliberately do not fully sort).
1515
"""
16+
from dataclasses import dataclass
17+
typing import NamedTuple
1618

1719
import pytest
1820

@@ -69,6 +71,17 @@ def test_heap_sort():
6971
strand_sort,
7072
)
7173

74+
@dataclass
75+
class Person:
76+
name: str = "Bob"
77+
age: int = 37
78+
cost: float = 0.0
79+
80+
class Dog(NamedTuple):
81+
name: str = "Fido"
82+
age: int = 5
83+
weight: float = 15.5
84+
7285
CASES = (
7386
[],
7487
[1],
@@ -79,6 +92,8 @@ def test_heap_sort():
7992
[5, 4, 3, 2, 1],
8093
[1, 2, 3, 4, 5],
8194
[-2, -2, 0, 0, 7, 7],
95+
[Person(cost=100.0), Person(cost=-100.0), Person(name="Al")],
96+
[Dog(weight=15.5), Dog(weight=15.1), Dog(name="Buddy")],
8297
)
8398

8499

0 commit comments

Comments
 (0)