45 std::exit(m_failures != 0);
61 operator int() const noexcept {
return m_failures; }
68 template<
typename X,
typename Y>
85 operator<<(std::ostream& out, const std::vector<T>&
v)
91 static OIIO::pvt::UnitTestFailureCounter unit_test_failures;
99 #define OIIO_CHECK_ASSERT(x) \
101 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
102 << __FILE__ << ":" << __LINE__ << ":\n" \
104 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
106 (void)++unit_test_failures))
108 #define OIIO_CHECK_EQUAL(x, y) \
111 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
112 << __FILE__ << ":" << __LINE__ << ":\n" \
114 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
115 << " == " << #y << "\n" \
116 << "\tvalues were '" << (x) << "' and '" << (y) \
118 (void)++unit_test_failures))
120 #define OIIO_CHECK_EQUAL_THRESH(x, y, eps) \
121 ((std::abs((x) - (y)) <= eps) \
123 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
124 << __FILE__ << ":" << __LINE__ << ":\n" \
126 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
127 << " == " << #y << "\n" \
128 << "\tvalues were '" << (x) << "' and '" << (y) << "'" \
129 << ", diff was " << std::abs((x) - (y)) << "\n"), \
130 (void)++unit_test_failures))
132 #define OIIO_CHECK_EQUAL_APPROX(x, y) \
133 (OIIO::pvt::equal_approx(x, y) \
135 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
136 << __FILE__ << ":" << __LINE__ << ":\n" \
138 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
139 << " == " << #y << "\n" \
140 << "\tvalues were '" << (x) << "' and '" << (y) << "'" \
141 << ", diff was " << ((x) - (y)) << "\n"), \
142 (void)++unit_test_failures))
144 #define OIIO_CHECK_NE(x, y) \
147 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
148 << __FILE__ << ":" << __LINE__ << ":\n" \
150 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
151 << " != " << #y << "\n" \
152 << "\tvalues were '" << (x) << "' and '" << (y) \
154 (void)++unit_test_failures))
156 #define OIIO_CHECK_LT(x, y) \
159 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
160 << __FILE__ << ":" << __LINE__ << ":\n" \
162 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
163 << " < " << #y << "\n" \
164 << "\tvalues were '" << (x) << "' and '" << (y) \
166 (void)++unit_test_failures))
168 #define OIIO_CHECK_GT(x, y) \
171 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
172 << __FILE__ << ":" << __LINE__ << ":\n" \
174 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
175 << " > " << #y << "\n" \
176 << "\tvalues were '" << (x) << "' and '" << (y) \
178 (void)++unit_test_failures))
180 #define OIIO_CHECK_LE(x, y) \
183 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
184 << __FILE__ << ":" << __LINE__ << ":\n" \
186 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
187 << " <= " << #y << "\n" \
188 << "\tvalues were '" << (x) << "' and '" << (y) \
190 (void)++unit_test_failures))
192 #define OIIO_CHECK_GE(x, y) \
195 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
196 << __FILE__ << ":" << __LINE__ << ":\n" \
198 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
199 << " >= " << #y << "\n" \
200 << "\tvalues were '" << (x) << "' and '" << (y) \
202 (void)++unit_test_failures))
206 #define OIIO_CHECK_SIMD_EQUAL(x, y) \
209 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
210 << __FILE__ << ":" << __LINE__ << ":\n" \
212 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
213 << " == " << #y << "\n" \
214 << "\tvalues were '" << (x) << "' and '" << (y) \
216 (void)++unit_test_failures))
218 #define OIIO_CHECK_SIMD_EQUAL_THRESH(x, y, eps) \
219 (all(abs((x) - (y)) <= (eps)) \
221 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
222 << __FILE__ << ":" << __LINE__ << ":\n" \
224 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
225 << " == " << #y << "\n" \
226 << "\tvalues were '" << (x) << "' and '" << (y) \
228 (void)++unit_test_failures))
239 #define OIIO_CHECK_IMAGEBUF_STATUS(buf, x) \
240 ((x && !buf.has_error()) \
242 : ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
243 << __FILE__ << ":" << __LINE__ << ":\n" \
245 << OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
246 << ": " << buf.geterror() << "\n"), \
247 (void)++unit_test_failures))
vint4 max(const vint4 &a, const vint4 &b)
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
String-related utilities, all in namespace Strutil.
SIM_API const UT_StringHolder all
vint4 abs(const vint4 &a)
std::string ansi(string_view command) const
Platform-independent utilities for various OS, hardware, and system resource functionality, all in namespace Sysutil.
int operator++(int) noexcept
~UnitTestFailureCounter()
const UnitTestFailureCounter & operator++() noexcept
UnitTestFailureCounter() noexcept
float max(float x, float y)
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
#define OIIO_NAMESPACE_END
Classes for SIMD processing.
UnitTestFailureCounter operator+=(int i) noexcept
#define OIIO_NAMESPACE_BEGIN
bool equal_approx(const X &x, const Y &y)