4 * @brief Interface of tester_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
31 /* must be defined here cause it is used in test_t */
32 typedef struct protected_tester_t protected_tester_t
;
34 typedef struct test_t test_t
;
37 * @brief Representing a specified test.
43 * Testfunction called for this test.
45 * @param tester associated tester_t object
47 void (*test_function
) (protected_tester_t
* tester
);
56 typedef struct tester_t tester_t
;
59 * @brief A class to perform tests.
68 * @brief Test all testcases in array tests with specific tester_t object.
70 * @param tester tester_t object
71 * @param tests pointer to an array of test_t-pointers.
72 * The last item has to be NULL to mark end of array.
74 void (*perform_tests
) (tester_t
*tester
,test_t
**tests
);
77 * @brief Run a specific test case.
79 * @param this tester_t object
80 * @param test pointer to a test_t object which will be performed
82 void (*perform_test
) (tester_t
*tester
, test_t
*test
);
85 * @brief Destroys a tester_t object.
87 * @param tester tester_t object
89 void (*destroy
) (tester_t
*tester
);
94 * @brief A class used in a specific testcase.
96 * For each testcase an object of this type is passed to the testfunction. The testfunction uses this
97 * object to check specific asserts with protected_tester_t.assert_true and protected_tester_t.assert_false.
104 struct protected_tester_t
{
107 * Public functions of a tester_t object
112 * @brief Is called in a testcase to check a specific situation for TRUE.
114 * Log-Values to the tester output are protected from multiple access.
116 * @param this tester_t object
117 * @param to_be_true assert which has to be TRUE
118 * @param assert_name name of the assertion
120 void (*assert_true
) (protected_tester_t
*tester
, bool to_be_true
, char *assert_name
);
123 * @brief Is called in a testcase to check a specific situation for FALSE.
125 * Log-Values to the tester output are protected from multiple access.
127 * @param this tester_t object
128 * @param to_be_false assert which has to be FALSE
129 * @param assert_name name of the assertion
131 void (*assert_false
) (protected_tester_t
*tester
, bool to_be_false
, char *assert_name
);
136 * @brief Creates a tester_t object used to perform tests with.
138 * @param output test output is written to this output.
139 * @param display_succeeded_asserts has to be TRUE, if all asserts should be displayed,
142 * @return tester_t object
146 tester_t
*tester_create(FILE *output
, bool display_succeeded_asserts
);