-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b94a55e
commit 6047f91
Showing
2 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/safeds/data/tabular/containers/_table/test_count_row_if.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import pytest | ||
from safeds.data.tabular.containers import Table | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("values", "expected"), | ||
[ | ||
([], 0), | ||
([1], 1), | ||
([2], 0), | ||
([None], 0), | ||
([1, None], 1), | ||
([2, None], 0), | ||
([1, 2], 1), | ||
([1, 2, None], 1), | ||
], | ||
ids=[ | ||
"empty", | ||
"always true", | ||
"always false", | ||
"always unknown", | ||
"true and unknown", | ||
"false and unknown", | ||
"true and false", | ||
"true and false and unknown", | ||
], | ||
) | ||
def test_should_handle_boolean_logic( | ||
values: list, | ||
expected: int, | ||
) -> None: | ||
table = Table({"a": values}) | ||
assert table.count_row_if(lambda row: row["a"] < 2) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("values", "expected"), | ||
[ | ||
([], 0), | ||
([1], 1), | ||
([2], 0), | ||
([None], None), | ||
([1, None], None), | ||
([2, None], None), | ||
([1, 2], 1), | ||
([1, 2, None], None), | ||
], | ||
ids=[ | ||
"empty", | ||
"always true", | ||
"always false", | ||
"always unknown", | ||
"true and unknown", | ||
"false and unknown", | ||
"true and false", | ||
"true and false and unknown", | ||
], | ||
) | ||
def test_should_handle_kleene_logic( | ||
values: list, | ||
expected: int | None, | ||
) -> None: | ||
table = Table({"a": values}) | ||
assert table.count_row_if(lambda row: row["a"] < 2, ignore_unknown=False) == expected |