From b69dfb5d6f0ba22e5d65944c341c4c525e23c698 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding@users.noreply.github.com> Date: Sat, 25 Jan 2025 15:17:33 -0600 Subject: [PATCH 1/2] Update mocking.h --- code/logic/fossil/test/mocking.h | 117 ++++++++++++++++--------------- 1 file changed, 62 insertions(+), 55 deletions(-) diff --git a/code/logic/fossil/test/mocking.h b/code/logic/fossil/test/mocking.h index 2560bf47..63fdd9bc 100644 --- a/code/logic/fossil/test/mocking.h +++ b/code/logic/fossil/test/mocking.h @@ -19,8 +19,69 @@ #include #include -#include +#include #include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// ***************************************************************************** +// Type declarations +// ***************************************************************************** + +typedef struct fossil_mock_call_t { + char *function_name; + char **arguments; + int num_args; + struct fossil_mock_call_t *next; +} fossil_mock_call_t; + +typedef struct { + fossil_mock_call_t *head; + fossil_mock_call_t *tail; + int size; +} fossil_mock_calllist_t; + +// ***************************************************************************** +// Function declarations +// ***************************************************************************** + +/** + * Initializes a fossil_mock_calllist_t. + * + * @param list The fossil_mock_calllist_t to initialize. + */ +void fossil_mock_init(fossil_mock_calllist_t *list); + +/** + * Destroys a fossil_mock_calllist_t and frees all associated memory. + * + * @param list The fossil_mock_calllist_t to destroy. + */ +void fossil_mock_destroy(fossil_mock_calllist_t *list); + +/** + * Adds a fossil_mock_call_t to the fossil_mock_calllist_t. + * + * @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(fossil_mock_calllist_t *list, const char *function_name, char **arguments, int num_args); + +/** + * Prints the contents of a fossil_mock_calllist_t. + * + * @param list The fossil_mock_calllist_t to print. + */ +void fossil_mock_print(fossil_mock_calllist_t *list); + +#ifdef __cplusplus +} +#endif /** * @brief Macro for initializing the mock list. @@ -112,58 +173,4 @@ typedef struct name #endif -#ifdef __cplusplus -extern "C" { -#endif - -// C interface - -typedef struct fossil_mock_call_t { - char *function_name; - char **arguments; - int num_args; - struct fossil_mock_call_t *next; -} fossil_mock_call_t; - -typedef struct { - fossil_mock_call_t *head; - fossil_mock_call_t *tail; - int size; -} fossil_mock_calllist_t; - -/** - * Initializes a fossil_mock_calllist_t. - * - * @param list The fossil_mock_calllist_t to initialize. - */ -void fossil_mock_init(fossil_mock_calllist_t *list); - -/** - * Destroys a fossil_mock_calllist_t and frees all associated memory. - * - * @param list The fossil_mock_calllist_t to destroy. - */ -void fossil_mock_destroy(fossil_mock_calllist_t *list); - -/** - * Adds a fossil_mock_call_t to the fossil_mock_calllist_t. - * - * @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(fossil_mock_calllist_t *list, const char *function_name, char **arguments, int num_args); - -/** - * Prints the contents of a fossil_mock_calllist_t. - * - * @param list The fossil_mock_calllist_t to print. - */ -void fossil_mock_print(fossil_mock_calllist_t *list); - -#ifdef __cplusplus -} -#endif - #endif // FOSSIL_MOCK_FRAMEWORK_H From a4c42aaf6e87c64d36083189637018a3f12c704f Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding@users.noreply.github.com> Date: Sat, 25 Jan 2025 15:17:51 -0600 Subject: [PATCH 2/2] Update mocking.c --- code/logic/mocking.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/logic/mocking.c b/code/logic/mocking.c index 5f4daa09..abbe2fd8 100644 --- a/code/logic/mocking.c +++ b/code/logic/mocking.c @@ -18,6 +18,10 @@ extern char *_custom_fossil_test_strdup(const char *str); +// ***************************************************************************** +// Function declarations +// ***************************************************************************** + void fossil_mock_init(fossil_mock_calllist_t *list) { if (!list) { return;