Skip to content

Commit db1f80c

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

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/test_sorts.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
on a graph, and ``stalin_sort``/``wiggle_sort`` deliberately do not fully sort).
1515
"""
1616

17+
from dataclasses import dataclass
18+
from typing import NamedTuple
19+
1720
import pytest
1821

1922
from sorts.binary_insertion_sort import binary_insertion_sort
@@ -69,6 +72,20 @@ def test_heap_sort():
6972
strand_sort,
7073
)
7174

75+
76+
@dataclass
77+
class Person:
78+
name: str = "Bob"
79+
age: int = 37
80+
cost: float = 0.0
81+
82+
83+
class Dog(NamedTuple):
84+
name: str = "Fido"
85+
age: int = 5
86+
weight: float = 15.5
87+
88+
7289
CASES = (
7390
[],
7491
[1],
@@ -79,6 +96,8 @@ def test_heap_sort():
7996
[5, 4, 3, 2, 1],
8097
[1, 2, 3, 4, 5],
8198
[-2, -2, 0, 0, 7, 7],
99+
[Person(cost=100.0), Person(cost=-100.0), Person(name="Al")],
100+
[Dog(weight=15.5), Dog(weight=15.1), Dog(name="Buddy")],
82101
)
83102

84103

0 commit comments

Comments
 (0)