|
19 | 19 |
|
20 | 20 | #include <stdio.h> |
21 | 21 | #include <stdlib.h> |
22 | | -#include <string.h> |
| 22 | +#include <stddef.h> |
23 | 23 | #include <stdbool.h> |
| 24 | +#include <string.h> |
| 25 | + |
| 26 | +#ifdef __cplusplus |
| 27 | +extern "C" { |
| 28 | +#endif |
| 29 | + |
| 30 | +// ***************************************************************************** |
| 31 | +// Type declarations |
| 32 | +// ***************************************************************************** |
| 33 | + |
| 34 | +typedef struct fossil_mock_call_t { |
| 35 | + char *function_name; |
| 36 | + char **arguments; |
| 37 | + int num_args; |
| 38 | + struct fossil_mock_call_t *next; |
| 39 | +} fossil_mock_call_t; |
| 40 | + |
| 41 | +typedef struct { |
| 42 | + fossil_mock_call_t *head; |
| 43 | + fossil_mock_call_t *tail; |
| 44 | + int size; |
| 45 | +} fossil_mock_calllist_t; |
| 46 | + |
| 47 | +// ***************************************************************************** |
| 48 | +// Function declarations |
| 49 | +// ***************************************************************************** |
| 50 | + |
| 51 | +/** |
| 52 | + * Initializes a fossil_mock_calllist_t. |
| 53 | + * |
| 54 | + * @param list The fossil_mock_calllist_t to initialize. |
| 55 | + */ |
| 56 | +void fossil_mock_init(fossil_mock_calllist_t *list); |
| 57 | + |
| 58 | +/** |
| 59 | + * Destroys a fossil_mock_calllist_t and frees all associated memory. |
| 60 | + * |
| 61 | + * @param list The fossil_mock_calllist_t to destroy. |
| 62 | + */ |
| 63 | +void fossil_mock_destroy(fossil_mock_calllist_t *list); |
| 64 | + |
| 65 | +/** |
| 66 | + * Adds a fossil_mock_call_t to the fossil_mock_calllist_t. |
| 67 | + * |
| 68 | + * @param list The fossil_mock_calllist_t to add the fossil_mock_call_t to. |
| 69 | + * @param function_name The name of the function being called. |
| 70 | + * @param arguments The arguments passed to the function. |
| 71 | + * @param num_args The number of arguments. |
| 72 | + */ |
| 73 | +void fossil_mock_add_call(fossil_mock_calllist_t *list, const char *function_name, char **arguments, int num_args); |
| 74 | + |
| 75 | +/** |
| 76 | + * Prints the contents of a fossil_mock_calllist_t. |
| 77 | + * |
| 78 | + * @param list The fossil_mock_calllist_t to print. |
| 79 | + */ |
| 80 | +void fossil_mock_print(fossil_mock_calllist_t *list); |
| 81 | + |
| 82 | +#ifdef __cplusplus |
| 83 | +} |
| 84 | +#endif |
24 | 85 |
|
25 | 86 | /** |
26 | 87 | * @brief Macro for initializing the mock list. |
|
112 | 173 | typedef struct name |
113 | 174 | #endif |
114 | 175 |
|
115 | | -#ifdef __cplusplus |
116 | | -extern "C" { |
117 | | -#endif |
118 | | - |
119 | | -// C interface |
120 | | - |
121 | | -typedef struct fossil_mock_call_t { |
122 | | - char *function_name; |
123 | | - char **arguments; |
124 | | - int num_args; |
125 | | - struct fossil_mock_call_t *next; |
126 | | -} fossil_mock_call_t; |
127 | | - |
128 | | -typedef struct { |
129 | | - fossil_mock_call_t *head; |
130 | | - fossil_mock_call_t *tail; |
131 | | - int size; |
132 | | -} fossil_mock_calllist_t; |
133 | | - |
134 | | -/** |
135 | | - * Initializes a fossil_mock_calllist_t. |
136 | | - * |
137 | | - * @param list The fossil_mock_calllist_t to initialize. |
138 | | - */ |
139 | | -void fossil_mock_init(fossil_mock_calllist_t *list); |
140 | | - |
141 | | -/** |
142 | | - * Destroys a fossil_mock_calllist_t and frees all associated memory. |
143 | | - * |
144 | | - * @param list The fossil_mock_calllist_t to destroy. |
145 | | - */ |
146 | | -void fossil_mock_destroy(fossil_mock_calllist_t *list); |
147 | | - |
148 | | -/** |
149 | | - * Adds a fossil_mock_call_t to the fossil_mock_calllist_t. |
150 | | - * |
151 | | - * @param list The fossil_mock_calllist_t to add the fossil_mock_call_t to. |
152 | | - * @param function_name The name of the function being called. |
153 | | - * @param arguments The arguments passed to the function. |
154 | | - * @param num_args The number of arguments. |
155 | | - */ |
156 | | -void fossil_mock_add_call(fossil_mock_calllist_t *list, const char *function_name, char **arguments, int num_args); |
157 | | - |
158 | | -/** |
159 | | - * Prints the contents of a fossil_mock_calllist_t. |
160 | | - * |
161 | | - * @param list The fossil_mock_calllist_t to print. |
162 | | - */ |
163 | | -void fossil_mock_print(fossil_mock_calllist_t *list); |
164 | | - |
165 | | -#ifdef __cplusplus |
166 | | -} |
167 | | -#endif |
168 | | - |
169 | 176 | #endif // FOSSIL_MOCK_FRAMEWORK_H |
0 commit comments