Skip to content

Commit ab8449c

Browse files
committed
comp
1 parent 2bc344a commit ab8449c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/comprehensionsTest.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from checkpy import *
2+
from _basics import *
3+
from _static_analysis import *
4+
5+
@t.passed(doctest_ok)
6+
def has_functions():
7+
"""alle gevraagde functies zijn aanwezig"""
8+
assert defines_function("four_random_letters")
9+
assert defines_function("ten_odd_plus_five")
10+
assert defines_function("password_numeric_analysis")
11+
assert defines_function("numbers_list_from_password")
12+
assert defines_function("numbers_from_password")
13+
assert not_in_code(ast.If)
14+
assert not_in_code(ast.While)
15+
assert not_in_code(ast.For)
16+
17+
@t.passed(has_functions)
18+
def test_four_random_letters(test):
19+
"""functie `four_random_letters` werkt correct"""
20+
assert getFunction("four_random_letters")("A") == "AAAA"
21+
assert getFunction("four_random_letters")("BBB") == "BBBB"
22+
assert len(getFunction("four_random_letters")("A")) == 4
23+
24+
@t.passed(has_functions)
25+
def test_ten_odd_plus_five(test):
26+
"""functie `ten_odd_plus_five` werkt correct"""
27+
assert getFunction("ten_odd_plus_five")(3) == [6, 8, 10]
28+
assert getFunction("ten_odd_plus_five")(1) == [6]
29+
assert getFunction("ten_odd_plus_five")(0) == []
30+
31+
@t.passed(has_functions)
32+
def test_password_numeric_analysis(test):
33+
"""functie `password_numeric_analysis` werkt correct"""
34+
assert getFunction("password_numeric_analysis")('1') == [True]
35+
assert getFunction("password_numeric_analysis")('a') == [False]
36+
assert getFunction("password_numeric_analysis")('1ab4A') == [True, False, False, True, False]
37+
38+
@t.passed(has_functions)
39+
def test_numbers_list_from_password(test):
40+
"""functie `numbers_list_from_password` werkt correct"""
41+
assert getFunction("numbers_list_from_password")('a1m!') == [1]
42+
assert getFunction("numbers_list_from_password")('') == []
43+
assert getFunction("numbers_list_from_password")('a') == []
44+
45+
@t.passed(has_functions)
46+
def test_numbers_from_password(test):
47+
"""functie `numbers_from_password` werkt correct"""
48+
assert getFunction("numbers_from_password")('a1m!') == "1"
49+
assert getFunction("numbers_from_password")('') == ""
50+
assert getFunction("numbers_from_password")('a') == ""

0 commit comments

Comments
 (0)