Skip to content

Commit

Permalink
feat: add test for empty tables for the method Table.sort_rows (#431)
Browse files Browse the repository at this point in the history
Closes #402

### Summary of Changes

implement the test for empty table in the tests for non empty tables.
  • Loading branch information
robmeth committed Jul 7, 2023
1 parent 5e3da8d commit f94b768
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/safeds/data/tabular/containers/_table/test_sort_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
@pytest.mark.parametrize(
("table", "comparator", "expected"),
[
# Check that it works with an empty table when https://github.com/Safe-DS/Stdlib/issues/75 is fixed.
(
Table(),
lambda row1, row2: row1["col1"] - row2["col1"],
Table(),
),
(
Table({"col1": [3, 2, 1]}),
lambda row1, row2: row1["col1"] - row2["col1"],
Table({"col1": [1, 2, 3]}),
),
],
ids=["empty", "3 rows"],
)
def test_should_return_sorted_table(
table: Table,
Expand All @@ -27,13 +32,18 @@ def test_should_return_sorted_table(
@pytest.mark.parametrize(
("table", "comparator", "expected"),
[
# Check that it works with an empty table when https://github.com/Safe-DS/Stdlib/issues/75 is fixed.
(
Table(),
lambda row1, row2: row1["col1"] - row2["col1"],
Table(),
),
(
Table({"col1": [3, 2, 1]}),
lambda row1, row2: row1["col1"] - row2["col1"],
Table({"col1": [3, 2, 1]}),
),
],
ids=["empty", "3 rows"],
)
def test_should_not_modify_original_table(
table: Table,
Expand All @@ -43,7 +53,3 @@ def test_should_not_modify_original_table(
table.sort_rows(comparator)
assert table.schema == expected.schema
assert table == expected


def test_should_not_sort_anything_on_empty_table() -> None:
assert Table() == Table().sort_rows(lambda row1, row2: row1["col1"] - row2["col1"])

0 comments on commit f94b768

Please sign in to comment.