diff options
author | Jan Hutter <jhutter@hsr.ch> | 2005-12-07 11:08:54 +0000 |
---|---|---|
committer | Jan Hutter <jhutter@hsr.ch> | 2005-12-07 11:08:54 +0000 |
commit | 51d56047d80383ddaa135d8862d6bee22b619489 (patch) | |
tree | 97736e3e5d52e9d6b50ad0fd228575c780b2309c /Source/charon/utils/tester.h | |
parent | f4d8999cc1f6473d9ceee87b5a30857de0758b6b (diff) | |
download | strongswan-51d56047d80383ddaa135d8862d6bee22b619489.tar.bz2 strongswan-51d56047d80383ddaa135d8862d6bee22b619489.tar.xz |
created protected_tester_t for testcases
Diffstat (limited to 'Source/charon/utils/tester.h')
-rw-r--r-- | Source/charon/utils/tester.h | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/Source/charon/utils/tester.h b/Source/charon/utils/tester.h index 3da6f9fb7..3decb2039 100644 --- a/Source/charon/utils/tester.h +++ b/Source/charon/utils/tester.h @@ -28,10 +28,10 @@ #include <types.h> -typedef struct test_t test_t; - /* must be defined here cause it is used in test_t */ -typedef struct tester_t tester_t; +typedef struct protected_tester_t protected_tester_t; + +typedef struct test_t test_t; /** * @brief Representing a specified test. @@ -44,7 +44,7 @@ struct test_t { * * @param tester associated tester_t object */ - void (*test_function) (tester_t * tester); + void (*test_function) (protected_tester_t * tester); /** * Name of the test. @@ -52,6 +52,9 @@ struct test_t { char * test_name; }; + +typedef struct tester_t tester_t; + /** * @brief A class to perform tests. * @@ -61,7 +64,6 @@ struct test_t { * @ingroup utils */ struct tester_t { - /** * @brief Test all testcases in array tests with specific tester_t object. * @@ -80,39 +82,56 @@ struct tester_t { void (*perform_test) (tester_t *tester, test_t *test); /** - * Is called in a testcase to check a specific situation for TRUE. + * @brief Destroys a tester_t object. * - * Log-Values to the tester output are protected from multiple access. + * @param tester tester_t object + */ + void (*destroy) (tester_t *tester); +}; + + +/** + * @brief A class used in a specific testcase. + * + * For each testcase an object of this type is passed to the testfunction. The testfunction uses this + * object to check specific asserts with protected_tester_t.assert_true and protected_tester_t.assert_false. + * + * @b Constructors: + * - tester_create() + * + * @ingroup utils + */ +struct protected_tester_t { + + /** + * Public functions of a tester_t object + */ + tester_t public; + + /** + * @brief Is called in a testcase to check a specific situation for TRUE. * - * @warning This function should only be called in a test_function. + * Log-Values to the tester output are protected from multiple access. * * @param this tester_t object * @param to_be_true assert which has to be TRUE * @param assert_name name of the assertion */ - void (*assert_true) (tester_t *tester, bool to_be_true, char *assert_name); + void (*assert_true) (protected_tester_t *tester, bool to_be_true, char *assert_name); /** - * Is called in a testcase to check a specific situation for FALSE. + * @brief Is called in a testcase to check a specific situation for FALSE. * * Log-Values to the tester output are protected from multiple access. * - * @warning This function should only be called in a test_function. - * * @param this tester_t object * @param to_be_false assert which has to be FALSE * @param assert_name name of the assertion */ - void (*assert_false) (tester_t *tester, bool to_be_false, char *assert_name); - - /** - * @brief Destroys a tester_t object. - * - * @param tester tester_t object - */ - void (*destroy) (tester_t *tester); + void (*assert_false) (protected_tester_t *tester, bool to_be_false, char *assert_name); }; + /** * @brief Creates a tester_t object used to perform tests with. * |