-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "number to word" tests & forbid too small/big numbers
- Loading branch information
Showing
3 changed files
with
31 additions
and
18 deletions.
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
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
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,30 @@ | ||
from application.helpers import Helpers | ||
|
||
import pytest | ||
|
||
|
||
class TestNumberWord: | ||
@pytest.mark.parametrize( | ||
"input, expected", | ||
[ | ||
(1, "one"), | ||
(2, "two"), | ||
(3, "three"), | ||
(10, "ten"), | ||
(18, "eighteen"), | ||
(76, "seventySix"), | ||
(100, "oneHundred"), | ||
(101, "oneHundredOne"), | ||
(123, "oneHundredTwentyThree"), | ||
(305, "threeHundredFive"), | ||
(911, "nineHundredEleven"), | ||
(999, "nineHundredNinetyNine"), | ||
], | ||
) | ||
def test_number_to_word(self, input, expected): | ||
assert Helpers.number_to_word(input) == expected | ||
|
||
@pytest.mark.parametrize("input", [1000, 1001, -1, -500]) | ||
def test_number_to_word_raises(self, input): | ||
with pytest.raises(ValueError, match="numbers between 0 and 999"): | ||
Helpers.number_to_word(input) |