Empirical
unit_tests.h
Go to the documentation of this file.
1 
12 #ifndef EMP_UNIT_TESTS_H
13 #define EMP_UNIT_TESTS_H
14 
18 
19 #define EMP_TEST_MACRO( MACRO, EXP_RESULT ) \
20  do { \
21  std::string result = std::string(EMP_STRINGIFY( MACRO )); \
22  bool match = (result == EXP_RESULT); \
23  if (verbose || !match) { \
24  std::cout << #MACRO << " == " << result << std::endl; \
25  } \
26  if (!match) { \
27  std::cout << "MATCH FAILED! Expected: " \
28  << EXP_RESULT << std::endl; \
29  abort(); \
30  } \
31  } while (false)
32 
33 
39 
40 #define EMP_TEST_VALUE( VALUE, EXP_RESULT ) \
41  do { \
42  std::stringstream ss; \
43  auto result = VALUE; \
44  ss << result; \
45  bool match = (ss.str() == EXP_RESULT); \
46  if (verbose || !match) { \
47  std::cout << #VALUE << " == " << result << std::endl; \
48  } \
49  if (!match) { \
50  std::cout << "MATCH FAILED! Expected: " \
51  << EXP_RESULT << std::endl; \
52  abort(); \
53  } \
54  } while (false)
55 
56 
57 #endif