141 CU_pSuite suite_to_run;
143 CU_pTest test_to_run;
144 CU_ErrorCode errCode = 0;
145 CU_pTestRegistry registry;
155 if (CUE_SUCCESS != CU_initialize_registry())
157 errCode = CU_get_error();
158 printf(
" Error attempting to initialize registry: %d. See CUError.h for error code list.\n", errCode);
170 CU_basic_set_mode(CU_BRM_VERBOSE);
173 errCode = CU_basic_run_tests();
180 registry = CU_get_registry();
181 for (index = 1; index < argc; index++)
183 suite_name = argv[index];
185 suite_to_run = CU_get_suite_by_name(suite_name, registry);
186 if (NULL == suite_to_run)
189 suite_to_run = registry->pSuite;
190 while (suite_to_run != NULL)
192 test_to_run = CU_get_test_by_name(suite_name, suite_to_run);
193 if (test_to_run != NULL)
196 test_name = suite_name;
197 suite_name = suite_to_run->pName;
200 suite_to_run = suite_to_run->pNext;
203 if (suite_to_run == NULL)
205 printf(
"\n'%s' does not appear to be either a suite name or a test name.\n\n", suite_name);
209 if (test_name != NULL)
212 printf(
"\nRunning test '%s' in suite '%s'.\n", test_name, suite_name);
216 errCode = CU_run_test(suite_to_run, test_to_run);
217 if (errCode != CUE_SUCCESS)
219 printf(
" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode);
223 num_run = CU_get_number_of_asserts();
224 num_failed = CU_get_number_of_failures();
225 printf(
"\n %s - asserts - %3d passed, %3d failed, %3d total.\n\n",
226 (0 == num_failed ?
"PASSED" :
"FAILED"), (num_run - num_failed), num_failed, num_run);
232 printf(
"\nRunning all tests in suite '%s'.\n", suite_name);
236 errCode = CU_run_suite(suite_to_run);
237 if (errCode != CUE_SUCCESS)
239 printf(
" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode);
243 num_run = CU_get_number_of_tests_run();
244 num_failed = CU_get_number_of_tests_failed();
245 printf(
"\n %s - tests - %3d passed, %3d failed, %3d total.\n",
246 (0 == num_failed ?
"PASSED" :
"FAILED"), (num_run - num_failed), num_failed, num_run);
247 num_run = CU_get_number_of_asserts();
248 num_failed = CU_get_number_of_failures();
249 printf(
" - asserts - %3d passed, %3d failed, %3d total.\n\n",
250 (num_run - num_failed), num_failed, num_run);
256 CU_basic_show_failures(CU_get_failure_list());
259 num_failed = CU_get_number_of_failures();
260 CU_cleanup_registry();
PG_SuiteSetup setupfuncs[]
static void cu_errorreporter(const char *fmt, va_list ap)
CUnit error handler Log message in a global var instead of printing in stderr.
void(* PG_SuiteSetup)(void)
void(*) typedef void(*) voi lwgeom_set_handlers)(lwallocator allocator, lwreallocator reallocator, lwfreeor freeor, lwreporter errorreporter, lwreporter noticereporter)
Install custom memory management and error handling functions you want your application to use...
void lwgeom_set_debuglogger(lwdebuglogger debuglogger)
static void cu_noticereporter(const char *fmt, va_list ap)
static void cu_debuglogger(int level, const char *fmt, va_list ap)