-
-
Notifications
You must be signed in to change notification settings - Fork 210
/
Copy pathtestutils.h
95 lines (86 loc) · 2.58 KB
/
testutils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef TINYSPLINE_TESTUTILS_H
#define TINYSPLINE_TESTUTILS_H
#include <CuTest.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tinyspline.h>
#ifdef __cplusplus
extern "C" {
#endif
#define POINT_EPSILON TS_POINT_EPSILON
#define ANGLE_EPSILON TS_POINT_EPSILON
#define ___SETUP___ tsStatus status;
#define ___GIVEN___ TS_TRY(try, status.code, &status)
#define ___WHEN___
#define ___THEN___
#define ___TEARDOWN___ TS_END_TRY if (status.code) CuFail(tc, status.message);
#define C(call) TS_CALL(try, status.code, (call))
/**
* Asserts that \p s1 and \p s2 have equal shape by evaluating them at
* different knots and comparing the distance of the evaluated points with
* \p eps (i.e., the distance of the evaluated points must be less than or
* equal to \p eps). The given splines may have different dimensions. In this
* case, the distance is computed with the lower dimension.
*
* @param tc
* The active test container.
* @param s1
* First spline.
* @param s2
* Second spline.
* @param eps
* Maximum distance of evaluated points. The type of this argument is
* double so as to simplify the use of this method in unit tests.
*/
void
assert_equal_shape_eps(CuTest *tc,
tsBSpline *s1,
tsBSpline *s2,
double eps);
/**
* Asserts that \p s1 and \p s2 have equal shape by evaluating them at
* different knots and comparing the distance of the evaluated points with
* ::POINT_EPSILON (i.e., the distance of the evaluated points must be less
* than or equal to ::POINT_EPSILON). The given splines may have different
* dimensions. In this case, the distance is computed with the lower dimension.
*
* Implementation detail: This function uses ::assert_equal_shape_eps.
*
* @param tc
* The active test container.
* @param s1
* First spline.
* @param s2
* Second spline.
*/
void
assert_equal_shape(CuTest *tc,
tsBSpline *s1,
tsBSpline *s2);
/**
* Returns the euclidean distance of the points \p x and \p first ... . Fails
* if \p dim is 0 (i.e., a failure is registered in \p tc).
*
* @param tc
* The active test container.
* @param dim
* The dim of \p x and \p first ... .
* @param x
* The x value
* @param first
* The first component of \p first ... .
* @param ...
* The remaining components of \p first ... .
* @return
*/
tsReal
ts_distance_varargs(CuTest *tc,
size_t dim,
const tsReal *x,
double first,
...);
#ifdef __cplusplus
}
#endif
#endif /* TINYSPLINE_TESTUTILS_H */