4848extern "C" {
4949#endif
5050
51- // Define the structure to hold parsed options
51+ /**
52+ * @struct fossil_options
53+ * @brief Structure to hold the configuration options for the test environment.
54+ *
55+ * This structure contains various fields to manage the configuration options for
56+ * the test environment, including flags to show version and help information, as
57+ * well as options to reverse the order of tests, repeat tests, and shuffle tests.
58+ *
59+ * @var fossil_options::show_version
60+ * Flag to show version information.
61+ *
62+ * @var fossil_options::show_help
63+ * Flag to show help information.
64+ *
65+ * @var fossil_options::show_info
66+ * Flag to show additional information.
67+ *
68+ * @var fossil_options::reverse
69+ * Flag to reverse the order of tests.
70+ *
71+ * @var fossil_options::repeat_enabled
72+ * Flag to enable repeating tests.
73+ *
74+ * @var fossil_options::repeat_count
75+ * Number of times to repeat tests.
76+ *
77+ * @var fossil_options::shuffle_enabled
78+ * Flag to enable shuffling of tests.
79+ */
5280typedef struct {
5381 bool show_version ;
5482 bool show_help ;
@@ -59,6 +87,13 @@ typedef struct {
5987 bool shuffle_enabled ;
6088} fossil_options_t ;
6189
90+ /**
91+ * @enum test_status
92+ * @brief Enumeration to represent the status of a test.
93+ *
94+ * This enumeration defines the possible status values for a test, including
95+ * pass, fail, skip, empty, and timeout.
96+ */
6297typedef enum {
6398 TEST_STATUS_PASS ,
6499 TEST_STATUS_FAIL ,
@@ -67,37 +102,128 @@ typedef enum {
67102 TEST_STATUS_TTIMEOUT
68103} test_status_t ;
69104
70- // Stack frame structure for tracking function call details during failures
71- typedef struct stack_frame {
72- const char * func ;
73- const char * file ;
74- int line ;
75- struct stack_frame * next ;
76- } stack_frame_t ;
77-
78- // Test case structure
105+ /**
106+ * @struct test_case
107+ * @brief Structure to hold a test case.
108+ *
109+ * This structure contains fields to hold information about a test case, including
110+ * the name, test function, setup function, teardown function, status, failure message,
111+ * execution time, and a pointer to the next test case.
112+ *
113+ * @var test_case::name
114+ * Test case name
115+ *
116+ * @var test_case::test_func
117+ * Pointer to test function
118+ *
119+ * @var test_case::setup_func
120+ * Pointer to setup function (optional)
121+ *
122+ * @var test_case::teardown_func
123+ * Pointer to teardown function (optional)
124+ *
125+ * @var test_case::status
126+ * Test status (pass, fail, skip)
127+ *
128+ * @var test_case::failure_message
129+ * Failure message (if any)
130+ *
131+ * @var test_case::execution_time
132+ * Execution time of the test
133+ *
134+ * @var test_case::next
135+ * Pointer to next test case in the list
136+ */
79137typedef struct test_case {
80- const char * name ; // Test case name
81- void (* test_func )(void ); // Pointer to test function
82- void (* setup_func )(void ); // Pointer to setup function (optional)
83- void (* teardown_func )(void ); // Pointer to teardown function (optional)
84- test_status_t status ; // Test status (pass, fail, skip)
85- const char * failure_message ; // Failure message (if any)
86- stack_frame_t * stack_trace ; // Stack trace for failures
87- double execution_time ; // Execution time of the test
88- struct test_case * next ; // Pointer to next test case in the list
138+ const char * name ;
139+ void (* test_func )(void );
140+ void (* setup_func )(void );
141+ void (* teardown_func )(void );
142+ test_status_t status ;
143+ const char * failure_message ;
144+ double execution_time ;
145+ struct test_case * next ;
89146} test_case_t ;
90147
91- // Test suite structure
148+ /**
149+ * @struct test_suite
150+ * @brief Structure to hold a test suite.
151+ *
152+ * This structure contains fields to hold information about a test suite, including
153+ * the name, suite setup function, suite teardown function, total execution time,
154+ * list of test cases, and a pointer to the next test suite.
155+ *
156+ * @var test_suite::name
157+ * Suite name
158+ *
159+ * @var test_suite::suite_setup_func
160+ * Pointer to suite setup function (optional)
161+ *
162+ * @var test_suite::suite_teardown_func
163+ * Pointer to suite teardown function (optional)
164+ *
165+ * @var test_suite::total_execution_time
166+ * Total execution time of all test cases
167+ *
168+ * @var test_suite::tests
169+ * List of test cases
170+ *
171+ * @var test_suite::next
172+ * Pointer to next suite in the list
173+ */
92174typedef struct test_suite {
93- const char * name ; // Suite name
94- void (* suite_setup_func )(void ); // Suite setup function (optional)
95- void (* suite_teardown_func )(void ); // Suite teardown function (optional)
96- double total_execution_time ; // Total execution time of all test cases
97- test_case_t * tests ; // List of test cases
98- struct test_suite * next ; // Pointer to next suite in the list
175+ const char * name ;
176+ void (* suite_setup_func )(void );
177+ void (* suite_teardown_func )(void );
178+ double total_execution_time ;
179+ test_case_t * tests ;
180+ struct test_suite * next ;
99181} test_suite_t ;
100182
183+ /**
184+ * @struct fossil_test_env
185+ * @brief Structure to hold the environment for fossil tests.
186+ *
187+ * This structure contains various fields to manage and track the state of
188+ * test execution, including options, counts of different test outcomes,
189+ * execution times, and a list of test suites.
190+ *
191+ * @var fossil_test_env::options
192+ * Configuration options for the fossil test environment.
193+ *
194+ * @var fossil_test_env::env
195+ * Environment buffer for handling non-local jumps (e.g., setjmp/longjmp).
196+ *
197+ * @var fossil_test_env::total_tests
198+ * Total number of tests to be executed.
199+ *
200+ * @var fossil_test_env::pass_count
201+ * Count of tests that have passed.
202+ *
203+ * @var fossil_test_env::fail_count
204+ * Count of tests that have failed.
205+ *
206+ * @var fossil_test_env::skip_count
207+ * Count of tests that have been skipped.
208+ *
209+ * @var fossil_test_env::empty_count
210+ * Count of tests that are empty (i.e., no test cases).
211+ *
212+ * @var fossil_test_env::timeout_count
213+ * Count of tests that have timed out.
214+ *
215+ * @var fossil_test_env::unexpected_count
216+ * Count of tests that have encountered unexpected errors.
217+ *
218+ * @var fossil_test_env::start_execution_time
219+ * Timestamp marking the start of test execution.
220+ *
221+ * @var fossil_test_env::end_execution_time
222+ * Timestamp marking the end of test execution.
223+ *
224+ * @var fossil_test_env::test_suites
225+ * Pointer to the list of test suites to be executed.
226+ */
101227typedef struct fossil_test_env {
102228 fossil_options_t options ;
103229 jmp_buf env ;
@@ -180,13 +306,16 @@ void fossil_test_run_case(test_case_t *test_case, fossil_test_env_t *env);
180306void fossil_test_run_suite (test_suite_t * suite , fossil_test_env_t * env );
181307
182308/**
183- * @brief Asserts a condition and prints a message if the assertion fails .
309+ * @brief Internal function to handle assertions with anomaly detection .
184310 *
185- * @param condition The condition to assert.
186- * @param message The message to print if the assertion fails.
187- * @param file The file where the assertion failed.
188- * @param line The line number where the assertion failed.
189- * @param func The function where the assertion failed.
311+ * This function is used internally by the test framework to handle assertions
312+ * and detect duplicate assertions. It is not intended to be called directly.
313+ *
314+ * @param condition The condition to check.
315+ * @param message The message to display if the condition is false.
316+ * @param file The file name where the assertion occurred.
317+ * @param line The line number where the assertion occurred.
318+ * @param func The function name where the assertion occurred.
190319 */
191320void fossil_test_assert_internal (bool condition , const char * message , const char * file , int line , const char * func );
192321
@@ -211,13 +340,6 @@ void fossil_test_summary(fossil_test_env_t *env);
211340 */
212341void fossil_test_run_all (fossil_test_env_t * env );
213342
214- /**
215- * @brief Prints the stack trace.
216- *
217- * @param stack_trace The stack trace to print.
218- */
219- void fossil_test_print_stack_trace (stack_frame_t * stack_trace );
220-
221343// *****************************************************************************
222344// Macro definitions
223345// *****************************************************************************
@@ -262,7 +384,6 @@ void fossil_test_print_stack_trace(stack_frame_t *stack_trace);
262384 nullptr, \
263385 TEST_STATUS_PASS, \
264386 nullptr, \
265- nullptr, \
266387 0.0, \
267388 nullptr \
268389 }; \
@@ -277,7 +398,6 @@ void fossil_test_print_stack_trace(stack_frame_t *stack_trace);
277398 .teardown_func = NULL, \
278399 .status = TEST_STATUS_PASS, \
279400 .failure_message = NULL, \
280- .stack_trace = NULL, \
281401 .execution_time = 0.0, \
282402 .next = NULL \
283403 }; \
0 commit comments