aboutsummaryrefslogtreecommitdiff
path: root/challenge-273/iangoodnight/python/tests/test_task1.py
blob: b27365fdac87b62fe3193296f9274fd8cd744edd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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