File containing macros and functions to for main testing. More...
#include <config.h>
#include <QTextStream>
#include <util/random.h>
#include <util/vector.h>
Go to the source code of this file.
Namespaces | |
namespace | test |
Namespace containing test facilities. | |
Defines | |
#define | CHECK(tst) TEST_RESULT &= test::check(tst, __LINE__, #tst) |
#define | CHECK_EQUAL(tst, value) TEST_RESULT &= test::check_equal(tst, value, __LINE__, #tst, #value) |
check if tst is equal to value. | |
#define | CHECK_FLOAT(tst, value, epsilon) TEST_RESULT &= test::check_float(tst, value, epsilon, __LINE__, #tst, #value) |
Check if tst is equal to value with a relative error of epsilon. | |
#define | CHECK_FLOAT_DIFF(tst, value, epsilon) TEST_RESULT &= test::check_float_diff(tst, value, epsilon, __LINE__, #tst, #value) |
Check if tst is different to value with a relative error of epsilon. | |
#define | CHECK_NOTEQUAL(tst, value) TEST_RESULT &= test::check_notequal(tst, value, __LINE__, #tst, #value) |
check if tst is equal to value. | |
#define | CHECK_ZERO(tst, epsilon) TEST_RESULT &= test::check_zero(tst, epsilon, __LINE__, #tst) |
Check if tst is equal to zero with an error of epsilon. | |
#define | FAILED_FUNCTION(line) test::out << "Test line " << line << " " << __PRETTY_FUNCTION__ << "() failed as "; |
#define | FAILED_TEST(line, tst) test::out << "Test line " << line << " " << tst << " failed as "; |
#define | TEST_FCT(tst, failed) |
Launch the function test_tst (replacing tst with the argument), expect it to return a boolean and display a message indicating if the test was successful or not. | |
Functions | |
bool | test::check (bool tst, size_t line_nb, const char *tst_str) |
template<typename T1 , typename T2 > | |
bool | test::check_equal (const T1 &tst, const T2 &value, size_t line_nb, const char *tst_str, const char *value_str) |
template<typename T1 , typename T2 , typename T3 > | |
bool | test::check_float (const T1 &tst, const T2 &value, const T3 &epsilon, size_t line_nb, const char *tst_str, const char *value_str) |
template<typename T1 , typename T2 , typename T3 > | |
bool | test::check_float_diff (const T1 &tst, const T2 &value, const T3 &epsilon, size_t line_nb, const char *tst_str, const char *value_str) |
template<typename T1 , typename T2 > | |
bool | test::check_notequal (const T1 &tst, const T2 &value, size_t line_nb, const char *tst_str, const char *value_str) |
template<typename T1 , typename T2 > | |
bool | test::check_zero (const T1 &tst, const T2 &epsilon, size_t line_nb, const char *tst_str) |
void | test::resetResult () |
template<size_t N, typename T > | |
void | test::shuffle (T array[]) |
File containing macros and functions to for main testing.
Definition in file test.h.
#define CHECK_EQUAL | ( | tst, | |||
value | ) | TEST_RESULT &= test::check_equal(tst, value, __LINE__, #tst, #value) |
#define CHECK_FLOAT | ( | tst, | |||
value, | |||||
epsilon | ) | TEST_RESULT &= test::check_float(tst, value, epsilon, __LINE__, #tst, #value) |
#define CHECK_FLOAT_DIFF | ( | tst, | |||
value, | |||||
epsilon | ) | TEST_RESULT &= test::check_float_diff(tst, value, epsilon, __LINE__, #tst, #value) |
#define CHECK_NOTEQUAL | ( | tst, | |||
value | ) | TEST_RESULT &= test::check_notequal(tst, value, __LINE__, #tst, #value) |
#define CHECK_ZERO | ( | tst, | |||
epsilon | ) | TEST_RESULT &= test::check_zero(tst, epsilon, __LINE__, #tst) |
#define TEST_FCT | ( | tst, | |||
failed | ) |
{ \ bool _11532fd4s85fds_test_failed = !test_##tst(); \ if(_11532fd4s85fds_test_failed) \ { \ failed = true; \ test::out << #tst " test failed" << endl; \ setExitCode(10); \ } \ else \ test::out << #tst " test passed" << endl;\ }
Launch the function test_tst (replacing tst with the argument), expect it to return a boolean and display a message indicating if the test was successful or not.
If the test failed, the boolean variable put as second argument is set to true. the variable is not changed otherwise.