Skip to content

Commit 8fb1b20

Browse files
committed
Test input validation in single coin flip function
1 parent 187ca44 commit 8fb1b20

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/tests/test_single_coin_flip.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test the single coin flip functionality from flip_coins"""
22

3+
import pytest
4+
35
import src.flip_coins
46

57

@@ -13,3 +15,21 @@ def test_single_coin_flip() -> None:
1315
assert 0 <= result["heads_count"][0] <= 1
1416
assert 0 <= result["tails_count"][0] <= 1
1517
assert result["heads_count"][0] != result["tails_count"][0]
18+
19+
20+
def test_single_coin_flip_invalid_input_type() -> None:
21+
"""Test the exception raising logic when given an invalid input type"""
22+
with pytest.raises(TypeError):
23+
src.flip_coins.flip_coin(5)
24+
25+
26+
def test_single_coin_flip_empty_string_value() -> None:
27+
"""Test the exception raising logic when given an empty string value"""
28+
with pytest.raises(ValueError):
29+
src.flip_coins.flip_coin("")
30+
31+
32+
def test_single_coin_flip_invalid_string_value() -> None:
33+
"""Test the exception raising logic when given an invalid string value"""
34+
with pytest.raises(ValueError):
35+
src.flip_coins.flip_coin("this_is_invalid")

0 commit comments

Comments
 (0)