Skip to content

Commit e345518

Browse files
testing this fix
1 parent e972969 commit e345518

File tree

1 file changed

+72
-60
lines changed

1 file changed

+72
-60
lines changed

code/logic/fossil/test/unittest.h

Lines changed: 72 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,83 @@ void fossil_test_print_stack_trace(stack_frame_t *stack_trace);
216216
#define _FOSSIL_TEST_DATA(name) \
217217
typedef struct name
218218

219+
// Macro for defining a test case
220+
#ifdef __cplusplus
221+
#define _FOSSIL_TEST_CASE(test_name) \
222+
extern "C" void test_name##_test_func(void); \
223+
test_case_t test_name##_test_case = { \
224+
.name = #test_name, \
225+
.test_func = test_name##_test_func, \
226+
.setup_func = NULL, \
227+
.teardown_func = NULL, \
228+
.status = TEST_STATUS_PASS, \
229+
.failure_message = NULL, \
230+
.stack_trace = NULL, \
231+
.execution_time = 0.0, \
232+
.next = NULL \
233+
}; \
234+
extern "C" void test_name##_test_func(void)
235+
#else
236+
#define _FOSSIL_TEST_CASE(test_name) \
237+
void test_name##_test_func(void); \
238+
test_case_t test_name##_test_case = { \
239+
.name = #test_name, \
240+
.test_func = test_name##_test_func, \
241+
.setup_func = NULL, \
242+
.teardown_func = NULL, \
243+
.status = TEST_STATUS_PASS, \
244+
.failure_message = NULL, \
245+
.stack_trace = NULL, \
246+
.execution_time = 0.0, \
247+
.next = NULL \
248+
}; \
249+
void test_name##_test_func(void)
250+
#endif
251+
252+
// Macro to create a test suite with setup and teardown hooks
253+
#ifdef __cplusplus
254+
#define _FOSSIL_TEST_SUITE(suite_name) \
255+
extern "C" void suite_name##_setup_func(void); \
256+
extern "C" void suite_name##_teardown_func(void); \
257+
test_suite_t suite_name = { \
258+
.name = #suite_name, \
259+
.suite_setup_func = suite_name##_setup_func, \
260+
.suite_teardown_func = suite_name##_teardown_func, \
261+
.total_execution_time = 0.0, \
262+
.tests = NULL, \
263+
.next = NULL \
264+
}
265+
#else
266+
#define _FOSSIL_TEST_SUITE(suite_name) \
267+
void suite_name##_setup_func(void); \
268+
void suite_name##_teardown_func(void); \
269+
test_suite_t suite_name = { \
270+
.name = #suite_name, \
271+
.suite_setup_func = suite_name##_setup_func, \
272+
.suite_teardown_func = suite_name##_teardown_func, \
273+
.total_execution_time = 0.0, \
274+
.tests = NULL, \
275+
.next = NULL \
276+
}
277+
#endif
278+
279+
#ifdef __cplusplus
280+
// Macro for setting up a test case
281+
#define _FOSSIL_TEST_SETUP(name) \
282+
extern "C" void name##_setup_func(void)
283+
284+
// Macro for tearing down a test case
285+
#define _FOSSIL_TEST_TEARDOWN(name) \
286+
extern "C" void name##_teardown_func(void)
287+
#else
219288
// Macro for setting up a test case
220289
#define _FOSSIL_TEST_SETUP(name) \
221290
void name##_setup_func(void)
222291

223292
// Macro for tearing down a test case
224293
#define _FOSSIL_TEST_TEARDOWN(name) \
225294
void name##_teardown_func(void)
295+
#endif
226296

227297
// Macro to register a suite with the test environment
228298
#define _FOSSIL_TEST_REGISTER(suite) \
@@ -286,67 +356,9 @@ void fossil_test_print_stack_trace(stack_frame_t *stack_trace);
286356
#endif
287357

288358
#ifdef __cplusplus
289-
extern "C" {
290-
// Macro for defining a test case
291-
#define _FOSSIL_TEST_CASE(test_name) \
292-
void test_name##_test_func(void); \
293-
test_case_t test_name##_test_case = { \
294-
.name = #test_name, \
295-
.test_func = test_name##_test_func, \
296-
.setup_func = nullptr, \
297-
.teardown_func = nullptr, \
298-
.status = TEST_STATUS_PASS, \
299-
.failure_message = nullptr, \
300-
.stack_trace = nullptr, \
301-
.execution_time = 0.0, \
302-
.next = nullptr \
303-
}; \
304-
void test_name##_test_func(void)
305-
306-
// Macro to create a test suite with setup and teardown hooks
307-
#define _FOSSIL_TEST_SUITE(suite_name) \
308-
void suite_name##_setup_func(void); \
309-
void suite_name##_teardown_func(void); \
310-
test_suite_t suite_name = { \
311-
.name = #suite_name, \
312-
.suite_setup_func = suite_name##_setup_func, \
313-
.suite_teardown_func = suite_name##_teardown_func, \
314-
.total_execution_time = 0.0, \
315-
.tests = nullptr, \
316-
.next = nullptr \
317-
}
318-
}
319-
#else
320-
321-
// Macro for defining a test case
322-
#define _FOSSIL_TEST_CASE(test_name) \
323-
void test_name##_test_func(void); \
324-
test_case_t test_name##_test_case = { \
325-
.name = #test_name, \
326-
.test_func = test_name##_test_func, \
327-
.setup_func = NULL, \
328-
.teardown_func = NULL, \
329-
.status = TEST_STATUS_PASS, \
330-
.failure_message = NULL, \
331-
.stack_trace = NULL, \
332-
.execution_time = 0.0, \
333-
.next = NULL \
334-
}; \
335-
void test_name##_test_func(void)
336-
337-
// Macro to create a test suite with setup and teardown hooks
338-
#define _FOSSIL_TEST_SUITE(suite_name) \
339-
void suite_name##_setup_func(void); \
340-
void suite_name##_teardown_func(void); \
341-
test_suite_t suite_name = { \
342-
.name = #suite_name, \
343-
.suite_setup_func = suite_name##_setup_func, \
344-
.suite_teardown_func = suite_name##_teardown_func, \
345-
.total_execution_time = 0.0, \
346-
.tests = NULL, \
347-
.next = NULL \
348-
}
359+
namespace fossil {
349360

361+
} // namespace fossil
350362
#endif
351363

352364
#endif

0 commit comments

Comments
 (0)