diff --git a/.github/workflows/meson_ci.yml b/.github/workflows/meson_ci.yml index 026ad8e7..bc792835 100644 --- a/.github/workflows/meson_ci.yml +++ b/.github/workflows/meson_ci.yml @@ -7,7 +7,6 @@ on: - "**.h" - "**.cpp" - "**.hpp" - - "**.rs" - "**.py" - "**.build" - "**.options" @@ -17,7 +16,6 @@ on: - "**.h" - "**.cpp" - "**.hpp" - - "**.rs" - "**.py" - "**.build" - "**.options" @@ -249,7 +247,7 @@ jobs: -w /workspace \ ${GITHUB_REPOSITORY}:${{ matrix.distro }} \ /bin/bash -c " - apt-get update + sudo apt update meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3 meson compile -C builddir meson test -C builddir -v" @@ -275,25 +273,25 @@ jobs: - name: Install Cross-Compilation Toolchain run: | - sudo apt-get update + sudo apt update if [ "${{ matrix.architecture }}" == "arm" ]; then - sudo apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi + sudo apt install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi elif [ "${{ matrix.architecture }}" == "arm64" ]; then - sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu elif [ "${{ matrix.architecture }}" == "mips" ]; then - sudo apt-get install -y gcc-mips-linux-gnu g++-mips-linux-gnu + sudo apt install -y gcc-mips-linux-gnu g++-mips-linux-gnu elif [ "${{ matrix.architecture }}" == "mipsel" ]; then - sudo apt-get install -y gcc-mipsel-linux-gnu g++-mipsel-linux-gnu + sudo apt install -y gcc-mipsel-linux-gnu g++-mipsel-linux-gnu elif [ "${{ matrix.architecture }}" == "riscv64" ]; then - sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu + sudo apt install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu elif [ "${{ matrix.architecture }}" == "ppc" ]; then - sudo apt-get install -y gcc-powerpc-linux-gnu g++-powerpc-linux-gnu + sudo apt install -y gcc-powerpc-linux-gnu g++-powerpc-linux-gnu elif [ "${{ matrix.architecture }}" == "ppc64le" ]; then - sudo apt-get install -y gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu + sudo apt install -y gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu elif [ "${{ matrix.architecture }}" == "sparc64" ]; then - sudo apt-get install -y gcc-sparc64-linux-gnu g++-sparc64-linux-gnu + sudo apt install -y gcc-sparc64-linux-gnu g++-sparc64-linux-gnu elif [ "${{ matrix.architecture }}" == "s390x" ]; then - sudo apt-get install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu + sudo apt install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu fi - name: Set Cross-Compilation Environment Variables diff --git a/Dockerfile b/Dockerfile index 0f4bfa77..69ef30c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,15 +6,13 @@ ENV DEBIAN_FRONTEND=noninteractive \ TZ=UTC # Install system dependencies and clean up -RUN apt-get update && \ - apt-get install -y \ +RUN apt update && \ + apt install -y \ build-essential \ gcc \ g++ \ gdb \ libstdc++-10-dev \ - rustc \ - cargo \ wget \ python3 \ python3-pip \ diff --git a/code/logic/fossil/test/marking.h b/code/logic/fossil/test/marking.h index d7f77fbd..ed5ae326 100644 --- a/code/logic/fossil/test/marking.h +++ b/code/logic/fossil/test/marking.h @@ -41,83 +41,83 @@ typedef struct { double min_duration; double max_duration; int running; -} fossil_benchmark_t; +} fossil_mark_t; /** - * @brief Initializes a fossil_benchmark_t object with the given name. - * @param benchmark The fossil_benchmark_t object to initialize. + * @brief Initializes a fossil_mark_t object with the given name. + * @param benchmark The fossil_mark_t object to initialize. * @param name The name of the benchmark. */ -void fossil_benchmark_init(fossil_benchmark_t* benchmark, const char* name); +void fossil_benchmark_init(fossil_mark_t* benchmark, const char* name); /** * @brief Starts the benchmark timer. - * @param benchmark The fossil_benchmark_t object to start. + * @param benchmark The fossil_mark_t object to start. */ -void fossil_benchmark_start(fossil_benchmark_t* benchmark); +void fossil_benchmark_start(fossil_mark_t* benchmark); /** * @brief Stops the benchmark timer. - * @param benchmark The fossil_benchmark_t object to stop. + * @param benchmark The fossil_mark_t object to stop. */ -void fossil_benchmark_stop(fossil_benchmark_t* benchmark); +void fossil_benchmark_stop(fossil_mark_t* benchmark); /** * @brief Returns the total elapsed time in seconds. - * @param benchmark The fossil_benchmark_t object to get the elapsed time from. + * @param benchmark The fossil_mark_t object to get the elapsed time from. * @return The total elapsed time in seconds. */ -double fossil_benchmark_elapsed_seconds(const fossil_benchmark_t* benchmark); +double fossil_benchmark_elapsed_seconds(const fossil_mark_t* benchmark); /** * @brief Returns the minimum elapsed time in seconds. - * @param benchmark The fossil_benchmark_t object to get the minimum time from. + * @param benchmark The fossil_mark_t object to get the minimum time from. * @return The minimum elapsed time in seconds. */ -double fossil_benchmark_min_time(const fossil_benchmark_t* benchmark); +double fossil_benchmark_min_time(const fossil_mark_t* benchmark); /** * @brief Returns the maximum elapsed time in seconds. - * @param benchmark The fossil_benchmark_t object to get the maximum time from. + * @param benchmark The fossil_mark_t object to get the maximum time from. * @return The maximum elapsed time in seconds. */ -double fossil_benchmark_max_time(const fossil_benchmark_t* benchmark); +double fossil_benchmark_max_time(const fossil_mark_t* benchmark); /** * @brief Returns the average elapsed time in seconds. - * @param benchmark The fossil_benchmark_t object to get the average time from. + * @param benchmark The fossil_mark_t object to get the average time from. * @return The average elapsed time in seconds. */ -double fossil_benchmark_avg_time(const fossil_benchmark_t* benchmark); +double fossil_benchmark_avg_time(const fossil_mark_t* benchmark); /** * @brief Resets the benchmark statistics. - * @param benchmark The fossil_benchmark_t object to reset. + * @param benchmark The fossil_mark_t object to reset. */ -void fossil_benchmark_reset(fossil_benchmark_t* benchmark); +void fossil_benchmark_reset(fossil_mark_t* benchmark); /** * @brief Prints a report of the benchmark statistics. - * @param benchmark The fossil_benchmark_t object to report. + * @param benchmark The fossil_mark_t object to report. */ -void fossil_benchmark_report(const fossil_benchmark_t* benchmark); +void fossil_benchmark_report(const fossil_mark_t* benchmark); typedef struct { - fossil_benchmark_t* benchmark; -} scoped_benchmark_t; + fossil_mark_t* benchmark; +} fossil_scoped_mark_t; /** - * @brief Initializes a scoped_benchmark_t object with the given benchmark. - * @param scoped_benchmark The scoped_benchmark_t object to initialize. + * @brief Initializes a fossil_scoped_mark_t object with the given benchmark. + * @param scoped_benchmark The fossil_scoped_mark_t object to initialize. * @param benchmark The benchmark to be scoped. */ -void fossil_scoped_benchmark_init(scoped_benchmark_t* scoped_benchmark, fossil_benchmark_t* benchmark); +void fossil_scoped_benchmark_init(fossil_scoped_mark_t* scoped_benchmark, fossil_mark_t* benchmark); /** - * @brief Destroys a scoped_benchmark_t object. - * @param scoped_benchmark The scoped_benchmark_t object to destroy. + * @brief Destroys a fossil_scoped_mark_t object. + * @param scoped_benchmark The fossil_scoped_mark_t object to destroy. */ -void fossil_scoped_benchmark_destroy(scoped_benchmark_t* scoped_benchmark); +void fossil_scoped_benchmark_destroy(fossil_scoped_mark_t* scoped_benchmark); /** * Function to test benchmark with specified duration type, expected value, and actual value. @@ -153,7 +153,7 @@ uint64_t fossil_test_stop_benchmark(void); * @param name The name of the benchmark. */ #define _MARK_BENCHMARK(name) \ - fossil_benchmark_t benchmark_##name; \ + fossil_mark_t benchmark_##name; \ fossil_benchmark_init(&benchmark_##name, #name) /** @@ -199,7 +199,7 @@ uint64_t fossil_test_stop_benchmark(void); * @param name The name of the benchmark. */ #define _MARK_SCOPED(name) \ - scoped_benchmark_t scoped_benchmark_##name; \ + fossil_scoped_mark_t scoped_benchmark_##name; \ fossil_scoped_benchmark_init(&scoped_benchmark_##name, &benchmark_##name) // ================================================================= diff --git a/code/logic/fossil/test/mocking.h b/code/logic/fossil/test/mocking.h index 57cf09f4..2560bf47 100644 --- a/code/logic/fossil/test/mocking.h +++ b/code/logic/fossil/test/mocking.h @@ -118,49 +118,49 @@ extern "C" { // C interface -typedef struct MockCall { +typedef struct fossil_mock_call_t { char *function_name; char **arguments; int num_args; - struct MockCall *next; -} MockCall; + struct fossil_mock_call_t *next; +} fossil_mock_call_t; typedef struct { - MockCall *head; - MockCall *tail; + fossil_mock_call_t *head; + fossil_mock_call_t *tail; int size; -} MockCallList; +} fossil_mock_calllist_t; /** - * Initializes a MockCallList. + * Initializes a fossil_mock_calllist_t. * - * @param list The MockCallList to initialize. + * @param list The fossil_mock_calllist_t to initialize. */ -void fossil_mock_init(MockCallList *list); +void fossil_mock_init(fossil_mock_calllist_t *list); /** - * Destroys a MockCallList and frees all associated memory. + * Destroys a fossil_mock_calllist_t and frees all associated memory. * - * @param list The MockCallList to destroy. + * @param list The fossil_mock_calllist_t to destroy. */ -void fossil_mock_destroy(MockCallList *list); +void fossil_mock_destroy(fossil_mock_calllist_t *list); /** - * Adds a MockCall to the MockCallList. + * Adds a fossil_mock_call_t to the fossil_mock_calllist_t. * - * @param list The MockCallList to add the MockCall to. + * @param list The fossil_mock_calllist_t to add the fossil_mock_call_t to. * @param function_name The name of the function being called. * @param arguments The arguments passed to the function. * @param num_args The number of arguments. */ -void fossil_mock_add_call(MockCallList *list, const char *function_name, char **arguments, int num_args); +void fossil_mock_add_call(fossil_mock_calllist_t *list, const char *function_name, char **arguments, int num_args); /** - * Prints the contents of a MockCallList. + * Prints the contents of a fossil_mock_calllist_t. * - * @param list The MockCallList to print. + * @param list The fossil_mock_calllist_t to print. */ -void fossil_mock_print(MockCallList *list); +void fossil_mock_print(fossil_mock_calllist_t *list); #ifdef __cplusplus } diff --git a/code/logic/fossil/test/testing.h b/code/logic/fossil/test/testing.h index 52dad6f9..c77cf62f 100644 --- a/code/logic/fossil/test/testing.h +++ b/code/logic/fossil/test/testing.h @@ -49,33 +49,33 @@ extern "C" { #endif /** - * @struct fossil_options_t + * @struct fossil_test_options_t * @brief Structure to hold various options for fossil testing. * * This structure contains various flags and parameters that control the behavior of the fossil testing framework. * - * @var fossil_options_t::show_version + * @var fossil_test_options_t::show_version * Flag to indicate if the version information should be displayed. * - * @var fossil_options_t::show_help + * @var fossil_test_options_t::show_help * Flag to indicate if the help information should be displayed. * - * @var fossil_options_t::show_info + * @var fossil_test_options_t::show_info * Flag to indicate if additional information should be displayed. * - * @var fossil_options_t::reverse + * @var fossil_test_options_t::reverse * Flag to indicate if the order of tests should be reversed. * - * @var fossil_options_t::repeat_enabled + * @var fossil_test_options_t::repeat_enabled * Flag to indicate if test repetition is enabled. * - * @var fossil_options_t::repeat_count + * @var fossil_test_options_t::repeat_count * Number of times to repeat the tests if repetition is enabled. * - * @var fossil_options_t::shuffle_enabled + * @var fossil_test_options_t::shuffle_enabled * Flag to indicate if the tests should be shuffled. * - * @var fossil_options_t::dry_run + * @var fossil_test_options_t::dry_run * Flag to indicate if the tests should be run in dry-run mode (no actual execution). * */ @@ -85,10 +85,10 @@ typedef struct { bool show_info; bool reverse; bool repeat_enabled; - int repeat_count; + int32_t repeat_count; bool shuffle_enabled; bool dry_run; -} fossil_options_t; +} fossil_test_options_t; /** * @enum test_status @@ -103,7 +103,7 @@ typedef enum { TEST_STATUS_SKIP, TEST_STATUS_EMPTY, TEST_STATUS_TTIMEOUT -} test_status_t; +} fossil_test_status_t; /** * @struct test_case @@ -142,46 +142,46 @@ typedef struct test_case { void (*test_func)(void); void (*setup_func)(void); void (*teardown_func)(void); - test_status_t status; + fossil_test_status_t status; const char *failure_message; double execution_time; struct test_case *next; -} test_case_t; +} fossil_test_case_t; /** - * @struct test_suite + * @struct fossil_test_suite_t * @brief Structure to hold a test suite. * * This structure contains fields to hold information about a test suite, including * the name, suite setup function, suite teardown function, total execution time, * list of test cases, and a pointer to the next test suite. * - * @var test_suite::name + * @var fossil_test_suite_t::name * Suite name * - * @var test_suite::suite_setup_func + * @var fossil_test_suite_t::suite_setup_func * Pointer to suite setup function (optional) * - * @var test_suite::suite_teardown_func + * @var fossil_test_suite_t::suite_teardown_func * Pointer to suite teardown function (optional) * - * @var test_suite::total_execution_time + * @var fossil_test_suite_t::total_execution_time * Total execution time of all test cases * - * @var test_suite::tests + * @var fossil_test_suite_t::tests * List of test cases * - * @var test_suite::next + * @var fossil_test_suite_t::next * Pointer to next suite in the list */ -typedef struct test_suite { +typedef struct fossil_test_suite_t { const char *name; void (*suite_setup_func)(void); void (*suite_teardown_func)(void); double total_execution_time; - test_case_t *tests; - struct test_suite *next; -} test_suite_t; + fossil_test_case_t *tests; + struct fossil_test_suite_t *next; +} fossil_test_suite_t; /** * @struct fossil_test_env @@ -228,18 +228,18 @@ typedef struct test_suite { * Pointer to the list of test suites to be executed. */ typedef struct fossil_test_env { - fossil_options_t options; + fossil_test_options_t options; jmp_buf env; - int total_tests; - int pass_count; - int fail_count; - int skip_count; - int empty_count; - int timeout_count; - int unexpected_count; + int32_t total_tests; + int32_t pass_count; + int32_t fail_count; + int32_t skip_count; + int32_t empty_count; + int32_t timeout_count; + int32_t unexpected_count; double start_execution_time; double end_execution_time; - test_suite_t *test_suites; + fossil_test_suite_t *test_suites; } fossil_test_env_t; // ***************************************************************************** @@ -252,7 +252,7 @@ typedef struct fossil_test_env { * @param name The name of the test suite. * @return A pointer to the created test suite. */ -test_suite_t* fossil_test_create_suite(const char *name); +fossil_test_suite_t* fossil_test_create_suite(const char *name); /** * @brief Registers a test suite with the test environment. @@ -260,7 +260,7 @@ test_suite_t* fossil_test_create_suite(const char *name); * @param env The test environment. * @param suite The test suite to register. */ -void fossil_test_register_suite(fossil_test_env_t *env, test_suite_t *suite); +void fossil_test_register_suite(fossil_test_env_t *env, fossil_test_suite_t *suite); /** * @brief Adds a test case to a test suite. @@ -268,7 +268,7 @@ void fossil_test_register_suite(fossil_test_env_t *env, test_suite_t *suite); * @param suite The test suite. * @param test_case The test case to add. */ -void fossil_test_add_case(test_suite_t *suite, test_case_t *test_case); +void fossil_test_add_case(fossil_test_suite_t *suite, fossil_test_case_t *test_case); /** * @brief Removes a test case from a test suite. @@ -276,21 +276,21 @@ void fossil_test_add_case(test_suite_t *suite, test_case_t *test_case); * @param suite The test suite. * @param test_case The test case to remove. */ -void fossil_test_remove_case(test_suite_t *suite, test_case_t *test_case); +void fossil_test_remove_case(fossil_test_suite_t *suite, fossil_test_case_t *test_case); /** * @brief Sets up a test case. * * @param test_case The test case to set up. */ -void fossil_test_case_setup(test_case_t *test_case); +void fossil_test_case_setup(fossil_test_case_t *test_case); /** * @brief Tears down a test case. * * @param test_case The test case to tear down. */ -void fossil_test_case_teardown(test_case_t *test_case); +void fossil_fossil_test_case_teardown(fossil_test_case_t *test_case); /** * @brief Runs a test case. @@ -298,7 +298,7 @@ void fossil_test_case_teardown(test_case_t *test_case); * @param test_case The test case to run. * @param env The test environment. */ -void fossil_test_run_case(test_case_t *test_case, fossil_test_env_t *env); +void fossil_test_run_case(fossil_test_case_t *test_case, fossil_test_env_t *env); /** * @brief Runs all test cases in a test suite. @@ -306,7 +306,7 @@ void fossil_test_run_case(test_case_t *test_case, fossil_test_env_t *env); * @param suite The test suite to run. * @param env The test environment. */ -void fossil_test_run_suite(test_suite_t *suite, fossil_test_env_t *env); +void fossil_test_run_suite(fossil_test_suite_t *suite, fossil_test_env_t *env); /** * @brief Internal function to handle assertions with anomaly detection. @@ -380,7 +380,7 @@ void fossil_test_run_all(fossil_test_env_t *env); #ifdef __cplusplus #define _FOSSIL_TEST_CASE(test_name) \ void test_name##_test_func(void); \ - test_case_t test_name##_test_case = { \ + fossil_test_case_t test_name##_test_case = { \ #test_name, \ test_name##_test_func, \ nullptr, \ @@ -394,7 +394,7 @@ void fossil_test_run_all(fossil_test_env_t *env); #else #define _FOSSIL_TEST_CASE(test_name) \ void test_name##_test_func(void); \ - test_case_t test_name##_test_case = { \ + fossil_test_case_t test_name##_test_case = { \ .name = #test_name, \ .test_func = test_name##_test_func, \ .setup_func = NULL, \ @@ -420,7 +420,7 @@ void fossil_test_run_all(fossil_test_env_t *env); #define _FOSSIL_TEST_SUITE(suite_name) \ void suite_name##_setup_func(void); \ void suite_name##_teardown_func(void); \ - test_suite_t suite_name = { \ + fossil_test_suite_t suite_name = { \ #suite_name, \ suite_name##_setup_func, \ suite_name##_teardown_func, \ @@ -432,7 +432,7 @@ void fossil_test_run_all(fossil_test_env_t *env); #define _FOSSIL_TEST_SUITE(suite_name) \ void suite_name##_setup_func(void); \ void suite_name##_teardown_func(void); \ - test_suite_t suite_name = { \ + fossil_test_suite_t suite_name = { \ .name = #suite_name, \ .suite_setup_func = suite_name##_setup_func, \ .suite_teardown_func = suite_name##_teardown_func, \ diff --git a/code/logic/marking.c b/code/logic/marking.c index 3fd1e0db..d7fef22d 100644 --- a/code/logic/marking.c +++ b/code/logic/marking.c @@ -123,7 +123,7 @@ void fossil_test_benchmark(char* duration_type, double expected, double actual) } } // end of func -void fossil_benchmark_init(fossil_benchmark_t* benchmark, const char* name) { +void fossil_benchmark_init(fossil_mark_t* benchmark, const char* name) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return; @@ -142,7 +142,7 @@ void fossil_benchmark_init(fossil_benchmark_t* benchmark, const char* name) { benchmark->running = 0; } -void fossil_benchmark_start(fossil_benchmark_t* benchmark) { +void fossil_benchmark_start(fossil_mark_t* benchmark) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return; @@ -154,7 +154,7 @@ void fossil_benchmark_start(fossil_benchmark_t* benchmark) { } } -void fossil_benchmark_stop(fossil_benchmark_t* benchmark) { +void fossil_benchmark_stop(fossil_mark_t* benchmark) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return; @@ -175,7 +175,7 @@ void fossil_benchmark_stop(fossil_benchmark_t* benchmark) { } } -double fossil_benchmark_elapsed_seconds(const fossil_benchmark_t* benchmark) { +double fossil_benchmark_elapsed_seconds(const fossil_mark_t* benchmark) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return 0.0; @@ -183,7 +183,7 @@ double fossil_benchmark_elapsed_seconds(const fossil_benchmark_t* benchmark) { return benchmark->total_duration; } -double fossil_benchmark_min_time(const fossil_benchmark_t* benchmark) { +double fossil_benchmark_min_time(const fossil_mark_t* benchmark) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return 0.0; @@ -191,7 +191,7 @@ double fossil_benchmark_min_time(const fossil_benchmark_t* benchmark) { return benchmark->min_duration; } -double fossil_benchmark_max_time(const fossil_benchmark_t* benchmark) { +double fossil_benchmark_max_time(const fossil_mark_t* benchmark) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return 0.0; @@ -199,7 +199,7 @@ double fossil_benchmark_max_time(const fossil_benchmark_t* benchmark) { return benchmark->max_duration; } -double fossil_benchmark_avg_time(const fossil_benchmark_t* benchmark) { +double fossil_benchmark_avg_time(const fossil_mark_t* benchmark) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return 0.0; @@ -207,7 +207,7 @@ double fossil_benchmark_avg_time(const fossil_benchmark_t* benchmark) { return benchmark->num_samples > 0 ? benchmark->total_duration / benchmark->num_samples : 0.0; } -void fossil_benchmark_reset(fossil_benchmark_t* benchmark) { +void fossil_benchmark_reset(fossil_mark_t* benchmark) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return; @@ -218,7 +218,7 @@ void fossil_benchmark_reset(fossil_benchmark_t* benchmark) { benchmark->max_duration = 0.0; } -void fossil_benchmark_report(const fossil_benchmark_t* benchmark) { +void fossil_benchmark_report(const fossil_mark_t* benchmark) { if (benchmark == NULL) { printf("Error: benchmark is NULL\n"); return; @@ -230,7 +230,7 @@ void fossil_benchmark_report(const fossil_benchmark_t* benchmark) { printf("\033[1;32mAvg Time : %.6f seconds\n", fossil_benchmark_avg_time(benchmark)); } -void fossil_scoped_benchmark_init(scoped_benchmark_t* scoped_benchmark, fossil_benchmark_t* benchmark) { +void fossil_scoped_benchmark_init(fossil_scoped_mark_t* scoped_benchmark, fossil_mark_t* benchmark) { if (scoped_benchmark == NULL) { printf("Error: scoped_benchmark is NULL\n"); return; @@ -245,7 +245,7 @@ void fossil_scoped_benchmark_init(scoped_benchmark_t* scoped_benchmark, fossil_b fossil_benchmark_start(scoped_benchmark->benchmark); } -void fossil_scoped_benchmark_destroy(scoped_benchmark_t* scoped_benchmark) { +void fossil_scoped_benchmark_destroy(fossil_scoped_mark_t* scoped_benchmark) { if (scoped_benchmark == NULL) { printf("Error: scoped_benchmark is NULL\n"); return; diff --git a/code/logic/mocking.c b/code/logic/mocking.c index 1b7d2a17..5f4daa09 100644 --- a/code/logic/mocking.c +++ b/code/logic/mocking.c @@ -18,7 +18,7 @@ extern char *_custom_fossil_test_strdup(const char *str); -void fossil_mock_init(MockCallList *list) { +void fossil_mock_init(fossil_mock_calllist_t *list) { if (!list) { return; } @@ -27,14 +27,14 @@ void fossil_mock_init(MockCallList *list) { list->size = 0; } -void fossil_mock_destroy(MockCallList *list) { +void fossil_mock_destroy(fossil_mock_calllist_t *list) { if (!list) { return; } - MockCall *current = list->head; + fossil_mock_call_t *current = list->head; while (current) { - MockCall *next = current->next; + fossil_mock_call_t *next = current->next; free(current->function_name); for (int i = 0; i < current->num_args; ++i) { free(current->arguments[i]); @@ -48,12 +48,12 @@ void fossil_mock_destroy(MockCallList *list) { list->size = 0; } -void fossil_mock_add_call(MockCallList *list, const char *function_name, char **arguments, int num_args) { +void fossil_mock_add_call(fossil_mock_calllist_t *list, const char *function_name, char **arguments, int num_args) { if (!list || !function_name || !arguments) { return; } - MockCall *call = (MockCall *)malloc(sizeof(MockCall)); + fossil_mock_call_t *call = (fossil_mock_call_t *)malloc(sizeof(fossil_mock_call_t)); if (!call) { return; } @@ -96,12 +96,12 @@ void fossil_mock_add_call(MockCallList *list, const char *function_name, char ** list->size++; } -void fossil_mock_print(MockCallList *list) { +void fossil_mock_print(fossil_mock_calllist_t *list) { if (!list) { return; } - MockCall *current = list->head; + fossil_mock_call_t *current = list->head; while (current) { printf("Function: %s\n", current->function_name); printf("Arguments: "); diff --git a/code/logic/testing.c b/code/logic/testing.c index fd7338f8..79f2cd5e 100644 --- a/code/logic/testing.c +++ b/code/logic/testing.c @@ -14,7 +14,7 @@ */ #include "fossil/test/testing.h" -#ifdef __WIN32 + // Array of messages for each category const char *sarcastic_messages[] = { "Wow, no tests were run! What a productive day!", @@ -46,7 +46,27 @@ const char *sarcastic_messages[] = { "No tests? Guess we're flawless.", "No tests executed. Time to unwind.", "No tests? Must be a coding break.", - "No tests run. Time to kick back." + "No tests run. Time to kick back.", + "No tests executed. What a surprise!", + "No tests? Guess we're all perfect coders.", + "No tests run. Time to take a nap.", + "No tests? Must be a coding dream.", + "No tests executed. Time to party!", + "No tests? Guess we're all geniuses.", + "No tests run. Time to celebrate!", + "No tests? Must be a coding legend.", + "No tests executed. Time to rejoice.", + "No tests? Guess we're all experts.", + "No tests run. Time to relax and enjoy.", + "No tests? Must be a coding utopia.", + "No tests executed. Time to have fun.", + "No tests? Guess we're all masters.", + "No tests run. Time to take a break.", + "No tests? Must be a coding paradise.", + "No tests executed. Time to chill out.", + "No tests? Guess we're all wizards.", + "No tests run. Time to unwind and relax.", + "No tests? Must be a coding heaven." }; const char *humorous_messages[] = { @@ -79,7 +99,26 @@ const char *humorous_messages[] = { "Your tests failed. Time to figure it out.", "Oops! That didn't go well. Time to debug.", "Well, that was a fail. Let's try again.", - "Looks like we have some errors to fix." + "Looks like we have some errors to fix.", + "Your tests failed. Time to troubleshoot.", + "Oops! That was unexpected. Time to investigate.", + "Well, that was a blunder. Let's correct it.", + "Looks like we have some debugging to do.", + "Your tests failed. Time to analyze the issue.", + "Oops! That didn't go as expected. Time to debug.", + "Well, that was a setback. Let's resolve it.", + "Looks like we have some fixing to do.", + "Your tests failed. Time to diagnose the problem.", + "Oops! That was a misstep. Time to debug.", + "Well, that was a glitch. Let's fix it.", + "Looks like we have some troubleshooting to do.", + "Your tests failed. Time to rectify the issue.", + "Oops! That was a hiccup. Time to debug.", + "Well, that was a malfunction. Let's repair it.", + "Looks like we have some correcting to do.", + "Your tests failed. Time to address the problem.", + "Oops! That was a slip-up. Time to debug.", + "Well, that was a snag. Let's fix it." }; const char *great_news_messages[] = { @@ -112,7 +151,27 @@ const char *great_news_messages[] = { "Incredible! All tests passed with no difficulties.", "Stellar! All tests passed with no challenges.", "Magnificent! All tests passed with no hurdles.", - "Fabulous! All tests passed with no impediments." + "Fabulous! All tests passed with no impediments.", + "Perfect! All tests passed without any issues.", + "Great! All tests passed with no errors.", + "Wonderful! All tests passed with no problems.", + "Amazing! All tests passed with no failures.", + "Fantastic! All tests passed with no bugs.", + "Excellent! All tests passed with no glitches.", + "Superb! All tests passed with no hiccups.", + "Outstanding! All tests passed with no snags.", + "Brilliant! All tests passed with no setbacks.", + "Impressive! All tests passed with no troubles.", + "Wonderful! All tests passed with no obstacles.", + "Terrific! All tests passed with no difficulties.", + "Marvelous! All tests passed with no challenges.", + "Spectacular! All tests passed with no hurdles.", + "Phenomenal! All tests passed with no impediments.", + "Remarkable! All tests passed with no issues.", + "Incredible! All tests passed with no errors.", + "Stellar! All tests passed with no problems.", + "Magnificent! All tests passed with no failures.", + "Fabulous! All tests passed with no bugs." }; const char *timeout_messages[] = { @@ -145,140 +204,32 @@ const char *timeout_messages[] = { "Tests are still running. Time to check for issues!", "Timeout detected. Some tests need optimization!", "Tests are taking forever. Time to investigate the cause!", - "Timeout alert. Some tests are not finishing in time!" -}; - -#else - -// Array of messages for each category -const char *sarcastic_messages[] = { - "Wow, no tests were run! What a productive day! 😏", - "No tests to run, guess we're all just too good at writing code. 🧐", - "Congratulations, you've done absolutely nothing today. πŸ™ƒ", - "Oh, look! No tests were executed. What an achievement! πŸ₯³", - "Not a single test run, but hey, that's one way to keep things perfect! πŸ˜†", - "All set for a day of zero productivity? Nice! πŸ’€", - "The test suite is empty, but hey, at least the code didn't break! 😜", - "Zero tests executed. Clearly, you've mastered the art of doing nothing. 😎", - "Great! We've made it through an entire test run without running a single test. πŸ₯³", - "Isn't it great when there's nothing to test? πŸ™ƒ", - "No tests today, must be a holiday! πŸ–οΈ", - "Looks like the tests took a day off. πŸ›Œ", - "No tests? Guess it's time for a coffee break. β˜•", - "No tests executed. Time to celebrate doing nothing! πŸŽ‰", - "No tests? Must be a sign of perfection. 🌟", - "No tests today. Enjoy the free time! πŸŽ‰", - "No tests? Must be a coding miracle. 🀯", - "No tests executed. Time to relax. 😌", - "No tests? Must be a coding vacation. 🏝️", - "No tests run. Time to take it easy. 😎", - "No tests? Guess we're flawless. πŸ€·β€β™‚οΈ", - "No tests executed. Time to unwind. πŸ›‹οΈ", - "No tests? Must be a coding break. πŸ€”", - "No tests run. Time to kick back. πŸš€" -}; - -const char *humorous_messages[] = { - "Well, that was an epic failure! Better luck next time! πŸ˜‚", - "Whoops! Someone's definitely gonna need to debug that. 🐞", - "Looks like someone forgot to write the test cases. πŸ€·β€β™‚οΈ", - "Your tests failed, but at least you got closer to perfection... not. πŸ€¦β€β™‚οΈ", - "Not all heroes wear capes. Some of them fail tests. πŸ¦Έβ€β™‚οΈ", - "Don't worry, failure is just success in disguise. Or maybe not. πŸ˜…", - "Well, that was awkward. Let's try again, shall we? πŸ€”", - "Looks like we've encountered a bug! Hope you've got a magnifying glass. 🧐", - "Your tests are taking a nap, but don't worry, we'll wake them up! 😴", - "It's not a failure, it's just a learning experience! A very *expensive* one. πŸ’Έ", - "Oops! That didn't go as planned. 😬", - "Well, that was a disaster. Time to debug! πŸ› οΈ", - "Looks like we hit a snag. Time to fix it! πŸ›", - "Your tests failed spectacularly. Congrats! πŸŽ‰", - "Well, that was a mess. Let's clean it up. 🧹", - "Oops! Something went wrong. Time to investigate. πŸ•΅οΈβ€β™‚οΈ", - "Well, that was a flop. Better luck next time. 🀞", - "Looks like we have some bugs to squash. 🐞", - "Your tests failed. Time to roll up your sleeves. πŸ’ͺ", - "Oops! That didn't work. Time to try again. πŸ”„", - "Well, that was a fail. Let's fix it. πŸ› οΈ", - "Looks like we have some issues to resolve. 🧐", - "Your tests failed. Time to get to work. πŸ› οΈ", - "Oops! That was a fail. Time to debug. πŸ›", - "Well, that was a bust. Let's fix it. πŸ› οΈ", - "Looks like we have some problems to solve. 🧐", - "Your tests failed. Time to figure it out. πŸ› οΈ", - "Oops! That didn't go well. Time to debug. πŸ›", - "Well, that was a fail. Let's try again. πŸ”„", - "Looks like we have some errors to fix. πŸ› οΈ" -}; - -const char *great_news_messages[] = { - "Great news! All tests passed. You're a testing genius! πŸŽ‰", - "Success! Everything works as expected. Go celebrate! πŸ₯³", - "You did it! All tests passed. You're officially a rock star! 🌟", - "Congrats, all tests passed! You've earned a gold star! πŸ…", - "Woohoo! All tests passed with flying colors! 🎨", - "No bugs found today, you're on fire! πŸ”₯", - "Amazing! You've got a perfect test suite. Keep it up! πŸ’ͺ", - "Nice job! All tests passed. I think we've found the next coding superhero! πŸ¦Έβ€β™€οΈ", - "Fantastic! No issues at all, just pure success! 😎", - "All tests passed, everything's awesome. 🎢", - "Great job! All tests passed with no issues. πŸ‘", - "Congratulations! All tests passed successfully. πŸŽ‰", - "Well done! All tests passed with flying colors. 🌈", - "Awesome! All tests passed without a hitch. πŸ‘Œ", - "Fantastic! All tests passed with no problems. πŸŽ‰", - "Excellent! All tests passed with ease. 😎", - "Superb! All tests passed without any issues. 🌟", - "Outstanding! All tests passed with no errors. πŸ†", - "Brilliant! All tests passed with no failures. 🌟", - "Impressive! All tests passed with no bugs. 🐞", - "Wonderful! All tests passed with no glitches. πŸŽ‰", - "Terrific! All tests passed with no hiccups. πŸ‘", - "Marvelous! All tests passed with no snags. 🌟", - "Spectacular! All tests passed with no setbacks. πŸŽ‰", - "Phenomenal! All tests passed with no troubles. πŸ†", - "Remarkable! All tests passed with no obstacles. 🌟", - "Incredible! All tests passed with no difficulties. πŸŽ‰", - "Stellar! All tests passed with no challenges. 🌟", - "Magnificent! All tests passed with no hurdles. πŸ†", - "Fabulous! All tests passed with no impediments. πŸŽ‰" + "Timeout alert. Some tests are not finishing in time!", + "Tests are taking too long. Time to find the bottleneck!", + "Timeout detected. Some tests need a performance review!", + "Tests are running indefinitely. Time to debug!", + "Timeout warning. Some tests are stuck!", + "Tests are taking too long. Time to optimize performance!", + "Timeout issue detected. Some tests need a closer look!", + "Tests are running slow. Time to investigate!", + "Timeout alert. Some tests are not completing!", + "Tests are taking too long. Time to debug!", + "Timeout detected. Some tests are running too long!", + "Tests are exceeding the time limit. Time to optimize!", + "Timeout issue. Some tests are not finishing!", + "Tests are running longer than expected. Time to debug!", + "Timeout warning. Some tests are taking too long!", + "Tests are still running. Time to check for issues!", + "Timeout detected. Some tests need optimization!", + "Tests are taking forever. Time to investigate the cause!", + "Timeout alert. Some tests are not finishing in time!", + "Tests are taking too long. Time to find the bottleneck!" }; -const char *timeout_messages[] = { - "Some tests timed out. Please check the test cases. ⏰", - "Looks like some tests took too long to complete. Time to debug! πŸ›", - "Uh-oh! Some tests took too long to run. Time to investigate! πŸ•΅οΈβ€β™‚οΈ", - "Looks like some tests are still running. Did you forget to add a timeout? πŸ€”", - "Some tests are still in progress. Time to grab a coffee and debug! β˜•", - "Timeout alert! Some tests didn't finish in time. ⏳", - "Tests are taking longer than expected. Time to check for infinite loops! πŸ”„", - "Some tests exceeded the time limit. Let's optimize! πŸš€", - "Tests are running slow. Time to profile and improve performance! πŸ“ˆ", - "Timeout detected! Some tests need a closer look. πŸ”", - "Tests are taking forever. Time to investigate! πŸ•΅οΈβ€β™€οΈ", - "Some tests are stuck. Time to debug! 🐞", - "Tests are running longer than expected. Time to check for bottlenecks! ⏱️", - "Timeout warning! Some tests didn't complete in time. ⏲️", - "Tests are still running. Time to check for performance issues! πŸ› οΈ", - "Some tests are taking too long. Time to optimize! βš™οΈ", - "Tests are timing out. Time to investigate the cause! πŸ”", - "Timeout issue detected. Some tests need attention! 🚨", - "Tests are running slow. Time to improve efficiency! πŸƒβ€β™‚οΈ", - "Timeout alert! Some tests are not finishing in time. ⏳", - "Tests are taking too long. Time to debug and optimize! πŸ› οΈ", - "Timeout detected. Some tests are running indefinitely! πŸ”„", - "Tests are exceeding the time limit. Time to investigate! πŸ•΅οΈβ€β™‚οΈ", - "Timeout issue. Some tests are not completing in time! ⏲️", - "Tests are running longer than expected. Time to debug! πŸ›", - "Timeout warning. Some tests are taking too long! ⏰", - "Tests are still running. Time to check for issues! πŸ› οΈ", - "Timeout detected. Some tests need optimization! πŸš€", - "Tests are taking forever. Time to investigate the cause! πŸ”", - "Timeout alert. Some tests are not finishing in time! ⏳" +enum { + _FOSSIL_TEST_RESPONSE_LENGTH = 50 }; -#endif - static const char *FOSSIL_TEST_OPTIONS[] = { "--version - Displays the current version of Fossil Test\n", "--help - Shows help message with usage\n", @@ -299,6 +250,9 @@ static const char *FOSSIL_TEST_LICENSE = "Mozilla Public License 2.0"; // Licens jmp_buf test_jump_buffer; // This will hold the jump buffer for longjmp static int _ASSERT_COUNT = 0; // Counter for the number of assertions +// ***************************************************************************** +// Helper function declarations +// ***************************************************************************** // Custom implementation of strdup to avoid warnings on some platforms char *_custom_fossil_test_strdup(const char *str) { @@ -311,9 +265,13 @@ char *_custom_fossil_test_strdup(const char *str) { return new_str; } +// ***************************************************************************** +// Function declarations +// ***************************************************************************** + // Initialize the options structure -fossil_options_t init_options(void) { - fossil_options_t options; +fossil_test_options_t fossil_test_init_options(void) { + fossil_test_options_t options; options.show_version = false; options.show_help = false; options.show_info = false; @@ -348,8 +306,8 @@ void version_info(void) { } // Parse command-line arguments -fossil_options_t fossil_options_parse(int argc, char **argv) { - fossil_options_t options = init_options(); +fossil_test_options_t fossil_options_parse(int argc, char **argv) { + fossil_test_options_t options = fossil_test_init_options(); for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "--version") == 0) { @@ -395,14 +353,14 @@ fossil_options_t fossil_options_parse(int argc, char **argv) { } // Function to reverse the order of test cases in the linked list -void reverse_test_cases(test_case_t **test_cases) { +void reverse_test_cases(fossil_test_case_t **test_cases) { if (!test_cases || !*test_cases) { return; // No test cases to reverse } - test_case_t *prev = NULL; - test_case_t *current = *test_cases; - test_case_t *next = NULL; + fossil_test_case_t *prev = NULL; + fossil_test_case_t *current = *test_cases; + fossil_test_case_t *next = NULL; // Traverse the linked list and reverse the 'next' pointers while (current) { @@ -417,14 +375,14 @@ void reverse_test_cases(test_case_t **test_cases) { } // Function to shuffle test cases using the Fisher-Yates algorithm -void shuffle_test_cases(test_case_t **test_cases) { +void shuffle_test_cases(fossil_test_case_t **test_cases) { if (!test_cases || !*test_cases) { return; // No test cases to shuffle } // Calculate the length of the linked list (number of test cases) int n = 0; - test_case_t *current = *test_cases; + fossil_test_case_t *current = *test_cases; while (current) { n++; current = current->next; @@ -436,7 +394,7 @@ void shuffle_test_cases(test_case_t **test_cases) { } // Create an array to hold the test cases - test_case_t **array = malloc(sizeof(test_case_t *) * n); + fossil_test_case_t **array = malloc(sizeof(fossil_test_case_t *) * n); if (!array) { return; // Memory allocation failed } @@ -456,7 +414,7 @@ void shuffle_test_cases(test_case_t **test_cases) { int j = rand() % (i + 1); // Swap the elements - test_case_t *temp = array[i]; + fossil_test_case_t *temp = array[i]; array[i] = array[j]; array[j] = temp; } @@ -475,12 +433,12 @@ void shuffle_test_cases(test_case_t **test_cases) { } // Creates and returns a new test suite -test_suite_t* fossil_test_create_suite(const char *name) { +fossil_test_suite_t* fossil_test_create_suite(const char *name) { if (!name) { return NULL; } - test_suite_t *suite = (test_suite_t*)malloc(sizeof(test_suite_t)); + fossil_test_suite_t *suite = (fossil_test_suite_t*)malloc(sizeof(fossil_test_suite_t)); if (!suite) { return NULL; } @@ -494,7 +452,7 @@ test_suite_t* fossil_test_create_suite(const char *name) { } // Registers a test suite in the environment -void fossil_test_register_suite(fossil_test_env_t *env, test_suite_t *suite) { +void fossil_test_register_suite(fossil_test_env_t *env, fossil_test_suite_t *suite) { if (!env || !suite) { return; } @@ -507,7 +465,7 @@ void fossil_test_register_suite(fossil_test_env_t *env, test_suite_t *suite) { } // Adds a test case to a suite -void fossil_test_add_case(test_suite_t *suite, test_case_t *test_case) { +void fossil_test_add_case(fossil_test_suite_t *suite, fossil_test_case_t *test_case) { if (!suite || !test_case) { return; } @@ -517,13 +475,13 @@ void fossil_test_add_case(test_suite_t *suite, test_case_t *test_case) { } // Removes and frees a test case from a suite -void fossil_test_remove_case(test_suite_t *suite, test_case_t *test_case) { +void fossil_test_remove_case(fossil_test_suite_t *suite, fossil_test_case_t *test_case) { if (!suite || !test_case) { return; } - test_case_t *prev = NULL; - test_case_t *curr = suite->tests; + fossil_test_case_t *prev = NULL; + fossil_test_case_t *curr = suite->tests; while (curr) { if (curr == test_case) { @@ -541,21 +499,21 @@ void fossil_test_remove_case(test_suite_t *suite, test_case_t *test_case) { } // Setup for individual test case -void fossil_test_case_setup(test_case_t *test_case) { +void fossil_test_case_setup(fossil_test_case_t *test_case) { if (test_case && test_case->setup_func) { test_case->setup_func(); } } // Teardown for individual test case -void fossil_test_case_teardown(test_case_t *test_case) { +void fossil_fossil_test_case_teardown(fossil_test_case_t *test_case) { if (test_case && test_case->teardown_func) { test_case->teardown_func(); } } // Run all test cases in a test suite -void fossil_test_run_suite(test_suite_t *suite, fossil_test_env_t *env) { +void fossil_test_run_suite(fossil_test_suite_t *suite, fossil_test_env_t *env) { if (!suite || !env) { return; } @@ -577,7 +535,7 @@ void fossil_test_run_suite(test_suite_t *suite, fossil_test_env_t *env) { } double total_execution_time = 0.0; - test_case_t *current_test = suite->tests; + fossil_test_case_t *current_test = suite->tests; while (current_test) { fossil_test_run_case(current_test, env); total_execution_time += current_test->execution_time; @@ -613,21 +571,19 @@ void fossil_test_assert_internal(bool condition, const char *message, const char printf(FOSSIL_TEST_COLOR_YELLOW "Duplicate or similar assertion detected: %s (%s:%d in %s) [Anomaly Count: %d]\n" FOSSIL_TEST_COLOR_RESET, message, file, line, func, anomaly_count); } else { anomaly_count = 0; // Reset anomaly count for new assertion + last_message = message; + last_file = file; + last_line = line; + last_func = func; printf(FOSSIL_TEST_COLOR_RED "Assertion failed: %s (%s:%d in %s)\n" FOSSIL_TEST_COLOR_RESET, message, file, line, func); } - // Update the last assertion details - last_message = message; - last_file = file; - last_line = line; - last_func = func; - longjmp(test_jump_buffer, 1); // Jump back to test case failure handler } } // Run an individual test case -void fossil_test_run_case(test_case_t *test_case, fossil_test_env_t *env) { +void fossil_test_run_case(fossil_test_case_t *test_case, fossil_test_env_t *env) { if (!test_case || !env) { return; } @@ -670,7 +626,7 @@ void fossil_test_run_case(test_case_t *test_case, fossil_test_env_t *env) { } // Run teardown - fossil_test_case_teardown(test_case); + fossil_fossil_test_case_teardown(test_case); // Log result switch (test_case->status) { @@ -704,7 +660,7 @@ void fossil_test_run_all(fossil_test_env_t *env) { return; } - test_suite_t *current_suite = env->test_suites; + fossil_test_suite_t *current_suite = env->test_suites; while (current_suite) { fossil_test_run_suite(current_suite, env); @@ -751,15 +707,13 @@ void fossil_test_message(fossil_test_env_t *env) { srand(time(NULL)); if (env->pass_count == 0 && env->fail_count == 0 && env->skip_count == 0 && env->timeout_count == 0 && env->empty_count > 0) { - printf(FOSSIL_TEST_COLOR_YELLOW FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET, sarcastic_messages[rand() % 30]); + printf(FOSSIL_TEST_COLOR_YELLOW FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET, sarcastic_messages[rand() % _FOSSIL_TEST_RESPONSE_LENGTH]); } else if (env->fail_count > 0) { - printf(FOSSIL_TEST_COLOR_RED FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET, humorous_messages[rand() % 30]); + printf(FOSSIL_TEST_COLOR_RED FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET, humorous_messages[rand() % _FOSSIL_TEST_RESPONSE_LENGTH]); } else if (env->pass_count > 0) { - printf(FOSSIL_TEST_COLOR_GREEN FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET, great_news_messages[rand() % 30]); + printf(FOSSIL_TEST_COLOR_GREEN FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET, great_news_messages[rand() % _FOSSIL_TEST_RESPONSE_LENGTH]); } else if (env->timeout_count > 0) { - printf(FOSSIL_TEST_COLOR_ORANGE FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET, timeout_messages[rand() % 30]); - } else { - puts(FOSSIL_TEST_COLOR_BLUE FOSSIL_TEST_ATTR_ITATIC "Test results are in. Keep pushing, you're getting there!" FOSSIL_TEST_COLOR_RESET); + printf(FOSSIL_TEST_COLOR_ORANGE FOSSIL_TEST_ATTR_ITATIC "%s\n" FOSSIL_TEST_COLOR_RESET, timeout_messages[rand() % _FOSSIL_TEST_RESPONSE_LENGTH]); } } @@ -774,9 +728,9 @@ void fossil_test_summary(fossil_test_env_t *env) { return; } - test_suite_t *suite = env->test_suites; + fossil_test_suite_t *suite = env->test_suites; while (suite != NULL) { - test_case_t *test = suite->tests; + fossil_test_case_t *test = suite->tests; while (test != NULL) { if (test->status == TEST_STATUS_PASS) { env->pass_count++; diff --git a/code/tests/cases/test_mock.c b/code/tests/cases/test_mock.c index 64973ca0..c15504a6 100644 --- a/code/tests/cases/test_mock.c +++ b/code/tests/cases/test_mock.c @@ -57,25 +57,25 @@ FOSSIL_MOCK_FUNC(int, mock_function, int a, int b) { // * * * * * * * * * * * * * * * * * * * * * * * * FOSSIL_TEST_CASE(c_mock_call_list_initialization) { - // Example of initializing a MockCallList - MockCallList list; + // Example of initializing a fossil_mock_calllist_t + fossil_mock_calllist_t list; fossil_mock_init(&list); // Test cases - FOSSIL_TEST_ASSUME(list.head == NULL, "MockCallList head should be NULL after initialization"); - FOSSIL_TEST_ASSUME(list.tail == NULL, "MockCallList tail should be NULL after initialization"); - FOSSIL_TEST_ASSUME(list.size == 0, "MockCallList size should be 0 after initialization"); + FOSSIL_TEST_ASSUME(list.head == NULL, "fossil_mock_calllist_t head should be NULL after initialization"); + FOSSIL_TEST_ASSUME(list.tail == NULL, "fossil_mock_calllist_t tail should be NULL after initialization"); + FOSSIL_TEST_ASSUME(list.size == 0, "fossil_mock_calllist_t size should be 0 after initialization"); } // end case FOSSIL_TEST_CASE(c_mock_call_list_addition) { - // Example of adding a MockCall to a MockCallList - MockCallList list; + // Example of adding a fossil_mock_call_t to a fossil_mock_calllist_t + fossil_mock_calllist_t list; fossil_mock_init(&list); char *args[] = {"arg1", "arg2"}; fossil_mock_add_call(&list, "test_function", args, 2); // Test cases - FOSSIL_TEST_ASSUME(list.size == 1, "MockCallList size should be 1 after adding a call"); + FOSSIL_TEST_ASSUME(list.size == 1, "fossil_mock_calllist_t size should be 1 after adding a call"); FOSSIL_TEST_ASSUME(strcmp(list.head->function_name, "test_function") == 0, "Function name should be 'test_function'"); FOSSIL_TEST_ASSUME(list.head->num_args == 2, "Number of arguments should be 2"); FOSSIL_TEST_ASSUME(strcmp(list.head->arguments[0], "arg1") == 0, "First argument should be 'arg1'"); @@ -83,12 +83,12 @@ FOSSIL_TEST_CASE(c_mock_call_list_addition) { } // end case FOSSIL_TEST_CASE(c_mock_call_list_destruction) { - // Example of destroying a MockCallList - MockCallList list; + // Example of destroying a fossil_mock_calllist_t + fossil_mock_calllist_t list; fossil_mock_init(&list); char *args[] = {"arg1", "arg2"}; fossil_mock_add_call(&list, "test_function", args, 2); - FOSSIL_TEST_ASSUME(list.size == 1, "MockCallList size should be 1 after adding a call"); + FOSSIL_TEST_ASSUME(list.size == 1, "fossil_mock_calllist_t size should be 1 after adding a call"); FOSSIL_TEST_ASSUME(strcmp(list.head->function_name, "test_function") == 0, "Function name should be 'test_function'"); FOSSIL_TEST_ASSUME(list.head->num_args == 2, "Number of arguments should be 2"); @@ -96,25 +96,25 @@ FOSSIL_TEST_CASE(c_mock_call_list_destruction) { } // end case FOSSIL_TEST_CASE(c_mock_call_list_initialization_macro) { - // Example of initializing a MockCallList using the macro - MockCallList list; + // Example of initializing a fossil_mock_calllist_t using the macro + fossil_mock_calllist_t list; MOCK_INIT(list); // Test cases - FOSSIL_TEST_ASSUME(list.head == NULL, "MockCallList head should be NULL after initialization"); - FOSSIL_TEST_ASSUME(list.tail == NULL, "MockCallList tail should be NULL after initialization"); - FOSSIL_TEST_ASSUME(list.size == 0, "MockCallList size should be 0 after initialization"); + FOSSIL_TEST_ASSUME(list.head == NULL, "fossil_mock_calllist_t head should be NULL after initialization"); + FOSSIL_TEST_ASSUME(list.tail == NULL, "fossil_mock_calllist_t tail should be NULL after initialization"); + FOSSIL_TEST_ASSUME(list.size == 0, "fossil_mock_calllist_t size should be 0 after initialization"); } // end case FOSSIL_TEST_CASE(c_mock_call_list_addition_macro) { - // Example of adding a MockCall to a MockCallList using the macro - MockCallList list; + // Example of adding a fossil_mock_call_t to a fossil_mock_calllist_t using the macro + fossil_mock_calllist_t list; MOCK_INIT(list); char *args[] = {"arg1", "arg2"}; MOCK_ADD_CALL(list, "test_function", args, 2); // Test cases - FOSSIL_TEST_ASSUME(list.size == 1, "MockCallList size should be 1 after adding a call"); + FOSSIL_TEST_ASSUME(list.size == 1, "fossil_mock_calllist_t size should be 1 after adding a call"); FOSSIL_TEST_ASSUME(strcmp(list.head->function_name, "test_function") == 0, "Function name should be 'test_function'"); FOSSIL_TEST_ASSUME(list.head->num_args == 2, "Number of arguments should be 2"); FOSSIL_TEST_ASSUME(strcmp(list.head->arguments[0], "arg1") == 0, "First argument should be 'arg1'"); @@ -122,13 +122,13 @@ FOSSIL_TEST_CASE(c_mock_call_list_addition_macro) { } // end case FOSSIL_TEST_CASE(c_mock_call_list_destruction_macro) { - // Example of destroying a MockCallList using the macro - MockCallList list; + // Example of destroying a fossil_mock_calllist_t using the macro + fossil_mock_calllist_t list; MOCK_INIT(list); char *args[] = {"arg1", "arg2"}; MOCK_ADD_CALL(list, "test_function", args, 2); - FOSSIL_TEST_ASSUME(list.size == 1, "MockCallList size should be 1 after adding a call"); + FOSSIL_TEST_ASSUME(list.size == 1, "fossil_mock_calllist_t size should be 1 after adding a call"); FOSSIL_TEST_ASSUME(strcmp(list.head->function_name, "test_function") == 0, "Function name should be 'test_function'"); FOSSIL_TEST_ASSUME(list.head->num_args == 2, "Number of arguments should be 2"); diff --git a/code/tests/cases/test_mock.cpp b/code/tests/cases/test_mock.cpp index 84311b78..baf8695c 100644 --- a/code/tests/cases/test_mock.cpp +++ b/code/tests/cases/test_mock.cpp @@ -58,25 +58,25 @@ FOSSIL_MOCK_FUNC(int, mock_function, int a, int b) { // * * * * * * * * * * * * * * * * * * * * * * * * FOSSIL_TEST_CASE(cpp_mock_call_list_initialization) { - // Example of initializing a MockCallList - MockCallList list; + // Example of initializing a fossil_mock_calllist_t + fossil_mock_calllist_t list; fossil_mock_init(&list); // Test cases - FOSSIL_TEST_ASSUME(list.head == NULL, "MockCallList head should be NULL after initialization"); - FOSSIL_TEST_ASSUME(list.tail == NULL, "MockCallList tail should be NULL after initialization"); - FOSSIL_TEST_ASSUME(list.size == 0, "MockCallList size should be 0 after initialization"); + FOSSIL_TEST_ASSUME(list.head == NULL, "fossil_mock_calllist_t head should be NULL after initialization"); + FOSSIL_TEST_ASSUME(list.tail == NULL, "fossil_mock_calllist_t tail should be NULL after initialization"); + FOSSIL_TEST_ASSUME(list.size == 0, "fossil_mock_calllist_t size should be 0 after initialization"); } // end case FOSSIL_TEST_CASE(cpp_mock_call_list_addition) { - // Example of adding a MockCall to a MockCallList - MockCallList list; + // Example of adding a fossil_mock_call_t to a fossil_mock_calllist_t + fossil_mock_calllist_t list; fossil_mock_init(&list); const char* args[] = {"arg1", "arg2"}; fossil_mock_add_call(&list, "test_function", (char**)args, 2); // Test cases - FOSSIL_TEST_ASSUME(list.size == 1, "MockCallList size should be 1 after adding a call"); + FOSSIL_TEST_ASSUME(list.size == 1, "fossil_mock_calllist_t size should be 1 after adding a call"); //FOSSIL_TEST_ASSUME(list.head->function_name == "test_function", "Function name should be 'test_function'"); FOSSIL_TEST_ASSUME(list.head->num_args == 2, "Number of arguments should be 2"); FOSSIL_TEST_ASSUME(std::strcmp(list.head->arguments[0], "arg1") == 0, "First argument should be 'arg1'"); @@ -84,12 +84,12 @@ FOSSIL_TEST_CASE(cpp_mock_call_list_addition) { } // end case FOSSIL_TEST_CASE(cpp_mock_call_list_destruction) { - // Example of destroying a MockCallList - MockCallList list; + // Example of destroying a fossil_mock_calllist_t + fossil_mock_calllist_t list; fossil_mock_init(&list); const char* args[] = {"arg1", "arg2"}; fossil_mock_add_call(&list, "test_function", (char**)args, 2); - FOSSIL_TEST_ASSUME(list.size == 1, "MockCallList size should be 1 after adding a call"); + FOSSIL_TEST_ASSUME(list.size == 1, "fossil_mock_calllist_t size should be 1 after adding a call"); FOSSIL_TEST_ASSUME(strcmp(list.head->function_name, "test_function") == 0, "Function name should be 'test_function'"); FOSSIL_TEST_ASSUME(list.head->num_args == 2, "Number of arguments should be 2"); @@ -97,25 +97,25 @@ FOSSIL_TEST_CASE(cpp_mock_call_list_destruction) { } // end case FOSSIL_TEST_CASE(cpp_mock_call_list_initialization_macro) { - // Example of initializing a MockCallList using the macro - MockCallList list; + // Example of initializing a fossil_mock_calllist_t using the macro + fossil_mock_calllist_t list; MOCK_INIT(list); // Test cases - FOSSIL_TEST_ASSUME(list.head == NULL, "MockCallList head should be NULL after initialization"); - FOSSIL_TEST_ASSUME(list.tail == NULL, "MockCallList tail should be NULL after initialization"); - FOSSIL_TEST_ASSUME(list.size == 0, "MockCallList size should be 0 after initialization"); + FOSSIL_TEST_ASSUME(list.head == NULL, "fossil_mock_calllist_t head should be NULL after initialization"); + FOSSIL_TEST_ASSUME(list.tail == NULL, "fossil_mock_calllist_t tail should be NULL after initialization"); + FOSSIL_TEST_ASSUME(list.size == 0, "fossil_mock_calllist_t size should be 0 after initialization"); } // end case FOSSIL_TEST_CASE(cpp_mock_call_list_addition_macro) { - // Example of adding a MockCall to a MockCallList using the macro - MockCallList list; + // Example of adding a fossil_mock_call_t to a fossil_mock_calllist_t using the macro + fossil_mock_calllist_t list; MOCK_INIT(list); const char* args[] = {"arg1", "arg2"}; MOCK_ADD_CALL(list, "test_function", (char**)args, 2); // Test cases - FOSSIL_TEST_ASSUME(list.size == 1, "MockCallList size should be 1 after adding a call"); + FOSSIL_TEST_ASSUME(list.size == 1, "fossil_mock_calllist_t size should be 1 after adding a call"); //FOSSIL_TEST_ASSUME(list.head->function_name == "test_function", "Function name should be 'test_function'"); FOSSIL_TEST_ASSUME(list.head->num_args == 2, "Number of arguments should be 2"); FOSSIL_TEST_ASSUME(std::strcmp(list.head->arguments[0], "arg1") == 0, "First argument should be 'arg1'"); @@ -123,12 +123,12 @@ FOSSIL_TEST_CASE(cpp_mock_call_list_addition_macro) { } // end case FOSSIL_TEST_CASE(cpp_mock_call_list_destruction_macro) { - // Example of destroying a MockCallList using the macro - MockCallList list; + // Example of destroying a fossil_mock_calllist_t using the macro + fossil_mock_calllist_t list; MOCK_INIT(list); const char* args[] = {"arg1", "arg2"}; MOCK_ADD_CALL(list, "test_function", (char**)args, 2); - FOSSIL_TEST_ASSUME(list.size == 1, "MockCallList size should be 1 after adding a call"); + FOSSIL_TEST_ASSUME(list.size == 1, "fossil_mock_calllist_t size should be 1 after adding a call"); FOSSIL_TEST_ASSUME(strcmp(list.head->function_name, "test_function") == 0, "Function name should be 'test_function'"); FOSSIL_TEST_ASSUME(list.head->num_args == 2, "Number of arguments should be 2");