31 #ifndef OPENIMAGEIO_UNITTEST_H
32 #define OPENIMAGEIO_UNITTEST_H
37 static int unit_test_failures = 0;
43 #define OIIO_CHECK_ASSERT(x) \
45 : ((std::cout << __FILE__ << ":" << __LINE__ << ":\n" \
46 << "FAILED: " << #x << "\n"), \
47 (void)++unit_test_failures))
49 #define OIIO_CHECK_EQUAL(x,y) \
50 (((x) == (y)) ? ((void)0) \
51 : ((std::cout << __FILE__ << ":" << __LINE__ << ":\n" \
52 << "FAILED: " << #x << " == " << #y << "\n" \
53 << "\tvalues were '" << (x) << "' and '" << (y) << "'\n"), \
54 (void)++unit_test_failures))
56 #define OIIO_CHECK_EQUAL_THRESH(x,y,eps) \
57 ((std::abs((x)-(y)) <= eps) ? ((void)0) \
58 : ((std::cout << __FILE__ << ":" << __LINE__ << ":\n" \
59 << "FAILED: " << #x << " == " << #y << "\n" \
60 << "\tvalues were '" << (x) << "' and '" << (y) << "'" \
61 << ", diff was " << std::abs((x)-(y)) << "\n"), \
62 (void)++unit_test_failures))
64 #define OIIO_CHECK_NE(x,y) \
65 (((x) != (y)) ? ((void)0) \
66 : ((std::cout << __FILE__ << ":" << __LINE__ << ":\n" \
67 << "FAILED: " << #x << " != " << #y << "\n" \
68 << "\tvalues were '" << (x) << "' and '" << (y) << "'\n"), \
69 (void)++unit_test_failures))
71 #define OIIO_CHECK_LT(x,y) \
72 (((x) < (y)) ? ((void)0) \
73 : ((std::cout << __FILE__ << ":" << __LINE__ << ":\n" \
74 << "FAILED: " << #x << " < " << #y << "\n" \
75 << "\tvalues were '" << (x) << "' and '" << (y) << "'\n"), \
76 (void)++unit_test_failures))
78 #define OIIO_CHECK_GT(x,y) \
79 (((x) > (y)) ? ((void)0) \
80 : ((std::cout << __FILE__ << ":" << __LINE__ << ":\n" \
81 << "FAILED: " << #x << " > " << #y << "\n" \
82 << "\tvalues were '" << (x) << "' and '" << (y) << "'\n"), \
83 (void)++unit_test_failures))
85 #define OIIO_CHECK_LE(x,y) \
86 (((x) <= (y)) ? ((void)0) \
87 : ((std::cout << __FILE__ << ":" << __LINE__ << ":\n" \
88 << "FAILED: " << #x << " <= " << #y << "\n" \
89 << "\tvalues were '" << (x) << "' and '" << (y) << "'\n"), \
90 (void)++unit_test_failures))
92 #define OIIO_CHECK_GE(x,y) \
93 (((x) >= (y)) ? ((void)0) \
94 : ((std::cout << __FILE__ << ":" << __LINE__ << ":\n" \
95 << "FAILED: " << #x << " >= " << #y << "\n" \
96 << "\tvalues were '" << (x) << "' and '" << (y) << "'\n"), \
97 (void)++unit_test_failures))