@@ -9,8 +9,17 @@ def has_functions():
99 """alle gevraagde functies zijn aanwezig"""
1010 assert defines_function ("same_first_last" )
1111 assert defines_function ("is_longer" )
12- assert not_in_code (ast .While )
13- assert not_in_code (ast .For )
12+ assert defines_function ("is_palindromish" )
13+ assert defines_function ("is_palindromish_eff" )
14+ assert defines_function ("filter_even" )
15+ assert defines_function ("all_even" )
16+ assert defines_function ("max_element" )
17+ assert defines_function ("element_exists" )
18+ assert defines_function ("count_occurrences" )
19+ assert defines_function ("remove_duplicates" )
20+ assert defines_function ("merge_sorted_lists" )
21+ # assert not_in_code(ast.While)
22+ # assert not_in_code(ast.For)
1423
1524@t .passed (has_functions )
1625def test_same_first_last (test ):
@@ -25,3 +34,163 @@ def test_is_longer(test):
2534 assert getFunction ("is_longer" )([1 , 2 , 3 ], [4 , 5 ]) == True
2635 assert getFunction ("is_longer" )(['abcdef' ], ['ab' , 'cd' , 'ef' ]) == False
2736 assert getFunction ("is_longer" )(['a' , 'b' , 'c' ], [1 , 2 , 3 ]) == False
37+
38+ @t .passed (has_functions )
39+ def test_is_palindromish (test ):
40+ """functie `is_palindromish` werkt correct"""
41+ assert getFunction ("is_palindromish" )([1 , 2 , 1 ]) == True
42+ assert getFunction ("is_palindromish" )([]) == True
43+ assert getFunction ("is_palindromish" )([1 ]) == True
44+ assert getFunction ("is_palindromish" )([0 ,0 ,1 ,0 ,0 ]) == True
45+ assert getFunction ("is_palindromish" )([0 ,0 ,1 ,0 ,1 ]) == False
46+
47+ @t .passed (has_functions )
48+ def test_is_palindromish_eff (test ):
49+ """functie `is_palindromish_eff` werkt correct"""
50+ assert getFunction ("is_palindromish_eff" )([1 , 2 , 1 ]) == True
51+ assert getFunction ("is_palindromish_eff" )([]) == True
52+ assert getFunction ("is_palindromish_eff" )([1 ]) == True
53+ assert getFunction ("is_palindromish_eff" )([0 ,0 ,1 ,0 ,0 ]) == True
54+ assert getFunction ("is_palindromish_eff" )([0 ,0 ,1 ,0 ,1 ]) == False
55+
56+ @t .passed (has_functions )
57+ def test_filter_even (test ):
58+ """functie `filter_even` werkt correct"""
59+ inp = [1 ,2 ,1 ]
60+ assert getFunction ("filter_even" )(inp ) == [2 ]
61+ assert inp == [1 ,2 ,1 ], "input-lijst is aangepast, dat mag niet"
62+
63+ inp = [20 , 10 , 34 ]
64+ assert getFunction ("filter_even" )(inp ) == [20 , 10 , 34 ]
65+ assert inp == [20 , 10 , 34 ], "input-lijst is aangepast, dat mag niet"
66+
67+ inp = [1 ]
68+ assert getFunction ("filter_even" )(inp ) == []
69+ assert inp == [1 ], "input-lijst is aangepast, dat mag niet"
70+
71+ inp = []
72+ assert getFunction ("filter_even" )(inp ) == []
73+ assert inp == [], "input-lijst is aangepast, dat mag niet"
74+
75+ @t .passed (has_functions )
76+ def test_all_even (test ):
77+ """functie `all_even` werkt correct"""
78+ inp = [1 ,2 ,1 ]
79+ assert getFunction ("all_even" )(inp ) == False
80+ assert inp == [1 ,2 ,1 ], "input-lijst is aangepast, dat mag niet"
81+
82+ inp = [20 , 10 , 34 ]
83+ assert getFunction ("all_even" )(inp ) == True
84+ assert inp == [20 , 10 , 34 ], "input-lijst is aangepast, dat mag niet"
85+
86+ inp = [1 ]
87+ assert getFunction ("all_even" )(inp ) == False
88+ assert inp == [1 ], "input-lijst is aangepast, dat mag niet"
89+
90+ inp = []
91+ assert getFunction ("all_even" )(inp ) == True
92+ assert inp == [], "input-lijst is aangepast, dat mag niet"
93+
94+ @t .passed (has_functions )
95+ def test_max_element (test ):
96+ """functie `max_element` werkt correct"""
97+ inp = [1 ,2 ,1 ]
98+ assert getFunction ("max_element" )(inp ) == 2
99+ assert inp == [1 ,2 ,1 ], "input-lijst is aangepast, dat mag niet"
100+
101+ inp = [20 , 10 , 34 ]
102+ assert getFunction ("max_element" )(inp ) == 34
103+ assert inp == [20 , 10 , 34 ], "input-lijst is aangepast, dat mag niet"
104+
105+ inp = [1 ]
106+ assert getFunction ("max_element" )(inp ) == 1
107+ assert inp == [1 ], "input-lijst is aangepast, dat mag niet"
108+
109+ @t .passed (has_functions )
110+ def test_element_exists (test ):
111+ """functie `element_exists` werkt correct"""
112+ inp = [1 ,2 ,1 ]
113+ assert getFunction ("element_exists" )(inp ,3 ) == False
114+ assert inp == [1 ,2 ,1 ], "input-lijst is aangepast, dat mag niet"
115+
116+ inp = [20 , 10 , 34 ]
117+ assert getFunction ("element_exists" )(inp ,10 ) == True
118+ assert inp == [20 , 10 , 34 ], "input-lijst is aangepast, dat mag niet"
119+
120+ inp = [[1 ]]
121+ assert getFunction ("element_exists" )(inp ,[1 ]) == True
122+ assert inp == [[1 ]], "input-lijst is aangepast, dat mag niet"
123+
124+ inp = []
125+ assert getFunction ("element_exists" )(inp ,1000 ) == False
126+ assert inp == [], "input-lijst is aangepast, dat mag niet"
127+
128+ @t .passed (has_functions )
129+ def test_count_occurrences (test ):
130+ """functie `count_occurrences` werkt correct"""
131+ inp = [1 ,2 ,1 ]
132+ assert getFunction ("count_occurrences" )(inp ,1 ) == 2
133+ assert inp == [1 ,2 ,1 ], "input-lijst is aangepast, dat mag niet"
134+
135+ inp = [20 , 10 , 34 ]
136+ assert getFunction ("count_occurrences" )(inp ,10 ) == 1
137+ assert inp == [20 , 10 , 34 ], "input-lijst is aangepast, dat mag niet"
138+
139+ inp = [[1 ]]
140+ assert getFunction ("count_occurrences" )(inp ,[1 ]) == 1
141+ assert inp == [[1 ]], "input-lijst is aangepast, dat mag niet"
142+
143+ inp = []
144+ assert getFunction ("count_occurrences" )(inp ,1000 ) == 0
145+ assert inp == [], "input-lijst is aangepast, dat mag niet"
146+
147+ @t .passed (has_functions )
148+ def test_remove_duplicates (test ):
149+ """functie `remove_duplicates` werkt correct"""
150+ inp = [1 ,2 ,1 ]
151+ assert getFunction ("remove_duplicates" )(inp ) == [1 ,2 ]
152+ assert inp == [1 ,2 ,1 ], "input-lijst is aangepast, dat mag niet"
153+
154+ inp = ['a' , 'a' , 'a' ]
155+ assert getFunction ("remove_duplicates" )(inp ) == ['a' ]
156+ assert inp == ['a' , 'a' , 'a' ], "input-lijst is aangepast, dat mag niet"
157+
158+ inp = [1 ]
159+ assert getFunction ("remove_duplicates" )(inp ) == [1 ]
160+ assert inp == [1 ], "input-lijst is aangepast, dat mag niet"
161+
162+ inp = []
163+ assert getFunction ("remove_duplicates" )(inp ) == []
164+ assert inp == [], "input-lijst is aangepast, dat mag niet"
165+
166+ inp = [True , False , True , False ]
167+ assert getFunction ("remove_duplicates" )(inp ) == [True , False ]
168+ assert inp == [True , False , True , False ], "input-lijst is aangepast, dat mag niet"
169+
170+ @t .passed (has_functions )
171+ def test_merge_sorted_lists (test ):
172+ """functie `merge_sorted_lists` werkt correct"""
173+ inp1 = [1 ,2 ,3 ]
174+ inp2 = [2 ]
175+ assert getFunction ("merge_sorted_lists" )(inp1 , inp2 ) == [1 ,2 ,2 ,3 ]
176+ assert inp1 == [1 ,2 ,3 ] and inp2 == [2 ], "een input-lijst is aangepast, dat mag niet"
177+
178+ inp1 = []
179+ inp2 = [2 ,2 ]
180+ assert getFunction ("merge_sorted_lists" )(inp1 , inp2 ) == [2 ,2 ]
181+ assert inp1 == [] and inp2 == [2 ,2 ], "een input-lijst is aangepast, dat mag niet"
182+
183+ inp2 = []
184+ inp1 = [2 ,2 ]
185+ assert getFunction ("merge_sorted_lists" )(inp1 , inp2 ) == [2 ,2 ]
186+ assert inp2 == [] and inp1 == [2 ,2 ], "een input-lijst is aangepast, dat mag niet"
187+
188+ inp1 = [1 ,2 ,6 ,7 ]
189+ inp2 = [4 ,5 ]
190+ assert getFunction ("merge_sorted_lists" )(inp1 , inp2 ) == [1 ,2 ,4 ,5 ,6 ,7 ]
191+ assert inp1 == [1 ,2 ,6 ,7 ] and inp2 == [4 ,5 ], "een input-lijst is aangepast, dat mag niet"
192+
193+ inp2 = [1 ,2 ,6 ,7 ]
194+ inp1 = [4 ,5 ]
195+ assert getFunction ("merge_sorted_lists" )(inp1 , inp2 ) == [1 ,2 ,4 ,5 ,6 ,7 ]
196+ assert inp2 == [1 ,2 ,6 ,7 ] and inp1 == [4 ,5 ], "een input-lijst is aangepast, dat mag niet"
0 commit comments