octomap 1.9.8
testing.h
Go to the documentation of this file.
1#include <math.h>
2#include <stdlib.h>
3
4// this is mimicing gtest expressions
5
6#define EXPECT_TRUE(args) { \
7 if (!(args)) { fprintf(stderr, "test failed (EXPECT_TRUE) in %s, line %d\n", __FILE__, __LINE__); \
8 exit(1); \
9 } }
10
11#define EXPECT_FALSE(args) { \
12 if (args) { fprintf(stderr, "test failed (EXPECT_FALSE) in %s, line %d\n", __FILE__, __LINE__); \
13 exit(1); \
14 } }
15
16#define EXPECT_EQ(a,b) { \
17 if (!((a) == (b))) { std::cerr << "test failed: " <<a<<"!="<<b<< " in " \
18 << __FILE__ << ", line " <<__LINE__ << std::endl; \
19 exit(1); \
20 } }
21
22#define EXPECT_FLOAT_EQ(a,b) { \
23 if (!(fabs((a) - (b)) <= 1e-5)) { fprintf(stderr, "test failed: %f != %f in %s, line %d\n", a, b, __FILE__, __LINE__); \
24 exit(1); \
25 } }
26
27#define EXPECT_NEAR(a,b,prec) { \
28 if (!(fabs((a) - (b)) <= prec)) { fprintf(stderr, "test failed: |%f - %f| > %f in %s, line %d\n", a, b, prec, __FILE__, __LINE__); \
29 exit(1); \
30 } }
31