@@ -463,6 +463,10 @@ void shuffle_test_cases(test_case_t **test_cases) {
463463// Creates and returns a new test suite
464464test_suite_t * fossil_test_create_suite (const char * name ) {
465465 test_suite_t * suite = (test_suite_t * )malloc (sizeof (test_suite_t ));
466+ if (!suite ) {
467+ return NULL ;
468+ }
469+
466470 suite -> name = name ;
467471 suite -> suite_setup_func = NULL ;
468472 suite -> suite_teardown_func = NULL ;
@@ -473,7 +477,10 @@ test_suite_t* fossil_test_create_suite(const char *name) {
473477
474478// Registers a test suite in the environment
475479void fossil_test_register_suite (fossil_test_env_t * env , test_suite_t * suite ) {
476- if (!suite ) return ;
480+ if (!env || !suite ) {
481+ return ;
482+ }
483+
477484 suite -> next = env -> test_suites ;
478485 env -> test_suites = suite ;
479486 if (env -> options .show_info ) {
@@ -483,15 +490,19 @@ void fossil_test_register_suite(fossil_test_env_t *env, test_suite_t *suite) {
483490
484491// Adds a test case to a suite
485492void fossil_test_add_case (test_suite_t * suite , test_case_t * test_case ) {
486- if (!suite || !test_case ) return ;
493+ if (!suite || !test_case ) {
494+ return ;
495+ }
487496
488497 test_case -> next = suite -> tests ;
489498 suite -> tests = test_case ;
490499}
491500
492501// Removes and frees a test case from a suite
493502void fossil_test_remove_case (test_suite_t * suite , test_case_t * test_case ) {
494- if (!suite || !test_case ) return ;
503+ if (!suite || !test_case ) {
504+ return ;
505+ }
495506
496507 test_case_t * prev = NULL ;
497508 test_case_t * curr = suite -> tests ;
@@ -527,7 +538,9 @@ void fossil_test_case_teardown(test_case_t *test_case) {
527538
528539// Run all test cases in a test suite
529540void fossil_test_run_suite (test_suite_t * suite , fossil_test_env_t * env ) {
530- if (!suite ) return ;
541+ if (!suite || !env ) {
542+ return ;
543+ }
531544
532545 if (env -> options .show_info ) {
533546 printf (FOSSIL_TEST_COLOR_BLUE "Running suite: %s\n" FOSSIL_TEST_COLOR_RESET , suite -> name );
@@ -597,7 +610,9 @@ void fossil_test_assert_internal(bool condition, const char *message, const char
597610
598611// Run an individual test case
599612void fossil_test_run_case (test_case_t * test_case , fossil_test_env_t * env ) {
600- if (!test_case ) return ;
613+ if (!test_case ) {
614+ return ;
615+ }
601616
602617 test_case -> status = TEST_STATUS_PASS ;
603618
@@ -652,6 +667,10 @@ void fossil_test_run_case(test_case_t *test_case, fossil_test_env_t *env) {
652667}
653668
654669void fossil_test_run_all (fossil_test_env_t * env ) {
670+ if (!env ) {
671+ return ;
672+ }
673+
655674 test_suite_t * current_suite = env -> test_suites ;
656675
657676 while (current_suite ) {
@@ -666,10 +685,12 @@ void fossil_test_init(fossil_test_env_t *env, int argc, char **argv) {
666685 version_info ();
667686 exit (EXIT_SUCCESS );
668687 }
688+
669689 if (env -> options .show_help ) {
670690 usage_info ();
671691 exit (EXIT_SUCCESS );
672692 }
693+
673694 env -> pass_count = 0 ;
674695 env -> fail_count = 0 ;
675696 env -> skip_count = 0 ;
@@ -696,7 +717,7 @@ void fossil_test_message(fossil_test_env_t *env) {
696717 } else if (env -> timeout_count > 0 ) {
697718 printf (FOSSIL_TEST_COLOR_ORANGE FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET , timeout_messages [rand () % 30 ]);
698719 } else {
699- printf (FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_ITATIC "Test results are in. Keep pushing, you're getting there! 💪\n " FOSSIL_TEST_COLOR_RESET );
720+ puts (FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_ITATIC "Test results are in. Keep pushing, you're getting there!" FOSSIL_TEST_COLOR_RESET );
700721 }
701722}
702723
0 commit comments