-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fizzbuzz.py
More file actions
32 lines (26 loc) · 873 Bytes
/
test_fizzbuzz.py
File metadata and controls
32 lines (26 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from typing import Tuple
import pytest
from src.fizzbuzz import fizzbuzz
def fizzbuz_test_case(length: int) -> Tuple[list[int], list[str]]:
"""Generate test cases with the imperative FizzBuzz solution"""
def carb(n: int) -> str:
if n % 15 == 0:
return "FizzBuzz"
elif n % 3 == 0:
return "Fizz"
elif n % 5 == 0:
return "Buzz"
else:
return str(n) # <-- carbonateRemaining
return list(range(length)), list(map(carb, range(length)))
@pytest.mark.parametrize(
"input,expected",
[
([1, 3, 5, 15], ["1", "Fizz", "Buzz", "FizzBuzz"]),
fizzbuz_test_case(length=100),
fizzbuz_test_case(length=500),
fizzbuz_test_case(length=1000),
]
)
def test_fizzbuzz(input: list[int], expected: list[str]) -> None:
assert fizzbuzz(input) == expected