Archeus 0.0.0
A C library and game engine that focuses on documentation
Loading...
Searching...
No Matches
test.h
Go to the documentation of this file.
1#ifndef ARC_TEST_H_
2#define ARC_TEST_H_
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <stdio.h>
10
13
14void ARC_Test_SetErrnoStream(void) __attribute__ ((constructor));
15void ARC_Test_UnsetErrnoStream(void) __attribute__ ((destructor));
16
17#define ARC_TEST_START_MESSAGE(MESSAGE) void ARC_TEST_START_MESSAGE__ ## MESSAGE(void) __attribute__ ((constructor));\
18 uint32_t arc_test_num_checks_run__ARC_TEST__ ## MESSAGE = 0;\
19 uint32_t arc_test_num_checks_passed__ARC_TEST__ ## MESSAGE = 0;\
20 void ARC_TEST_START_MESSAGE__ ## MESSAGE(void){\
21 printf("[ARC TEST] Running: %s\n", #MESSAGE);\
22 temp_arc_test_num_checks_run__ARC_TEST__ = &arc_test_num_checks_run__ARC_TEST__ ## MESSAGE; \
23 temp_arc_test_num_checks_passed__ARC_TEST__ = &arc_test_num_checks_passed__ARC_TEST__ ## MESSAGE; \
24 }
25
26#define ARC_TEST_END_MESSAGE(MESSAGE) void ARC_TEST_END_MESSAGE__ ## MESSAGE(void) __attribute__ ((destructor));\
27 void ARC_TEST_END_MESSAGE__ ## MESSAGE(void){\
28 printf("[ARC TEST] RUN: %4u, PASSED: %4u, FAILED: %4u, Completed: %s\n", arc_test_num_checks_run__ARC_TEST__ ## MESSAGE, arc_test_num_checks_passed__ARC_TEST__ ## MESSAGE, arc_test_num_checks_run__ARC_TEST__ ## MESSAGE - arc_test_num_checks_passed__ARC_TEST__ ## MESSAGE, #MESSAGE);\
29 }
30
31#define ARC_TEST(MESSAGE) ARC_TEST_START_MESSAGE(MESSAGE) ARC_TEST_END_MESSAGE(MESSAGE) void ARC_TEST__ ## MESSAGE(void) __attribute__ ((constructor)); void ARC_TEST__ ## MESSAGE (void)
32
33#define ARC_CHECK(TEST)\
34 if(temp_arc_test_num_checks_run__ARC_TEST__ == NULL || temp_arc_test_num_checks_passed__ARC_TEST__ == NULL){ return; }\
35 printf(" %4u) ", *temp_arc_test_num_checks_run__ARC_TEST__);\
36 ++*temp_arc_test_num_checks_run__ARC_TEST__;\
37 if(TEST){ printf("PASS\t\n"); ++*temp_arc_test_num_checks_passed__ARC_TEST__; }\
38 else { printf("FAIL\t%s\n", #TEST); }
39
40#ifdef __cplusplus
41}
42#endif
43
44#endif // !ARC_TEST_H_
void ARC_Test_UnsetErrnoStream(void) __attribute__((destructor))
Definition test.c:14
uint32_t * temp_arc_test_num_checks_run__ARC_TEST__
Definition test.c:7
uint32_t * temp_arc_test_num_checks_passed__ARC_TEST__
Definition test.c:8
void ARC_Test_SetErrnoStream(void) __attribute__((constructor))
Definition test.c:10