first commit
[synclust.git] / src / tests / helpers.h
1 #ifndef SYNCLUST_HELPERS_H
2 #define SYNCLUST_HELPERS_H
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <string.h>
7 #include <math.h>
8 #include <time.h>
9 #include "sources/utils/boolean.h"
10
11 //auxiliary to check vectors equality
12 int checkEqualV(
13 double* v1,
14 double* v2,
15 int n
16 );
17
18 // auxiliary to count distinct values in an integer array
19 int countDistinctValues(
20 int* v,
21 int n
22 );
23
24 // check if clusters proportions match a given fraction (tolerance 'tol')
25 int checkClustersProportions(
26 int* clusters,
27 int n,
28 int clustCount,
29 double tol
30 );
31
32 // basic unit tests macros
33 #define ASSERT_TRUE(b) \
34 do { \
35 if (!(b)) { \
36 fprintf(stdout, "Error in file %s at line %i\n", __FILE__, __LINE__); \
37 return; \
38 } \
39 } while (0)
40
41 #define ASSERT_FALSE(b) \
42 do { \
43 if (b) { \
44 fprintf(stdout, "Error in file %s at line %i\n", __FILE__, __LINE__); \
45 return; \
46 } \
47 } while (0)
48
49 #endif