8
8
import pytest
9
9
from geomdl import utilities
10
10
11
+ GEOMDL_DELTA = 10e-8
12
+
11
13
12
14
def test_generate_knot_vector1 ():
13
15
with pytest .raises (ValueError ):
@@ -63,6 +65,13 @@ def test_check_knot_vector4():
63
65
assert check_result
64
66
65
67
68
+ def test_check_knot_vector5 ():
69
+ degree = 4
70
+ num_ctrlpts = 12
71
+ with pytest .raises (TypeError ):
72
+ utilities .check_knot_vector (degree = degree , num_ctrlpts = num_ctrlpts , knot_vector = 5 )
73
+
74
+
66
75
def test_normalize_knot_vector1 ():
67
76
# check for empty list/tuple
68
77
with pytest .raises (ValueError ):
@@ -76,6 +85,11 @@ def test_normalize_knot_vector2():
76
85
assert to_check == output_kv
77
86
78
87
88
+ def test_normalize_knot_vector3 ():
89
+ with pytest .raises (TypeError ):
90
+ utilities .normalize_knot_vector (5 )
91
+
92
+
79
93
def test_check_uv1 ():
80
94
with pytest .raises (ValueError ):
81
95
u = - 0.1
@@ -128,6 +142,11 @@ def test_vector_dot2():
128
142
assert to_check == result
129
143
130
144
145
+ def test_vector_dot3 ():
146
+ with pytest .raises (TypeError ):
147
+ utilities .vector_dot (5 , 9.7 )
148
+
149
+
131
150
def test_vector_cross1 ():
132
151
with pytest .raises (ValueError ):
133
152
vec1 = ()
@@ -150,6 +169,11 @@ def test_vector_cross3():
150
169
assert to_check == result
151
170
152
171
172
+ def test_vector_cross4 ():
173
+ with pytest .raises (TypeError ):
174
+ utilities .vector_cross (5 , 9.7 )
175
+
176
+
153
177
def test_vector_normalize1 ():
154
178
with pytest .raises (ValueError ):
155
179
vec = ()
@@ -162,6 +186,11 @@ def test_vector_normalize2():
162
186
utilities .vector_normalize (vec )
163
187
164
188
189
+ def test_vector_normalize3 ():
190
+ with pytest .raises (TypeError ):
191
+ utilities .vector_normalize (5 )
192
+
193
+
165
194
def test_vector3_normalize ():
166
195
vec = (5 , 2.5 , 5 )
167
196
result = [0.667 , 0.333 , 0.667 ]
@@ -194,7 +223,12 @@ def test_vector_generate2():
194
223
assert to_check_normalized == result_normalized
195
224
196
225
197
- def test_vector_translate1 ():
226
+ def test_vector_generate3 ():
227
+ with pytest .raises (TypeError ):
228
+ utilities .vector_generate (5 , 9.7 )
229
+
230
+
231
+ def test_point_translate1 ():
198
232
with pytest .raises (ValueError ):
199
233
pt1 = ()
200
234
pt2 = (1 , 2 , 3 )
@@ -209,6 +243,11 @@ def test_point_translate2():
209
243
assert to_check == result
210
244
211
245
246
+ def test_point_translate3 ():
247
+ with pytest .raises (TypeError ):
248
+ utilities .point_translate (5 , 9.7 )
249
+
250
+
212
251
def test_binomial_coefficient1 ():
213
252
result = 0.0
214
253
to_check = utilities .binomial_coefficient (13 , 14 )
@@ -227,7 +266,7 @@ def test_binomial_coefficient3():
227
266
assert to_check == result
228
267
229
268
230
- def test_frange ():
269
+ def test_frange1 ():
231
270
start = 5
232
271
stop = 11
233
272
step = 2
@@ -238,6 +277,16 @@ def test_frange():
238
277
assert to_check == result
239
278
240
279
280
+ def test_frange2 ():
281
+ check = list (utilities .frange (0 , 1 , 0.1 ))
282
+ result = [0.0 , 0.1 , 0.2 , 0.3 , 0.4 , 0.5 , 0.6 , 0.7 , 0.8 , 0.9 , 1.0 ]
283
+ check_flag = True
284
+ for c , r in zip (check , result ):
285
+ if abs (c - r ) > GEOMDL_DELTA :
286
+ check_flag = False
287
+ assert check_flag
288
+
289
+
241
290
def test_color_generator ():
242
291
seed = 17 # some number to be used as the random seed
243
292
result = utilities .color_generator (seed )
0 commit comments