HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unittest.h File Reference
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <OpenImageIO/simd.h>
#include <OpenImageIO/strutil.h>
#include <OpenImageIO/sysutil.h>
+ Include dependency graph for unittest.h:

Go to the source code of this file.

Classes

class  pvt::UnitTestFailureCounter
 

Namespaces

 simd
 
 pvt
 

Macros

#define OIIO_CHECK_ASSERT(x)
 
#define OIIO_CHECK_EQUAL(x, y)
 
#define OIIO_CHECK_FALSE(x)   OIIO_CHECK_EQUAL(x, false)
 
#define OIIO_CHECK_EQUAL_THRESH(x, y, eps)
 
#define OIIO_CHECK_EQUAL_THRESH_REL(x, y, epsabs, epsrel)
 
#define OIIO_CHECK_EQUAL_APPROX(x, y)
 
#define OIIO_CHECK_NE(x, y)
 
#define OIIO_CHECK_LT(x, y)
 
#define OIIO_CHECK_GT(x, y)
 
#define OIIO_CHECK_LE(x, y)
 
#define OIIO_CHECK_GE(x, y)
 
#define OIIO_CHECK_SIMD_EQUAL(x, y)
 
#define OIIO_CHECK_SIMD_EQUAL_THRESH(x, y, eps)
 
#define OIIO_CHECK_IMAGEBUF_STATUS(buf, x)
 

Functions

float simd::abs (float x)
 
float simd::max (float x, float y)
 
template<typename X , typename Y >
bool pvt::equal_approx (const X &x, const Y &y)
 
template<typename T >
OIIO_NAMESPACE_END std::ostream & operator<< (std::ostream &out, const std::vector< T > &v)
 

Macro Definition Documentation

#define OIIO_CHECK_ASSERT (   x)
Value:
((x) ? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< "\n"), \
(void)++unit_test_failures))
void
Definition: png.h:1083
GLint GLenum GLint x
Definition: glcorearb.h:409

OIIO_CHECK_* macros checks if the conditions is met, and if not, prints an error message indicating the module and line where the error occurred, but does NOT abort. This is helpful for unit tests where we do not want one failure.

Definition at line 101 of file unittest.h.

#define OIIO_CHECK_EQUAL (   x,
  y 
)
Value:
(((x) == (y)) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " == " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) \
<< "'\n"), \
(void)++unit_test_failures))
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409

Definition at line 110 of file unittest.h.

#define OIIO_CHECK_EQUAL_APPROX (   x,
  y 
)
Value:
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " == " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) << "'" \
<< ", diff was " << ((x) - (y)) << "\n"), \
(void)++unit_test_failures))
void
Definition: png.h:1083
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409
bool equal_approx(const X &x, const Y &y)
Definition: unittest.h:72

Definition at line 148 of file unittest.h.

#define OIIO_CHECK_EQUAL_THRESH (   x,
  y,
  eps 
)
Value:
((std::abs((x) - (y)) <= eps) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " == " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) << "'" \
<< ", diff was " << std::abs((x) - (y)) << "\n"), \
(void)++unit_test_failures))
void
Definition: png.h:1083
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
Definition: ImathFun.h:26

Definition at line 124 of file unittest.h.

#define OIIO_CHECK_EQUAL_THRESH_REL (   x,
  y,
  epsabs,
  epsrel 
)
Value:
((std::abs((x) - (y)) <= (epsabs + epsrel * std::max(abs(x), abs(y)))) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " == " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) << "'" \
<< ", diff was " << std::abs((x) - (y)) << "\n"), \
(void)++unit_test_failures))
void
Definition: png.h:1083
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409
float max(float x, float y)
Definition: unittest.h:27
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
Definition: ImathFun.h:26

Definition at line 136 of file unittest.h.

#define OIIO_CHECK_FALSE (   x)    OIIO_CHECK_EQUAL(x, false)

Definition at line 122 of file unittest.h.

#define OIIO_CHECK_GE (   x,
  y 
)
Value:
(((x) >= (y)) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " >= " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) \
<< "'\n"), \
(void)++unit_test_failures))
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409

Definition at line 208 of file unittest.h.

#define OIIO_CHECK_GT (   x,
  y 
)
Value:
(((x) > (y)) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " > " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) \
<< "'\n"), \
(void)++unit_test_failures))
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409

Definition at line 184 of file unittest.h.

#define OIIO_CHECK_IMAGEBUF_STATUS (   buf,
  x 
)
Value:
((x && !buf.has_error()) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< ": " << buf.geterror() << "\n"), \
(void)++unit_test_failures))
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
GLint GLenum GLint x
Definition: glcorearb.h:409

Definition at line 255 of file unittest.h.

#define OIIO_CHECK_LE (   x,
  y 
)
Value:
(((x) <= (y)) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " <= " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) \
<< "'\n"), \
(void)++unit_test_failures))
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409

Definition at line 196 of file unittest.h.

#define OIIO_CHECK_LT (   x,
  y 
)
Value:
(((x) < (y)) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " < " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) \
<< "'\n"), \
(void)++unit_test_failures))
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409

Definition at line 172 of file unittest.h.

#define OIIO_CHECK_NE (   x,
  y 
)
Value:
(((x) != (y)) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " != " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) \
<< "'\n"), \
(void)++unit_test_failures))
GLint y
Definition: glcorearb.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409

Definition at line 160 of file unittest.h.

#define OIIO_CHECK_SIMD_EQUAL (   x,
  y 
)
Value:
(all((x) == (y)) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " == " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) \
<< "'\n"), \
(void)++unit_test_failures))
void
Definition: png.h:1083
GLint y
Definition: glcorearb.h:103
SIM_API const UT_StringHolder all
GLint GLenum GLint x
Definition: glcorearb.h:409

Definition at line 222 of file unittest.h.

#define OIIO_CHECK_SIMD_EQUAL_THRESH (   x,
  y,
  eps 
)
Value:
(all(abs((x) - (y)) <= (eps)) \
? ((void)0) \
: ((std::cout << OIIO::Sysutil::Term(std::cout).ansi("red,bold") \
<< __FILE__ << ":" << __LINE__ << ":\n" \
<< "FAILED: " \
<< OIIO::Sysutil::Term(std::cout).ansi("normal") << #x \
<< " == " << #y << "\n" \
<< "\tvalues were '" << (x) << "' and '" << (y) \
<< "'\n"), \
(void)++unit_test_failures))
void
Definition: png.h:1083
GLint y
Definition: glcorearb.h:103
SIM_API const UT_StringHolder all
GLint GLenum GLint x
Definition: glcorearb.h:409
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
Definition: ImathFun.h:26

Definition at line 234 of file unittest.h.

Function Documentation

template<typename T >
OIIO_NAMESPACE_END std::ostream& operator<< ( std::ostream &  out,
const std::vector< T > &  v 
)
inline

Definition at line 87 of file unittest.h.