IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
test_macros.h
Go to the documentation of this file.
1 /**
2  * \file IMP/test/test_macros.h
3  * \brief Macros for writing C++ tests.
4  *
5  * These should only be used in test code (i.e. C++ binaries in the test/
6  * subdirectory that link against IMP libraries and are run as part of the
7  * test suite). For runtime checks of IMP itself, see IMP_INTERNAL_CHECK
8  * and IMP_USAGE_CHECK.
9  *
10  * Copyright 2007-2018 IMP Inventors. All rights reserved.
11  *
12  */
13 
14 #ifndef IMPTEST_TEST_MACROS_H
15 #define IMPTEST_TEST_MACROS_H
16 #include <IMP/log_macros.h>
17 
18 //! Report an error if a != b
19 #define IMP_TEST_EQUAL(a, b) \
20  if (a != b) { \
21  IMP_ERROR("Test failed: " << #a << " != " << #b << " values are " << a \
22  << " != " << b); \
23  }
24 
25 //! Report an error if !a
26 #define IMP_TEST_TRUE(a) \
27  if (!(a)) { \
28  IMP_ERROR("Test failed: !" << #a); \
29  }
30 
31 //! Report an error if a >= b
32 #define IMP_TEST_LESS_THAN(a, b) \
33  if (a >= b) { \
34  IMP_ERROR("Test failed: " << #a << " >= " << #b << " values are " << a \
35  << " >= " << b); \
36  }
37 
38 //! Report an error if a < b
39 #define IMP_TEST_GREATER_THAN(a, b) \
40  if (a <= b) { \
41  IMP_ERROR("Test failed: " << #a << " <= " << #b << " values are " << a \
42  << " <= " << b); \
43  }
44 
45 #endif /* IMPTEST_TEST_MACROS_H */
Logging and error reporting support.