Coverage Report

Created: 2019-07-03 22:50

/home/liu/buildslave/linux-x64-runtests/build/test/ccv_case.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef _GUARD_ccv_case_h_
2
#define _GUARD_ccv_case_h_
3
4
#include <math.h>
5
#include <assert.h>
6
#include <string.h>
7
#include <sys/stat.h>
8
9
50
#define REQUIRE_MATRIX_EQ(a, b, err, ...) { \
10
50
if (ccv_matrix_eq(a, b) != 0) \
11
0
{ \
12
0
  if (isatty(fileno(stdout))) \
13
0
    printf("\n\t\033[0;31mREQUIRE_MATRIX_EQ\033[0;0m: %s:%d: %s != %s, " err, __FILE__, __LINE__, #a, #b, ##__VA_ARGS__); \
14
0
  else \
15
0
    printf("\n\tREQUIRE_MATRIX_EQ: %s:%d: %s != %s, " err, __FILE__, __LINE__, #a, #b, ##__VA_ARGS__); \
16
0
  ABORT_CASE; \
17
0
} }
18
19
25
#define REQUIRE_MATRIX_FILE_EQ(a, f, err, ...) { \
20
25
ccv_dense_matrix_t* __case_b__ = 0; \
21
25
ccv_read(f, &__case_b__, CCV_IO_ANY_FILE); \
22
25
if (ccv_matrix_eq(a, __case_b__) != 0) \
23
0
{ \
24
0
  if (isatty(fileno(stdout))) \
25
0
    printf("\n\t\033[0;31mREQUIRE_MATRIX_FILE_EQ\033[0;0m: %s:%d: %s != %s, " err, __FILE__, __LINE__, #a, #f, ##__VA_ARGS__); \
26
0
  else \
27
0
    printf("\n\tREQUIRE_MATRIX_FILE_EQ: %s:%d: %s != %s, " err, __FILE__, __LINE__, #a, #f, ##__VA_ARGS__); \
28
0
  ccv_matrix_free(__case_b__); \
29
0
  ABORT_CASE; \
30
25
} \
31
25
ccv_matrix_free(__case_b__); }
32
33
10
#define REQUIRE_ARRAY_EQ_WITHIN_ANGLE_AND_MAGNITUDE(type, a, b, len, angle, magnitude, err, ...) { \
34
10
int __case_i__; \
35
10
double __dot_prod__ = 0, __mag_a__ = 0, __mag_b__ = 0; \
36
1.44k
for (__case_i__ = 0; __case_i__ < (len); 
__case_i__++1.43k
) \
37
1.43k
{ \
38
1.43k
  __dot_prod__ += (double)(((type*)(a))[__case_i__] * ((type*)(b))[__case_i__]); \
39
1.43k
  __mag_a__ += (double)(((type*)(a))[__case_i__] * ((type*)(a))[__case_i__]); \
40
1.43k
  __mag_b__ += (double)(((type*)(b))[__case_i__] * ((type*)(b))[__case_i__]); \
41
1.43k
} \
42
10
__mag_a__ = sqrt(__mag_a__), __mag_b__ = sqrt(__mag_b__); \
43
10
if (acos(__dot_prod__ / (__mag_a__ * __mag_b__)) * 180 / 3.141592653 > angle || fabs(__mag_a__ - __mag_b__) / ccv_max(ccv_max(__mag_a__, __mag_b__), 1) > magnitude) \
44
0
{ \
45
0
  if (isatty(fileno(stdout))) \
46
0
    printf("\n\t\033[0;31mREQUIRE_ARRAY_EQ_WITHIN_ANGLE_AND_MAGNITUDE\033[0;0m: %s:%d: angle: %lg | %lg, magnitude: %lg != %lg | +-%lg, " err, __FILE__, __LINE__, (double)(acos(__dot_prod__ / (__mag_a__ * __mag_b__)) * 180 / 3.141592653), (double)angle, __mag_a__, __mag_b__, (double)(magnitude), ##__VA_ARGS__); \
47
0
  else \
48
0
    printf("\n\tREQUIRE_ARRAY_EQ_WITHIN_ANGLE_AND_MAGNITUDE: %s:%d: angle: %lg | %lg, magnitude: %lg != %lg | +-%lg, " err, __FILE__, __LINE__, (double)(acos(__dot_prod__ / (__mag_a__ * __mag_b__)) * 180 / 3.141592653), (double)angle, __mag_a__, __mag_b__, (double)(magnitude), ##__VA_ARGS__); \
49
0
  ABORT_CASE; \
50
0
} }
51
52
#endif