From d87e83206ea21bc2290ce459ffba878e94e49f95 Mon Sep 17 00:00:00 2001 From: Ian Goodnight Date: Sun, 16 Jun 2024 14:44:45 -0400 Subject: week 273 --- .../iangoodnight/python/tests/test_task1.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 challenge-273/iangoodnight/python/tests/test_task1.py (limited to 'challenge-273/iangoodnight/python/tests/test_task1.py') diff --git a/challenge-273/iangoodnight/python/tests/test_task1.py b/challenge-273/iangoodnight/python/tests/test_task1.py new file mode 100644 index 0000000000..b27365fdac --- /dev/null +++ b/challenge-273/iangoodnight/python/tests/test_task1.py @@ -0,0 +1,22 @@ +"""Tests for task1.py""" +from python.task1 import percentage_of_character + + +def test_examples() -> None: + """Test if function returns correct percentage of character""" + assert percentage_of_character("perl", "e") == 25 + assert percentage_of_character("java", "a") == 50 + assert percentage_of_character("python", "m") == 0 + assert percentage_of_character("ada", "a") == 67 + assert percentage_of_character("ballerina", "l") == 22 + assert percentage_of_character("analitik", "k") == 13 + + +def test_empty_string() -> None: + """Test if function returns 0 for empty string""" + assert percentage_of_character("", "a") == 0 + + +def test_empty_character() -> None: + """Test if function returns 0 for empty character""" + assert percentage_of_character("python", "") == 0 -- cgit