libcester
cester.h
Go to the documentation of this file.
1 
17 #ifndef LIBOPEN_CESTER_H
18 #define LIBOPEN_CESTER_H
19 
20 /*
21  BEFORE YOU SUGGEST ANY EDIT PLEASE TRY TO
22  UNDERSTAND THIS CODE VERY WELL.
23 */
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
36 #ifdef __STDC_VERSION__
37  #define __CESTER_STDC_VERSION__ __STDC_VERSION__
38 #else
39  #ifdef __cplusplus
40  #if __cplusplus > 199711L
41  #define __CESTER_STDC_VERSION__ __cplusplus
42  #endif
43  #endif
44 #endif
45 #ifndef __CESTER_STDC_VERSION__
46  #define __CESTER_INLINE__
47  #define __CESTER_LONG_LONG__ long
48  #define __CESTER_LONG_LONG_FORMAT__ "%ld"
49  #ifdef __FUNCTION__
50  #define __CESTER_FUNCTION__ __FUNCTION__
51  #else
52  #define __CESTER_FUNCTION__ "<unknown>"
53  #endif
54  #define CESTER_NULL 0L
55  #define inline
56 #else
57  #define __CESTER_INLINE__ inline
58  #define __CESTER_LONG_LONG__ long long
59  #define __CESTER_LONG_LONG_FORMAT__ "%lld"
60  #define __CESTER_FUNCTION__ __func__
61  #define CESTER_NULL NULL
62 #endif
63 
64 #ifdef __cplusplus
65 #if defined(_WIN32) && !defined(CESTER_EXCLUDE_WINDOWS_H)
66  #define __CESTER_CAST_CHAR_ARRAY__ (unsigned)
67 #else
68  #define __CESTER_CAST_CHAR_ARRAY__ (char*)
69 #endif
70 #else
71  #define __CESTER_CAST_CHAR_ARRAY__
72 #endif
73 
74 #if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
75 #define _POSIX_SOURCE
76 #include <unistd.h>
77 #include <sys/wait.h>
78 #include <sys/types.h>
79 #endif
80 
81 #include <stdlib.h>
82 #include <time.h>
83 #include <stdio.h>
84 #include <string.h>
85 #include <sys/types.h>
86 #include <sys/stat.h>
87 #ifndef CESTER_NO_SIGNAL
88 #include <signal.h>
89 #include <setjmp.h>
90 jmp_buf buf;
91 #endif
92 
93 #ifndef __BASE_FILE__
94 #ifdef _MSC_VER
95  #pragma message("__BASE_FILE__ not defined. Define the __BASE_FILE__ directive in Properties -> C/C++ -> Preprocessor -> Preprocessor Definition as __BASE_FILE__=\"%(Filename)%(Extension)\" or register your test cases manually.")
96 #else
97  #pragma message("__BASE_FILE__ not defined. Define __BASE_FILE__ during compilation. -D__BASE_FILE__=\"/the/path/to/yout/testfile.c\" or register your test cases manually.")
98 #endif
99 #endif
100 
102 #define cester_meta_free(x) free(x); x = CESTER_NULL
103 
104 #if defined __has_include
105  #if !__has_include (__BASE_FILE__)
106  #pragma message("__BASE_FILE__ is not in include directory. Add the option '-I.' for your compiler so it can find the file.")
107  #endif
108 #endif
109 
110 #ifdef _WIN32
111 #ifndef CESTER_EXCLUDE_WINDOWS_H
112 #ifndef NOMINMAX
113  #define NOMINMAX
114 #endif
115 #include <windows.h>
116 #endif
117 #include <direct.h>
118 
119 #define mkdir(x,y) _mkdir(x)
120 #ifndef stat
121 #define stat __stat64
122 #endif
123 /*
124 ** Windows
125 ** Support Windows XP
126 ** To avoid error message : procedure entry point ** InitializeConditionVariable could not be located ** in Kernel32.dll
127 */
128 #ifdef _WIN32_WINNT
129 #undef _WIN32_WINNT
130 #endif
131 #define _WIN32_WINNT 0x502
132 #define EXOTICTYPES_WINDLLEXPORT 1
133 /* Linux */
134 #else
135 #define EXOTICTYPES_WINDLLEXPORT 0
136 #endif
137 #ifndef __cplusplus
138  #if EXOTICTYPES_WINDLLEXPORT
139  #define EXOTIC_API __declspec(dllexport)
140  #else
141  #define EXOTIC_API extern
142  #endif
143 #else
144  #define EXOTIC_API
145 #endif
146 
147 #if defined(_WIN32) && !defined(CESTER_EXCLUDE_WINDOWS_H)
148 
149 #define CESTER_RESET_TERMINAL 15
150 #define CESTER_BOLD 15
151 #define CESTER_FOREGROUND_BLACK 8
152 #define CESTER_FOREGROUND_RED 4
153 #define CESTER_FOREGROUND_GREEN 2
154 #define CESTER_FOREGROUND_YELLOW 6
155 #define CESTER_FOREGROUND_BLUE 3
156 #define CESTER_FOREGROUND_MAGENTA 5
157 #define CESTER_FOREGROUND_CYAN 11
158 #define CESTER_FOREGROUND_WHITE 15
159 #define CESTER_FOREGROUND_GRAY 8
160 #define CESTER_BACKGROUND_BLACK 0
161 #define CESTER_BACKGROUND_RED 64
162 #define CESTER_BACKGROUND_GREEN 39
163 #define CESTER_BACKGROUND_YELLOW 96
164 #define CESTER_BACKGROUND_BLUE 48
165 #define CESTER_BACKGROUND_MAGENTA 87
166 #define CESTER_BACKGROUND_CYAN 176
167 #define CESTER_BACKGROUND_GRAY 0
168 #define CESTER_BACKGROUND_WHITE 10
169 #define CESTER_RESET_TERMINAL_ATTR() SetConsoleTextAttribute(cester_hConsole, cester_default_color);
171 #else
172 
173 #define CESTER_RESET_TERMINAL "\x1B[0m"
174 #define CESTER_BOLD "\x1B[1m"
175 #define CESTER_FOREGROUND_BLACK "\x1B[30m"
176 #define CESTER_FOREGROUND_RED "\x1B[31m"
177 #define CESTER_FOREGROUND_GREEN "\x1B[32m"
178 #define CESTER_FOREGROUND_YELLOW "\x1B[33m"
179 #define CESTER_FOREGROUND_BLUE "\x1B[34m"
180 #define CESTER_FOREGROUND_MAGENTA "\x1B[35m"
181 #define CESTER_FOREGROUND_CYAN "\x1B[36m"
182 #define CESTER_FOREGROUND_WHITE "\x1B[37m"
183 #define CESTER_FOREGROUND_GRAY "\x1B[90m"
184 #define CESTER_BACKGROUND_BLACK "\x1B[40m"
185 #define CESTER_BACKGROUND_RED "\x1B[41m"
186 #define CESTER_BACKGROUND_GREEN "\x1B[42m"
187 #define CESTER_BACKGROUND_YELLOW "\x1B[43m"
188 #define CESTER_BACKGROUND_BLUE "\x1B[44m"
189 #define CESTER_BACKGROUND_MAGENTA "\x1B[45m"
190 #define CESTER_BACKGROUND_CYAN "\x1B[46m"
191 #define CESTER_BACKGROUND_GRAY "\x1B[100m"
192 #define CESTER_BACKGROUND_WHITE "\x1B[47m"
193 #define CESTER_RESET_TERMINAL_ATTR() ;
195 #endif
196 
200 #define CESTER_VERSION "0.4"
201 
205 #define CESTER_VERSION_NUM 0.4
206 
210 #define CESTER_LICENSE "MIT License"
211 
215 #define CESTER_AUTHOR "Adewale Azeez and other contributors"
216 
220 #define CESTER_HASH_SIGN #
221 
225 #define CESTER_CONCAT(x, y) x y
226 
239 };
240 
252 #ifndef CESTER_NO_MEM_TEST
254 #endif
257 };
258 
259 typedef enum cester_test_type {
270 } TestType;
271 
272 #ifndef CESTER_NO_STREAM_CAPTURE
273 
282 typedef struct captured_stream {
283  unsigned line_num;
293 
294 #endif
295 
301 typedef struct test_instance {
302  unsigned argc;
303  char **argv;
304  void *arg;
305 } TestInstance;
306 
311 typedef void (*cester_test)(TestInstance*);
312 
317 typedef void (*cester_before_after_each)(TestInstance*, char * const, unsigned);
318 
322 typedef void (*cester_void)(void);
323 
324 typedef struct test_case {
325  unsigned execution_status;
326  unsigned line_num;
328 #ifndef CESTER_NO_TIME
329  double start_tic;
330  double execution_time;
331 #endif
333  char *name;
338 } TestCase;
339 
340 #ifndef CESTER_NO_MEM_TEST
341 
342 typedef struct allocated_memory {
343  unsigned line_num;
346  char* address;
348  const char* file_name;
350 
351 #endif
352 
357 #define CESTER_ARRAY_INITIAL_CAPACITY 30
358 
364 #define CESTER_ARRAY_MAX_CAPACITY ((size_t) - 5)
365 
366 typedef struct cester_array_struct {
367  size_t size;
368  size_t capacity;
369  void** buffer;
370 } CesterArray;
371 
372 
373 #define CESTER_ARRAY_FOREACH(w,x,y,z) for (x = 0; x < w->size; ++x) {\
374  void* y = w->buffer[x];\
375  z\
376  }
377 
383 typedef struct super_test_instance {
384  unsigned no_color;
385  unsigned total_tests_count;
386  unsigned total_tests_ran;
390  unsigned verbose_level;
391  unsigned print_error_only;
392  unsigned print_version;
396  unsigned mem_test_active;
399  unsigned isolate_tests;
401  unsigned todo_tests_count;
402  unsigned format_test_name;
406 #ifndef CESTER_NO_TIME
407  double start_tic;
408 #endif
413 #ifndef CESTER_NO_STREAM_CAPTURE
416 #endif
418 #ifndef CESTER_NO_STREAM_CAPTURE
420 #endif
426 #ifndef CESTER_NO_MEM_TEST
428 #endif
430 
431 /* CesterArray */
432 static __CESTER_INLINE__ unsigned cester_array_init(CesterArray**);
433 static __CESTER_INLINE__ unsigned cester_array_add(CesterArray*, void*);
434 static __CESTER_INLINE__ void* cester_array_remove_at(CesterArray*, size_t);
435 static __CESTER_INLINE__ void cester_array_destroy(CesterArray*);
436 
437 static __CESTER_INLINE__ unsigned cester_run_all_test(unsigned, char **);
438 static __CESTER_INLINE__ void cester_str_value_after_first(char *, char, char**);
439 
440 
442  0, /* no_color */
443  0, /* total_tests_count */
444  0, /* total_tests_ran */
445  0, /* total_failed_tests_count */
446  0, /* total_passed_tests_count */
447  0, /* total_test_errors_count */
448  0, /* verbose_level */
449  1, /* print_error_only */
450  0, /* print_version */
451  0, /* selected_test_cases_size */
452  0, /* selected_test_cases_found */
453  0, /* single_output_only */
454  1, /* mem_test_active */
455  1, /* stream_capture_active */
456  CESTER_RESULT_SUCCESS, /* current_execution_status */
457  1, /* isolate_tests */
458  0, /* skipped_test_count */
459  0, /* todo_tests_count */
460  1, /* format_test_name */
461  0, /* report_success_regardless */
462  0, /* report_failure_regardless */
463  CESTER_TESTS_TERMINATOR, /* current_cester_function_type */
464 #ifndef CESTER_NO_TIME
465  0.0, /* start_tic */
466 #endif
467  (char*)"", /* main_execution_output */
468  (char*)"", /* flattened_cmd_argv */
469 #ifdef __BASE_FILE__
470  (char*)__BASE_FILE__, /* test_file_path */
471 #else
472  (char*)__FILE__, /* test_file_path */
473 #endif
474  CESTER_NULL, /* output_format */
475 #ifndef CESTER_NO_STREAM_CAPTURE
476  (char*)"", /* output_stream_str */
477  (char*)"./build/libcester/captured_streams/", /* captured_streams_tmp_folder */
478 #endif
479  CESTER_NULL, /* test_instance */
480 #ifndef CESTER_NO_STREAM_CAPTURE
481  CESTER_NULL, /* output_stream_address */
482 #endif
483  0, /* output_stream */
484  CESTER_NULL, /* selected_test_cases_names */
485  0, /* current_test_case */
486  0, /* registered_test_cases */
487  0, /* captured_streams */
488 #ifndef CESTER_NO_MEM_TEST
489  0 /* mem_alloc_manager */
490 #endif
491 };
492 
493 #ifdef _MSC_VER
494 #define cester_sprintf(x,y,z,a,b,c) sprintf_s(x, y, z, a, b, c);
495 #define cester_sprintf1(x,y,z,a) cester_sprintf(x,y,z,a,"","")
496 #define cester_sprintf2(x,y,z,a,b) cester_sprintf(x,y,z,a,b,"")
497 #define cester_sprintf3(x,y,z,a,b,c) cester_sprintf(x,y,z,a,b,c)
498 #else
499 #define cester_sprintf(x,y,z,a,b) sprintf(x, z, a, b);
500 #define cester_sprintf1(x,y,z,a) sprintf(x, z, a)
501 #define cester_sprintf2(x,y,z,a,b) sprintf(x, z, a, b)
502 #define cester_sprintf3(x,y,z,a,b,c) sprintf(x, z, a, b, c)
503 #endif
504 
505 
506 /* cester options */
507 
519 #define CESTER_CHANGE_STREAM(x) { cester_ptr_to_str(&(superTestInstance.output_stream_str), x); superTestInstance.output_stream_address = *x; } (superTestInstance.output_stream = x)
520 
527 #define CESTER_NOCOLOR() (superTestInstance.no_color = 1)
528 
535 #define CESTER_PRINT_ERROR_ONLY(x) (superTestInstance.print_error_only = x)
536 
544 #define CESTER_MINIMAL() (superTestInstance.verbose_level = 0)
545 
556 #define CESTER_VERBOSE() (superTestInstance.verbose_level = 10); (superTestInstance.print_error_only = 0)
557 
564 #define CESTER_DEBUG_LEVEL(x) (superTestInstance.verbose_level = x)
565 
569 #define CESTER_VERBOSE_LEVEL(x) (superTestInstance.verbose_level = x)
570 
576 #define CESTER_PRINT_VERSION() (superTestInstance.print_version = 1)
577 
583 #define CESTER_SINGLE_OUPUT_ONLY() (superTestInstance.single_output_only = 1)
584 
593 #define CESTER_NO_ISOLATION() (superTestInstance.isolate_tests = 0)
594 
600 #define CESTER_NO_MEMTEST() (superTestInstance.mem_test_active = 0)
601 
612 #define CESTER_DO_MEMTEST() (superTestInstance.mem_test_active = 1)
613 
619 #define CESTER_NO_STREAMCAPTURE() (superTestInstance.stream_capture_active = 0)
620 
631 #define CESTER_DO_STREAMCAPTURE() (superTestInstance.stream_capture_active = 1)
632 
636 #define CESTER_OUTPUT_TEXT() superTestInstance.output_format = (char*) "text"
637 
641 #define CESTER_OUTPUT_JUNITXML() superTestInstance.output_format = (char*) "junitxml"
642 
646 #define CESTER_OUTPUT_TAP() superTestInstance.output_format = (char*) "tap"
647 
651 #define CESTER_OUTPUT_TAPV13() superTestInstance.output_format = (char*) "tapV13"
652 
659 #define CESTER_FORMAT_TESTNAME() superTestInstance.format_test_name = 1;
660 
665 #define CESTER_DONT_FORMAT_TESTNAME() superTestInstance.format_test_name = 0;
666 
667 /* test counts */
668 
672 #define CESTER_TOTAL_TESTS_COUNT (superTestInstance.total_tests_count)
673 
677 #define CESTER_TOTAL_TESTS_RAN (superTestInstance.total_tests_ran)
678 
682 #define CESTER_TOTAL_FAILED_TESTS_COUNT (superTestInstance.total_failed_tests_count)
683 
694 #define CESTER_TOTAL_TEST_ERRORS_COUNT (superTestInstance.total_test_errors_count)
695 
703 #define CESTER_TOTAL_TESTS_SKIPPED (superTestInstance.skipped_test_count)
704 
708 #define CESTER_TOTAL_PASSED_TESTS_COUNT (superTestInstance.total_passed_tests_count)
709 
717 #define CESTER_TOTAL_TODO_TESTS (superTestInstance.todo_tests_count)
718 
726 #define CESTER_RUN_ALL_TESTS(x,y) cester_run_all_test(x,y)
727 
732 #define CESTER_REPORT_SUCCESS_REGARDLESS() (superTestInstance.report_failure_regardless = 0); (superTestInstance.report_success_regardless = 1)
733 
738 #define CESTER_REPORT_FAILURE_REGARDLESS() (superTestInstance.report_success_regardless = 0); (superTestInstance.report_failure_regardless = 1)
739 
740 #if defined(_WIN32) && !defined(CESTER_EXCLUDE_WINDOWS_H)
742  HANDLE cester_hConsole;
743 #else
745 #endif
746 
747 static void cester_copy_str(char **src_out, char **dest_out, int size)
748 {
749  int index = 0;
750  while (index < size) {
751  (*dest_out)[index] = (*src_out)[index];
752  index++;
753  }
754  (*dest_out)[index] = '\0';
755 }
756 
757 static __CESTER_INLINE__ char *cester_extract_name(char const* const file_path) {
758  unsigned i = 0, j = 0;
759  char *file_name_only_actual;
760  char *file_name_only = (char*) malloc (sizeof (char) * 200);
761  while (file_path[i] != '\0') {
762  if (file_path[i] == '\\' || file_path[i] == '/') {
763  j = 0;
764  } else {
765  file_name_only[j] = file_path[i];
766  j++;
767  }
768  ++i;
769  }
770  file_name_only_actual = (char*) malloc(j+1);
771  cester_copy_str(&file_name_only, &file_name_only_actual, j);
772  cester_meta_free(file_name_only);
773  return file_name_only_actual;
774 }
775 
776 static __CESTER_INLINE__ char *cester_extract_name_only(char const* const file_path) {
777  unsigned i = 0;
778  char *file_name = cester_extract_name(file_path);
779  while (file_name[i] != '\0') {
780  if (file_name[i] == '.') {
781  file_name[i] = '\0';
782  break;
783  }
784  ++i;
785  }
786  return file_name;
787 }
788 
789 static __CESTER_INLINE__ void cester_concat_str(char **out, const char * extra);
790 
791 /* For some wierd reasons sprintf clears old array first
792 before concatenatng in old compiler e.g Turbo C.
793 So we first convert int to str then concat it to str*/
794 
795 static __CESTER_INLINE__ void cester_concat_char(char **out, char extra) {
796  char tmp[5] ;
797  cester_sprintf1(tmp, 5, "%c", extra);
798  cester_concat_str(out, tmp);
799 }
800 
801 static __CESTER_INLINE__ void cester_concat_int(char **out, int extra) {
802  char tmp[30];
803  cester_sprintf1(tmp, 30, "%d", extra);
804  cester_concat_str(out, tmp);
805 }
806 
807 static __CESTER_INLINE__ void cester_concat_sizet(char ** out, size_t extra) {
808  char tmp[30];
810  cester_concat_str(out, tmp);
811 }
812 
813 static __CESTER_INLINE__ void cester_ptr_to_str(char **out, void* extra) {
814  (*out) = (char*) malloc(sizeof(char) * 30 );
815  cester_sprintf1((*out), (30), "%p", extra);
816 }
817 
818 static __CESTER_INLINE__ unsigned cester_str_after_prefix(const char* arg, char* prefix, unsigned prefix_size, char** out) {
819  unsigned i = 0, index = 0;
820  char *value = (char*) malloc(sizeof (char) * 1000);
821 
822  while (1) {
823  if (arg[i] == '\0') {
824  if (i < prefix_size) {
825  cester_meta_free(value);
826  return 0;
827  } else {
828  break;
829  }
830  }
831  if (i < prefix_size && arg[i] != prefix[i]) {
832  cester_meta_free(value);
833  return 0;
834  }
835  if (i >= prefix_size) {
836  value[i-prefix_size] = arg[i];
837  }
838  ++i;
839  }
840  i = i-prefix_size;
841  *out = (char*) malloc(i+1);
842  cester_copy_str(&value, out, i);
843  cester_meta_free(value);
844  return 1;
845 }
846 
847 static __CESTER_INLINE__ char* cester_str_replace(char* str, char old_char, char new_char) {
848  char* tmp = (char*) malloc(strlen(str) + 1);
849  unsigned index = 0;
850  do {
851  if (*str == old_char) {
852  tmp[index] = new_char;
853  } else {
854  tmp[index] = *str;
855  }
856  ++str;
857  index++;
858  } while (*str != '\0');
859  tmp[index] = '\0';
860 
861  return tmp;
862 }
863 
864 static __CESTER_INLINE__ unsigned cester_string_equals(char* arg, char* arg1) {
865  unsigned i = 0;
866  if (arg == CESTER_NULL || arg1 == CESTER_NULL) {
867  return 0;
868  }
869  while (1) {
870  if (arg[i] == '\0' && arg1[i] == '\0') {
871  break;
872  }
873  if (arg[i] != arg1[i]) {
874  return 0;
875  }
876  ++i;
877  }
878  return 1;
879 }
880 
881 static __CESTER_INLINE__ unsigned cester_string_contains(char* arg, char* arg1) {
882  unsigned i = 0, index = 0;
883  if (arg == CESTER_NULL || arg1 == CESTER_NULL) {
884  return 0;
885  }
886  while (1) {
887  if (arg[i] == '\0' || arg1[index] == '\0') {
888  return 0;
889  }
890  if (arg[i] == arg1[index]) {
891  i++;
892  index++;
893  while (arg[i] == arg1[index]) {
894  if (arg[i] == '\0') {
895  break;
896  }
897  i++;
898  index++;
899  }
900  if (arg1[index] == '\0') {
901  return 1;
902  }
903  index = 0;
904  continue;
905  }
906  ++i;
907  }
908  return 1;
909 }
910 
911 #ifndef CESTER_NO_PRINT_INFO
912 static __CESTER_INLINE__ unsigned cester_str_size(char* arg) {
913  unsigned size = 0;
914  while (1) {
915  if (arg[size] == '\0') {
916  break;
917  }
918  ++size;
919  }
920  return size;
921 }
922 #endif
923 
924 static __CESTER_INLINE__ unsigned cester_string_starts_with(char* arg, char* arg1) {
925  unsigned i = 0;
926  while (1) {
927  if (arg[i] == '\0' && arg1[i] == '\0') {
928  break;
929  }
930  if (arg[i] != arg1[i]) {
931  if (arg1[i] == '\0') {
932  break;
933  } else {
934  return 0;
935  }
936  }
937  ++i;
938  }
939  return 1;
940 }
941 
942 static __CESTER_INLINE__ void unpack_selected_extra_args(char *arg, char ***out, unsigned *out_size) {
943  unsigned i = 0;
944  unsigned size = 0, current_index = 0;
945  char* prefix = (char*) "test=";
946  char **arr = (char**) malloc(30 * sizeof(char*));
947 
948  arr[size] = (char*) malloc(sizeof(char) * 1000);
949  while (1) {
950  if (arg[i] == '\0') {
951  ++size;
952  break;
953  }
954  if (i < 5 && arg[i] != prefix[i]) {
955  break;
956  }
957  if (arg[i] == ',') {
958  arr[size][current_index] = '\0';
959  current_index = 0;
960  ++size;
961  arr[size] = (char*) malloc(sizeof(char) * 1000);
962  goto continue_loop;
963  }
964  if (i >= 5) {
965  arr[size][current_index] = arg[i];
966  ++current_index;
967  }
968  continue_loop:
969  ++i;
970  }
971  if (current_index > 0) {
972  arr[size-1][current_index] = '\0';
973  }
974 
975  if (current_index == 0) {
976  cester_meta_free(arr[0]);
977  cester_meta_free(arr);
978  return;
979  }
980 
981  current_index = 0;
982  (*out) = (char**) malloc(size * sizeof(char*));
983  while (current_index < size) {
984  (*out)[current_index] = arr[current_index];
985  current_index++;
986  }
987  cester_meta_free(arr);
988 
989  *out_size = size;
990 }
991 
992 static __CESTER_INLINE__ void cester_str_value_after_first(char *arg, char from, char** out) {
993  unsigned i = 0, index = 0;
994  unsigned found_char = 0;
995  char *value = (char*) malloc(sizeof(char) * 200);
996  while (1) {
997  if (arg[i] == '\0') {
998  break;
999  }
1000  if (arg[i] == from) {
1001  found_char = 1;
1002  goto continue_loop;
1003  }
1004  if (found_char == 1) {
1005  value[index] = arg[i];
1006  ++index;
1007  }
1008  continue_loop:
1009  ++i;
1010  }
1011  (*out) = (char*) malloc(index+1);
1012  cester_copy_str(&value, out, index);
1013  cester_meta_free(value);
1014 }
1015 
1016 static __CESTER_INLINE__ void cester_concat_str(char **out, const char * extra) {
1017 
1018  size_t extra_length;
1019  size_t original_length;
1020  size_t new_length;
1021  char * concatted;
1022 
1023  if (!extra) {
1024  extra_length = 0;
1025  }
1026  else {
1027  extra_length = strlen(extra);
1028  }
1029 
1030  if (*out) {
1031  original_length = strlen(*out);
1032  }
1033  else {
1034  original_length = 0;
1035  }
1036 
1037  new_length = original_length + extra_length;
1038  concatted = (char *)malloc(sizeof(char) * new_length + 1);
1039 
1040  if (original_length > 0) {
1041  strncpy(concatted, *out, original_length);
1042  concatted[original_length] = 0;
1043  }
1044  else {
1045  concatted[0] = 0;
1046  }
1047 
1048  if (extra_length > 0) {
1049  strncpy(concatted + original_length, extra, extra_length);
1050  concatted[original_length + extra_length] = 0;
1051  }
1052 
1053  if (*out && *out[0] != 0) {
1054  cester_meta_free(*out);
1055  }
1056  *out = concatted;
1057 }
1058 
1059 static __CESTER_INLINE__ void cester_concat_ptr(char **out, void *ptr) {
1060  char *extra;
1061  cester_ptr_to_str(&extra, ptr);
1062  cester_concat_str(out, extra);
1063  cester_meta_free(extra);
1064 }
1065 
1066 static __CESTER_INLINE__ unsigned cester_is_validate_output_option(char *format_option) {
1067  return (cester_string_equals(format_option, (char*) "junitxml") ||
1068  cester_string_equals(format_option, (char*) "tap") ||
1069  cester_string_equals(format_option, (char*) "tapV13") ||
1070  cester_string_equals(format_option, (char*) "text"));
1071 }
1072 
1073 #ifdef _WIN32
1074 #define CESTER_SELECTCOLOR(x) (superTestInstance.no_color == 1 ? cester_default_color : x)
1075 #else
1076 #define CESTER_SELECTCOLOR(x) (superTestInstance.no_color == 1 ? "" : x)
1077 #endif
1078 #define CESTER_GET_RESULT_AGGR (superTestInstance.total_failed_tests_count == 0 ? "SUCCESS" : "FAILURE")
1079 #define CESTER_GET_RESULT_AGGR_COLOR (superTestInstance.total_failed_tests_count == 0 ? (CESTER_FOREGROUND_GREEN) : (CESTER_FOREGROUND_RED))
1080 
1081 #if defined(_WIN32) && !defined(CESTER_EXCLUDE_WINDOWS_H)
1082 #define CESTER_DELEGATE_FPRINT(y) fprintf(superTestInstance.output_stream, "%s", y)
1083 #define CESTER_DELEGATE_FPRINT_STR(x,y) SetConsoleTextAttribute(cester_hConsole, CESTER_SELECTCOLOR(x)); fprintf(superTestInstance.output_stream, "%s", y)
1084 #define CESTER_DELEGATE_FPRINT_PTR(x,y) SetConsoleTextAttribute(cester_hConsole, CESTER_SELECTCOLOR(x)); fprintf(superTestInstance.output_stream, "%p", y)
1085 #define CESTER_DELEGATE_FPRINT_INT(x,y) SetConsoleTextAttribute(cester_hConsole, CESTER_SELECTCOLOR(x)); fprintf(superTestInstance.output_stream, "%d", y)
1086 #define CESTER_DELEGATE_FPRINT_UINT(x,y) SetConsoleTextAttribute(cester_hConsole, CESTER_SELECTCOLOR(x)); fprintf(superTestInstance.output_stream, "%u", y)
1087 #ifndef CESTER_NO_TIME
1088 #define CESTER_DELEGATE_FPRINT_DOUBLE(x,y) SetConsoleTextAttribute(cester_hConsole, CESTER_SELECTCOLOR(x)); fprintf(superTestInstance.output_stream, "%f", y)
1089 #define CESTER_DELEGATE_FPRINT_DOUBLE_2(x,y) SetConsoleTextAttribute(cester_hConsole, CESTER_SELECTCOLOR(x)); fprintf(superTestInstance.output_stream, "%.2f", y)
1090 #endif
1091 #else
1092 #define CESTER_DELEGATE_FPRINT(y) fprintf(superTestInstance.output_stream, "%s", y)
1093 #define CESTER_DELEGATE_FPRINT_STR(x,y) fprintf(superTestInstance.output_stream, "%s%s%s", CESTER_SELECTCOLOR(x), y, CESTER_SELECTCOLOR(CESTER_RESET_TERMINAL))
1094 #define CESTER_DELEGATE_FPRINT_PTR(x,y) fprintf(superTestInstance.output_stream, "%s%p%s", CESTER_SELECTCOLOR(x), y, CESTER_SELECTCOLOR(CESTER_RESET_TERMINAL))
1095 #define CESTER_DELEGATE_FPRINT_INT(x,y) fprintf(superTestInstance.output_stream, "%s%d%s", CESTER_SELECTCOLOR(x), y, CESTER_SELECTCOLOR(CESTER_RESET_TERMINAL))
1096 #define CESTER_DELEGATE_FPRINT_UINT(x,y) fprintf(superTestInstance.output_stream, "%s%u%s", CESTER_SELECTCOLOR(x), y, CESTER_SELECTCOLOR(CESTER_RESET_TERMINAL))
1097 #ifndef CESTER_NO_TIME
1098 #define CESTER_DELEGATE_FPRINT_DOUBLE(x,y) fprintf(superTestInstance.output_stream, "%s%f%s", CESTER_SELECTCOLOR(x), y, CESTER_SELECTCOLOR(CESTER_RESET_TERMINAL))
1099 #define CESTER_DELEGATE_FPRINT_DOUBLE_2(x,y) fprintf(superTestInstance.output_stream, "%s%.2f%s", CESTER_SELECTCOLOR(x), y, CESTER_SELECTCOLOR(CESTER_RESET_TERMINAL))
1100 #endif
1101 #endif
1102 
1103 static __CESTER_INLINE__ void cester_print_version(void) {
1109 }
1110 
1111 static __CESTER_INLINE__ void cester_print_help(void) {
1112  char *file_name = cester_extract_name_only(superTestInstance.test_file_path);
1116  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " [--FLAGS] [ARGS...]\n");
1117  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "\nwhere --FLAGS include:\n");
1118  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-verbose-level=[LEVEL] change how much information is printed in the terminal\n");
1119  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-minimal print minimal info into the output stream\n");
1120  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-verbose print as much info as possible into the output stream\n");
1121  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-nocolor do not print info with coloring\n");
1122  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-singleoutput display cester version and exit. Does not report flag error\n");
1123 #ifndef CESTER_NO_MEM_TEST
1124  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-nomemtest disable memory leak detection in the tests\n");
1125 #endif
1126 #ifndef CESTER_NO_STREAM_CAPTURE
1127  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-nostreamcapture disable stream capture and assertions in the tests\n");
1128 #endif
1129 #ifdef __CESTER_STDC_VERSION__
1130  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-noisolation run all the test on a single process. Prevents recovery from crash.\n");
1131 #endif
1132  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-printversion display cester version before running the tests\n");
1133  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-dontformatname leave the test case name as declared in the source file in the output\n");
1134  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-test=Test1,... run only selected tests. Seperate the test cases by comma\n");
1135  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-output=[FORMAT] change the format in which the test results are printed\n");
1136 #ifndef CESTER_NO_PRINT_INFO
1137  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-info=[IOPTIONS],[IOPTIONS...] print out all or specific information about the test executablle\n");
1138 #endif
1139  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-version display cester version and exit\n");
1140  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " --cester-help display this help info version and exit\n");
1141  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "See https://exoticlibraries.github.io/libcester/docs/options.html for more details\n");
1142  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "\nSupported output formats. [FORMAT]:\n");
1147  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "\nSupported info options. [IOPTIONS]:\n");
1161  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "\nVerbose levels. [LEVEL]:\n");
1162  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " 0 - No information alias of --cester-minimal\n");
1164  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " 3 - Meaningful information\n");
1166  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " 10 - Meaningful informations + garbage alias of --cester-verbose\n");
1167  cester_meta_free(file_name);
1168 }
1169 
1170 static void cester_print_test_case_message(char const* const type, char const* const message, char const* const file_path, unsigned const line_num) {
1171  char *cleaned_name = (char *) (superTestInstance.verbose_level >= 4 ? file_path : cester_extract_name(file_path) );
1172  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
1173  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "# ");
1174 
1175  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
1176  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " - ");
1177 
1178  }
1179  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, type);
1180  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " ");
1181  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, cleaned_name);
1182  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ":");
1183  cester_concat_int(&(superTestInstance.current_test_case)->execution_output, line_num);
1184  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ":");
1185  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " in '");
1186  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, (superTestInstance.current_test_case)->name);
1187  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "': ");
1188  if (superTestInstance.verbose_level >= 2) {
1189  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, message);
1190  }
1191  if (superTestInstance.verbose_level < 4) {
1192  cester_meta_free(cleaned_name);
1193  }
1194 }
1195 
1196 static __CESTER_INLINE__ void cester_print_assertion(char const* const expression, char const* const file_path, unsigned const line_num) {
1197  char *cleaned_name = (char *) (superTestInstance.verbose_level >= 4 ? file_path : cester_extract_name(file_path) );
1198  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, cleaned_name);
1199  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ":");
1200  cester_concat_int(&(superTestInstance.current_test_case)->execution_output, line_num);
1201  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ":");
1202  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " in '");
1203  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, (superTestInstance.current_test_case)->name);
1204  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "'");
1205  if (superTestInstance.verbose_level >= 2) {
1206  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " expr => '");
1207  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, expression);
1208  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "'");
1209  }
1210  if (superTestInstance.verbose_level < 4) {
1211  cester_meta_free(cleaned_name);
1212  }
1213 }
1214 
1215 static __CESTER_INLINE__ void cester_print_expect_actual(unsigned expecting, char const* const expect, char const* const received, char const* const file_path, unsigned const line_num) {
1216  char *cleaned_name = (char *) (superTestInstance.verbose_level >= 4 ? file_path : cester_extract_name(file_path) );
1217  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, cleaned_name);
1218  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ":");
1219  cester_concat_int(&(superTestInstance.current_test_case)->execution_output, line_num);
1220  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ":");
1221  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " in '");
1222  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, (superTestInstance.current_test_case)->name);
1223  if (superTestInstance.verbose_level >= 2) {
1224  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "' =>");
1225  if (expecting == 0) {
1226  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " not expecting ");
1227  } else {
1228  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " expected ");
1229  }
1230 
1231  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "'");
1232  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, expect);
1233  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "'");
1234  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ", received ");
1235  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "'");
1236  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, received);
1237  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "'");
1238  }
1239 
1240  /*CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), (superTestInstance.verbose_level >= 4 ? file_path : cester_extract_name(file_path) ));
1241  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), ":");
1242  CESTER_DELEGATE_FPRINT_INT((CESTER_FOREGROUND_YELLOW), line_num);
1243  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), ":");
1244  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " in '");
1245  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), (superTestInstance.current_test_case)->name);
1246  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "' =>");
1247  if (expecting == 0) {
1248  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " not expecting ");
1249  } else {
1250  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), " expected ");
1251  }
1252  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), received);
1253  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), ", received ");
1254  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), expect);*/
1255  if (superTestInstance.verbose_level < 4) {
1256  cester_meta_free(cleaned_name);
1257  }
1258 }
1259 
1260 #ifndef CESTER_NO_TIME
1261 static __CESTER_INLINE__ void print_test_result(double time_spent) {
1262 #else
1263 static __CESTER_INLINE__ void print_test_result(void) {
1264 #endif
1265  unsigned cached_total_failed_tests_count = superTestInstance.total_failed_tests_count;
1268  #ifndef CESTER_NO_TIME
1270  CESTER_DELEGATE_FPRINT_DOUBLE_2((CESTER_FOREGROUND_WHITE), (time_spent > 60 ? (time_spent / 60) : time_spent) );
1271  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), (time_spent > 60 ? " Minutes\n" : " Seconds\n" ));
1272  #else
1274  #endif
1275 
1281  } else if (superTestInstance.report_failure_regardless == 1) {
1283  } else {
1285  }
1286  superTestInstance.total_failed_tests_count = cached_total_failed_tests_count;
1296  }
1297  if (CESTER_TOTAL_TESTS_SKIPPED > 0) {
1300  }
1301  if (CESTER_TOTAL_TODO_TESTS > 0) {
1304  }
1307  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Avoid using the CESTER_REPORT_*_REGARDLESS macros, they hides the actual result of the test\n");
1308  }
1309 }
1310 
1311 static __CESTER_INLINE__ void print_test_case_result(TestCase* test_case) {
1312  char *cleaned_name = (superTestInstance.format_test_name == 1 ? cester_str_replace(test_case->name, '_', ' ') : test_case->name );
1313  #if defined(_WIN32) && !defined(CESTER_EXCLUDE_WINDOWS_H)
1314  unsigned print_color = __CESTER_CAST_CHAR_ARRAY__ CESTER_FOREGROUND_GRAY;
1315  #else
1317  #endif
1321  #ifndef CESTER_NO_TIME
1326  #endif
1330  } else {
1332  #ifdef _WIN32
1334  #else
1335  #ifdef __CESTER_STDC_VERSION__
1337  #else
1339  #endif
1340  #endif
1341  } else {
1342  #ifdef _WIN32
1344  #else
1345  #ifdef __CESTER_STDC_VERSION__
1347  #else
1349  #endif
1350  #endif
1352  }
1353  #ifndef CESTER_NO_TIME
1354  CESTER_DELEGATE_FPRINT_STR((print_color), "(");
1356  CESTER_DELEGATE_FPRINT_STR((print_color), (test_case->execution_time > 60 ? "m" : "s"));
1357  CESTER_DELEGATE_FPRINT_STR((print_color), ") ");
1358  #endif
1359  CESTER_DELEGATE_FPRINT_STR((print_color), cleaned_name);
1360  CESTER_DELEGATE_FPRINT_STR((print_color), "\n");
1361  }
1363  cester_meta_free(cleaned_name);
1364  }
1365 }
1366 
1367 static __CESTER_INLINE__ void print_test_case_outputs(TestCase* test_case) {
1368  char *cleaned_name = (superTestInstance.verbose_level >= 4 ? superTestInstance.test_file_path : cester_extract_name(superTestInstance.test_file_path) );
1372  } else {
1373  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "PrematureTermination ");
1374  }
1380  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "Segmentation fault ");
1381  } else {
1382  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_WHITE), "Premature Termination ");
1383  }
1387 
1388  }
1390  if (superTestInstance.verbose_level < 4) {
1391  cester_meta_free(cleaned_name);
1392  }
1393 }
1394 
1395 static __CESTER_INLINE__ void write_testcase_tap(TestCase *a_test_case, char* file_name, int index) {
1396  char *cleaned_name = (superTestInstance.format_test_name == 1 ? cester_str_replace(a_test_case->name, '_', ' ') : a_test_case->name );
1397  #if defined(_WIN32) && !defined(CESTER_EXCLUDE_WINDOWS_H)
1399  #else
1401  #endif
1402  if (a_test_case->execution_status == CESTER_RESULT_SUCCESS ||
1403  a_test_case->test_type == CESTER_NORMAL_SKIP_TEST ||
1404  a_test_case->test_type == CESTER_NORMAL_TODO_TEST) {
1405 
1406  if (a_test_case->execution_status == CESTER_RESULT_SUCCESS) {
1408  }
1409  CESTER_DELEGATE_FPRINT_STR((print_color), "ok ");
1410 
1411  } else {
1413  CESTER_DELEGATE_FPRINT_STR((print_color), "not ok ");
1414  }
1415  CESTER_DELEGATE_FPRINT_INT((print_color), index);
1416  CESTER_DELEGATE_FPRINT_STR((print_color), " - ");
1417  if (a_test_case->test_type == CESTER_NORMAL_SKIP_TEST) {
1418  CESTER_DELEGATE_FPRINT_STR((print_color), "# SKIP ");
1419 
1420  } else if (a_test_case->test_type == CESTER_NORMAL_TODO_TEST) {
1421  CESTER_DELEGATE_FPRINT_STR((print_color), "# TODO ");
1422 
1423  }
1424  CESTER_DELEGATE_FPRINT_STR((print_color), cleaned_name);
1425  CESTER_DELEGATE_FPRINT_STR((print_color), ", ");
1426  switch (a_test_case->execution_status) {
1427  case CESTER_RESULT_SUCCESS:
1428  CESTER_DELEGATE_FPRINT_STR((print_color), "Passed");
1429  break;
1431  CESTER_DELEGATE_FPRINT_STR((print_color), "Failed: Segmentation fault ");
1432  break;
1434  CESTER_DELEGATE_FPRINT_STR((print_color), "Failed: Premature Termination ");
1435  break;
1437  CESTER_DELEGATE_FPRINT_STR((print_color), "Failed: Unreleased Stream ");
1438  break;
1439 #ifndef CESTER_NO_MEM_TEST
1441  CESTER_DELEGATE_FPRINT_STR((print_color), "Failed: Memory leak");
1442  break;
1443 #endif
1444  default:
1445  if (a_test_case->test_type != CESTER_NORMAL_SKIP_TEST &&
1446  a_test_case->test_type != CESTER_NORMAL_TODO_TEST) {
1447 
1448  CESTER_DELEGATE_FPRINT_STR((print_color), "Failed");
1449  }
1450  break;
1451  }
1452  CESTER_DELEGATE_FPRINT_STR((print_color), "\n");
1453  if (superTestInstance.verbose_level >= 1) {
1455  }
1457  cester_meta_free(cleaned_name);
1458  }
1459 }
1460 
1461 static __CESTER_INLINE__ void write_testcase_tap_v13(TestCase *a_test_case, char* file_name, int index) {
1462  char *cleaned_name = (superTestInstance.format_test_name == 1 ? cester_str_replace(a_test_case->name, '_', ' ') : a_test_case->name );
1463  char *clean_file_path = (superTestInstance.verbose_level >= 4 ? superTestInstance.test_file_path : cester_extract_name(superTestInstance.test_file_path));
1464  #if defined(_WIN32) && !defined(CESTER_EXCLUDE_WINDOWS_H)
1466  #else
1468  #endif
1469  if (a_test_case->execution_status == CESTER_RESULT_SUCCESS ||
1470  a_test_case->test_type == CESTER_NORMAL_SKIP_TEST ||
1471  a_test_case->test_type == CESTER_NORMAL_TODO_TEST) {
1472 
1473  if (a_test_case->execution_status == CESTER_RESULT_SUCCESS) {
1475  }
1476  CESTER_DELEGATE_FPRINT_STR((print_color), "ok ");
1477 
1478  } else {
1480  CESTER_DELEGATE_FPRINT_STR((print_color), "not ok ");
1481  }
1482  CESTER_DELEGATE_FPRINT_INT((print_color), index);
1483  CESTER_DELEGATE_FPRINT_STR((print_color), " - ");
1484  if (a_test_case->test_type == CESTER_NORMAL_SKIP_TEST) {
1485  CESTER_DELEGATE_FPRINT_STR((print_color), "# SKIP ");
1486 
1487  } else if (a_test_case->test_type == CESTER_NORMAL_TODO_TEST) {
1488  CESTER_DELEGATE_FPRINT_STR((print_color), "# TODO ");
1489 
1490  }
1491  CESTER_DELEGATE_FPRINT_STR((print_color), cleaned_name);
1492  CESTER_DELEGATE_FPRINT_STR((print_color), "\n");
1493  if (superTestInstance.verbose_level >= 1 && a_test_case->test_type != CESTER_NORMAL_SKIP_TEST &&
1494  a_test_case->test_type != CESTER_NORMAL_TODO_TEST) {
1497  cester_meta_free(cleaned_name);
1498  }
1499  return;
1500  }
1515  switch (a_test_case->execution_status) {
1516  case CESTER_RESULT_SUCCESS:
1518  break;
1520  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " failed: Segmentation fault ");
1521  break;
1523  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " failed: Premature termination ");
1524  break;
1526  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " failed: Unreleased stream ");
1527  break;
1528 #ifndef CESTER_NO_MEM_TEST
1530  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " failed: Memory leak");
1531  break;
1532 #endif
1533  default:
1534  if (a_test_case->test_type != CESTER_NORMAL_SKIP_TEST &&
1535  a_test_case->test_type != CESTER_NORMAL_TODO_TEST) {
1536 
1538  }
1539  break;
1540  }
1541  #ifndef CESTER_NO_TIME
1544  #endif
1546  }
1548  cester_meta_free(cleaned_name);
1549  }
1550  if (superTestInstance.verbose_level < 4) {
1551  cester_meta_free(clean_file_path);
1552  }
1553 }
1554 
1555 static __CESTER_INLINE__ void write_testcase_junitxml(TestCase *a_test_case, char* file_name) {
1556  char *clean_file_path = (superTestInstance.verbose_level >= 4 ? superTestInstance.test_file_path : cester_extract_name(superTestInstance.test_file_path));
1557 
1566  #ifndef CESTER_NO_TIME
1571  #endif
1573  switch (a_test_case->execution_status) {
1574  case CESTER_RESULT_SUCCESS:
1576  break;
1581  if (a_test_case->execution_status == CESTER_RESULT_SEGFAULT) {
1582  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"the test case crashed\"");
1584  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"SegmentationFault\"");
1587  } else {
1588  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"the test case was terminated\"");
1590  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"PrematureTermination\"");
1592  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), "PrematureTermination ");
1593  }
1598  if (a_test_case->execution_status == CESTER_RESULT_SEGFAULT) {
1599  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), "Segmentation fault ");
1600  } else {
1601  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), "Premature Termination ");
1602  }
1607  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " </failure>\n </testcase>\n");
1608  break;
1612  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"the test case failed to release captured streams\"");
1614  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"StreamCaptureError\"");
1617  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), "\n </failure>\n </testcase>\n");
1618  break;
1619 #ifndef CESTER_NO_MEM_TEST
1623  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"the test case leaks memory\"");
1625  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"MemoryLeakError\"");
1628  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), "\n </failure>\n </testcase>\n");
1629  break;
1630 #endif
1631  default:
1634  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"the test case failed\"");
1639  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " </failure>\n </testcase>\n");
1640  break;
1641  }
1642  if (superTestInstance.verbose_level < 4) {
1643  cester_meta_free(clean_file_path);
1644  }
1645 
1646 }
1647 
1648 #ifndef CESTER_NO_MEM_TEST
1649 static __CESTER_INLINE__ unsigned check_memory_allocated_for_functions(char *funcname1, char *funcname2, char *prefix, char **write_string) {
1650  unsigned mem_index;
1651  unsigned leaked_memory_count = 0;
1652  char *cleaned_name = (superTestInstance.verbose_level >= 4 ? superTestInstance.test_file_path : cester_extract_name(superTestInstance.test_file_path) );
1655  if ((funcname1 != CESTER_NULL && cester_string_equals((char*)((AllocatedMemory*)alloc_mem)->function_name, funcname1)) ||
1656  (funcname2 != CESTER_NULL && cester_string_equals((char*)((AllocatedMemory*)alloc_mem)->function_name, funcname2))) {
1657 
1658  leaked_memory_count += 1;
1659  if (superTestInstance.current_test_case != CESTER_NULL) {
1660  cester_concat_str(write_string, prefix);
1661  cester_concat_str(write_string, "MemoryLeakError ");
1662  cester_concat_str(write_string, cleaned_name);
1663  cester_concat_str(write_string, ":");
1664  cester_concat_int(write_string, ((AllocatedMemory*)alloc_mem)->line_num);
1665  cester_concat_str(write_string, ": ");
1666  cester_concat_str(write_string, "in '");
1667  cester_concat_str(write_string, (char*)((AllocatedMemory*)alloc_mem)->function_name);
1668  if (superTestInstance.verbose_level >= 2) {
1669  cester_concat_str(write_string, "' => Memory allocated in line '");
1670  cester_concat_int(write_string, ((AllocatedMemory*)alloc_mem)->line_num);
1671  cester_concat_str(write_string, "' not freed. Leaking '");
1672  cester_concat_sizet(write_string, ((AllocatedMemory *)alloc_mem)->allocated_bytes);
1673  cester_concat_str(write_string, "' Bytes ");
1674  }
1675  cester_concat_str(write_string, "\n");
1676  }
1677  }
1678  })
1679  }
1680  if (superTestInstance.verbose_level < 4) {
1681  cester_meta_free(cleaned_name);
1682  }
1683  return leaked_memory_count;
1684 }
1685 #endif
1686 
1691 static void cester_cleanup_super_instance(void);
1692 
1693 static __CESTER_INLINE__ int cester_print_result(TestCase cester_test_cases[], TestInstance* test_instance) {
1694  unsigned index_sub, ret_val;
1695  unsigned i, index4, index5, index6, index7;
1696  char *prefix = (char *) "";
1697  char *file_name = cester_extract_name_only(superTestInstance.test_file_path);
1698 
1699  #ifndef CESTER_NO_TIME
1700  clock_t tok;
1701  double time_spent;
1702 
1703  tok = clock();
1704  time_spent = (double)(tok - superTestInstance.start_tic) / CLOCKS_PER_SEC;
1705  #endif
1707  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
1708  if (cester_test_cases[i].test_type == CESTER_AFTER_ALL_TEST && superTestInstance.single_output_only == 0) {
1710  ((cester_test)cester_test_cases[i].test_function)(test_instance);
1711  }
1712  }
1713  }
1715  if (((TestCase*)test_case)->test_type == CESTER_AFTER_ALL_TEST && superTestInstance.single_output_only == 0) {
1716  superTestInstance.current_cester_function_type = CESTER_AFTER_ALL_TEST;
1717  ((cester_test)((TestCase*)test_case)->test_function)(test_instance);
1718  }
1719  })
1720  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1 ||
1721  cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
1722  prefix = (char *) "# ";
1723  }
1724 
1725 #ifndef CESTER_NO_MEM_TEST
1726  ret_val = check_memory_allocated_for_functions((char *)"CESTER_BEFORE_ALL", (char *)"CESTER_OPTIONS", prefix, &superTestInstance.main_execution_output);
1727  if (ret_val > 0) {
1730  }
1731 #endif
1732 
1734  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml") == 1) {
1761  #ifndef CESTER_NO_TIME
1766  #endif
1770  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
1771  if (cester_test_cases[i].test_type == CESTER_NORMAL_TEST && cester_test_cases[i].execution_status != CESTER_RESULT_UNKNOWN) {
1772  write_testcase_junitxml(&cester_test_cases[i], file_name);
1773  }
1774  }
1775  }
1777  if (((TestCase*)test_case)->test_type == CESTER_NORMAL_TEST && ((TestCase*)test_case)->execution_status != CESTER_RESULT_UNKNOWN) {
1778  write_testcase_junitxml(((TestCase*)test_case), file_name);
1779  }
1780  })
1782 
1783  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
1788  index_sub = 1;
1790  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
1791  if ((cester_test_cases[i].test_type == CESTER_NORMAL_TEST || cester_test_cases[i].test_type == CESTER_NORMAL_TODO_TEST ||
1792  cester_test_cases[i].test_type == CESTER_NORMAL_SKIP_TEST)) {
1793 
1794  if (superTestInstance.selected_test_cases_size > 0 && cester_test_cases[i].execution_status == CESTER_RESULT_UNKNOWN) {
1795  continue;
1796  }
1797  write_testcase_tap(&cester_test_cases[i], file_name, index_sub);
1798  ++index_sub;
1799  }
1800  }
1801  }
1803  if (((TestCase*)test_case)->test_type == CESTER_NORMAL_TEST || ((TestCase*)test_case)->test_type == CESTER_NORMAL_TODO_TEST ||
1804  ((TestCase*)test_case)->test_type == CESTER_NORMAL_SKIP_TEST) {
1805 
1806  if (superTestInstance.selected_test_cases_size > 0 && ((TestCase*)test_case)->execution_status == CESTER_RESULT_UNKNOWN) {
1807  continue;
1808  }
1809  write_testcase_tap(((TestCase*)test_case), file_name, index_sub);
1810  ++index_sub;
1811  }
1812  })
1814  if (superTestInstance.verbose_level >= 1) {
1818  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " total error(s) occured\n");
1819  }
1820  if (CESTER_TOTAL_TODO_TESTS > 0) {
1823  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " todo test case(s) skipped\n");
1824  }
1825  if (CESTER_TOTAL_TESTS_SKIPPED > 0) {
1828  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " test case(s) skipped\n");
1829  }
1834  #ifndef CESTER_NO_TIME
1835  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " tests\n# Time ");
1836  CESTER_DELEGATE_FPRINT_DOUBLE_2((CESTER_FOREGROUND_GRAY), (time_spent > 60 ? (time_spent / 60) : time_spent));
1837  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), (time_spent > 60 ? " Minutes\n" : " Seconds\n" ));
1838  #else
1840  #endif
1841  }
1842 
1843  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
1850  index_sub = 1;
1852  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
1853  if ((cester_test_cases[i].test_type == CESTER_NORMAL_TEST || cester_test_cases[i].test_type == CESTER_NORMAL_TODO_TEST ||
1854  cester_test_cases[i].test_type == CESTER_NORMAL_SKIP_TEST)) {
1855 
1856  if (superTestInstance.selected_test_cases_size > 0 && cester_test_cases[i].execution_status == CESTER_RESULT_UNKNOWN) {
1857  continue;
1858  }
1859  write_testcase_tap_v13(&cester_test_cases[i], file_name, index_sub);
1860  ++index_sub;
1861  }
1862  }
1863  }
1865  if (((TestCase*)test_case)->test_type == CESTER_NORMAL_TEST || ((TestCase*)test_case)->test_type == CESTER_NORMAL_TODO_TEST ||
1866  ((TestCase*)test_case)->test_type == CESTER_NORMAL_SKIP_TEST) {
1867 
1868  if (superTestInstance.selected_test_cases_size > 0 && ((TestCase*)test_case)->execution_status == CESTER_RESULT_UNKNOWN) {
1869  continue;
1870  }
1871  write_testcase_tap_v13(((TestCase*)test_case), file_name, index_sub);
1872  ++index_sub;
1873  }
1874  })
1876  if (superTestInstance.verbose_level >= 1) {
1880  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " total error(s) occured\n");
1881  }
1882  if (CESTER_TOTAL_TODO_TESTS > 0) {
1885  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " todo test case(s) skipped\n");
1886  }
1887  if (CESTER_TOTAL_TESTS_SKIPPED > 0) {
1890  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " test case(s) skipped\n");
1891  }
1896  #ifndef CESTER_NO_TIME
1897  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), " tests\n# Time ");
1898  CESTER_DELEGATE_FPRINT_DOUBLE_2((CESTER_FOREGROUND_GRAY), (time_spent > 60 ? (time_spent / 60) : time_spent));
1899  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_GRAY), (time_spent > 60 ? " Minutes\n" : " Seconds\n" ));
1900  #else
1902  #endif
1903  }
1904 
1905  } else {
1908  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
1909  if (superTestInstance.selected_test_cases_size > 0 && cester_test_cases[i].execution_status != CESTER_RESULT_UNKNOWN) {
1910  print_test_case_result(&cester_test_cases[i]);
1911 
1912  } else if (((cester_test_cases[i].test_type == CESTER_NORMAL_TEST && cester_test_cases[i].execution_status != CESTER_RESULT_UNKNOWN) ||
1913  (cester_test_cases[i].test_type == CESTER_NORMAL_TODO_TEST || cester_test_cases[i].test_type == CESTER_NORMAL_SKIP_TEST)) &&
1915 
1916  print_test_case_result(&cester_test_cases[i]);
1917  }
1918  }
1919  }
1920  CESTER_ARRAY_FOREACH(superTestInstance.registered_test_cases, index6, test_case_delegate, {
1921  TestCase* test_case = (TestCase*) test_case_delegate;
1922  if (superTestInstance.selected_test_cases_size > 0 && test_case->execution_status != CESTER_RESULT_UNKNOWN) {
1923  print_test_case_result(test_case);
1924 
1928 
1929  print_test_case_result(test_case);
1930  }
1931  })
1932 
1935  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
1936  if (cester_test_cases[i].test_type == CESTER_NORMAL_TEST && cester_test_cases[i].execution_status != CESTER_RESULT_UNKNOWN) {
1937  print_test_case_outputs(&cester_test_cases[i]);
1938  }
1939  }
1940  }
1941  CESTER_ARRAY_FOREACH(superTestInstance.registered_test_cases, index7, test_case_delegate1, {
1942  TestCase* test_case1 = (TestCase*) test_case_delegate1;
1943  if (test_case1->test_type == CESTER_NORMAL_TEST && test_case1->execution_status != CESTER_RESULT_UNKNOWN) {
1944  print_test_case_outputs(test_case1);
1945  }
1946  })
1947 
1949  #ifndef CESTER_NO_TIME
1950  print_test_result(time_spent);
1951  #else
1952  print_test_result();
1953  #endif
1954  }
1955  }
1956 
1958  cester_cleanup_super_instance();
1960  cester_meta_free(file_name);
1961  return CESTER_RESULT_FAILURE;
1962  }
1964  cester_meta_free(file_name);
1965  return CESTER_RESULT_SUCCESS;
1966  } else if (superTestInstance.report_failure_regardless == 1) {
1967  cester_meta_free(file_name);
1968  return CESTER_RESULT_FAILURE;
1969  }
1970  cester_meta_free(file_name);
1972 }
1973 
1974 /* Assertions, Tests */
1975 
1976 
1982 #define cester_assert_nothing()
1983 
1984 
1988 #define cester_swallow(param)
1989 
1999 #define cester_assert_cmp_msg(w,x,y,z) cester_evaluate_expression(w x y, z, __FILE__, __LINE__)
2000 
2009 #define cester_assert_cmp(x,y,z) cester_assert_cmp_msg(x, y, z, "(" #x " " #y " " #z ")")
2010 
2017 #define cester_assert_true(x) cester_assert_cmp_msg(x, ==, 1, "(" #x ")")
2018 
2027 #define cester_assert_true_msg(x,y) cester_assert_cmp_msg(x, ==, 1, y)
2028 
2035 #define cester_assert_false(x) cester_assert_cmp_msg(x, ==, 0, "(" #x ")")
2036 
2045 #define cester_assert_false_msg(x,y) cester_assert_cmp_msg(x, ==, 0, y)
2046 
2053 #define cester_assert_null(x) cester_assert_cmp_msg(x, ==, CESTER_NULL, "(" #x ")")
2054 
2061 #define cester_assert_not_null(x) cester_assert_cmp_msg(x, !=, CESTER_NULL, "!(" #x ")")
2062 
2070 #define cester_assert_equal(x,y) cester_evaluate_expect_actual(x==y, 1, #x, #y, __FILE__, __LINE__)
2071 
2079 #define cester_assert_not_equal(x,y) cester_evaluate_expect_actual(x!=y, 0, #x, #y, __FILE__, __LINE__)
2080 
2089 #define cester_assert_str_equal(x,y) cester_evaluate_expect_actual_str(x, y, #x, #y, 1, __FILE__, __LINE__)
2090 
2094 #define cester_assert_str_eq cester_assert_str_equal
2095 
2104 #define cester_assert_str_not_equal(x,y) cester_evaluate_expect_actual_str(x, y, #x, #y, 0, __FILE__, __LINE__)
2105 
2109 #define cester_assert_str_ne cester_assert_str_not_equal
2110 
2119 #define cester_assert_ptr_equal(x,y) cester_evaluate_expect_actual_ptr(x, y, #x, #y, 1, __FILE__, __LINE__)
2120 
2124 #define cester_assert_ptr_eq cester_assert_ptr_equal
2125 
2134 #define cester_assert_ptr_not_equal(x,y) cester_evaluate_expect_actual_ptr(x, y, #x, #y, 0, __FILE__, __LINE__)
2135 
2139 #define cester_assert_ptr_ne cester_assert_ptr_not_equal
2140 
2141 /* document the following, add 'compile time only' */
2142 #define __internal_cester_assert_cmp(w,x,y,z) (w x y, z, w, y, #x, __FILE__, __LINE__)
2143 #define __internal_cester_assert_eq(x,y,z) (CESTER_COMPARATOR_EQUAL, "expected " #z ",%s received " #z, y, x, "", __FILE__, __LINE__)
2144 #define __internal_cester_assert_ne(x,y,z) (CESTER_COMPARATOR_NOT_EQUAL, "not expecting " #z ",%s found " #z, x, y, "", __FILE__, __LINE__)
2145 #define __internal_cester_assert_gt(x,y,z) (CESTER_COMPARATOR_GREATER_THAN, "expected value to be greater than " #z ",%s received " #z, x, y, "", __FILE__, __LINE__)
2146 #define __internal_cester_assert_ge(x,y,z) (CESTER_COMPARATOR_GREATER_THAN_OR_EQUAL, "expected value to be greater than or equal to " #z ",%s received " #z, x, y, "", __FILE__, __LINE__)
2147 #define __internal_cester_assert_lt(x,y,z) (CESTER_COMPARATOR_LESSER_THAN, "expected value to be lesser than " #z ",%s received " #z, x, y, "", __FILE__, __LINE__)
2148 #define __internal_cester_assert_le(x,y,z) (CESTER_COMPARATOR_LESSER_THAN_OR_EQUAL, "expected value to be lesser than or equal to " #z ",%s received " #z, x, y, "", __FILE__, __LINE__)
2149 
2160 #define cester_assert_cmp_char(w,x,y,z) CESTER_CONCAT(cester_compare_char_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2161 
2170 #define cester_assert_char_eq(x,y) CESTER_CONCAT(cester_compare_char, __internal_cester_assert_eq(x,y,%c))
2171 
2180 #define cester_assert_char_ne(x,y) CESTER_CONCAT(cester_compare_char, __internal_cester_assert_ne(x,y,%c))
2181 
2190 #define cester_assert_char_gt(x,y) CESTER_CONCAT(cester_compare_char, __internal_cester_assert_gt(x,y,%c))
2191 
2200 #define cester_assert_char_ge(x,y) CESTER_CONCAT(cester_compare_char, __internal_cester_assert_ge(x,y,%c))
2201 
2210 #define cester_assert_char_lt(x,y) CESTER_CONCAT(cester_compare_char, __internal_cester_assert_lt(x,y,%c))
2211 
2220 #define cester_assert_char_le(x,y) CESTER_CONCAT(cester_compare_char, __internal_cester_assert_le(x,y,%c))
2221 
2232 #define cester_assert_cmp_uchar(w,x,y,z) CESTER_CONCAT(cester_compare_uchar_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2233 
2242 #define cester_assert_uchar_eq(x,y) CESTER_CONCAT(cester_compare_uchar, __internal_cester_assert_eq(x,y,%c))
2243 
2252 #define cester_assert_uchar_ne(x,y) CESTER_CONCAT(cester_compare_uchar, __internal_cester_assert_ne(x,y,%c))
2253 
2262 #define cester_assert_uchar_gt(x,y) CESTER_CONCAT(cester_compare_uchar, __internal_cester_assert_gt(x,y,%c))
2263 
2272 #define cester_assert_uchar_ge(x,y) CESTER_CONCAT(cester_compare_uchar, __internal_cester_assert_ge(x,y,%c))
2273 
2282 #define cester_assert_uchar_lt(x,y) CESTER_CONCAT(cester_compare_uchar, __internal_cester_assert_lt(x,y,%c))
2283 
2292 #define cester_assert_uchar_le(x,y) CESTER_CONCAT(cester_compare_uchar, __internal_cester_assert_le(x,y,%c))
2293 
2304 #define cester_assert_cmp_short(w,x,y,z) CESTER_CONCAT(cester_compare_short_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2305 
2314 #define cester_assert_short_eq(x,y) CESTER_CONCAT(cester_compare_short, __internal_cester_assert_eq(x,y,%hi))
2315 
2324 #define cester_assert_short_ne(x,y) CESTER_CONCAT(cester_compare_short, __internal_cester_assert_ne(x,y,%hi))
2325 
2334 #define cester_assert_short_gt(x,y) CESTER_CONCAT(cester_compare_short, __internal_cester_assert_gt(x,y,%hi))
2335 
2344 #define cester_assert_short_ge(x,y) CESTER_CONCAT(cester_compare_short, __internal_cester_assert_ge(x,y,%hi))
2345 
2354 #define cester_assert_short_lt(x,y) CESTER_CONCAT(cester_compare_short, __internal_cester_assert_lt(x,y,%hi))
2355 
2364 #define cester_assert_short_le(x,y) CESTER_CONCAT(cester_compare_short, __internal_cester_assert_le(x,y,%hi))
2365 
2376 #define cester_assert_cmp_ushort(w,x,y,z) CESTER_CONCAT(cester_compare_ushort_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2377 
2386 #define cester_assert_ushort_eq(x,y) CESTER_CONCAT(cester_compare_ushort, __internal_cester_assert_eq(x,y,%hu))
2387 
2396 #define cester_assert_ushort_ne(x,y) CESTER_CONCAT(cester_compare_ushort, __internal_cester_assert_ne(x,y,%hu))
2397 
2406 #define cester_assert_ushort_gt(x,y) CESTER_CONCAT(cester_compare_ushort, __internal_cester_assert_gt(x,y,%hu))
2407 
2416 #define cester_assert_ushort_ge(x,y) CESTER_CONCAT(cester_compare_ushort, __internal_cester_assert_ge(x,y,%hu))
2417 
2426 #define cester_assert_ushort_lt(x,y) CESTER_CONCAT(cester_compare_ushort, __internal_cester_assert_lt(x,y,%hu))
2427 
2436 #define cester_assert_ushort_le(x,y) CESTER_CONCAT(cester_compare_ushort, __internal_cester_assert_le(x,y,%hu))
2437 
2448 #define cester_assert_cmp_int(w,x,y,z) CESTER_CONCAT(cester_compare_int_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2449 
2458 #define cester_assert_int_eq(x,y) CESTER_CONCAT(cester_compare_int, __internal_cester_assert_eq(x,y,%d))
2459 
2468 #define cester_assert_int_ne(x,y) CESTER_CONCAT(cester_compare_int, __internal_cester_assert_ne(x,y,%d))
2469 
2478 #define cester_assert_int_gt(x,y) CESTER_CONCAT(cester_compare_int, __internal_cester_assert_gt(x,y,%d))
2479 
2488 #define cester_assert_int_ge(x,y) CESTER_CONCAT(cester_compare_int, __internal_cester_assert_ge(x,y,%d))
2489 
2498 #define cester_assert_int_lt(x,y) CESTER_CONCAT(cester_compare_int, __internal_cester_assert_lt(x,y,%d))
2499 
2508 #define cester_assert_int_le(x,y) CESTER_CONCAT(cester_compare_int, __internal_cester_assert_le(x,y,%d))
2509 
2520 #define cester_assert_cmp_uint(w,x,y,z) CESTER_CONCAT(cester_compare_uint_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2521 
2530 #define cester_assert_uint_eq(x,y) CESTER_CONCAT(cester_compare_uint, __internal_cester_assert_eq(x,y,%u))
2531 
2540 #define cester_assert_uint_ne(x,y) CESTER_CONCAT(cester_compare_uint, __internal_cester_assert_ne(x,y,%u))
2541 
2550 #define cester_assert_uint_gt(x,y) CESTER_CONCAT(cester_compare_uint, __internal_cester_assert_gt(x,y,%u))
2551 
2560 #define cester_assert_uint_ge(x,y) CESTER_CONCAT(cester_compare_uint, __internal_cester_assert_ge(x,y,%u))
2561 
2570 #define cester_assert_uint_lt(x,y) CESTER_CONCAT(cester_compare_uint, __internal_cester_assert_lt(x,y,%u))
2571 
2580 #define cester_assert_uint_le(x,y) CESTER_CONCAT(cester_compare_uint, __internal_cester_assert_le(x,y,%u))
2581 
2592 #define cester_assert_cmp_long(w,x,y,z) CESTER_CONCAT(cester_compare_long_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2593 
2602 #define cester_assert_long_eq(x,y) CESTER_CONCAT(cester_compare_long, __internal_cester_assert_eq(x,y,%li))
2603 
2612 #define cester_assert_long_ne(x,y) CESTER_CONCAT(cester_compare_long, __internal_cester_assert_ne(x,y,%li))
2613 
2622 #define cester_assert_long_gt(x,y) CESTER_CONCAT(cester_compare_long, __internal_cester_assert_gt(x,y,%li))
2623 
2632 #define cester_assert_long_ge(x,y) CESTER_CONCAT(cester_compare_long, __internal_cester_assert_ge(x,y,%li))
2633 
2642 #define cester_assert_long_lt(x,y) CESTER_CONCAT(cester_compare_long, __internal_cester_assert_lt(x,y,%li))
2643 
2652 #define cester_assert_long_le(x,y) CESTER_CONCAT(cester_compare_long, __internal_cester_assert_le(x,y,%li))
2653 
2664 #define cester_assert_cmp_ulong(w,x,y,z) CESTER_CONCAT(cester_compare_ulong_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2665 
2674 #define cester_assert_ulong_eq(x,y) CESTER_CONCAT(cester_compare_ulong, __internal_cester_assert_eq(x,y,%lu))
2675 
2684 #define cester_assert_ulong_ne(x,y) CESTER_CONCAT(cester_compare_ulong, __internal_cester_assert_ne(x,y,%lu))
2685 
2694 #define cester_assert_ulong_gt(x,y) CESTER_CONCAT(cester_compare_ulong, __internal_cester_assert_gt(x,y,%lu))
2695 
2704 #define cester_assert_ulong_ge(x,y) CESTER_CONCAT(cester_compare_ulong, __internal_cester_assert_ge(x,y,%lu))
2705 
2714 #define cester_assert_ulong_lt(x,y) CESTER_CONCAT(cester_compare_ulong, __internal_cester_assert_lt(x,y,%lu))
2715 
2724 #define cester_assert_ulong_le(x,y) CESTER_CONCAT(cester_compare_ulong, __internal_cester_assert_le(x,y,%lu))
2725 
2736 #define cester_assert_cmp_llong(w,x,y,z) CESTER_CONCAT(cester_compare_llong_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2737 
2746 #ifndef __CESTER_STDC_VERSION__
2747 #define cester_assert_llong_eq(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_eq(x,y,%li))
2748 #else
2749 #define cester_assert_llong_eq(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_eq(x,y,%lli))
2750 #endif
2751 
2760 #ifndef __CESTER_STDC_VERSION__
2761 #define cester_assert_llong_ne(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_ne(x,y,%li))
2762 #else
2763 #define cester_assert_llong_ne(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_ne(x,y,%lli))
2764 #endif
2765 
2774 #ifndef __CESTER_STDC_VERSION__
2775 #define cester_assert_llong_gt(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_gt(x,y,%li))
2776 #else
2777 #define cester_assert_llong_gt(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_gt(x,y,%lli))
2778 #endif
2779 
2788 #ifndef __CESTER_STDC_VERSION__
2789 #define cester_assert_llong_ge(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_ge(x,y,%li))
2790 #else
2791 #define cester_assert_llong_ge(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_ge(x,y,%lli))
2792 #endif
2793 
2802 #ifndef __CESTER_STDC_VERSION__
2803 #define cester_assert_llong_lt(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_lt(x,y,%li))
2804 #else
2805 #define cester_assert_llong_lt(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_lt(x,y,%lli))
2806 #endif
2807 
2816 #ifndef __CESTER_STDC_VERSION__
2817 #define cester_assert_llong_le(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_ge(x,y,%li))
2818 #else
2819 #define cester_assert_llong_le(x,y) CESTER_CONCAT(cester_compare_llong, __internal_cester_assert_ge(x,y,%lli))
2820 #endif
2821 
2832 #define cester_assert_cmp_ullong(w,x,y,z) CESTER_CONCAT(cester_compare_ullong_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2833 
2842 #define cester_assert_ullong_eq(x,y) CESTER_CONCAT(cester_compare_ullong, __internal_cester_assert_eq(x,y,%llu))
2843 
2852 #define cester_assert_ullong_ne(x,y) CESTER_CONCAT(cester_compare_ullong, __internal_cester_assert_ne(x,y,%llu))
2853 
2862 #define cester_assert_ullong_gt(x,y) CESTER_CONCAT(cester_compare_ullong, __internal_cester_assert_gt(x,y,%llu))
2863 
2872 #define cester_assert_ullong_ge(x,y) CESTER_CONCAT(cester_compare_ullong, __internal_cester_assert_ge(x,y,%llu))
2873 
2882 #define cester_assert_ullong_lt(x,y) CESTER_CONCAT(cester_compare_ullong, __internal_cester_assert_lt(x,y,%llu))
2883 
2892 #define cester_assert_ullong_le(x,y) CESTER_CONCAT(cester_compare_ullong, __internal_cester_assert_le(x,y,%llu))
2893 
2904 #define cester_assert_cmp_float(w,x,y,z) CESTER_CONCAT(cester_compare_float_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2905 
2914 #define cester_assert_float_eq(x,y) CESTER_CONCAT(cester_compare_float, __internal_cester_assert_eq(x,y,%f))
2915 
2924 #define cester_assert_float_ne(x,y) CESTER_CONCAT(cester_compare_float, __internal_cester_assert_ne(x,y,%f))
2925 
2934 #define cester_assert_float_gt(x,y) CESTER_CONCAT(cester_compare_float, __internal_cester_assert_gt(x,y,%f))
2935 
2944 #define cester_assert_float_ge(x,y) CESTER_CONCAT(cester_compare_float, __internal_cester_assert_ge(x,y,%f))
2945 
2954 #define cester_assert_float_lt(x,y) CESTER_CONCAT(cester_compare_float, __internal_cester_assert_lt(x,y,%f))
2955 
2964 #define cester_assert_float_le(x,y) CESTER_CONCAT(cester_compare_float, __internal_cester_assert_le(x,y,%f))
2965 
2976 #define cester_assert_cmp_double(w,x,y,z) CESTER_CONCAT(cester_compare_double_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
2977 
2986 #define cester_assert_double_eq(x,y) CESTER_CONCAT(cester_compare_double, __internal_cester_assert_eq(x,y,%lf))
2987 
2996 #define cester_assert_double_ne(x,y) CESTER_CONCAT(cester_compare_double, __internal_cester_assert_ne(x,y,%lf))
2997 
3006 #define cester_assert_double_gt(x,y) CESTER_CONCAT(cester_compare_double, __internal_cester_assert_gt(x,y,%lf))
3007 
3016 #define cester_assert_double_ge(x,y) CESTER_CONCAT(cester_compare_double, __internal_cester_assert_ge(x,y,%lf))
3017 
3026 #define cester_assert_double_lt(x,y) CESTER_CONCAT(cester_compare_double, __internal_cester_assert_lt(x,y,%lf))
3027 
3036 #define cester_assert_double_le(x,y) CESTER_CONCAT(cester_compare_double, __internal_cester_assert_le(x,y,%lf))
3037 
3048 #define cester_assert_cmp_ldouble(w,x,y,z) CESTER_CONCAT(cester_compare_ldouble_pre_evaluated, __internal_cester_assert_cmp(w,x,y,z))
3049 
3058 #define cester_assert_ldouble_eq(x,y) CESTER_CONCAT(cester_compare_ldouble, __internal_cester_assert_eq(x,y,%e))
3059 
3068 #define cester_assert_ldouble_ne(x,y) CESTER_CONCAT(cester_compare_ldouble, __internal_cester_assert_ne(x,y,%e))
3069 
3078 #define cester_assert_ldouble_gt(x,y) CESTER_CONCAT(cester_compare_ldouble, __internal_cester_assert_gt(x,y,%e))
3079 
3088 #define cester_assert_ldouble_ge(x,y) CESTER_CONCAT(cester_compare_ldouble, __internal_cester_assert_ge(x,y,%e))
3089 
3098 #define cester_assert_ldouble_lt(x,y) CESTER_CONCAT(cester_compare_ldouble, __internal_cester_assert_lt(x,y,%e))
3099 
3108 #define cester_assert_ldouble_le(x,y) CESTER_CONCAT(cester_compare_ldouble, __internal_cester_assert_le(x,y,%e))
3109 
3110 static __CESTER_INLINE__ void cester_evaluate_expression(unsigned eval_result, char const* const expression, char const* const file_path, unsigned const line_num) {
3111  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
3112  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "# ");
3113 
3114  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
3115  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " - ");
3116  }
3117  if (eval_result == 0) {
3119  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "EvaluationError ");
3121  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "Passed ");
3122  }
3123  /*my brain failed to work in this if condition. I beleive the if condition can be simplified*/
3124  if ((superTestInstance.verbose_level >= 1 || eval_result == 0) && ((superTestInstance.print_error_only == 1 && eval_result == 0) || superTestInstance.print_error_only == 0)) {
3125  cester_print_assertion(expression, file_path, line_num);
3126  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "\n");
3127  }
3128 }
3129 
3130 static __CESTER_INLINE__ void cester_evaluate_expect_actual(unsigned eval_result, unsigned expecting, char const* const expected, char const* const actual,
3131  char const* const file_path, unsigned const line_num) {
3132 
3133 
3134  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
3135  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "# ");
3136 
3137  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
3138  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " - ");
3139  }
3140  if (eval_result == 0) {
3142  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "AssertionError ");
3144  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "Passed ");
3145  }
3146  if ((superTestInstance.verbose_level >= 1 || eval_result == 0) && ((superTestInstance.print_error_only == 1 && eval_result == 0) || superTestInstance.print_error_only == 0)) {
3147  cester_print_expect_actual(expecting, expected, actual, file_path, line_num);
3148  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "\n");
3149  }
3150 }
3151 
3152 static __CESTER_INLINE__ void cester_evaluate_expect_actual_str(char const* const expected_in, char const* const actual_in, char const* const expected_expr,
3153  char const* const actual_expr, unsigned expecting, char const* const file_path, unsigned const line_num) {
3154 
3155  unsigned eval_result;
3156  char *expected;
3157  char *actual;
3158 
3159 
3160  expected = (char*) "";
3161  actual = (char*) "";
3162  eval_result = cester_string_equals((char*)expected_in, (char*)actual_in);
3163  if (superTestInstance.verbose_level >= 3) {
3164  cester_concat_str(&expected, expected_expr);
3165  cester_concat_str(&actual, actual_expr);
3166 
3167  cester_concat_char(&expected, '=');
3168  cester_concat_char(&actual, '=');
3169  }
3170  cester_concat_str(&expected, expected_in);
3171  cester_concat_str(&actual, actual_in);
3172 
3173  if (eval_result != expecting) {
3175  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
3176  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "# ");
3177 
3178  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
3179  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " - ");
3180  }
3181  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "AssertionError ");
3183  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
3184  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "# ");
3185 
3186  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
3187  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " - ");
3188  }
3189  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "Passed ");
3190  }
3191  if ((superTestInstance.verbose_level >= 1 || eval_result != expecting) && ((superTestInstance.print_error_only == 1 && eval_result != expecting) || superTestInstance.print_error_only == 0)) {
3192  cester_print_expect_actual(expecting, expected, actual, file_path, line_num);
3193  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "\n");
3194  }
3195  cester_meta_free(expected);
3196  cester_meta_free(actual);
3197 }
3198 
3199 static __CESTER_INLINE__ void cester_evaluate_expect_actual_ptr(void* ptr1, void* ptr2, char const* const expected_expr, char const* const actual_expr,
3200  unsigned expecting, char const* const file_path, unsigned const line_num) {
3201 
3202  unsigned eval_result;
3203  char *expected;
3204  char *actual;
3205 
3206  eval_result = ptr1 == ptr2;
3207  if (superTestInstance.verbose_level >= 3) {
3208  expected = (char*) "";
3209  actual = (char*) "";
3210  cester_concat_str(&expected, expected_expr);
3211  cester_concat_str(&actual, actual_expr);
3212 
3213  cester_concat_char(&expected, '=');
3214  cester_concat_char(&actual, '=');
3215 
3216  cester_concat_ptr(&expected, ptr1);
3217  cester_concat_ptr(&actual, ptr2);
3218  } else {
3219  cester_ptr_to_str(&expected, ptr1);
3220  cester_ptr_to_str(&actual, ptr2);
3221  }
3222  if (eval_result != expecting) {
3224  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
3225  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "# ");
3226 
3227  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
3228  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " - ");
3229  }
3230  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "AssertionError ");
3232  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
3233  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "# ");
3234 
3235  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
3236  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, " - ");
3237  }
3238  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "Passed ");
3239  }
3240  if ((superTestInstance.verbose_level >= 1 || eval_result != expecting) && ((superTestInstance.print_error_only == 1 && eval_result != expecting) || superTestInstance.print_error_only == 0)) {
3241  cester_print_expect_actual(expecting, expected, actual, file_path, line_num);
3242  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "\n");
3243  }
3244  cester_meta_free(expected);
3245  cester_meta_free(actual);
3246 }
3247 
3248 /*
3249  Use the cester_assertion_caparator type to determine what comparission
3250  operation to perform on the two values
3251 */
3252 #define CESTER_INTERNAL_EVALUATE(comparator_type, x, y, result) {\
3253  if (comparator_type == CESTER_COMPARATOR_EQUAL) {\
3254  result = (x == y);\
3255  } else if (comparator_type == CESTER_COMPARATOR_NOT_EQUAL) {\
3256  result = (x != y);\
3257  } else if (comparator_type == CESTER_COMPARATOR_GREATER_THAN) {\
3258  result = (x > y);\
3259  } else if (comparator_type == CESTER_COMPARATOR_GREATER_THAN_OR_EQUAL) {\
3260  result = (x >= y);\
3261  } else if (comparator_type == CESTER_COMPARATOR_LESSER_THAN) {\
3262  result = (x < y);\
3263  } else if (comparator_type == CESTER_COMPARATOR_LESSER_THAN_OR_EQUAL) {\
3264  result = (x <= y);\
3265  } else {\
3266  result = (x == y);\
3267  }\
3268 }
3269 
3270 static __CESTER_INLINE__ void cester_compare_char_pre_evaluated(int eval_result, char const* const expr, char first, char second, char const* const op, char const* const file_path, unsigned const line_num) {
3271  char expression[2048] = "";
3272  cester_sprintf3(expression, 2048, expr, second, op, first);
3273  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3274 }
3275 
3276 static __CESTER_INLINE__ void cester_compare_char(enum cester_assertion_caparator comparator_type, char const* const expr, char first, char second, char const* const op, char const* const file_path, unsigned const line_num) {
3277  int eval_result = 0;
3278  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3279  cester_compare_char_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3280 }
3281 
3282 static __CESTER_INLINE__ void cester_compare_uchar_pre_evaluated(int eval_result, char const* const expr, unsigned char first, unsigned char second, char const* const op, char const* const file_path, unsigned const line_num) {
3283  char expression[2048] = "";
3284  cester_sprintf3(expression, 2048, expr, second, op, first);
3285  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3286 }
3287 
3288 static __CESTER_INLINE__ void cester_compare_uchar(enum cester_assertion_caparator comparator_type, char const* const expr, unsigned char first, unsigned char second, char const* const op, char const* const file_path, unsigned const line_num) {
3289  int eval_result = 0;
3290  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3291  cester_compare_uchar_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3292 }
3293 
3294 static __CESTER_INLINE__ void cester_compare_int_pre_evaluated(int eval_result, char const* const expr, int first, int second, char const* const op, char const* const file_path, unsigned const line_num) {
3295  char expression[2048] = "";
3296  cester_sprintf3(expression, 2048, expr, second, op, first);
3297  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3298 }
3299 
3300 static __CESTER_INLINE__ void cester_compare_int(enum cester_assertion_caparator comparator_type, char const* const expr, int first, int second, char const* const op, char const* const file_path, unsigned const line_num) {
3301  int eval_result = 0;
3302  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3303  cester_compare_int_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3304 }
3305 
3306 static __CESTER_INLINE__ void cester_compare_uint_pre_evaluated(int eval_result, char const* const expr, unsigned int first, unsigned int second, char const* const op, char const* const file_path, unsigned const line_num) {
3307  char expression[2048] = "";
3308  cester_sprintf3(expression, 2048, expr, second, op, first);
3309  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3310 }
3311 
3312 static __CESTER_INLINE__ void cester_compare_uint(enum cester_assertion_caparator comparator_type, char const* const expr, unsigned int first, unsigned int second, char const* const op, char const* const file_path, unsigned const line_num) {
3313  int eval_result = 0;
3314  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3315  cester_compare_uint_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3316 }
3317 
3318 static __CESTER_INLINE__ void cester_compare_short_pre_evaluated(int eval_result, char const* const expr, short first, short second, char const* const op, char const* const file_path, unsigned const line_num) {
3319  char expression[2048] = "";
3320  cester_sprintf3(expression, 2048, expr, second, op, first);
3321  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3322 }
3323 
3324 static __CESTER_INLINE__ void cester_compare_short(enum cester_assertion_caparator comparator_type, char const* const expr, short first, short second, char const* const op, char const* const file_path, unsigned const line_num) {
3325  int eval_result = 0;
3326  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3327  cester_compare_short_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3328 }
3329 
3330 static __CESTER_INLINE__ void cester_compare_ushort_pre_evaluated(int eval_result, char const* const expr, unsigned short first, unsigned short second, char const* const op, char const* const file_path, unsigned const line_num) {
3331  char expression[2048] = "";
3332  cester_sprintf3(expression, 2048, expr, second, op, first);
3333  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3334 }
3335 
3336 static __CESTER_INLINE__ void cester_compare_ushort(enum cester_assertion_caparator comparator_type, char const* const expr, unsigned short first, unsigned short second, char const* const op, char const* const file_path, unsigned const line_num) {
3337  int eval_result = 0;
3338  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3339  cester_compare_ushort_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3340 }
3341 
3342 static __CESTER_INLINE__ void cester_compare_long_pre_evaluated(int eval_result, char const* const expr, long first, long second, char const* const op, char const* const file_path, unsigned const line_num) {
3343  char expression[2048] = "";
3344  cester_sprintf3(expression, 2048, expr, second, op, first);
3345  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3346 }
3347 
3348 static __CESTER_INLINE__ void cester_compare_long(enum cester_assertion_caparator comparator_type, char const* const expr, long first, long second, char const* const op, char const* const file_path, unsigned const line_num) {
3349  int eval_result = 0;
3350  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3351  cester_compare_long_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3352 }
3353 
3354 static __CESTER_INLINE__ void cester_compare_ulong_pre_evaluated(int eval_result, char const* const expr, unsigned long first, unsigned long second, char const* const op, char const* const file_path, unsigned const line_num) {
3355  char expression[2048] = "";
3356  cester_sprintf3(expression, 2048, expr, second, op, first);
3357  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3358 }
3359 
3360 static __CESTER_INLINE__ void cester_compare_ulong(enum cester_assertion_caparator comparator_type, char const* const expr, unsigned long first, unsigned long second, char const* const op, char const* const file_path, unsigned const line_num) {
3361  int eval_result = 0;
3362  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3363  cester_compare_ulong_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3364 }
3365 
3366 static __CESTER_INLINE__ void cester_compare_llong_pre_evaluated(int eval_result, char const* const expr, __CESTER_LONG_LONG__ first, __CESTER_LONG_LONG__ second, char const* const op, char const* const file_path, unsigned const line_num) {
3367  char expression[2048] = "";
3368  cester_sprintf3(expression, 2048, expr, second, op, first);
3369  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3370 }
3371 
3372 static __CESTER_INLINE__ void cester_compare_llong(enum cester_assertion_caparator comparator_type, char const* const expr, __CESTER_LONG_LONG__ first, __CESTER_LONG_LONG__ second, char const* const op, char const* const file_path, unsigned const line_num) {
3373  int eval_result = 0;
3374  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3375  cester_compare_llong_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3376 }
3377 
3378 static __CESTER_INLINE__ void cester_compare_ullong_pre_evaluated(int eval_result, char const* const expr, unsigned __CESTER_LONG_LONG__ first, unsigned __CESTER_LONG_LONG__ second, char const* const op, char const* const file_path, unsigned const line_num) {
3379  char expression[2048] = "";
3380  cester_sprintf3(expression, 2048, expr, second, op, first);
3381  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3382 }
3383 
3384 static __CESTER_INLINE__ void cester_compare_ullong(enum cester_assertion_caparator comparator_type, char const* const expr, unsigned __CESTER_LONG_LONG__ first, unsigned __CESTER_LONG_LONG__ second, char const* const op, char const* const file_path, unsigned const line_num) {
3385  int eval_result = 0;
3386  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3387  cester_compare_ullong_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3388 }
3389 
3390 static __CESTER_INLINE__ void cester_compare_float_pre_evaluated(int eval_result, char const* const expr, float first, float second, char const* const op, char const* const file_path, unsigned const line_num) {
3391  char expression[2048] = "";
3392  cester_sprintf3(expression, 2048, expr, second, op, first);
3393  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3394 }
3395 
3396 static __CESTER_INLINE__ void cester_compare_float(enum cester_assertion_caparator comparator_type, char const* const expr, float first, float second, char const* const op, char const* const file_path, unsigned const line_num) {
3397  int eval_result = 0;
3398  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3399  cester_compare_float_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3400 }
3401 
3402 static __CESTER_INLINE__ void cester_compare_double_pre_evaluated(int eval_result, char const* const expr, double first, double second, char const* const op, char const* const file_path, unsigned const line_num) {
3403  char expression[2048] = "";
3404  cester_sprintf3(expression, 2048, expr, second, op, first);
3405  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3406 }
3407 
3408 static __CESTER_INLINE__ void cester_compare_double(enum cester_assertion_caparator comparator_type, char const* const expr, double first, double second, char const* const op, char const* const file_path, unsigned const line_num) {
3409  int eval_result = 0;
3410  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3411  cester_compare_double_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3412 }
3413 
3414 static __CESTER_INLINE__ void cester_compare_ldouble_pre_evaluated(int eval_result, char const* const expr, long double first, long double second, char const* const op, char const* const file_path, unsigned const line_num) {
3415  char expression[2048] = "";
3416  cester_sprintf3(expression, 2048, expr, second, op, first);
3417  cester_evaluate_expression(eval_result, (char*)expression, file_path, line_num);
3418 }
3419 
3420 static __CESTER_INLINE__ void cester_compare_ldouble(enum cester_assertion_caparator comparator_type, char const* const expr, long double first, long double second, char const* const op, char const* const file_path, unsigned const line_num) {
3421  int eval_result = 0;
3422  CESTER_INTERNAL_EVALUATE(comparator_type, first, second, eval_result);
3423  cester_compare_ldouble_pre_evaluated(eval_result, expr, first, second, op, file_path, line_num);
3424 }
3425 
3426 #ifndef __CESTER_STDC_VERSION__
3427 
3431 #define CESTER_TEST(x,y,z) static void cester_test_##x(TestInstance* y);
3432 
3441 #define CESTER_TODO_TEST(x,y,z) static void cester_test_##x(TestInstance* y);
3442 
3449 #define CESTER_SKIP_TEST(x,y,z) static void cester_test_##x(TestInstance* y);
3450 
3456 #define CESTER_BEFORE_ALL(x,y) void cester_before_all_test(TestInstance* x);
3457 
3462 #define CESTER_BEFORE_EACH(w,x,y,z) void cester_before_each_test(TestInstance* w, char * const x, unsigned y);
3463 
3469 #define CESTER_AFTER_ALL(x,y) void cester_after_all_test(TestInstance* x);
3470 
3475 #define CESTER_AFTER_EACH(w,x,y,z) void cester_after_each_test(TestInstance* w, char * const x, unsigned y);
3476 
3481 #define CESTER_OPTIONS(x) void cester_options_before_main(void);
3482 
3491 #define CESTER_BODY(x)
3492 
3503 #define CESTER_COMMENT(x) void cester_test_file_comment_function(void);
3504 
3505 #ifndef CESTER_NO_MOCK
3506 
3519 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,z) __attribute__((weak)) y x; y __real_##x;
3520 
3524 #define CESTER_MOCK_FUNCTION(x,y,z) __attribute__((weak)) y x; extern y __real_##x;
3525 #else
3526 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,z)
3527 #define CESTER_MOCK_FUNCTION(x,y,z)
3528 #endif
3529 
3530 #else
3531 
3532 #define CESTER_TEST(x,y,...) static void cester_test_##x(TestInstance* y);
3533 #define CESTER_TODO_TEST(x,y,...) static void cester_test_##x(TestInstance* y);
3534 #define CESTER_SKIP_TEST(x,y,...) static void cester_test_##x(TestInstance* y);
3535 #define CESTER_BEFORE_ALL(x,...) void cester_before_all_test(TestInstance* x);
3536 #define CESTER_BEFORE_EACH(w,x,y,...) void cester_before_each_test(TestInstance* w, char * const x, unsigned y);
3537 #define CESTER_AFTER_ALL(x,...) void cester_after_all_test(TestInstance* x);
3538 #define CESTER_AFTER_EACH(w,x,y,...) void cester_after_each_test(TestInstance* w, char * const x, unsigned y);
3539 #define CESTER_OPTIONS(...) void cester_options_before_main(void);
3540 #define CESTER_BODY(...)
3541 #define CESTER_COMMENT(...) void cester_test_file_comment_function(void);
3542 #ifndef CESTER_NO_MOCK
3543 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,...) __attribute__((weak)) y x; y __real_##x;
3544 #define CESTER_MOCK_FUNCTION(x,y,...) __attribute__((weak)) y x; extern y __real_##x;
3545 #else
3546 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,...)
3547 #define CESTER_MOCK_FUNCTION(x,y,...)
3548 #endif
3549 #endif
3550 
3551 #ifdef __BASE_FILE__
3552 #ifdef __cplusplus
3553 }
3554 #endif
3555  #include __BASE_FILE__
3556 #ifdef __cplusplus
3557 extern "C" {
3558 #endif
3559 #else
3560 
3561 #endif
3562 
3563 #undef CESTER_TEST
3564 #undef CESTER_TODO_TEST
3565 #undef CESTER_SKIP_TEST
3566 #undef CESTER_BEFORE_ALL
3567 #undef CESTER_BEFORE_EACH
3568 #undef CESTER_AFTER_ALL
3569 #undef CESTER_AFTER_EACH
3570 #undef CESTER_OPTIONS
3571 #undef CESTER_BODY
3572 #undef CESTER_COMMENT
3573 #undef CESTER_MOCK_SIMPLE_FUNCTION
3574 #undef CESTER_MOCK_FUNCTION
3575 
3576 #ifdef __CESTER_STDC_VERSION__
3577 #ifndef CESTER_NO_TIME
3578 #define CESTER_TEST(x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_TEST },
3579 #define CESTER_TODO_TEST(x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_TODO_TEST },
3580 #define CESTER_SKIP_TEST(x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_SKIP_TEST },
3581 #define CESTER_BEFORE_ALL(x,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_before_all_test", (cester_before_all_test), CESTER_NULL, CESTER_NULL, CESTER_BEFORE_ALL_TEST },
3582 #define CESTER_BEFORE_EACH(w,x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) (char*) "", (char*) "cester_before_each_test", CESTER_NULL, (cester_before_each_test), CESTER_NULL, CESTER_BEFORE_EACH_TEST },
3583 #define CESTER_AFTER_ALL(x,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_after_all_test", (cester_after_all_test), CESTER_NULL, CESTER_NULL, CESTER_AFTER_ALL_TEST },
3584 #define CESTER_AFTER_EACH(w,x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_after_each_test", CESTER_NULL, (cester_after_each_test), CESTER_NULL, CESTER_AFTER_EACH_TEST },
3585 #define CESTER_OPTIONS(...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_options_before_main", CESTER_NULL, CESTER_NULL, (cester_options_before_main), CESTER_OPTIONS_FUNCTION },
3586 #define CESTER_COMMENT(...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_test_file_comment_function", CESTER_NULL, CESTER_NULL, (cester_test_file_comment_function), CESTER_TEST_FILE_COMMENT },
3587 #else
3588 #define CESTER_TEST(x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_TEST },
3589 #define CESTER_TODO_TEST(x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_TODO_TEST },
3590 #define CESTER_SKIP_TEST(x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_SKIP_TEST },
3591 #define CESTER_BEFORE_ALL(x,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_before_all_test", (cester_before_all_test), CESTER_NULL, CESTER_NULL, CESTER_BEFORE_ALL_TEST },
3592 #define CESTER_BEFORE_EACH(w,x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) (char*) "", (char*) "cester_before_each_test", CESTER_NULL, (cester_before_each_test), CESTER_NULL, CESTER_BEFORE_EACH_TEST },
3593 #define CESTER_AFTER_ALL(x,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_after_all_test", (cester_after_all_test), CESTER_NULL, CESTER_NULL, CESTER_AFTER_ALL_TEST },
3594 #define CESTER_AFTER_EACH(w,x,y,...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_after_each_test", CESTER_NULL, (cester_after_each_test), CESTER_NULL, CESTER_AFTER_EACH_TEST },
3595 #define CESTER_OPTIONS(...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_options_before_main", CESTER_NULL, CESTER_NULL, (cester_options_before_main), CESTER_OPTIONS_FUNCTION },
3596 #define CESTER_COMMENT(...) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_test_file_comment_function", CESTER_NULL, CESTER_NULL, (cester_test_file_comment_function), CESTER_TEST_FILE_COMMENT },
3597 #endif
3598 #define CESTER_BODY(...)
3599 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,...)
3600 #define CESTER_MOCK_FUNCTION(x,y,...)
3601 #else
3602 #ifndef CESTER_NO_TIME
3603 #define CESTER_TEST(x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_TEST },
3604 #define CESTER_TODO_TEST(x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_TODO_TEST },
3605 #define CESTER_SKIP_TEST(x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_SKIP_TEST },
3606 #define CESTER_BEFORE_ALL(x,y) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_before_all_test", (cester_before_all_test), CESTER_NULL, CESTER_NULL, CESTER_BEFORE_ALL_TEST },
3607 #define CESTER_BEFORE_EACH(w,x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) (char*) "", (char*) "cester_before_each_test", CESTER_NULL, (cester_before_each_test), CESTER_NULL, CESTER_BEFORE_EACH_TEST },
3608 #define CESTER_AFTER_ALL(x,y) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_after_all_test", (cester_after_all_test), CESTER_NULL, CESTER_NULL, CESTER_AFTER_ALL_TEST },
3609 #define CESTER_AFTER_EACH(w,x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_after_each_test", CESTER_NULL, (cester_after_each_test), CESTER_NULL, CESTER_AFTER_EACH_TEST },
3610 #define CESTER_OPTIONS(x) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_options_before_main", CESTER_NULL, CESTER_NULL, (cester_options_before_main), CESTER_OPTIONS_FUNCTION },
3611 #define CESTER_COMMENT(x) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, 0.000, 0.000, (char*) "", (char*) "cester_test_file_comment_function", CESTER_NULL, CESTER_NULL, (cester_test_file_comment_function), CESTER_TEST_FILE_COMMENT },
3612 #else
3613 #define CESTER_TEST(x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_TEST },
3614 #define CESTER_TODO_TEST(x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_TODO_TEST },
3615 #define CESTER_SKIP_TEST(x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) #x, (cester_test_##x), CESTER_NULL, CESTER_NULL, CESTER_NORMAL_SKIP_TEST },
3616 #define CESTER_BEFORE_ALL(x,y) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_before_all_test", (cester_before_all_test), CESTER_NULL, CESTER_NULL, CESTER_BEFORE_ALL_TEST },
3617 #define CESTER_BEFORE_EACH(w,x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) (char*) "", (char*) "cester_before_each_test", CESTER_NULL, (cester_before_each_test), CESTER_NULL, CESTER_BEFORE_EACH_TEST },
3618 #define CESTER_AFTER_ALL(x,y) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_after_all_test", (cester_after_all_test), CESTER_NULL, CESTER_NULL, CESTER_AFTER_ALL_TEST },
3619 #define CESTER_AFTER_EACH(w,x,y,z) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_after_each_test", CESTER_NULL, (cester_after_each_test), CESTER_NULL, CESTER_AFTER_EACH_TEST },
3620 #define CESTER_OPTIONS(x) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_options_before_main", CESTER_NULL, CESTER_NULL, (cester_options_before_main), CESTER_OPTIONS_FUNCTION },
3621 #define CESTER_COMMENT(x) { CESTER_RESULT_UNKNOWN, __LINE__, CESTER_RESULT_SUCCESS, (char*) "", (char*) "cester_test_file_comment_function", CESTER_NULL, CESTER_NULL, (cester_test_file_comment_function), CESTER_TEST_FILE_COMMENT },
3622 #endif
3623 #define CESTER_BODY(x)
3624 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,z)
3625 #define CESTER_MOCK_FUNCTION(x,y,z)
3626 #endif
3627 
3628 #ifdef __cplusplus
3629 }
3630 #endif
3631 static TestCase cester_test_cases[] = {
3632 #ifdef __BASE_FILE__
3633  #include __BASE_FILE__
3634 #endif
3635 #ifndef CESTER_NO_TIME
3637 #else
3639 #endif
3640 };
3641 #ifdef __cplusplus
3642 extern "C" {
3643 #endif
3644 
3645 #undef CESTER_TEST
3646 #undef CESTER_TODO_TEST
3647 #undef CESTER_SKIP_TEST
3648 #undef CESTER_BEFORE_ALL
3649 #undef CESTER_BEFORE_EACH
3650 #undef CESTER_AFTER_ALL
3651 #undef CESTER_AFTER_EACH
3652 #undef CESTER_OPTIONS
3653 #undef CESTER_BODY
3654 #undef CESTER_COMMENT
3655 #undef CESTER_MOCK_SIMPLE_FUNCTION
3656 #undef CESTER_MOCK_FUNCTION
3657 
3658 #ifdef __CESTER_STDC_VERSION__
3659 #define CESTER_TEST(x,y,...) static void cester_test_##x(TestInstance* y) { __VA_ARGS__ }
3660 #define CESTER_TODO_TEST(x,y,...) static void cester_test_##x(TestInstance* y) { }
3661 #define CESTER_SKIP_TEST(x,y,...) static void cester_test_##x(TestInstance* y) { __VA_ARGS__ }
3662 #define CESTER_BEFORE_ALL(x,...) void cester_before_all_test(TestInstance* x) { __VA_ARGS__ CESTER_NO_ISOLATION(); }
3663 #define CESTER_BEFORE_EACH(w,x,y,...) void cester_before_each_test(TestInstance* w, char * const x, unsigned y) { __VA_ARGS__ CESTER_NO_ISOLATION(); }
3664 #define CESTER_AFTER_ALL(x,...) void cester_after_all_test(TestInstance* x) { __VA_ARGS__ CESTER_NO_ISOLATION(); }
3665 #define CESTER_AFTER_EACH(w,x,y,...) void cester_after_each_test(TestInstance* w, char * const x, unsigned y) { __VA_ARGS__ CESTER_NO_ISOLATION(); }
3666 #define CESTER_OPTIONS(...) void cester_options_before_main(void) { __VA_ARGS__ }
3667 #define CESTER_BODY(...) __VA_ARGS__
3668 #define CESTER_COMMENT(...) void cester_test_file_comment_function(void) { if (cester_string_equals(superTestInstance.output_format, (char*) "text") == 1) { CESTER_DELEGATE_FPRINT_STR((cester_default_color), "\n"); CESTER_DELEGATE_FPRINT_STR((cester_default_color), #__VA_ARGS__); CESTER_DELEGATE_FPRINT_STR((cester_default_color), "\n"); } }
3669 #ifndef CESTER_NO_MOCK
3670 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,...) y __wrap_##x { return __VA_ARGS__; }
3671 #define CESTER_MOCK_FUNCTION(x,y,...) y __wrap_##x { __VA_ARGS__ }
3672 #else
3673 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,...)
3674 #define CESTER_MOCK_FUNCTION(x,y,...)
3675 #endif
3676 
3677 #else
3678 
3679 #define CESTER_TEST(x,y,z) static void cester_test_##x(TestInstance* y) { z }
3680 #define CESTER_TODO_TEST(x,y,z) static void cester_test_##x(TestInstance* y) { }
3681 #define CESTER_SKIP_TEST(x,y,z) static void cester_test_##x(TestInstance* y) { z }
3682 #define CESTER_BEFORE_ALL(x,y) void cester_before_all_test(TestInstance* x) { y CESTER_NO_ISOLATION(); }
3683 #define CESTER_BEFORE_EACH(w,x,y,z) void cester_before_each_test(TestInstance* w, char * const x, unsigned y) { z CESTER_NO_ISOLATION(); }
3684 #define CESTER_AFTER_ALL(x,y) void cester_after_all_test(TestInstance* x) { y CESTER_NO_ISOLATION(); }
3685 #define CESTER_AFTER_EACH(w,x,y,z) void cester_after_each_test(TestInstance* w, char * const x, unsigned y) { z CESTER_NO_ISOLATION(); }
3686 #define CESTER_OPTIONS(x) void cester_options_before_main(void) { x }
3687 #define CESTER_BODY(x) x
3688 #define CESTER_COMMENT(x) void cester_test_file_comment_function(void) { if (cester_string_equals(superTestInstance.output_format, (char*) "text") == 1) { CESTER_DELEGATE_FPRINT_STR((cester_default_color), "\n"); CESTER_DELEGATE_FPRINT_STR((cester_default_color), #x); CESTER_DELEGATE_FPRINT_STR((cester_default_color), "\n"); } }
3689 #ifndef CESTER_NO_MOCK
3690 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,z) y __wrap_##x { return z; }
3691 #define CESTER_MOCK_FUNCTION(x,y,z) y __wrap_##x { z }
3692 #else
3693 #define CESTER_MOCK_SIMPLE_FUNCTION(x,y,z)
3694 #define CESTER_MOCK_FUNCTION(x,y,z)
3695 #endif
3696 #endif
3697 
3705 #define CESTER_REGISTER_TEST(x) cester_register_test((char*)#x, (cester_test_##x), CESTER_NULL, CESTER_NULL, __LINE__, CESTER_NORMAL_TEST)
3706 
3714 #define CESTER_REGISTER_SKIP_TEST(x) cester_register_test((char*)#x, (cester_test_##x), CESTER_NULL, CESTER_NULL, __LINE__, CESTER_NORMAL_SKIP_TEST)
3715 
3720 #define CESTER_REGISTER_TODO_TEST(x) cester_register_test((char*)#x, (cester_test_##x), CESTER_NULL, CESTER_NULL, __LINE__, CESTER_NORMAL_TODO_TEST)
3721 
3726 #define CESTER_REGISTER_BEFORE_ALL() cester_register_test("cester_before_all_test", (cester_before_all_test), CESTER_NULL, CESTER_NULL, __LINE__, CESTER_BEFORE_ALL_TEST)
3727 
3732 #define CESTER_REGISTER_BEFORE_EACH() cester_register_test("cester_before_each_test", CESTER_NULL, (cester_before_each_test), CESTER_NULL, __LINE__, CESTER_BEFORE_EACH_TEST)
3733 
3738 #define CESTER_REGISTER_AFTER_ALL() cester_register_test("cester_after_all_test", (cester_after_all_test), CESTER_NULL, CESTER_NULL, __LINE__, CESTER_AFTER_ALL_TEST)
3739 
3744 #define CESTER_REGISTER_AFTER_EACH() cester_register_test("cester_after_each_test", CESTER_NULL, (cester_after_each_test), CESTER_NULL, __LINE__, CESTER_AFTER_EACH_TEST)
3745 
3750 #define CESTER_REGISTER_OPTIONS() cester_register_test("cester_options_before_main", CESTER_NULL, CESTER_NULL, (cester_options_before_main), __LINE__, CESTER_OPTIONS_FUNCTION)
3751 
3756 #define CESTER_REGISTER_COMMENT() cester_register_test("cester_test_file_comment_function", CESTER_NULL, CESTER_NULL, (cester_test_file_comment_function), __LINE__, CESTER_OPTIONS_FUNCTION)
3757 
3764 #define CESTER_TEST_SHOULD(x,y) cester_expected_test_result(#x, y);
3765 
3773 #define CESTER_TEST_SHOULD_SEGFAULT(x) CESTER_TEST_SHOULD(x, CESTER_RESULT_SEGFAULT);
3774 
3782 #define CESTER_TEST_SHOULD_FAIL(x) CESTER_TEST_SHOULD(x, CESTER_RESULT_FAILURE);
3783 
3790 #define CESTER_TEST_SHOULD_BE_TERMINATED(x) CESTER_TEST_SHOULD(x, CESTER_RESULT_TERMINATED);
3791 
3802 #define CESTER_TEST_SHOULD_NOT_RELEASE_STREAM(x) CESTER_TEST_SHOULD(x, CESTER_RESULT_UNRELEASED_STREAM);
3803 
3804 #ifndef CESTER_NO_MEM_TEST
3805 
3811 #define CESTER_TEST_SHOULD_LEAK_MEMORY(x) CESTER_TEST_SHOULD(x, CESTER_RESULT_MEMORY_LEAK);
3812 #else
3813 #define CESTER_TEST_SHOULD_LEAK_MEMORY(x)
3814 #endif
3815 
3816 #if !defined(__unix__) && !defined(__unix) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(_WIN32)
3817  #pragma message("Stream capture not supported on this platform, open an issue on the github repo with the platform details")
3818 #endif
3819 
3820 #ifndef CESTER_NO_STREAM_CAPTURE
3821 
3828 static void cester_set_captured_streams_tmp_folder(char *path1, char *fallback_path) {
3829  struct stat st = {0};
3830  if (path1) {
3832  } else {
3834  }
3835 #if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(_WIN32)
3837  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Unable to create the temp folder '");
3839  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "' stream capture tests might fail\n");
3840  }
3841 #endif
3842 }
3843 
3850 #define CESTER_CHANGE_STREAM_CAPTURE_TM_FOLDER(x) cester_set_captured_streams_tmp_folder(x, CESTER_NULL)
3851 
3866 static void cester_capture_stream(FILE *stream, char const* const file_path, unsigned const line_num) {
3868  char *replaced_stream_file_path = (char *) "";
3869  FILE *replaced_stream = CESTER_NULL;
3870  struct stat st = {0};
3871 
3872  if (superTestInstance.stream_capture_active == 0) return;
3874  if (cester_array_init(&superTestInstance.captured_streams) == 0) {
3877  cester_ptr_to_str(&(superTestInstance.output_stream_str), stdout);
3879  }
3880  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Unable to initialize the captured stream array. Input and Output Stream test disabled.\n");
3881  return;
3882  }
3883  }
3884 #if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(_WIN32)
3885  if (stat(superTestInstance.captured_streams_tmp_folder, &st) == -1) {
3886  cester_print_test_case_message("StreamCaptureWarning", "", file_path, line_num);
3887  cester_concat_str(&superTestInstance.current_test_case->execution_output, "Unable to capture the stream because temp folder '");
3889  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' cannot be created.\n");
3890  return;
3891  }
3892 #else
3893  cester_print_test_case_message("StreamCaptureWarning", "", file_path, line_num);
3894  cester_concat_str(&superTestInstance.current_test_case->execution_output, "Unable to capture the stream because this platform ");
3895  cester_concat_str(&superTestInstance.current_test_case->execution_output, "is currently not supported, open an issue on the github ");
3896  cester_concat_str(&superTestInstance.current_test_case->execution_output, "repo with this platform detail.\n");
3897  return;
3898 #endif
3899  cester_concat_str(&replaced_stream_file_path, superTestInstance.captured_streams_tmp_folder);
3900  cester_concat_str(&replaced_stream_file_path, "/");
3901  cester_concat_ptr(&replaced_stream_file_path, stream);
3902  cester_concat_str(&replaced_stream_file_path, ".txt");
3903  replaced_stream = fopen(replaced_stream_file_path, "w+");
3904  if (!captured_stream || replaced_stream == CESTER_NULL) {
3905  cester_print_test_case_message("StreamCaptureWarning", "", file_path, line_num);
3906  cester_concat_str(&superTestInstance.current_test_case->execution_output, "Unable to capture the stream '");
3907  cester_concat_ptr(&superTestInstance.current_test_case->execution_output, stream);
3908  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' due to memory allocation error, all assertion will fail for the stream.\n");
3909  goto cester_capture_stream_cleanup;
3910  return;
3911  }
3912  captured_stream->line_num = line_num;
3913  captured_stream->original_stream = *stream;
3915  captured_stream->replaced_stream_handle = replaced_stream;
3916  captured_stream->replaced_stream_file_path = replaced_stream_file_path;
3919  cester_ptr_to_str(&(captured_stream->original_stream_ptr_str), stream);
3920  cester_ptr_to_str(&(captured_stream->replaced_stream_ptr_str), replaced_stream);
3921  if (cester_array_add(superTestInstance.captured_streams, captured_stream) == 0) {
3922  cester_print_test_case_message("StreamCaptureWarning", "", file_path, line_num);
3923  cester_concat_str(&superTestInstance.current_test_case->execution_output, "Unable to capture the stream '");
3924  cester_concat_ptr(&superTestInstance.current_test_case->execution_output, stream);
3925  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' all assertion will fail for the stream.\n");
3926  goto cester_capture_stream_cleanup;
3927  return;
3928  }
3930  return;
3931 
3932  cester_capture_stream_cleanup:
3933  if (replaced_stream != CESTER_NULL) {
3934  fclose(replaced_stream);
3935  if (remove(replaced_stream_file_path)) {
3936  cester_print_test_case_message("StreamCaptureCleanupWarning", "", file_path, line_num);
3937  cester_concat_str(&superTestInstance.current_test_case->execution_output, "Failed to delete residual stream file '");
3938  cester_concat_str(&superTestInstance.current_test_case->execution_output, replaced_stream_file_path);
3939  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' manually delete it from your file system.\n");
3940  }
3941  }
3942  if (captured_stream) {
3944  }
3945 }
3946 
3962 static void cester_release_captured_stream(FILE *stream, CapturedStream *captured_stream, char const* const file_path, unsigned const line_num) {
3963  if (superTestInstance.stream_capture_active == 0) return;
3964  if (stream != CESTER_NULL) {
3965  fflush(stream);
3968  cester_print_test_case_message("StreamCaptureCleanupWarning", "", file_path, line_num);
3969  cester_concat_str(&superTestInstance.current_test_case->execution_output, "Failed to delete residual stream file '");
3971  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' manually delete it from your file system.\n");
3972  }
3973  *stream = captured_stream->original_stream;
3974  }
3977  }
3982 }
3983 
3992 static void cester_reset_stream(FILE *stream, char const* const file_path, unsigned const line_num) {
3993  size_t index;
3994  char *stream_ptr_str;
3995 
3996  if (superTestInstance.stream_capture_active == 0) return;
3998  goto cester_reset_stream_cleanup;
3999  }
4000  cester_ptr_to_str(&stream_ptr_str, stream);
4002  CESTER_ARRAY_FOREACH(superTestInstance.captured_streams, index, captured_stream_, {
4003  CapturedStream *captured_stream;
4004  if (captured_stream_ != CESTER_NULL) {
4005  captured_stream = (CapturedStream *) captured_stream_;
4006  if (cester_string_equals(captured_stream->original_stream_ptr_str, stream_ptr_str) == 1) {
4007  if (stream != CESTER_NULL) {
4008  fclose(captured_stream->replaced_stream_handle);
4009  captured_stream->replaced_stream_handle = fopen(captured_stream->replaced_stream_file_path, "w+");
4010  *stream = *(captured_stream->replaced_stream_handle);
4011  captured_stream->line_num = line_num;
4012  }
4013  cester_meta_free(stream_ptr_str);
4014  return;
4015  }
4016  }
4017  })
4018  }
4019  cester_reset_stream_cleanup:
4020  cester_print_test_case_message("StreamCaptureWarning", "", file_path, line_num);
4021  cester_concat_str(&superTestInstance.current_test_case->execution_output, "No stream with the pointer address '");
4022  cester_concat_str(&superTestInstance.current_test_case->execution_output, stream_ptr_str);
4023  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' captured so nothing is reset \n");
4024  cester_meta_free(stream_ptr_str);
4025 }
4026 
4037 static char *cester_stream_content(FILE *stream, char const* const file_path, unsigned const line_num) {
4038  size_t index;
4039  size_t length;
4040  char *stream_ptr_str;
4041 
4043  return (char *) "";
4044  }
4045  cester_ptr_to_str(&stream_ptr_str, stream);
4047  CESTER_ARRAY_FOREACH(superTestInstance.captured_streams, index, captured_stream_, {
4048  CapturedStream *captured_stream;
4049  if (captured_stream_ != CESTER_NULL) {
4050  captured_stream = (CapturedStream *) captured_stream_;
4051  if (cester_string_equals(captured_stream->original_stream_ptr_str, stream_ptr_str) == 1) {
4052  if (stream != CESTER_NULL) {
4053  fflush(stream);
4054  fseek(captured_stream->replaced_stream_handle, 0, SEEK_END);
4055  length = ftell(captured_stream->replaced_stream_handle);
4056  fseek(captured_stream->replaced_stream_handle, 0, SEEK_SET);
4057  if (captured_stream->stream_buffer != CESTER_NULL) {
4058  cester_meta_free(captured_stream->stream_buffer);
4059  }
4060  captured_stream->stream_buffer = (char *) malloc(length+1);
4061  if (captured_stream->stream_buffer) {
4062  length = fread(captured_stream->stream_buffer, 1, length, captured_stream->replaced_stream_handle);
4063  captured_stream->stream_buffer[length] = '\0';
4064  }
4065  cester_meta_free(stream_ptr_str);
4066  return captured_stream->stream_buffer;
4067  }
4068  cester_meta_free(stream_ptr_str);
4069  return (char *) "";
4070  }
4071  }
4072  })
4073  }
4074  cester_meta_free(stream_ptr_str);
4075  return (char *) "";
4076 }
4077 
4089 static void cester_release_stream(FILE *stream, char const* const file_path, unsigned const line_num) {
4090  size_t index;
4091  char *stream_ptr_str;
4092 
4093  if (superTestInstance.stream_capture_active == 0) return;
4095  goto cester_release_stream_cleanup;
4096  }
4097  cester_ptr_to_str(&stream_ptr_str, stream);
4099  CESTER_ARRAY_FOREACH(superTestInstance.captured_streams, index, captured_stream_, {
4100  CapturedStream *captured_stream;
4101  if (captured_stream_ != CESTER_NULL) {
4102  captured_stream = (CapturedStream *) captured_stream_;
4103  if (cester_string_equals(captured_stream->original_stream_ptr_str, stream_ptr_str) == 1) {
4104  if (cester_array_remove_at(superTestInstance.captured_streams, index) == CESTER_NULL) {
4105  cester_print_test_case_message("StreamCaptureCleanupWarning", "", file_path, line_num);
4106  cester_concat_str(&superTestInstance.current_test_case->execution_output, "Failed to remove captured stream with pointer address '");
4107  cester_concat_str(&superTestInstance.current_test_case->execution_output, stream_ptr_str);
4108  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' from captured stream array, expect non breaking issues.\n");
4109  }
4110  cester_meta_free(stream_ptr_str);
4111  cester_release_captured_stream(stream, captured_stream, file_path, line_num);
4112  captured_stream = CESTER_NULL;
4113  return;
4114  }
4115  }
4116  })
4117  }
4118  cester_release_stream_cleanup:
4119  cester_print_test_case_message("StreamCaptureWarning", "", file_path, line_num);
4120  cester_concat_str(&superTestInstance.current_test_case->execution_output, "No stream with the pointer address '");
4121  cester_concat_str(&superTestInstance.current_test_case->execution_output, stream_ptr_str);
4122  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' captured so nothing is realeased \n");
4123  cester_meta_free(stream_ptr_str);
4124 }
4125 
4135 static unsigned release_forgotten_captured_streams(TestCase *test_case) {
4136  size_t index;
4137  unsigned unreleased_stream_count = 0;
4138 
4140  goto release_forgotten_captured_streams_cleanup;
4141  }
4142  CESTER_ARRAY_FOREACH(superTestInstance.captured_streams, index, captured_stream_, {
4143  CapturedStream *captured_stream = (CapturedStream *) captured_stream_;
4144  if (captured_stream == CESTER_NULL) {
4145  continue;
4146  }
4148  fflush(superTestInstance.output_stream);
4149  *(superTestInstance.output_stream) = superTestInstance.output_stream_address;
4150  }
4151  if (captured_stream != CESTER_NULL && cester_string_equals(captured_stream->function_name, test_case->name) == 1) {
4152  unreleased_stream_count++;
4153  cester_print_test_case_message("StreamCaptureError", "", superTestInstance.test_file_path, captured_stream->line_num);
4154  cester_concat_str(&test_case->execution_output, "You forgot to realease the stream '");
4155  cester_concat_str(&test_case->execution_output, captured_stream->original_stream_ptr_str);
4156  cester_concat_str(&test_case->execution_output, "' captured in line ");
4157  cester_concat_int(&test_case->execution_output, captured_stream->line_num);
4158  cester_concat_str(&test_case->execution_output, "\n");
4159  };
4160  if (cester_array_remove_at(superTestInstance.captured_streams, index) == CESTER_NULL) {
4161  cester_print_test_case_message("StreamCaptureCleanupWarning", "", superTestInstance.test_file_path, captured_stream->line_num);
4162  cester_concat_str(&superTestInstance.current_test_case->execution_output, "Failed to remove captured stream with pointer address '");
4163  cester_concat_str(&superTestInstance.current_test_case->execution_output, captured_stream->original_stream_ptr_str);
4164  cester_concat_str(&superTestInstance.current_test_case->execution_output, "' from captured stream array, expect non breaking issues.\n");
4165  } else {
4166  index--;
4167  }
4170  })
4171  release_forgotten_captured_streams_cleanup:
4172  return unreleased_stream_count;
4173 }
4174 
4178 #define CESTER_CAPTURE_STREAM(x) cester_capture_stream(x, __FILE__, __LINE__)
4179 
4183 #define CESTER_STREAM_CONTENT(x) cester_stream_content(x, __FILE__, __LINE__)
4184 
4188 #define CESTER_RESET_STREAM(x) cester_reset_stream(x, __FILE__, __LINE__)
4189 
4193 #define CESTER_RELEASE_STREAM(x) cester_release_stream(x, __FILE__, __LINE__)
4194 
4199 #define CESTER_CAPTURE_STDIN() CESTER_CAPTURE_STREAM(stdin)
4200 
4204 #define CESTER_STDIN_CONTENT() CESTER_STREAM_CONTENT(stdin)
4205 
4209 #define CESTER_RESET_STDIN() CESTER_RESET_STREAM(stdin)
4210 
4215 #define CESTER_RELEASE_STDIN() CESTER_RELEASE_STREAM(stdin)
4216 
4221 #define CESTER_CAPTURE_STDOUT() CESTER_CAPTURE_STREAM(stdout)
4222 
4226 #define CESTER_STDOUT_CONTENT() CESTER_STREAM_CONTENT(stdout)
4227 
4231 #define CESTER_RESET_STDOUT() CESTER_RESET_STREAM(stdout)
4232 
4237 #define CESTER_RELEASE_STDOUT() CESTER_RELEASE_STREAM(stdout)
4238 
4242 #define CESTER_CAPTURE_STDERR() CESTER_CAPTURE_STREAM(stderr)
4243 
4247 #define CESTER_STDERR_CONTENT() CESTER_STREAM_CONTENT(stderr)
4248 
4252 #define CESTER_RESET_STDERR() CESTER_RESET_STREAM(stderr)
4253 
4257 #define CESTER_RELEASE_STDERR() CESTER_RELEASE_STREAM(stderr)
4258 
4265 #define cester_assert_stream_content_equal(x,y) cester_assert_str_equal(CESTER_STREAM_CONTENT(x), y)
4266 
4273 #define cester_assert_stream_content_contain(x, y) cester_assert_true(cester_string_contains(CESTER_STREAM_CONTENT(x), y))
4274 
4281 #define cester_assert_stream_content_not_equal(x,y) cester_assert_str_not_equal(CESTER_STREAM_CONTENT(x), y)
4282 
4289 #define cester_assert_stream_content_not_contain(x, y) cester_assert_false(cester_string_contains(CESTER_STREAM_CONTENT(x), y))
4290 
4294 #define cester_assert_stdin_stream_content_equal(y) cester_assert_str_equal(CESTER_STDIN_CONTENT(), y)
4295 
4299 #define cester_assert_stdin_stream_content_contain(y) cester_assert_true(cester_string_contains(CESTER_STDIN_CONTENT(), y))
4300 
4304 #define cester_assert_stdin_stream_content_not_equal(y) cester_assert_str_not_equal(CESTER_STDIN_CONTENT(), y)
4305 
4309 #define cester_assert_stdin_stream_content_not_contain(y) cester_assert_false(cester_string_contains(CESTER_STDIN_CONTENT(), y))
4310 
4314 #define cester_assert_stdout_stream_content_equal(y) cester_assert_str_equal(CESTER_STDOUT_CONTENT(), y)
4315 
4319 #define cester_assert_printf_equal cester_assert_stdout_stream_content_equal
4320 
4324 #define cester_assert_stdout_stream_content_contain(y) cester_assert_true(cester_string_contains(CESTER_STDOUT_CONTENT(), y))
4325 
4329 #define cester_assert_printf_contain cester_assert_stdout_stream_content_contain
4330 
4334 #define cester_assert_stdout_stream_content_not_equal(y) cester_assert_str_not_equal(CESTER_STDOUT_CONTENT(), y)
4335 
4339 #define cester_assert_printf_not_equal cester_assert_stdout_stream_content_not_equal
4340 
4344 #define cester_assert_stdout_stream_content_not_contain(y) cester_assert_false(cester_string_contains(CESTER_STDOUT_CONTENT(), y))
4345 
4349 #define cester_assert_printf_not_contain cester_assert_stdout_stream_content_not_contain
4350 
4354 #define cester_assert_stderr_stream_content_equal(y) cester_assert_str_equal(CESTER_STDERR_CONTENT(), y)
4355 
4359 #define cester_assert_stderr_stream_content_contain(y) cester_assert_true(cester_string_contains(CESTER_STDERR_CONTENT(), y))
4360 
4364 #define cester_assert_stderr_stream_content_not_equal(y) cester_assert_str_not_equal(CESTER_STDERR_CONTENT(), y)
4365 
4369 #define cester_assert_stderr_stream_content_not_contain(y) cester_assert_false(cester_string_contains(CESTER_STDERR_CONTENT(), y))
4370 
4371 #else
4372 
4373 /* Empty Shells for the stream capturing feature to keep the
4374  test file valid still */
4375 
4376 #define CESTER_CAPTURE_STREAM(x)
4377 #define CESTER_STREAM_CONTENT(x)
4378 #define CESTER_RESET_STREAM(x)
4379 #define CESTER_RELEASE_STREAM(x)
4380 #define CESTER_CAPTURE_STDIN() CESTER_CAPTURE_STREAM(stdin)
4381 #define CESTER_STDIN_CONTENT() CESTER_STREAM_CONTENT(stdin)
4382 #define CESTER_RESET_STDIN() CESTER_RESET_STREAM(stdin)
4383 #define CESTER_RELEASE_STDIN() CESTER_RELEASE_STREAM(stdin)
4384 #define CESTER_CAPTURE_STDOUT() CESTER_CAPTURE_STREAM(stdout)
4385 #define CESTER_STDOUT_CONTENT() CESTER_STREAM_CONTENT(stdout)
4386 #define CESTER_RESET_STDOUT() CESTER_RESET_STREAM(stdout)
4387 #define CESTER_RELEASE_STDOUT() CESTER_RELEASE_STREAM(stdout)
4388 #define CESTER_CAPTURE_STDERR() CESTER_CAPTURE_STREAM(stderr)
4389 #define CESTER_STDERR_CONTENT() CESTER_STREAM_CONTENT(stderr)
4390 #define CESTER_RESET_STDERR() CESTER_RESET_STREAM(stderr)
4391 #define CESTER_RELEASE_STDERR() CESTER_RELEASE_STREAM(stderr)
4392 #define cester_assert_stream_content_equal(x,y)
4393 #define cester_assert_stream_content_contain(x, y)
4394 #define cester_assert_stream_content_not_equal(x,y)
4395 #define cester_assert_stream_content_not_contain(x, y)
4396 #define cester_assert_stdin_stream_content_equal(y)
4397 #define cester_assert_stdin_stream_content_contain(y)
4398 #define cester_assert_stdin_stream_content_not_equal(y)
4399 #define cester_assert_stdin_stream_content_not_contain(y)
4400 #define cester_assert_stdout_stream_content_equal(y)
4401 #define cester_assert_printf_equal cester_assert_stdout_stream_content_equal
4402 #define cester_assert_stdout_stream_content_contain(y)
4403 #define cester_assert_printf_contain cester_assert_stdout_stream_content_contain
4404 #define cester_assert_stdout_stream_content_not_equal(y)
4405 #define cester_assert_printf_not_equal cester_assert_stdout_stream_content_not_equal
4406 #define cester_assert_stdout_stream_content_not_contain(y)
4407 #define cester_assert_printf_not_contain cester_assert_stdout_stream_content_not_contain
4408 #define cester_assert_stderr_stream_content_equal(y)
4409 #define cester_assert_stderr_stream_content_contain(y)
4410 #define cester_assert_stderr_stream_content_not_equal(y)
4411 #define cester_assert_stderr_stream_content_not_contain(y)
4412 
4413 #endif
4414 
4418 static __CESTER_INLINE__ void cester_register_test(char *test_name, cester_test f1, cester_before_after_each f2, cester_void f3, unsigned line_num, TestType test_type) {
4419  TestCase* test_case ;
4421  if (cester_array_init(&superTestInstance.registered_test_cases) == 0) {
4424 #ifndef CESTER_NO_STREAM_CAPTURE
4425  cester_ptr_to_str(&(superTestInstance.output_stream_str), stdout);
4427 #endif
4428  }
4429  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Unable to initialize the test cases array. Cannot run manually registered tests.\n");
4431  return;
4432  }
4433  }
4434  test_case = (TestCase*) malloc(sizeof(TestCase));
4435  if (!test_case) {
4436  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "memory allocation error: Unable to register the test case '");
4440  return;
4441  }
4443  test_case->line_num = line_num;
4445  #ifndef CESTER_NO_TIME
4446  test_case->start_tic = 0.000;
4447  test_case->execution_time = 0.000;
4448  #endif
4449  test_case->execution_output = (char*) "";
4450  test_case->test_function = f1;
4453  test_case->name = test_name;
4454  test_case->test_type = test_type;
4455  if (cester_array_add(superTestInstance.registered_test_cases, test_case) == 0) {
4458 #ifndef CESTER_NO_STREAM_CAPTURE
4459  cester_ptr_to_str(&(superTestInstance.output_stream_str), stdout);
4461 #endif
4462  }
4464  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Failed to register '");
4469  }
4470 }
4471 
4472 static __CESTER_INLINE__ void cester_expected_test_result(const char* const test_name, enum cester_test_status expected_result) {
4473  unsigned i,index;
4475  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
4476  if ((cester_test_cases[i].test_type == CESTER_NORMAL_TEST ||
4477  cester_test_cases[i].test_type == CESTER_NORMAL_TODO_TEST ||
4478  cester_test_cases[i].test_type == CESTER_NORMAL_SKIP_TEST) &&
4479  cester_string_equals(cester_test_cases[i].name, (char*)test_name) == 1) {
4480 
4481  cester_test_cases[i].expected_result = expected_result;
4482  }
4483 
4484  }
4485  }
4486 
4488  if ((((TestCase*)test_case)->test_type == CESTER_NORMAL_TEST ||
4489  ((TestCase*)test_case)->test_type == CESTER_NORMAL_TODO_TEST ||
4490  ((TestCase*)test_case)->test_type == CESTER_NORMAL_SKIP_TEST) &&
4491  cester_string_equals(((TestCase*)test_case)->name, (char*)test_name) == 1) {
4492 
4493  ((TestCase*)test_case)->expected_result = expected_result;
4494  }
4495  })
4496 }
4497 
4498 static __CESTER_INLINE__ unsigned cester_run_test_no_isolation(TestInstance *, TestCase *, unsigned);
4499 
4500 static __CESTER_INLINE__ void cester_report_single_test_result(unsigned last_status, TestCase *a_test_case) {
4501  char *cleaned_name = (superTestInstance.verbose_level >= 4 ? superTestInstance.test_file_path : cester_extract_name(superTestInstance.test_file_path) );
4502  #ifndef CESTER_NO_TIME
4503  clock_t tok ;
4504 
4505  tok = clock();
4506  a_test_case->execution_time = (double)(((double)tok) - ((double)a_test_case->start_tic)) / CLOCKS_PER_SEC;
4507  #endif
4508  if ((a_test_case->expected_result == last_status || a_test_case->expected_result == CESTER_RESULT_FAILURE) &&
4509  (last_status != CESTER_RESULT_SUCCESS)) {
4510 
4511  a_test_case->execution_status = CESTER_RESULT_SUCCESS;
4512  cester_concat_str(&a_test_case->execution_output, "Passed ");
4513  cester_concat_str(&a_test_case->execution_output, cleaned_name);
4514  cester_concat_str(&a_test_case->execution_output, ":");
4515  cester_concat_int(&a_test_case->execution_output, a_test_case->line_num);
4516  cester_concat_str(&a_test_case->execution_output, ":");
4517  cester_concat_str(&a_test_case->execution_output, " in '");
4518  cester_concat_str(&a_test_case->execution_output, a_test_case->name);
4519  cester_concat_str(&a_test_case->execution_output, "'");
4520  if (superTestInstance.verbose_level >= 2) {
4521  cester_concat_str(&a_test_case->execution_output, " => ");
4522  switch (a_test_case->expected_result) {
4523  case CESTER_RESULT_FAILURE:
4524  cester_concat_str(&a_test_case->execution_output, "Failed as expected");
4525  break;
4527  cester_concat_str(&a_test_case->execution_output, "Segfault as expected");
4528  break;
4530  cester_concat_str(&a_test_case->execution_output, "Prematurely terminated as expected");
4531  break;
4533  cester_concat_str(&a_test_case->execution_output, "Timed out as expected");
4534  break;
4536  cester_concat_str(&a_test_case->execution_output, "Have unreleased stream as expected (ARE YOU SERIOUS? BAD IDEA!!!!)");
4537  break;
4538 #ifndef CESTER_NO_MEM_TEST
4540  cester_concat_str(&a_test_case->execution_output, "Leaked memory as expected");
4541  break;
4542 #endif
4543  case CESTER_RESULT_SUCCESS:
4544  case CESTER_RESULT_UNKNOWN:
4545  break;
4546  }
4547  }
4548  cester_concat_str(&a_test_case->execution_output, "\n");
4549 
4550  } else if (a_test_case->expected_result != last_status && a_test_case->expected_result != CESTER_RESULT_SUCCESS) {
4551  a_test_case->execution_status = last_status;
4552  cester_concat_str(&a_test_case->execution_output, "ResultError ");
4553  cester_concat_str(&a_test_case->execution_output, cleaned_name);
4554  cester_concat_str(&a_test_case->execution_output, ":");
4555  cester_concat_int(&a_test_case->execution_output, a_test_case->line_num);
4556  cester_concat_str(&a_test_case->execution_output, ":");
4557  cester_concat_str(&a_test_case->execution_output, " in '");
4558  cester_concat_str(&a_test_case->execution_output, a_test_case->name);
4559  cester_concat_str(&a_test_case->execution_output, "'");
4560  if (superTestInstance.verbose_level >= 2) {
4561  cester_concat_str(&a_test_case->execution_output, " => ");
4562  switch (a_test_case->expected_result) {
4563  case CESTER_RESULT_FAILURE:
4564  cester_concat_str(&a_test_case->execution_output, "Expected to Fail but passed");
4565  break;
4567  cester_concat_str(&a_test_case->execution_output, "Expected to Segfault but passed");
4568  break;
4570  cester_concat_str(&a_test_case->execution_output, "Expected to be Prematurely terminated but exit gracefully");
4571  break;
4573  cester_concat_str(&a_test_case->execution_output, "Expected to Time out but ends in time");
4574  break;
4576  cester_concat_str(&a_test_case->execution_output, "Expected to have unreleased stream but all streams were released");
4577  break;
4578  #ifndef CESTER_NO_MEM_TEST
4580  cester_concat_str(&a_test_case->execution_output, "Expected to Leak memory but no memory was leaked");
4581  break;
4582  #endif
4583  case CESTER_RESULT_SUCCESS:
4584  case CESTER_RESULT_UNKNOWN:
4585  break;
4586  }
4587  }
4588  cester_concat_str(&a_test_case->execution_output, "\n");
4589  } else {
4590  a_test_case->execution_status = last_status;
4591  }
4592  if (a_test_case->execution_status == CESTER_RESULT_SUCCESS) {
4594  } else {
4596  }
4599  } else {
4601  }
4602  if (superTestInstance.verbose_level < 4) {
4603  cester_meta_free(cleaned_name);
4604  }
4605 }
4606 
4607 static __CESTER_INLINE__ void cester_run_test(TestInstance *test_instance, TestCase *a_test_case, unsigned index) {
4608  unsigned last_status;
4609 
4610  last_status = CESTER_RESULT_UNKNOWN;
4611 #ifndef CESTER_NO_SIGNAL
4612  if (setjmp(buf) == 1) {
4613  goto check_isolation;
4614  }
4615 #endif
4616 #ifndef CESTER_NO_TIME
4617  a_test_case->start_tic = clock();
4618 #endif
4619 #ifndef __CESTER_STDC_VERSION__
4620  #pragma message("Isolated tests not supported in C version less than C99 and C++ version less than C++11. cester will rely on signal for crash reporting")
4622 #endif
4623  if (superTestInstance.isolate_tests == 1 && last_status == CESTER_RESULT_UNKNOWN) {
4624 #ifdef __CESTER_STDC_VERSION__
4625 #if defined(_WIN32) && !defined(CESTER_EXCLUDE_WINDOWS_H)
4626  HANDLE stdout_pipe_read;
4627  HANDLE stdout_pipe_write;
4628  SECURITY_ATTRIBUTES sa;
4629  sa.nLength = sizeof(SECURITY_ATTRIBUTES);
4630  sa.bInheritHandle = TRUE;
4631  sa.lpSecurityDescriptor = CESTER_NULL;
4632 
4633  CreatePipe(&stdout_pipe_read, &stdout_pipe_write, &sa, 0);
4634 #ifdef __cplusplus
4635  PROCESS_INFORMATION pi;
4636  STARTUPINFO si;
4637  si = {
4638  .cb = sizeof(STARTUPINFO),
4639  .dwFlags = STARTF_USESTDHANDLES,
4640  .hStdOutput = stdout_pipe_write
4641  };
4642  pi = {0};
4643 #else
4644  STARTUPINFO si = {
4645  .cb = sizeof(STARTUPINFO),
4646  .dwFlags = STARTF_USESTDHANDLES,
4647  .hStdOutput = stdout_pipe_write
4648  };
4649  PROCESS_INFORMATION pi = {0};
4650 #endif
4651 
4652 
4653 
4654  CHAR command[1500];
4655  snprintf(command, 1500, "%s --cester-test=%s --cester-singleoutput --cester-noisolation --cester-verbose-level=%d %s %s %s %s %s %s",
4656  test_instance->argv[0],
4657  a_test_case->name,
4659  (superTestInstance.mem_test_active == 0 ? "--cester-nomemtest" : ""),
4660  (superTestInstance.format_test_name == 1 ? "--cester-dontformatname" : ""),
4661  (superTestInstance.stream_capture_active == 0 ? "--cester-nostreamcapture" : ""),
4662  (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1 ? "--cester-output=tap" : ""),
4663  (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1 ? "--cester-output=tapV13" : ""),
4665 
4666  CreateProcess(
4667  CESTER_NULL,
4668  command,
4669  CESTER_NULL,
4670  CESTER_NULL,
4671  TRUE,
4672  0,
4673  CESTER_NULL,
4674  CESTER_NULL,
4675  &si,
4676  &pi);
4677 
4678  CloseHandle(stdout_pipe_write);
4679 
4680  DWORD len;
4681  DWORD maxlen;
4682  CHAR buffer[700];
4683 
4684  maxlen = 700;
4685  do {
4686  ReadFile(stdout_pipe_read, buffer, maxlen, &len, CESTER_NULL);
4687  buffer[len] = '\0';
4688  cester_concat_str(&a_test_case->execution_output, buffer);
4689  } while (len > 0);
4690 
4691  WaitForSingleObject(pi.hProcess, INFINITE);
4692 
4693  DWORD status;
4694  GetExitCodeProcess(pi.hProcess, &status);
4695 
4696  if ((status & 0x80000000)) {
4697  last_status = CESTER_RESULT_SEGFAULT;
4698  } else if (status == 1 && strlen(a_test_case->execution_output) == 0) {
4699  last_status = CESTER_RESULT_TERMINATED;
4700  } else {
4701  last_status = status;
4702  }
4703 
4704  end_sub_process:
4705  CloseHandle(pi.hProcess);
4706  CloseHandle(pi.hThread);
4707 #elif defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
4708  pid_t pid;
4709  int pipefd[2];
4710  char *selected_test_unix;
4711  char *verbose_level_str;
4712 
4713  pipe(pipefd);
4714  pid = fork();
4715 
4716  if (pid == -1) {
4717  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Unable to create a seperate process for the '");
4719  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "'. Running the test on main process.");
4720  last_status = cester_run_test_no_isolation(test_instance, a_test_case, index);
4721 
4722  } else if (pid == 0) {
4723  selected_test_unix = (char*) "";
4724  verbose_level_str = (char *) "";
4725  cester_concat_str(&selected_test_unix, "--cester-test=");
4726  cester_concat_str(&selected_test_unix, a_test_case->name);
4727  cester_concat_str(&verbose_level_str, "--cester-verbose-level=");
4728  cester_concat_int(&verbose_level_str, superTestInstance.verbose_level);
4729 
4730  close(pipefd[0]);
4731  dup2(pipefd[1], STDOUT_FILENO);
4732  execl(test_instance->argv[0],
4733  test_instance->argv[0],
4734  selected_test_unix,
4735  "--cester-singleoutput",
4736  "--cester-noisolation",
4737  verbose_level_str,
4738  (superTestInstance.mem_test_active == 0 ? "--cester-nomemtest" : ""),
4739  (superTestInstance.format_test_name == 1 ? "--cester-dontformatname" : ""),
4740  (superTestInstance.stream_capture_active == 0 ? "--cester-nostreamcapture" : ""),
4741  (superTestInstance.no_color == 1 ? "--cester-nocolor" : ""),
4742  (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1 ? "--cester-output=tap" : ""),
4743  (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1 ? "--cester-output=tapV13" : ""),
4745  (char*)CESTER_NULL);
4746  cester_meta_free(selected_test_unix);
4747  cester_meta_free(verbose_level_str);
4748  exit(CESTER_RESULT_FAILURE);
4749 
4750  } else {
4751  int status;
4752  char buffer[700];
4753  size_t len;
4754 
4755  close(pipefd[1]);
4756  while ((len = read(pipefd[0], buffer, 700)) != 0) {
4757  buffer[len] = '\0';
4758  cester_concat_str(&a_test_case->execution_output, buffer);
4759  }
4760  waitpid(pid, &status, 0);
4761  close(pipefd[0]);
4762  last_status = WEXITSTATUS(status);
4763  end_sub_process:
4764  kill(pid, SIGTERM);
4765  }
4766 #else
4767  #pragma message("Isolated tests not supported in this environment. The tests will be run on the main process")
4768  last_status = cester_run_test_no_isolation(test_instance, a_test_case, index);
4769 #define CESTER_NO_SUBPROCESS 1
4770 #endif
4771 #endif
4772  } else if (last_status == CESTER_RESULT_UNKNOWN) {
4773  last_status = cester_run_test_no_isolation(test_instance, a_test_case, index);
4774  }
4775  resolve_test_result:
4776  cester_report_single_test_result(last_status, a_test_case);
4777  return;
4778 
4779  check_isolation:
4781 #ifdef __CESTER_STDC_VERSION__
4782 #ifndef CESTER_NO_SUBPROCESS
4783  if (superTestInstance.isolate_tests == 1) {
4784  goto end_sub_process;
4785  }
4786 #endif
4787 #endif
4788  goto resolve_test_result;
4789 }
4790 
4791 static __CESTER_INLINE__ unsigned cester_run_test_no_isolation(TestInstance *test_instance, TestCase *a_test_case, unsigned index) {
4792  unsigned i, index1, index2, ret_val;
4793  char *prefix = (char *) "";
4796  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
4797  if (cester_test_cases[i].test_type == CESTER_BEFORE_EACH_TEST) {
4799  ((cester_before_after_each)cester_test_cases[i].test_ba_function)(test_instance, a_test_case->name, index);
4800  }
4801  }
4802  }
4804  if (((TestCase*)test_case)->test_type == CESTER_BEFORE_EACH_TEST) {
4805  superTestInstance.current_cester_function_type = CESTER_BEFORE_EACH_TEST;
4806  ((cester_before_after_each)((TestCase*)test_case)->test_ba_function)(test_instance, a_test_case->name, index);
4807  }
4808  })
4810  superTestInstance.current_test_case = a_test_case;
4811  ((cester_test)a_test_case->test_function)(test_instance);
4812  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1) {
4813  prefix = (char *) "# ";
4814 
4815  } else if (cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
4816  prefix = (char *) " - ";
4817 
4818  }
4819 
4820 #ifndef CESTER_NO_STREAM_CAPTURE
4821  if (release_forgotten_captured_streams(a_test_case) > 0) {
4823  }
4824 #endif
4825 #ifndef CESTER_NO_MEM_TEST
4826  if (check_memory_allocated_for_functions(a_test_case->name, CESTER_NULL, prefix, &(superTestInstance.current_test_case)->execution_output) > 0) {
4828  }
4829 #endif
4830 
4832  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
4833  if (cester_test_cases[i].test_type == CESTER_AFTER_EACH_TEST) {
4835  ((cester_before_after_each)cester_test_cases[i].test_ba_function)(test_instance, a_test_case->name, index);
4836  }
4837  }
4838  }
4840  if (((TestCase*)test_case)->test_type == CESTER_AFTER_EACH_TEST) {
4841  superTestInstance.current_cester_function_type = CESTER_AFTER_EACH_TEST;
4842  ((cester_before_after_each)((TestCase*)test_case)->test_ba_function)(test_instance, a_test_case->name, index);
4843  }
4844  })
4845  if (cester_string_equals(superTestInstance.output_format, (char*) "tap") == 1 ||
4846  cester_string_equals(superTestInstance.output_format, (char*) "tapV13") == 1) {
4847  prefix = (char *) "# ";
4848  }
4849 
4850 #ifndef CESTER_NO_MEM_TEST
4851  ret_val = check_memory_allocated_for_functions((char *)"CESTER_BEFORE_EACH", CESTER_NULL, prefix, &superTestInstance.main_execution_output);
4852  if (ret_val > 0) {
4854  }
4855 #endif
4856 
4860  }
4862 }
4863 
4864 #ifndef CESTER_NO_SIGNAL
4865 /*void (*signal(int , void (*)(int)))(int);*/
4866 void cester_capture_signals(void);
4867 void cester_recover_on_signal(int sig_num);
4868 #endif
4869 
4870 /* use start param to save the state index instead of starting
4871 loop again or super var */
4872 static __CESTER_INLINE__ void cester_run_all_test_iterator(int start) {
4873  unsigned i, j, index2, index3, test_index;
4874  unsigned found_test;
4875  char* selected_test_case_name;
4876 
4877  found_test = 0;
4878  test_index = 0;
4881  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
4882  if (cester_test_cases[i].test_type == CESTER_NORMAL_TEST && cester_test_cases[i].execution_status == CESTER_RESULT_UNKNOWN) {
4883  cester_run_test(superTestInstance.test_instance, &cester_test_cases[i], ++test_index);
4884 
4885  } else if (cester_test_cases[i].test_type == CESTER_NORMAL_TODO_TEST) {
4887 
4888  } else if (cester_test_cases[i].test_type == CESTER_NORMAL_SKIP_TEST) {
4890 
4891  }
4892  }
4893  }
4895  if (((TestCase*)test_case)->test_type == CESTER_NORMAL_TEST && ((TestCase*)test_case)->execution_status == CESTER_RESULT_UNKNOWN) {
4896  cester_run_test(superTestInstance.test_instance, ((TestCase*)test_case), ++test_index);
4897 
4898  } else if (((TestCase*)test_case)->test_type == CESTER_NORMAL_TODO_TEST) {
4900 
4901  } else if (((TestCase*)test_case)->test_type == CESTER_NORMAL_SKIP_TEST) {
4903 
4904  }
4905  })
4906 
4907  } else {
4909  selected_test_case_name = superTestInstance.selected_test_cases_names[j];
4910  found_test = 0;
4912  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
4913  if ((cester_test_cases[i].test_type == CESTER_NORMAL_TEST || cester_test_cases[i].test_type == CESTER_NORMAL_TODO_TEST ||
4914  cester_test_cases[i].test_type == CESTER_NORMAL_SKIP_TEST) &&
4915  cester_string_equals(cester_test_cases[i].name, selected_test_case_name) == 1 &&
4916  cester_test_cases[i].execution_status == CESTER_RESULT_UNKNOWN) {
4917 
4918  found_test = 1;
4919  if (cester_test_cases[i].test_type == CESTER_NORMAL_TEST) {
4921  cester_run_test(superTestInstance.test_instance, &cester_test_cases[i], ++test_index);
4922  } else {
4923  cester_test_cases[i].execution_status = CESTER_RESULT_SUCCESS;
4924  if (cester_test_cases[i].test_type == CESTER_NORMAL_SKIP_TEST) {
4926  } else {
4928  }
4929  }
4930  }
4931  }
4932  }
4933  if (found_test == 0) {
4935  if ((((TestCase*)test_case)->test_type == CESTER_NORMAL_TEST || ((TestCase*)test_case)->test_type == CESTER_NORMAL_TODO_TEST ||
4936  ((TestCase*)test_case)->test_type == CESTER_NORMAL_SKIP_TEST) &&
4937  cester_string_equals(((TestCase*)test_case)->name, selected_test_case_name) == 1 &&
4938  ((TestCase*)test_case)->execution_status == CESTER_RESULT_UNKNOWN) {
4939 
4940  found_test = 1;
4941  if (((TestCase*)test_case)->test_type == CESTER_NORMAL_TEST) {
4942  ++superTestInstance.selected_test_cases_found;
4943  cester_run_test(superTestInstance.test_instance, ((TestCase*)test_case), ++test_index);
4944  } else {
4945  ((TestCase*)test_case)->execution_status = CESTER_RESULT_SUCCESS;
4946  if (((TestCase*)test_case)->test_type == CESTER_NORMAL_SKIP_TEST) {
4947  ++superTestInstance.skipped_test_count;
4948  } else {
4949  ++superTestInstance.todo_tests_count;
4950  }
4951  }
4952  }
4953  })
4954  if (found_test == 0) {
4955  if (superTestInstance.verbose_level > 0 && cester_string_equals(superTestInstance.output_format, (char*) "text") == 1) {
4956  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Warning: the test case '");
4958  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "' was not found! \n");
4960  }
4961  }
4962  }
4963  }
4964  }
4965 }
4966 
4967 static void cester_cleanup_super_instance(void)
4968 {
4969  unsigned index;
4970 
4971 #ifndef CESTER_NO_MEM_TEST
4974  if (alloc_mem != CESTER_NULL) {
4975  cester_meta_free(alloc_mem);
4976  }
4977  if (cester_array_remove_at(superTestInstance.mem_alloc_manager, index) != CESTER_NULL) {
4978  index--;
4979  }
4980  });
4981  cester_array_destroy(superTestInstance.mem_alloc_manager);
4982  }
4983 #endif
4985  index = 0;
4987  if (strlen(((TestCase *)test_case)->execution_output) > 0) {
4988  cester_meta_free(((TestCase *)test_case)->execution_output);
4989  }
4991  if (cester_array_remove_at(superTestInstance.registered_test_cases, index) != CESTER_NULL) {
4992  index--;
4993  }
4994  })
4995  cester_array_destroy(superTestInstance.registered_test_cases);
4996  }
4998  index = 0;
4999  for (; index < superTestInstance.selected_test_cases_size; ++index) {
5001  }
5002  }
5005  }
5006 #ifndef CESTER_NO_STREAM_CAPTURE
5009  }
5010 #endif
5013  }
5014 }
5015 
5016 #ifndef CESTER_NO_PRINT_INFO
5017 
5021 #define CESTER_TEST_FUNTION_TYPE_TO_STRING(test_type) (test_type == CESTER_NORMAL_TEST ? "CESTER_NORMAL_TEST" :\
5022  (test_type == CESTER_NORMAL_TODO_TEST ? "CESTER_NORMAL_TODO_TEST" :\
5023  (test_type == CESTER_NORMAL_SKIP_TEST ? "CESTER_NORMAL_SKIP_TEST" :\
5024  (test_type == CESTER_BEFORE_ALL_TEST ? "CESTER_BEFORE_ALL_TEST" :\
5025  (test_type == CESTER_BEFORE_EACH_TEST ? "CESTER_BEFORE_EACH_TEST" :\
5026  (test_type == CESTER_AFTER_ALL_TEST ? "CESTER_AFTER_ALL_TEST" :\
5027  (test_type == CESTER_AFTER_EACH_TEST ? "CESTER_AFTER_EACH_TEST" :\
5028  (test_type == CESTER_OPTIONS_FUNCTION ? "CESTER_OPTIONS_FUNCTION" :\
5029  (test_type == CESTER_TEST_FILE_COMMENT ? "CESTER_TEST_FILE_COMMENT" : "CESTER_TESTS_TERMINATOR")))))))))
5030 
5034 #define CESTER_PRINT_TEST_FUNCTION(tab, text_prefix, test_case) if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {\
5035  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), "" tab "<function");\
5036  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_RED), " name=");\
5037  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"");\
5038  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), test_case.name);\
5039  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"");\
5040  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_RED), " line_number=");\
5041  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"");\
5042  CESTER_DELEGATE_FPRINT_INT((CESTER_FOREGROUND_MAGENTA), test_case.line_num);\
5043  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"");\
5044  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_RED), " type=");\
5045  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"");\
5046  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), CESTER_TEST_FUNTION_TYPE_TO_STRING(test_case.test_type));\
5047  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_MAGENTA), "\"");\
5048  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), "/>\n");\
5049  } else {\
5050  CESTER_DELEGATE_FPRINT(text_prefix); CESTER_DELEGATE_FPRINT(test_case.name);\
5051  if (!cester_string_equals(info_section, "all")) CESTER_DELEGATE_FPRINT("\n");\
5052  }
5053 
5059 static __CESTER_INLINE__ unsigned int cester_print_tests_information(char *info_section) {
5060  unsigned index;
5061  char *file_name = cester_extract_name_only(superTestInstance.test_file_path);
5062 
5063  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5080  }
5081  if (cester_string_equals(info_section, "all")) {
5082  if (cester_string_equals(superTestInstance.output_format, (char*) "text")) {
5083  CESTER_DELEGATE_FPRINT("cester v");
5085  CESTER_DELEGATE_FPRINT(" by ");
5087  CESTER_DELEGATE_FPRINT(".\n");
5088  }
5089 
5090  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5091  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " <options_and_comments");
5093  } else {
5094  CESTER_DELEGATE_FPRINT("\nOptions and Comments");
5095  }
5096  for (index = 0; cester_test_cases[index].test_type != CESTER_TESTS_TERMINATOR; ++index) {
5097  if (cester_test_cases[index].test_type == CESTER_OPTIONS_FUNCTION || cester_test_cases[index].test_type == CESTER_TEST_FILE_COMMENT) {
5098  CESTER_PRINT_TEST_FUNCTION(" ", "\n - ", cester_test_cases[index])
5099  }
5100  }
5101  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5102  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " </options_and_comments>\n");
5103  }
5104 
5105  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5106  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " <fixture_before");
5108  } else {
5109  CESTER_DELEGATE_FPRINT("\nFixture - Before");
5110  }
5111  for (index = 0; cester_test_cases[index].test_type != CESTER_TESTS_TERMINATOR; ++index) {
5112  if (cester_test_cases[index].test_type == CESTER_BEFORE_ALL_TEST || cester_test_cases[index].test_type == CESTER_BEFORE_EACH_TEST) {
5113  CESTER_PRINT_TEST_FUNCTION(" ", "\n - ", cester_test_cases[index])
5114  }
5115  }
5116  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5117  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " </fixture_before>\n");
5118  }
5119 
5120  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5121  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " <fixture_after");
5123  } else {
5124  CESTER_DELEGATE_FPRINT("\n\nFixture - After");
5125  }
5126  for (index = 0; cester_test_cases[index].test_type != CESTER_TESTS_TERMINATOR; ++index) {
5127  if (cester_test_cases[index].test_type == CESTER_AFTER_ALL_TEST || cester_test_cases[index].test_type == CESTER_AFTER_EACH_TEST) {
5128  CESTER_PRINT_TEST_FUNCTION(" ", "\n - ", cester_test_cases[index])
5129  }
5130  }
5131  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5132  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " </fixture_after>\n");
5133  }
5134 
5135  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5138  } else {
5139  CESTER_DELEGATE_FPRINT("\n\nTests");
5140  }
5141  for (index = 0; cester_test_cases[index].test_type != CESTER_TESTS_TERMINATOR; ++index) {
5142  if (cester_test_cases[index].test_type == CESTER_NORMAL_TEST) {
5143  CESTER_PRINT_TEST_FUNCTION(" ", "\n - ", cester_test_cases[index])
5144  }
5145  }
5146  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5148  }
5149 
5150  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5153  } else {
5154  CESTER_DELEGATE_FPRINT("\n\nSkip Tests");
5155  }
5156  for (index = 0; cester_test_cases[index].test_type != CESTER_TESTS_TERMINATOR; ++index) {
5157  if (cester_test_cases[index].test_type == CESTER_NORMAL_SKIP_TEST) {
5158  CESTER_PRINT_TEST_FUNCTION(" ", "\n - ", cester_test_cases[index])
5159  }
5160  }
5161  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5162  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " </skip_tests>\n");
5163  }
5164 
5165  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5168  } else {
5169  CESTER_DELEGATE_FPRINT("\n\nTodo Tests");
5170  }
5171  for (index = 0; cester_test_cases[index].test_type != CESTER_TESTS_TERMINATOR; ++index) {
5172  if (cester_test_cases[index].test_type == CESTER_NORMAL_TODO_TEST) {
5173  CESTER_PRINT_TEST_FUNCTION(" ", "\n - ", cester_test_cases[index])
5174  }
5175  }
5176  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5177  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_BLUE), " </todo_tests>\n");
5178  }
5179  } else {
5180  for (index = 0; cester_test_cases[index].test_type != CESTER_TESTS_TERMINATOR; ++index) {
5181  if (cester_test_cases[index].test_type == CESTER_OPTIONS_FUNCTION && cester_string_contains(info_section, "options")) {
5182  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5183 
5184  } else if (cester_test_cases[index].test_type == CESTER_TEST_FILE_COMMENT && cester_string_contains(info_section, "comments")) {
5185  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5186 
5187  } else if (cester_test_cases[index].test_type == CESTER_BEFORE_ALL_TEST && (cester_string_contains(info_section, "before_all") ||
5188  cester_string_contains(info_section, "before*"))) {
5189  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5190 
5191  } else if (cester_test_cases[index].test_type == CESTER_BEFORE_EACH_TEST && (cester_string_contains(info_section, "before_each") ||
5192  cester_string_contains(info_section, "before*"))) {
5193  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5194 
5195  } else if (cester_test_cases[index].test_type == CESTER_AFTER_ALL_TEST && (cester_string_contains(info_section, "after_all") ||
5196  cester_string_contains(info_section, "after*"))) {
5197  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5198 
5199  } else if (cester_test_cases[index].test_type == CESTER_AFTER_EACH_TEST && (cester_string_contains(info_section, "after_each") ||
5200  cester_string_contains(info_section, "after*"))) {
5201  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5202 
5203  } else if (cester_test_cases[index].test_type == CESTER_NORMAL_TEST && (((cester_string_starts_with(info_section, "test") &&
5204  cester_str_size(info_section) == 4) || cester_string_contains(info_section, "test,") || cester_string_contains(info_section, "test ")) ||
5205  cester_string_contains(info_section, "test*"))) {
5206  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5207 
5208  } else if (cester_test_cases[index].test_type == CESTER_NORMAL_SKIP_TEST && (cester_string_contains(info_section, "test_skip") ||
5209  cester_string_contains(info_section, "test*"))) {
5210  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5211 
5212  } else if (cester_test_cases[index].test_type == CESTER_NORMAL_TODO_TEST && (cester_string_contains(info_section, "test_todo") ||
5213  cester_string_contains(info_section, "test*"))) {
5214  CESTER_PRINT_TEST_FUNCTION(" ", "", cester_test_cases[index])
5215 
5216  }
5217  }
5218  }
5219  if (cester_string_equals(superTestInstance.output_format, (char*) "junitxml")) {
5221  }
5222  if (!cester_string_equals(superTestInstance.output_format, (char*) "text")) {
5224  }
5225  if (cester_string_equals(info_section, "all")) {
5226  CESTER_DELEGATE_FPRINT("\n");
5227  }
5228  cester_meta_free(file_name);
5229  cester_meta_free(info_section);
5230 
5231  return CESTER_RESULT_SUCCESS;
5232 }
5233 #endif
5234 
5235 static __CESTER_INLINE__ unsigned cester_run_all_test(unsigned argc, char **argv) {
5236  char *arg;
5237  char *extra;
5238 #ifndef CESTER_NO_PRINT_INFO
5239  char *info_section;
5240 #endif
5241  unsigned i, j, index, index1;
5242  char *cester_option = CESTER_NULL;
5243 #ifdef _WIN32
5244  #ifndef CESTER_EXCLUDE_WINDOWS_H
5245  CONSOLE_SCREEN_BUFFER_INFO info;
5246  if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info)) {
5247  cester_default_color = info.wAttributes;
5248  }
5249  cester_hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
5250  #endif
5251  #ifndef CESTER_NO_STREAM_CAPTURE
5252  cester_set_captured_streams_tmp_folder(getenv("TEMP"), (char *)"C:/libcester_tmp/");
5253  #endif
5254 #else
5255  #ifndef CESTER_NO_STREAM_CAPTURE
5256  cester_set_captured_streams_tmp_folder(getenv("TMPDIR"), (char *)"/tmp/libcester_tmp/");
5257  #endif
5258 #endif
5259 
5260 #ifndef CESTER_NO_SIGNAL
5262 #endif
5263 
5264  i = 0;
5265  j = 1;
5266 #ifndef CESTER_NO_PRINT_INFO
5267  info_section = CESTER_NULL;
5268 #endif
5271 #ifndef CESTER_NO_STREAM_CAPTURE
5272  cester_ptr_to_str(&(superTestInstance.output_stream_str), stdout);
5274 #endif
5275  }
5276 #ifndef CESTER_NO_MEM_TEST
5278  if (cester_array_init(&superTestInstance.mem_alloc_manager) == 0) {
5279  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Unable to initialize the memory management array. Memory test disabled.\n");
5281  }
5282  }
5283 #endif
5285  if (cester_array_init(&superTestInstance.registered_test_cases) == 0) {
5286  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_RED), "Unable to initialize the registered test cases array. Cannot continue tests.\n");
5287  return CESTER_RESULT_FAILURE;
5288  }
5289  }
5290 
5291  /* resolve command line options */
5292  for (;j < argc; ++j) {
5293  arg = argv[j];
5294  if (cester_str_after_prefix(arg, (char*) "--cester-", 9, &cester_option) == 1) {
5295  if (cester_string_equals(cester_option, (char*) "minimal") == 1) {
5297 
5298  } else if (cester_string_equals(cester_option, (char*) "verbose") == 1) {
5301 
5302  } else if (cester_string_equals(cester_option, (char*) "nocolor") == 1) {
5304 
5305  } else if (cester_string_equals(cester_option, (char*) "printversion") == 1) {
5307 
5308  } else if (cester_string_equals(cester_option, (char*) "singleoutput") == 1) {
5310 
5311  } else if (cester_string_equals(cester_option, (char*) "noisolation") == 1) {
5313 
5314  } else if (cester_string_equals(cester_option, (char*) "dontformatname") == 1) {
5316 #ifndef CESTER_NO_MEM_TEST
5317  } else if (cester_string_equals(cester_option, (char*) "nomemtest") == 1) {
5319 #endif
5320 #ifndef CESTER_NO_STREAM_CAPTURE
5321  } else if (cester_string_equals(cester_option, (char*) "nostreamcapture") == 1) {
5323 #endif
5324  } else if (cester_string_equals(cester_option, (char*) "version") == 1) {
5325  CESTER_NOCOLOR();
5326  cester_print_version();
5327  cester_meta_free(cester_option);
5328  cester_cleanup_super_instance();
5329  if (info_section != CESTER_NULL) { cester_meta_free(info_section); }
5330  return EXIT_SUCCESS;
5331 
5332  } else if (cester_string_equals(cester_option, (char*) "help") == 1) {
5333  CESTER_NOCOLOR();
5334  cester_print_version();
5335  cester_print_help();
5336  cester_meta_free(cester_option);
5337  if (info_section != CESTER_NULL) { cester_meta_free(info_section); }
5338  cester_cleanup_super_instance();
5339  return EXIT_SUCCESS;
5340 
5341 #ifndef CESTER_NO_PRINT_INFO
5342  } else if (cester_string_starts_with(cester_option, (char*) "info=") == 1) {
5343  cester_str_value_after_first(cester_option, '=', &info_section);
5344 #endif
5345 
5346  } else if (cester_string_starts_with(cester_option, (char*) "test=") == 1) {
5347  unpack_selected_extra_args(cester_option, &superTestInstance.selected_test_cases_names, &superTestInstance.selected_test_cases_size);
5348 
5349  } else if (cester_string_starts_with(cester_option, (char*) "verbose-level=") == 1) {
5350  cester_str_value_after_first(cester_option, '=', &extra);
5351  superTestInstance.verbose_level = atoi(extra);
5352  cester_meta_free(extra);
5353  if (superTestInstance.verbose_level >= 10) {
5355  }
5356 
5357  } else if (cester_string_starts_with(cester_option, (char*) "output=") == 1) {
5358  cester_str_value_after_first(cester_option, '=', &extra);
5359  if (cester_is_validate_output_option(extra) == 0) {
5360  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_RED), "Invalid cester output format: ");
5363  if (cester_string_starts_with(extra, (char*) "tap")) {
5364  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Did you mean 'tap' or 'tapV13?'\n");
5365  }
5367  cester_meta_free(extra);
5368  cester_meta_free(cester_option);
5369  return EXIT_FAILURE;
5370  } else {
5371  if (cester_string_equals(extra, (char*) "junitxml")) { superTestInstance.output_format = (char*) "junitxml"; }
5372  else if (cester_string_equals(extra, (char*) "tap")) { superTestInstance.output_format = (char*) "tap"; }
5373  else if (cester_string_equals(extra, (char*) "tapV13")) { superTestInstance.output_format = (char*) "tapV13"; }
5374  else { superTestInstance.output_format = (char*) "text"; }
5375  }
5376  cester_meta_free(extra);
5377 
5378  } else if (superTestInstance.single_output_only != 1) {
5379  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_RED), "Invalid cester option: --cester-");
5383  cester_meta_free(cester_option);
5384  return EXIT_FAILURE;
5385  }
5386  if (cester_option != CESTER_NULL) {
5387  cester_meta_free(cester_option);
5388  cester_option = CESTER_NULL;
5389  }
5390  } else {
5391  if (strlen(argv[j]) != 0) {
5392  cester_concat_str(&superTestInstance.flattened_cmd_argv, argv[j]);
5393  cester_concat_str(&superTestInstance.flattened_cmd_argv, " ");
5394  }
5395  }
5396  }
5399  }
5400 
5401 #ifndef CESTER_NO_PRINT_INFO
5402  if (info_section != CESTER_NULL) {
5403  return cester_print_tests_information(info_section);
5404  }
5405 #endif
5406 
5407  if (superTestInstance.print_version == 1) {
5408  cester_print_version();
5411  }
5412 
5416 
5417  /* execute options */
5418  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
5419  if ((cester_test_cases[i].test_type == CESTER_OPTIONS_FUNCTION || cester_test_cases[i].test_type == CESTER_TEST_FILE_COMMENT) &&
5422  ((cester_void)cester_test_cases[i].test_void_function)();
5423 
5424  } else if ((cester_test_cases[i].test_type == CESTER_NORMAL_TEST ||
5425  cester_test_cases[i].test_type == CESTER_NORMAL_TODO_TEST ||
5426  cester_test_cases[i].test_type == CESTER_NORMAL_SKIP_TEST) &&
5428 
5430  }
5431 
5432  }
5433 
5435  if ((((TestCase*)test_case)->test_type == CESTER_OPTIONS_FUNCTION || ((TestCase*)test_case)->test_type == CESTER_TEST_FILE_COMMENT) &&
5436  superTestInstance.single_output_only == 0) {
5437  superTestInstance.current_cester_function_type = CESTER_OPTIONS_FUNCTION;
5438  ((cester_void)((TestCase*)test_case)->test_void_function)();
5439 
5440  } else if (((TestCase*)test_case)->test_type == CESTER_NORMAL_TEST ||
5441  ((TestCase*)test_case)->test_type == CESTER_NORMAL_TODO_TEST ||
5442  ((TestCase*)test_case)->test_type == CESTER_NORMAL_SKIP_TEST) {
5443 
5445  }
5446  })
5447 
5448  /* before all */
5450  for (i=0;cester_test_cases[i].test_type != CESTER_TESTS_TERMINATOR;++i) {
5451  if (cester_test_cases[i].test_type == CESTER_BEFORE_ALL_TEST && superTestInstance.single_output_only == 0) {
5453  ((cester_test)cester_test_cases[i].test_function)(superTestInstance.test_instance);
5454  }
5455  }
5456  }
5458  if (((TestCase*)test_case)->test_type == CESTER_BEFORE_ALL_TEST && superTestInstance.single_output_only == 0) {
5459  superTestInstance.current_cester_function_type = CESTER_BEFORE_ALL_TEST;
5460  ((cester_test)((TestCase*)test_case)->test_function)(superTestInstance.test_instance);
5461  }
5462  })
5463 
5464  #ifndef CESTER_NO_TIME
5465  superTestInstance.start_tic = clock();
5466  #endif
5467  cester_run_all_test_iterator(0);
5468 
5469  return cester_print_result(cester_test_cases, superTestInstance.test_instance);
5470 }
5471 
5472 #ifndef CESTER_NO_MAIN
5473 int main(int argc, char **argv) {
5474  return CESTER_RUN_ALL_TESTS(argc, argv);
5475 }
5476 #endif
5477 
5478 #ifndef CESTER_NO_SIGNAL
5480  signal(SIGINT , cester_recover_on_signal);
5481  signal(SIGABRT , cester_recover_on_signal);
5482  signal(SIGILL , cester_recover_on_signal);
5483  signal(SIGFPE , cester_recover_on_signal);
5484  signal(SIGSEGV, cester_recover_on_signal);
5485  signal(SIGTERM , cester_recover_on_signal);
5486 }
5487 
5488 /* This is still faulty it works for SIGSEGV
5489 but SIGINT just crash to my face. So I will
5490 manually try to recover the test instead of using
5491 longjmp and setjmp which is behaving
5492 inconsistently. This still messes up for more
5493 than 2 crashes
5494  */
5495 void cester_recover_on_signal(int sig_num) {
5497  switch (sig_num) {
5498 #ifndef CESTER_NO_MEM_TEST
5499  case SIGILL:
5501  break;
5502 #endif
5503  case SIGSEGV:
5505  break;
5506  case SIGINT: /* this is one crazy kill signal */
5507  if (superTestInstance.isolate_tests == 1) {
5508  return;
5509  }
5512  cester_run_all_test_iterator(0);
5513  exit(cester_print_result(cester_test_cases, superTestInstance.test_instance));
5514  break;
5515  case SIGFPE:
5516  case SIGTERM:
5517  case SIGABRT:
5519  break;
5520  }
5521  longjmp(buf, 1);
5522 
5523 }
5524 #endif
5525 
5526 /* CesterArray */
5527 
5528 static __CESTER_INLINE__ unsigned cester_array_init(CesterArray** out) {
5529  void **buffer;
5530  CesterArray* array_local = (CesterArray*) malloc(sizeof(CesterArray));
5531  if (!array_local) {
5532  return 0;
5533  }
5534  array_local->size = 0;
5535  array_local->capacity = CESTER_ARRAY_INITIAL_CAPACITY;
5536  buffer = (void**) malloc(sizeof(void*) * array_local->capacity);
5537  if (!buffer) {
5538  cester_meta_free(array_local);
5539  return 0;
5540  }
5541  array_local->buffer = buffer;
5542  *out = array_local;
5543  return 1;
5544 }
5545 
5546 static __CESTER_INLINE__ unsigned cester_array_add(CesterArray* array, void* item) {
5547  void** new_buffer;
5548  if (array->size >= array->capacity) {
5549  if (array->capacity >= CESTER_ARRAY_MAX_CAPACITY) {
5550  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Max managable memory allocation reached, cannot expand array. Further Memory test disabled.\n");
5552  return 0;
5553  }
5555  new_buffer = (void**) malloc(sizeof(void*) * array->capacity);
5556  if (!new_buffer) {
5557  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Failed to expand the memory allocation array. Further Memory test disabled.\n");
5559  return 0;
5560  }
5561  memcpy(new_buffer, array->buffer, array->size * sizeof(void*));
5562  cester_meta_free(array->buffer);
5563  array->buffer = new_buffer;
5564  }
5565  array->buffer[array->size] = item;
5566  ++array->size;
5567  return 1;
5568 }
5569 
5570 static __CESTER_INLINE__ void* cester_array_remove_at(CesterArray* array, size_t index) {
5571  void* item;
5572  if (index >= array->size) {
5573  return CESTER_NULL;
5574  }
5575  item = array->buffer[index];
5576  if (index != array->size - 1) {
5577  size_t block_size = (array->size - 1 - index) * sizeof(void*);
5578  memmove(&(array->buffer[index]),
5579  &(array->buffer[index + 1]),
5580  block_size);
5581  }
5582  array->size--;
5583  return item;
5584 }
5585 
5586 static __CESTER_INLINE__ void cester_array_destroy(CesterArray* array) {
5587  cester_meta_free(array->buffer);
5588  cester_meta_free(array);
5589 }
5590 
5591 /* Memory leak Detection procedures */
5592 
5593 #ifndef CESTER_NO_MEM_TEST
5594 
5595 static __CESTER_INLINE__ void* cester_allocator(size_t nitems, size_t size, unsigned type, const char *file, unsigned line, const char *func) {
5596  void* p;
5597  const char* actual_function_name;
5598 #ifndef __CESTER_STDC_VERSION__
5600  actual_function_name = superTestInstance.current_test_case->name;
5601  } else {
5602  actual_function_name = func;
5603  }
5604 #else
5605  actual_function_name = func;
5606 #endif
5608  actual_function_name = "CESTER_BEFORE_ALL";
5609 
5611  actual_function_name = "CESTER_OPTIONS";
5612 
5614  actual_function_name = "CESTER_BEFORE_EACH";
5615 
5616  }
5619  if (cester_array_init(&superTestInstance.mem_alloc_manager) == 0) {
5622 #ifndef CESTER_NO_STREAM_CAPTURE
5623  cester_ptr_to_str(&(superTestInstance.output_stream_str), stdout);
5625 #endif
5626  }
5627  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Unable to initialize the memory management array. Memory test disabled.\n");
5629  }
5630  }
5631  }
5632  switch (type) {
5633  case 1:
5634  p = calloc(nitems, size);
5635  break;
5636  case 0:
5637  default:
5638  p = malloc(size);
5639  }
5641  AllocatedMemory* allocated_mem = (AllocatedMemory*) malloc(sizeof(AllocatedMemory));
5642  allocated_mem->line_num = line;
5643  allocated_mem->allocated_bytes = size;
5644  allocated_mem->function_name_allocated = 1;
5645  if (cester_str_after_prefix(actual_function_name, (char*) "cester_test_", 12, (char **) &(allocated_mem->function_name)) == 0) {
5646  allocated_mem->function_name = (char *) actual_function_name;
5647  allocated_mem->function_name_allocated = 0;
5648  }
5649  allocated_mem->file_name = file;
5650  cester_ptr_to_str(&allocated_mem->address, p);
5651  if (cester_array_add(superTestInstance.mem_alloc_manager, allocated_mem) == 0) {
5652  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Failed to register allocated memory. Memory test disabled.\n");
5654  }
5655  }
5656  return p;
5657 }
5658 
5659 static __CESTER_INLINE__ void cester_free(void *pointer, const char *file, unsigned line, const char *func) {
5660  unsigned index;
5661  char *cleaned_name = (char *) (superTestInstance.verbose_level >= 4 ? superTestInstance.test_file_path : cester_extract_name(superTestInstance.test_file_path) );
5662  if (pointer == CESTER_NULL) {
5664  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "InvalidOperation ");
5665  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, cleaned_name);
5666  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ":");
5667  cester_concat_int(&(superTestInstance.current_test_case)->execution_output, line);
5668  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, ": ");
5669  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "in '");
5670  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, (superTestInstance.current_test_case)->name);
5671  if (superTestInstance.verbose_level >= 2) {
5672  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "' => Attempting to free a CESTER_NULL pointer");
5673  }
5674  cester_concat_str(&(superTestInstance.current_test_case)->execution_output, "\n");
5676  }
5677  if (superTestInstance.verbose_level < 4) {
5678  cester_meta_free(cleaned_name);
5679  }
5680  return;
5681  }
5683  char* address;
5684  cester_ptr_to_str(&address, pointer);
5686  if (cester_string_equals(((AllocatedMemory*)alloc_mem)->address, address) == 1) {
5687  if (!cester_array_remove_at(superTestInstance.mem_alloc_manager, index)) {
5688  CESTER_DELEGATE_FPRINT_STR((CESTER_FOREGROUND_YELLOW), "Memory allocation array corrupted. Further Memory test disabled.\n");
5689  superTestInstance.mem_test_active = 0;
5690  }
5691  if (((AllocatedMemory*)alloc_mem)->function_name_allocated == 1) {
5692  cester_meta_free(((AllocatedMemory*)alloc_mem)->function_name);
5693  }
5694  cester_meta_free(((AllocatedMemory*)alloc_mem)->address);
5695  cester_meta_free(alloc_mem);
5696  break;
5697  }
5698  })
5699  cester_meta_free(address);
5700  }
5701  if (superTestInstance.verbose_level < 4) {
5702  cester_meta_free(cleaned_name);
5703  }
5704  cester_meta_free(pointer);
5705 }
5706 
5707 #define malloc(x) cester_allocator( 0, x, 0, __FILE__, __LINE__, __CESTER_FUNCTION__)
5708 #define calloc(x,y) cester_allocator( x, y, 1, __FILE__, __LINE__, __CESTER_FUNCTION__)
5709 #define free(x) cester_free( x, __FILE__, __LINE__, __CESTER_FUNCTION__)
5710 #endif
5711 
5712 #ifdef __cplusplus
5713 }
5714 #endif
5715 
5716 #endif
CESTER_NORMAL_TODO_TEST
@ CESTER_NORMAL_TODO_TEST
Definition: cester.h:261
CESTER_RUN_ALL_TESTS
#define CESTER_RUN_ALL_TESTS(x, y)
Definition: cester.h:726
super_test_instance::isolate_tests
unsigned isolate_tests
Definition: cester.h:399
CESTER_ARRAY_INITIAL_CAPACITY
#define CESTER_ARRAY_INITIAL_CAPACITY
Definition: cester.h:357
CESTER_ARRAY_FOREACH
#define CESTER_ARRAY_FOREACH(w, x, y, z)
Definition: cester.h:373
super_test_instance::selected_test_cases_size
unsigned selected_test_cases_size
Definition: cester.h:393
test_instance::argv
char ** argv
Definition: cester.h:303
cester_array_struct::size
size_t size
Definition: cester.h:367
super_test_instance
Definition: cester.h:383
super_test_instance::captured_streams_tmp_folder
char * captured_streams_tmp_folder
Definition: cester.h:415
test_instance::arg
void * arg
Definition: cester.h:304
super_test_instance::print_version
unsigned print_version
Definition: cester.h:392
test_case::expected_result
enum cester_test_status expected_result
Definition: cester.h:327
CESTER_OPTIONS_FUNCTION
@ CESTER_OPTIONS_FUNCTION
Definition: cester.h:267
cester_before_after_each
void(* cester_before_after_each)(TestInstance *, char *const, unsigned)
Definition: cester.h:317
super_test_instance::total_tests_count
unsigned total_tests_count
Definition: cester.h:385
CESTER_TOTAL_TESTS_COUNT
#define CESTER_TOTAL_TESTS_COUNT
Definition: cester.h:672
super_test_instance::format_test_name
unsigned format_test_name
Definition: cester.h:402
super_test_instance::mem_alloc_manager
CesterArray * mem_alloc_manager
Definition: cester.h:427
CESTER_NULL
#define CESTER_NULL
Definition: cester.h:54
CESTER_NOCOLOR
#define CESTER_NOCOLOR()
Definition: cester.h:527
__CESTER_LONG_LONG__
#define __CESTER_LONG_LONG__
Definition: cester.h:47
CESTER_FOREGROUND_CYAN
#define CESTER_FOREGROUND_CYAN
Definition: cester.h:181
CESTER_RESULT_UNKNOWN
@ CESTER_RESULT_UNKNOWN
Definition: cester.h:256
CESTER_TOTAL_TODO_TESTS
#define CESTER_TOTAL_TODO_TESTS
Definition: cester.h:717
main
int main(int argc, char **argv)
Definition: cester.h:5473
test_case::name
char * name
Definition: cester.h:333
cester_array_struct
Definition: cester.h:366
CESTER_FOREGROUND_RED
#define CESTER_FOREGROUND_RED
Definition: cester.h:176
test_instance
Definition: cester.h:301
cester_array_struct::buffer
void ** buffer
Definition: cester.h:369
super_test_instance::skipped_test_count
unsigned skipped_test_count
Definition: cester.h:400
CESTER_RESULT_TIMED_OUT
@ CESTER_RESULT_TIMED_OUT
Definition: cester.h:255
cester_test_type
cester_test_type
Definition: cester.h:259
CESTER_RESET_TERMINAL_ATTR
#define CESTER_RESET_TERMINAL_ATTR()
Definition: cester.h:193
CESTER_NORMAL_TEST
@ CESTER_NORMAL_TEST
Definition: cester.h:260
allocated_memory::file_name
const char * file_name
Definition: cester.h:348
CESTER_ARRAY_MAX_CAPACITY
#define CESTER_ARRAY_MAX_CAPACITY
Definition: cester.h:364
test_case::test_void_function
cester_void test_void_function
Definition: cester.h:336
CESTER_GET_RESULT_AGGR
#define CESTER_GET_RESULT_AGGR
Definition: cester.h:1078
allocated_memory
Definition: cester.h:342
super_test_instance::mem_test_active
unsigned mem_test_active
Definition: cester.h:396
CESTER_DELEGATE_FPRINT_STR
#define CESTER_DELEGATE_FPRINT_STR(x, y)
Definition: cester.h:1093
CESTER_TOTAL_TEST_ERRORS_COUNT
#define CESTER_TOTAL_TEST_ERRORS_COUNT
Definition: cester.h:694
CESTER_DELEGATE_FPRINT_INT
#define CESTER_DELEGATE_FPRINT_INT(x, y)
Definition: cester.h:1095
super_test_instance::todo_tests_count
unsigned todo_tests_count
Definition: cester.h:401
captured_stream
Definition: cester.h:282
__CESTER_INLINE__
#define __CESTER_INLINE__
Definition: cester.h:46
CESTER_FOREGROUND_BLUE
#define CESTER_FOREGROUND_BLUE
Definition: cester.h:179
captured_stream::line_num
unsigned line_num
Definition: cester.h:283
CESTER_COMPARATOR_GREATER_THAN
@ CESTER_COMPARATOR_GREATER_THAN
Definition: cester.h:235
CESTER_TESTS_TERMINATOR
@ CESTER_TESTS_TERMINATOR
Definition: cester.h:269
CESTER_COMPARATOR_GREATER_THAN_OR_EQUAL
@ CESTER_COMPARATOR_GREATER_THAN_OR_EQUAL
Definition: cester.h:236
__CESTER_CAST_CHAR_ARRAY__
#define __CESTER_CAST_CHAR_ARRAY__
Definition: cester.h:71
super_test_instance::verbose_level
unsigned verbose_level
Definition: cester.h:390
super_test_instance::output_stream
FILE * output_stream
Definition: cester.h:421
CESTER_RESULT_MEMORY_LEAK
@ CESTER_RESULT_MEMORY_LEAK
Definition: cester.h:253
CESTER_DELEGATE_FPRINT_DOUBLE_2
#define CESTER_DELEGATE_FPRINT_DOUBLE_2(x, y)
Definition: cester.h:1099
test_case::start_tic
double start_tic
Definition: cester.h:329
captured_stream::replaced_stream_file_path
char * replaced_stream_file_path
Definition: cester.h:288
super_test_instance::report_failure_regardless
unsigned report_failure_regardless
Definition: cester.h:404
captured_stream::original_stream_handle
FILE * original_stream_handle
Definition: cester.h:290
super_test_instance::output_format
char * output_format
Definition: cester.h:412
CESTER_AUTHOR
#define CESTER_AUTHOR
Definition: cester.h:215
TestType
enum cester_test_type TestType
test_case::test_function
cester_test test_function
Definition: cester.h:334
test_case::test_ba_function
cester_before_after_each test_ba_function
Definition: cester.h:335
cester_meta_free
#define cester_meta_free(x)
Definition: cester.h:102
CESTER_RESET_TERMINAL
#define CESTER_RESET_TERMINAL
Definition: cester.h:173
cester_test
void(* cester_test)(TestInstance *)
Definition: cester.h:311
CESTER_AFTER_ALL_TEST
@ CESTER_AFTER_ALL_TEST
Definition: cester.h:265
cester_assertion_caparator
cester_assertion_caparator
Definition: cester.h:232
CESTER_AFTER_EACH_TEST
@ CESTER_AFTER_EACH_TEST
Definition: cester.h:266
CESTER_BEFORE_ALL_TEST
@ CESTER_BEFORE_ALL_TEST
Definition: cester.h:263
SuperTestInstance
struct super_test_instance SuperTestInstance
buf
jmp_buf buf
Definition: cester.h:90
cester_void
void(* cester_void)(void)
Definition: cester.h:322
calloc
#define calloc(x, y)
Definition: cester.h:5708
CESTER_RESULT_TERMINATED
@ CESTER_RESULT_TERMINATED
Definition: cester.h:249
cester_array_struct::capacity
size_t capacity
Definition: cester.h:368
super_test_instance::current_execution_status
unsigned current_execution_status
Definition: cester.h:398
test_instance::argc
unsigned argc
Definition: cester.h:302
super_test_instance::main_execution_output
char * main_execution_output
Definition: cester.h:409
CESTER_VERSION
#define CESTER_VERSION
Definition: cester.h:200
CESTER_RESULT_SUCCESS
@ CESTER_RESULT_SUCCESS
Definition: cester.h:247
CESTER_GET_RESULT_AGGR_COLOR
#define CESTER_GET_RESULT_AGGR_COLOR
Definition: cester.h:1079
super_test_instance::captured_streams
CesterArray * captured_streams
Definition: cester.h:425
CESTER_TOTAL_PASSED_TESTS_COUNT
#define CESTER_TOTAL_PASSED_TESTS_COUNT
Definition: cester.h:708
super_test_instance::total_test_errors_count
unsigned total_test_errors_count
Definition: cester.h:389
CESTER_FOREGROUND_GRAY
#define CESTER_FOREGROUND_GRAY
Definition: cester.h:183
CESTER_TOTAL_FAILED_TESTS_COUNT
#define CESTER_TOTAL_FAILED_TESTS_COUNT
Definition: cester.h:682
cester_sprintf1
#define cester_sprintf1(x, y, z, a)
Definition: cester.h:500
CESTER_TOTAL_TESTS_RAN
#define CESTER_TOTAL_TESTS_RAN
Definition: cester.h:677
super_test_instance::total_tests_ran
unsigned total_tests_ran
Definition: cester.h:386
CESTER_FOREGROUND_WHITE
#define CESTER_FOREGROUND_WHITE
Definition: cester.h:182
super_test_instance::selected_test_cases_names
char ** selected_test_cases_names
Definition: cester.h:422
super_test_instance::single_output_only
unsigned single_output_only
Definition: cester.h:395
CESTER_INTERNAL_EVALUATE
#define CESTER_INTERNAL_EVALUATE(comparator_type, x, y, result)
Definition: cester.h:3252
CESTER_BEFORE_EACH_TEST
@ CESTER_BEFORE_EACH_TEST
Definition: cester.h:264
CESTER_FOREGROUND_GREEN
#define CESTER_FOREGROUND_GREEN
Definition: cester.h:177
test_case::line_num
unsigned line_num
Definition: cester.h:326
CESTER_DELEGATE_FPRINT
#define CESTER_DELEGATE_FPRINT(y)
Definition: cester.h:1092
allocated_memory::function_name
char * function_name
Definition: cester.h:347
super_test_instance::test_file_path
char * test_file_path
Definition: cester.h:411
super_test_instance::print_error_only
unsigned print_error_only
Definition: cester.h:391
captured_stream::replaced_stream_handle
FILE * replaced_stream_handle
Definition: cester.h:291
allocated_memory::allocated_bytes
size_t allocated_bytes
Definition: cester.h:344
CESTER_FOREGROUND_MAGENTA
#define CESTER_FOREGROUND_MAGENTA
Definition: cester.h:180
cester_capture_signals
void cester_capture_signals(void)
Definition: cester.h:5479
CapturedStream
struct captured_stream CapturedStream
test_case
Definition: cester.h:324
super_test_instance::output_stream_address
FILE output_stream_address
Definition: cester.h:419
cester_recover_on_signal
void cester_recover_on_signal(int sig_num)
Definition: cester.h:5495
allocated_memory::line_num
unsigned line_num
Definition: cester.h:343
super_test_instance::total_passed_tests_count
unsigned total_passed_tests_count
Definition: cester.h:388
CESTER_RESULT_FAILURE
@ CESTER_RESULT_FAILURE
Definition: cester.h:248
allocated_memory::address
char * address
Definition: cester.h:346
CESTER_TEST_FILE_COMMENT
@ CESTER_TEST_FILE_COMMENT
Definition: cester.h:268
__CESTER_LONG_LONG_FORMAT__
#define __CESTER_LONG_LONG_FORMAT__
Definition: cester.h:48
super_test_instance::report_success_regardless
unsigned report_success_regardless
Definition: cester.h:403
super_test_instance::current_cester_function_type
TestType current_cester_function_type
Definition: cester.h:405
super_test_instance::start_tic
double start_tic
Definition: cester.h:407
allocated_memory::function_name_allocated
unsigned function_name_allocated
Definition: cester.h:345
CESTER_COMPARATOR_NOT_EQUAL
@ CESTER_COMPARATOR_NOT_EQUAL
Definition: cester.h:234
super_test_instance::registered_test_cases
CesterArray * registered_test_cases
Definition: cester.h:424
super_test_instance::test_instance
TestInstance * test_instance
Definition: cester.h:417
super_test_instance::selected_test_cases_found
unsigned selected_test_cases_found
Definition: cester.h:394
super_test_instance::current_test_case
TestCase * current_test_case
Definition: cester.h:423
super_test_instance::flattened_cmd_argv
char * flattened_cmd_argv
Definition: cester.h:410
test_case::execution_time
double execution_time
Definition: cester.h:330
captured_stream::replaced_stream_ptr_str
char * replaced_stream_ptr_str
Definition: cester.h:286
CESTER_PRINT_TEST_FUNCTION
#define CESTER_PRINT_TEST_FUNCTION(tab, text_prefix, test_case)
Definition: cester.h:5034
superTestInstance
SuperTestInstance superTestInstance
Definition: cester.h:441
CESTER_TOTAL_TESTS_SKIPPED
#define CESTER_TOTAL_TESTS_SKIPPED
Definition: cester.h:703
TestCase
struct test_case TestCase
super_test_instance::output_stream_str
char * output_stream_str
Definition: cester.h:414
test_case::execution_status
unsigned execution_status
Definition: cester.h:325
super_test_instance::total_failed_tests_count
unsigned total_failed_tests_count
Definition: cester.h:387
captured_stream::original_stream
FILE original_stream
Definition: cester.h:289
CesterArray
struct cester_array_struct CesterArray
captured_stream::stream_buffer
char * stream_buffer
Definition: cester.h:287
CESTER_FOREGROUND_YELLOW
#define CESTER_FOREGROUND_YELLOW
Definition: cester.h:178
captured_stream::original_stream_ptr_str
char * original_stream_ptr_str
Definition: cester.h:285
CESTER_RESULT_SEGFAULT
@ CESTER_RESULT_SEGFAULT
Definition: cester.h:250
TestInstance
struct test_instance TestInstance
test_case::execution_output
char * execution_output
Definition: cester.h:332
cester_sprintf3
#define cester_sprintf3(x, y, z, a, b, c)
Definition: cester.h:502
test_case::test_type
TestType test_type
Definition: cester.h:337
CESTER_RESULT_UNRELEASED_STREAM
@ CESTER_RESULT_UNRELEASED_STREAM
Definition: cester.h:251
CESTER_NORMAL_SKIP_TEST
@ CESTER_NORMAL_SKIP_TEST
Definition: cester.h:262
CESTER_COMPARATOR_EQUAL
@ CESTER_COMPARATOR_EQUAL
Definition: cester.h:233
super_test_instance::stream_capture_active
unsigned stream_capture_active
Definition: cester.h:397
captured_stream::function_name
char * function_name
Definition: cester.h:284
cester_default_color
const char * cester_default_color
Definition: cester.h:744
CESTER_LICENSE
#define CESTER_LICENSE
Definition: cester.h:210
AllocatedMemory
struct allocated_memory AllocatedMemory
CESTER_COMPARATOR_LESSER_THAN_OR_EQUAL
@ CESTER_COMPARATOR_LESSER_THAN_OR_EQUAL
Definition: cester.h:238
malloc
#define malloc(x)
Definition: cester.h:5707
CESTER_COMPARATOR_LESSER_THAN
@ CESTER_COMPARATOR_LESSER_THAN
Definition: cester.h:237
cester_test_status
cester_test_status
Definition: cester.h:246
super_test_instance::no_color
unsigned no_color
Definition: cester.h:384