Skip to content

Commit db5f03c

Browse files
authored
pangram: add tests for alphabetical min/max (exercism#2192)
Resolves exercism#2190 Signed-off-by: Corey McCandless <corey.mccandless@atlasied.com>
1 parent 4499a2b commit db5f03c

3 files changed

Lines changed: 44 additions & 5 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"cases": [
3+
{
4+
"description": "sentence without lower bound",
5+
"property": "isPangram",
6+
"input": {
7+
"sentence": "bcdefghijklmnopqrstuvwxyz"
8+
},
9+
"expected": false
10+
},
11+
{
12+
"description": "sentence without upper bound",
13+
"property": "isPangram",
14+
"input": {
15+
"sentence": "abcdefghijklmnopqrstuvwxy"
16+
},
17+
"expected": false
18+
}
19+
]
20+
}
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
{%- import "generator_macros.j2" as macros with context -%}
2-
{{ macros.header() }}
3-
4-
class {{ exercise | camel_case }}Test(unittest.TestCase):
5-
{# All test cases in this exercise are nested, so use two for loops -#}
6-
{% for case in cases -%}
2+
{% macro test_case(case) -%}
3+
{%- set input = case["input"] -%}
74
def test_{{ case["description"] | to_snake }}(self):
85
self.assertIs(
96
{{ case["property"] | to_snake }}("{{ case["input"]["sentence"].replace('"', '\\"') }}"),
107
{{ case["expected"] }}
118
)
9+
{%- endmacro %}
10+
{{ macros.header()}}
11+
12+
class {{ exercise | camel_case }}Test(unittest.TestCase):
13+
{# All test cases in this exercise are nested, so use two for loops -#}
14+
{% for case in cases -%}
15+
{{ test_case(case) }}
1216
{% endfor %}
17+
{% if additional_cases | length -%}
1318

19+
# Additional tests for this track
20+
21+
{% for case in additional_cases -%}
22+
{{ test_case(case) }}
23+
{% endfor %}
24+
{%- endif %}
1425
{{ macros.footer() }}

exercises/pangram/pangram_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ def test_mixed_case_and_punctuation(self):
4141
def test_case_insensitive(self):
4242
self.assertIs(is_pangram("the quick brown fox jumps over with lazy FX"), False)
4343

44+
# Additional tests for this track
45+
46+
def test_sentence_without_lower_bound(self):
47+
self.assertIs(is_pangram("bcdefghijklmnopqrstuvwxyz"), False)
48+
49+
def test_sentence_without_upper_bound(self):
50+
self.assertIs(is_pangram("abcdefghijklmnopqrstuvwxy"), False)
51+
4452

4553
if __name__ == "__main__":
4654
unittest.main()

0 commit comments

Comments
 (0)