8 #ifndef TurtleBrains_UnitTest_hpp
9 #define TurtleBrains_UnitTest_hpp
11 #include <turtle_brains/core/tb_configuration.hpp>
12 #include <turtle_brains/core/tb_defines.hpp>
13 #include <turtle_brains/core/tb_string.hpp>
14 #include <turtle_brains/core/tb_noncopyable.hpp>
23 #define tbFailTestIf(test, failMessage, ...) { TurtleBrains::Core::UnitTest::FailTestIf((test) ? true : false, __FILE__, __LINE__, failMessage, ##__VA_ARGS__); }
28 #define tbFailTestIfNot(test, failMessage, ...) { TurtleBrains::Core::UnitTest::FailTestIf((test) ? false : true, __FILE__, __LINE__, failMessage, ##__VA_ARGS__); }
37 void RunAllTests(
const tbCore::tbString& testResultFile =
"test_results.txt");
39 void FailTestIf(
bool testResult,
const char*
const fromFile,
int onLineNumber,
const char*
const failMessage, ...);
41 void Log(
const char*
const failMessage, ...);
42 void Log(
const char*
const fromFile,
int onLineNumber,
const char*
const failMessage, ...);
43 void Log(
const char*
const fromFile,
int onLineNumber,
const char*
const failMessage, va_list argumentList);
51 const std::string& GetTestName(
void)
const {
return mTestName; }
52 const std::string& GetMessageBuffer(
void)
const {
return mMessageBuffer; }
55 bool IsWeakTest(
void)
const {
return mIsWeakTest; }
64 template <
typename Type>
bool ExpectedValue(
const Type& value,
const Type& expectedValue,
const tbCore::tbString formattedMessage, ...)
66 if (value == expectedValue)
71 va_list argumentsList;
72 va_start(argumentsList, formattedMessage);
73 FailedExpectation(formattedMessage, argumentsList);
74 va_end(argumentsList);
79 bool ExpectedValue(
float value,
float expectedValue,
tbCore::tbString formattedMessage, ...);
80 bool ExpectedValueWithin(
float value,
float expectedValue,
float epsilon,
tbCore::tbString formattedMessage, ...);
81 bool ExpectedValue(
double value,
double expectedValue,
tbCore::tbString formattedMessage, ...);
82 bool ExpectedValueWithin(
double value,
double expectedValue,
double epsilon,
tbCore::tbString formattedMessage, ...);
84 bool ExpectedValues(
size_t numberOfValues,
const float* values,
const float* expectedValues,
tbCore::tbString formattedMessage, ...);
85 bool ExpectedValuesWithin(
size_t numberOfValues,
const float* values,
const float* expectedValues,
float epsilon,
tbCore::tbString formattedMessage, ...);
86 bool ExpectedValues(
size_t numberOfValues,
const double* values,
const double* expectedValues,
tbCore::tbString formattedMessage, ...);
87 bool ExpectedValuesWithin(
size_t numberOfValues,
const double* values,
const double* expectedValues,
double epsilon,
tbCore::tbString formattedMessage, ...);
96 virtual bool OnRunTest(
void) = 0;
98 void FailedExpectation(
tbCore::tbString formattedMessage, va_list argumentList);
103 bool mAllExpectationPassed;
void SetWeakTest(void)
Definition: tb_unit_test.hpp:62
Definition: tb_noncopyable.hpp:22
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
Definition: tb_unit_test.hpp:45
void Log(const char *formattedMessage,...)
bool ExpectedException(std::function< void(void)> testCode, const tbCore::tbString formattedMessage,...)
Contains core functionality for each component of the API.
Definition: tb_debug_logger.hpp:88
std::string tbString
Definition: tb_string.hpp:335