1#ifndef included_AMP_AMPUnitTest
2#define included_AMP_AMPUnitTest
4#include "AMP/utils/UtilityMacros.h"
120 void report(
const int level = 1,
bool removeDuplicates =
true )
const;
127 inline void passes(
const char *format, ... )
130 va_start( ap, format );
132 int n = vsnprintf( tmp,
sizeof tmp, format, ap );
134 AMP_INSIST( n >= 0,
"Error using stringf: encoding error" );
135 AMP_INSIST( n < (
int)
sizeof tmp,
"Error using stringf: internal buffer size" );
136 passes( std::string( tmp ) );
139 inline void failure(
const char *format, ... )
142 va_start( ap, format );
144 int n = vsnprintf( tmp,
sizeof tmp, format, ap );
146 AMP_INSIST( n >= 0,
"Error using stringf: encoding error" );
147 AMP_INSIST( n < (
int)
sizeof tmp,
"Error using stringf: internal buffer size" );
154 va_start( ap, format );
156 int n = vsnprintf( tmp,
sizeof tmp, format, ap );
158 AMP_INSIST( n >= 0,
"Error using stringf: encoding error" );
159 AMP_INSIST( n < (
int)
sizeof tmp,
"Error using stringf: internal buffer size" );
163 inline void pass_fail(
bool pass,
const char *format, ... )
166 va_start( ap, format );
168 int n = vsnprintf( tmp,
sizeof tmp, format, ap );
170 AMP_INSIST( n >= 0,
"Error using stringf: encoding error" );
171 AMP_INSIST( n < (
int)
sizeof tmp,
"Error using stringf: internal buffer size" );
Class UnitTest is simple utility for running unit tests. It provides basic routines for tracing succe...
size_t NumFailLocal() const
Return the number of failed tests locally.
void passes(const char *format,...)
size_t NumFailGlobal() const
Return the number of failed tests locally.
void pass_fail(bool pass, std::string in)
Indicate a pass/fail test.
void pass_fail(bool pass, const char *format,...)
UnitTest()=default
Default constructor.
std::vector< std::string > d_expected
size_t NumPassGlobal() const
Return the number of passed tests locally.
UnitTest & operator=(const UnitTest &)=delete
const auto & getFail() const
Return the number of failed tests locally.
void failure(std::string in)
Indicate a failed test (thread-safe)
void expected_failure(std::string in)
Indicate an expected failed test (thread-safe)
void failure(const char *format,...)
const auto & getPass() const
Return the tests passed locally.
void report(const int level=1, bool removeDuplicates=true) const
std::vector< std::string > d_pass
void passes(std::string in)
Indicate a passed test (thread-safe)
std::vector< std::string > d_fail
size_t NumExpectedFailGlobal() const
Return the number of expected failed tests locally.
const auto & getExpected() const
Return the number of expected failed tests locally.
void expected_failure(const char *format,...)
void reset()
Clear the messages.
UnitTest(const UnitTest &)=delete
size_t NumPassLocal() const
Return the number of passed tests locally.
size_t NumExpectedFailLocal() const
Return the number of expected failed tests locally.
#define AMP_INSIST(EXP, MSG)
Insist error.