20 #if !defined(__MITSUBA_RENDER_TESTCASE_H_)
21 #define __MITSUBA_RENDER_TESTCASE_H_
27 #if defined(MTS_TESTCASE)
31 #define assertEquals(actual, expected) assertEqualsImpl(actual, expected, 0, __FILE__, __LINE__)
32 #define assertEqualsEpsilon(actual, expected, epsilon) assertEqualsImpl(actual, expected, epsilon, __FILE__, __LINE__)
33 #define assertTrue(expr) assertTrueImpl(expr, #expr, __FILE__, __LINE__)
34 #define assertFalse(expr) assertFalseImpl(expr, #expr, __FILE__, __LINE__)
35 #define failAndContinue(msg) failAndContinueImpl(msg, __FILE__, __LINE__)
60 virtual void shutdown();
74 void assertEqualsImpl(
int actual,
int expected,
Float epsilon,
const char *file,
int line);
77 void assertEqualsImpl(
Float actual,
Float expected,
Float epsilon,
const char *file,
int line);
80 void assertEqualsImpl(
const Spectrum &actual,
const Spectrum &expected,
Float epsilon,
const char *file,
int line);
83 void assertEqualsImpl(
const Vector2 &actual,
const Vector2 &expected,
Float epsilon,
const char *file,
int line);
86 void assertEqualsImpl(
const Vector &actual,
const Vector &expected,
Float epsilon,
const char *file,
int line);
89 void assertEqualsImpl(
const Vector4 &actual,
const Vector4 &expected,
Float epsilon,
const char *file,
int line);
92 void assertEqualsImpl(
const Point2 &actual,
const Point2 &expected,
Float epsilon,
const char *file,
int line);
95 void assertEqualsImpl(
const Point &actual,
const Point &expected,
Float epsilon,
const char *file,
int line);
100 for (
int i=0; i<M; ++i)
101 for (
int j=0; j<N; ++j)
102 if (std::abs(expected.
m[i][j]-actual.
m[i][j]) > epsilon)
106 "expected matrix %s, got %s.", expected.
toString().c_str(), actual.
toString().c_str());
110 void assertTrueImpl(
bool condition,
const char *expr,
const char *file,
int line);
113 void assertFalseImpl(
bool condition,
const char *expr,
const char *file,
int line);
116 void failAndContinueImpl(
const std::string &msg,
const char *file,
int line);
126 #define EXECUTE_GUARDED(name) \
128 Log(EInfo, "Executing test \"%s\" ..", #name); \
132 } catch (std::exception &e) {\
133 Log(EInfo, "Testcase failed with error: %s", e.what());\
136 #define MTS_BEGIN_TESTCASE() \
137 MTS_DECLARE_CLASS() \
138 int run(int argc, char **argv) {\
140 Log(EInfo, "Executing testcase \"%s\" ..", getClass()->getName().c_str()); \
141 m_executed = m_succeeded = 0;
143 #define MTS_DECLARE_TEST(name) \
144 EXECUTE_GUARDED(name)
146 #define MTS_END_TESTCASE()\
148 return m_executed - m_succeeded;\
151 #define MTS_EXPORT_TESTCASE(name, descr) \
152 MTS_IMPLEMENT_CLASS(name, false, TestCase) \
154 void MTS_EXPORT *CreateUtility() { \
157 const char MTS_EXPORT *GetDescription() { \
std::string toString() const
Return a string representation.
Definition: matrix.h:426
Logger * getLogger()
Return the thread's logger instance.
void assertEqualsImpl(const Matrix< M, N, Float > &actual, const Matrix< M, N, Float > &expected, Float epsilon, const char *file, int line)
Asserts that the two 4x4 matrices are equal.
Definition: testcase.h:98
Generic fixed-size dense matrix class using a row-major storage format.
Definition: matrix.h:33
int getExecuted() const
Return the number of executed testcases.
Definition: testcase.h:63
int m_succeeded
Definition: testcase.h:121
Abstract utility class – can be used to implement loadable utility plugins that perform various actio...
Definition: util.h:32
static Thread * getThread()
Return the current thread.
void log(ELogLevel level, const Class *theClass, const char *fileName, int lineNumber, const char *fmt,...)
Process a log message.
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
T m[M][N]
Definition: matrix.h:35
Base class of all testcases.
Definition: testcase.h:48
Error message, causes an exception to be thrown.
Definition: formatter.h:33
int getSucceeded() const
Return the number of successfully executed testcases.
Definition: testcase.h:66
Discrete spectral power distribution based on a number of wavelength bins over the 360-830 nm range...
Definition: spectrum.h:663