UTPP
|
Definition of Check... template functions and CHECK_... macro-definitions. More...
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <cmath>
#include <cstring>
Go to the source code of this file.
Macros | |
#define | CHECK(value) |
Generate a failure if value is 0. Failure message is the value itself. | |
#define | CHECK_EX(value, ...) |
Generate a failure with the given message if value is 0. | |
#define | CHECK_EQUAL(expected, actual) |
Generate a failure if actual value is different from expected. | |
#define | CHECK_NAN(value) |
Generate a failure if value is not NaN. | |
#define | CHECK_EQUAL_EX(expected, actual, ...) |
Generate a failure if actual value is different from expected. The given message is appended to the standard CHECK_EQUAL message. | |
#define | CHECK_CLOSE(expected, actual, ...) |
Generate a failure if actual value differs from expected value with more than tolerance. | |
#define | CHECK_CLOSE_EX(expected, actual, tolerance, ...) |
Generate a failure if actual value differs from expected value with more than given tolerance. The given message is appended to the standard CHECK_CLOSE message. | |
#define | CHECK_ARRAY_EQUAL(expected, actual, count) |
Generate a failure if actual array is different from expected one. | |
#define | CHECK_ARRAY_CLOSE(expected, actual, count, ...) |
Generate a failure if actual array elements differs from expected ones with more than given tolerance . | |
#define | CHECK_ARRAY2D_EQUAL(expected, actual, rows, columns) |
Generate a failure if 2D array actual differs from expected values. | |
#define | CHECK_ARRAY2D_CLOSE(expected, actual, rows, columns, ...) |
Generate a failure if 2D array actual differs from expected values with more than given tolerance . | |
#define | CHECK_THROW(expr, except) |
Generate a failure if evaluating the expression does not throw an exception of the expected type. | |
#define | CHECK_THROW_EX(expr, except, ...) |
Generate a failure if evaluating the expression does not throw an exception of the expected type. | |
#define | CHECK_THROW_EQUAL(expression, value, except) |
Checks if evaluating the expression triggers an exception of the given type and with the expected value. | |
#define | CHECK_THROW_EQUAL_EX(expression, value, except, ...) |
Checks if evaluating the expression triggers an exception of the given type and with the expected value. | |
#define | CHECK_FILE_EQUAL(expected, actual) |
Generate a failure if the two files are different. | |
#define | EXPECT_TRUE(x) |
#define | EXPECT_FALSE(x) |
#define | EXPECT_EQ(A, B) |
#define | EXPECT_NE(A, B) |
#define | EXPECT_GE(A, B) |
#define | EXPECT_GT(A, B) |
#define | EXPECT_LE(A, B) |
#define | EXPECT_LT(A, B) |
#define | EXPECT_NEAR(A, B, tol) |
#define | EXPECT_THROW(expr, except) |
#define | ASSERT_TRUE(expr) |
#define | ASSERT_FALSE(expr) |
#define | ASSERT_EQ(e1, e2) |
#define | ASSERT_NE(e1, e2) |
#define | ASSERT_GE(e1, e2) |
#define | ASSERT_GT(e1, e2) |
#define | ASSERT_LE(e1, e2) |
#define | ASSERT_LT(e1, e2) |
Functions | |
template<typename Value> | |
bool | UnitTest::Check (Value const value) |
template<typename Value> | |
bool | UnitTest::CheckNaN (Value const value) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckEqual (const std::vector< expected_T > &expected, const std::vector< actual_T > &actual, std::string &msg) |
template<typename expected_T, typename actual_T, size_t N> | |
bool | UnitTest::CheckEqual (const std::array< expected_T, N > &expected, const std::array< actual_T, N > &actual, std::string &msg) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckEqual (const std::list< expected_T > &expected, const std::list< actual_T > &actual, std::string &msg) |
std::string | UnitTest::to_utf8 (const std::wstring &ws) |
Internal function for conversion from UTF-16 to UTF-8. | |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::isClose (const expected_T &expected, const actual_T &actual, double tolerance) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckClose (const expected_T &expected, const actual_T &actual, double tolerance, std::string &msg) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::Equal1D (const expected_T &expected, const actual_T &actual, size_t count) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckArrayEqual (const expected_T &expected, const actual_T &actual, size_t count, std::string &msg) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::isClose1D (const expected_T &expected, const actual_T &actual, size_t count, double tolerance) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckArrayClose (const expected_T &expected, const actual_T &actual, size_t count, double tolerance, std::string &msg) |
template<> | |
bool | UnitTest::CheckEqual< void, void > (const void *expected, const void *actual, std::string &msg) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckClose (const std::vector< expected_T > &expected, const std::vector< actual_T > &actual, double tolerance, std::string &msg) |
template<typename expected_T, typename actual_T, size_t N> | |
bool | UnitTest::CheckClose (const std::array< expected_T, N > &expected, const std::array< actual_T, N > &actual, double tolerance, std::string &msg) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::Equal2D (const expected_T &expected, const actual_T &actual, size_t rows, size_t columns) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckArray2DEqual (const expected_T &expected, const actual_T &actual, size_t rows, size_t columns, std::string &msg) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::isClose2D (const expected_T &expected, const actual_T &actual, size_t rows, size_t columns, double tolerance) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckArray2DClose (const expected_T &expected, const actual_T &actual, size_t rows, size_t columns, double tolerance, std::string &msg) |
bool | UnitTest::CheckFileEqual (const std::string &ref, const std::string &actual, std::string &message) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckEqual (const expected_T &expected, const actual_T &actual, std::string &msg) |
template<typename expected_T, typename actual_T> | |
bool | UnitTest::CheckEqual (const expected_T *expected, const actual_T *actual, std::string &msg) |
bool | UnitTest::CheckEqual (const std::wstring expected, const std::wstring actual, std::string &msg) |
bool | UnitTest::CheckEqual (const wchar_t *expected, const wchar_t *actual, std::string &msg) |
bool | UnitTest::CheckEqual (wchar_t *expected, wchar_t *actual, std::string &msg) |
bool | UnitTest::CheckEqual (const wchar_t *expected, wchar_t *actual, std::string &msg) |
bool | UnitTest::CheckEqual (wchar_t *expected, const wchar_t *actual, std::string &msg) |
bool | UnitTest::CheckEqual (const char *expected, const char *actual, std::string &msg) |
bool | UnitTest::CheckEqual (char *expected, char *actual, std::string &msg) |
bool | UnitTest::CheckEqual (const char *expected, char *actual, std::string &msg) |
bool | UnitTest::CheckEqual (char *expected, const char *actual, std::string &msg) |
Variables | |
double | UnitTest::default_tolerance |
Default tolerance for CLOSE... macros. | |
Definition of Check... template functions and CHECK_... macro-definitions.
bool UnitTest::Check | ( | Value const | value | ) |
Check if value is true (or not 0)
value | object to check. Must have convertible to bool |
true
if successful bool UnitTest::CheckArray2DClose | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
size_t | rows, | ||
size_t | columns, | ||
double | tolerance, | ||
std::string & | msg ) |
Check if values in two 2D arrays are closer than specified tolerance. If not, generate a failure message.
expected | - array of expected values |
actual | - array of actual values |
rows | - number of rows in each array |
columns | - number of columns in each array |
tolerance | - allowed tolerance |
msg | - generated error message |
true
if all values in the two arrays are within given tolerance bool UnitTest::CheckArray2DEqual | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
size_t | rows, | ||
size_t | columns, | ||
std::string & | msg ) |
Check if two 2D arrays are equal. If not, generate a failure message.
expected | - array of expected values |
actual | - array of actual values |
rows | - number of rows in each array |
columns | - number of columns in each array |
msg | - generated error message |
true
if the two arrays are equal bool UnitTest::CheckArrayClose | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
size_t | count, | ||
double | tolerance, | ||
std::string & | msg ) |
Check if values in two C arrays are closer than specified tolerance. If not, generate a failure message.
expected | - array of expected values |
actual | - array of actual values |
count | - arrays size |
tolerance | - allowed tolerance |
msg | - generated error message |
true
if all actual values are within the tolerance range bool UnitTest::CheckArrayEqual | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
size_t | count, | ||
std::string & | msg ) |
Check if two arrays are equal. If not, generate a failure message.
expected | - Expected value |
actual | - Actual value |
count | - number of elements in each array |
msg | - generated error message |
true
if the two values are equal bool UnitTest::CheckClose | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
double | tolerance, | ||
std::string & | msg ) |
Check if two values are closer than specified tolerance. If not, generate a failure message.
expected | - expected value |
actual | - actual value |
tolerance | - allowed tolerance |
msg | - generated error message |
true
if actual value is within the tolerance range bool UnitTest::CheckClose | ( | const std::array< expected_T, N > & | expected, |
const std::array< actual_T, N > & | actual, | ||
double | tolerance, | ||
std::string & | msg ) |
Check if values in two C++ arrays are closer than specified tolerance. If not, generate a failure message.
expected | - array of expected values |
actual | - array of actual values |
tolerance | - allowed tolerance |
msg | - generated error message |
true
if all actual values are within the tolerance range bool UnitTest::CheckClose | ( | const std::vector< expected_T > & | expected, |
const std::vector< actual_T > & | actual, | ||
double | tolerance, | ||
std::string & | msg ) |
Check if values in two C++ vectors are closer than specified tolerance. If not, generate a failure message.
expected | - vector of expected values |
actual | - vector of actual values |
tolerance | - allowed tolerance |
msg | - generated error message |
true
if all actual values are within the tolerance range
|
inline |
Specializations of CheckEqual function for C strings
|
inline |
Specializations of CheckEqual function for C strings
|
inline |
Specializations of CheckEqual function for C strings
|
inline |
Specializations of CheckEqual function for C strings
bool UnitTest::CheckEqual | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
std::string & | msg ) |
Check if two values are equal. If not, generate a failure message.
expected | - expected value |
actual | - actual value |
msg | - generated error message |
true
if values compare as equal bool UnitTest::CheckEqual | ( | const expected_T * | expected, |
const actual_T * | actual, | ||
std::string & | msg ) |
Check if two values are equal. If not, generate a failure message.
expected | - expected value |
actual | - actual value |
msg | - generated error message |
true
if values compare as equal
|
inline |
CheckEqual for C++ arrays.
The generated error message lists the expected and actual array elements.
expected | - expected_T array |
actual | - actual_T array |
msg | - generated error message |
true
if arrays compare as equal
|
inline |
CheckEqual for C++ lists.
The generated error message shows the expected and actual list elements.
expected | - expected_T list |
actual | - actual_T list |
msg | - generated error message |
true
if lists compare as equal
|
inline |
CheckEqual for C++ vectors.
The generated error message lists the expected and actual vector elements.
expected | - expected_T vector values |
actual | - actual_T vector values |
msg | - generated error message |
true
if vectors compare as equal
|
inline |
CheckEqual function for wide C++ strings.
expected | - expected string value |
actual | - actual string value |
msg | - generated error message |
true
if strings match
|
inline |
CheckEqual function for wide C strings.
expected | - expected string value |
actual | - actual string value |
msg | - generated error message |
true
if strings match
|
inline |
CheckEqual function for wide C++ strings.
expected | - expected string value |
actual | - actual string value |
msg | - generated error message |
true
if strings match
|
inline |
CheckEqual function for wide C++ strings.
expected | - expected string value |
actual | - actual string value |
msg | - generated error message |
true
if strings match
|
inline |
CheckEqual function for wide C++ strings.
expected | - expected string value |
actual | - actual string value |
msg | - generated error message |
true
if strings match
|
inline |
CheckEqual function for const void* pointers.
expected | - expected_T pointer value |
actual | - actual_T pointer value |
msg | - generated error message |
true
if strings match
|
inline |
Function called by CHECK_FILE_EQUAL() macro to compare two files.
ref | Name of reference file |
actual | Name of output file |
message | Generated error message |
true
if files are equalFiles are compared as ASCII files and the error message tries to show where the first difference is.
bool UnitTest::CheckNaN | ( | Value const | value | ) |
Check if value is a NaN
value | object to check. Must be a floating point type |
true
if object is a NaN bool UnitTest::Equal1D | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
size_t | count ) |
Return true if two arrays are equal.
expected | - array of expected values |
actual | - array of actual values |
count | - number of elements in each array |
true
if the two arrays are equal bool UnitTest::Equal2D | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
size_t | rows, | ||
size_t | columns ) |
Return true if two 2D arrays are equal.
expected | - array of expected values |
actual | - array of actual values |
rows | - number of rows in each array |
columns | - number of columns in each array |
true
if the two arrays are equal bool UnitTest::isClose | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
double | tolerance ) |
Check if two values are closer than specified tolerance. If not, generate a failure message.
expected | - expected value |
actual | - actual value |
tolerance | - allowed tolerance |
true
if actual value is within the tolerance rangeIf tolerance
is 0, the function uses UnitTest::default_tolerance value.
If UnitTest::default_tolerance is 0, the function throws an exception causing test to abort.
bool UnitTest::isClose1D | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
size_t | count, | ||
double | tolerance ) |
Return true if values in two arrays are closer than specified tolerance.
expected | - array of expected values |
actual | - array of actual values |
count | - number of elements in each array |
tolerance | - allowed tolerance |
true
if all actual values are within the tolerance rangeCalls isClose() for each element of the array to verify that it is within allowed limits.
bool UnitTest::isClose2D | ( | const expected_T & | expected, |
const actual_T & | actual, | ||
size_t | rows, | ||
size_t | columns, | ||
double | tolerance ) |
Return true if values in two 2D arrays are closer than specified tolerance.
expected | - array of expected values |
actual | - array of actual values |
rows | - number of rows in each array |
columns | - number of columns in each array |
tolerance | - allowed tolerance |
true
if all values in the two arrays are within given tolerance