#define _di_f_iki_content_partial_is_
//#define _di_f_iki_data_delete_
#define _di_f_iki_data_destroy_
-#define _di_f_iki_datas_adjust_
+#define _di_f_iki_datas_adjust_callback_
#define _di_f_iki_datas_append_
#define _di_f_iki_datas_append_all_
-#define _di_f_iki_datas_decimate_by_
-#define _di_f_iki_datas_decrease_by_
-#define _di_f_iki_datas_increase_
-#define _di_f_iki_datas_increase_by_
-#define _di_f_iki_datas_resize_
-#define _di_f_iki_datass_adjust_
+#define _di_f_iki_datas_resize_callack_
#define _di_f_iki_datass_append_
#define _di_f_iki_datass_append_all_
-#define _di_f_iki_datass_decimate_by_
-#define _di_f_iki_datass_decrease_by_
-#define _di_f_iki_datass_increase_
-#define _di_f_iki_datass_increase_by_
-#define _di_f_iki_datass_resize_
#define _di_f_iki_datass_t_
#define _di_f_iki_datas_t_
//#define _di_f_iki_data_t_
#endif
#ifndef _di_f_account_delete_
- f_status_t f_account_delete(f_account_t *account) {
+ f_status_t f_account_delete(f_account_t * const account) {
#ifndef _di_level_0_parameter_checking_
if (!account) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_account_delete(account);
+ f_status_t status = f_string_dynamic_resize(0, &account->home);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_resize(0, &account->label);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_resize(0, &account->name);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_resize(0, &account->password);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_resize(0, &account->shell);
+ if (F_status_is_error(status)) return status;
+
+ return F_none;
}
#endif // _di_f_account_delete_
#ifndef _di_f_account_destroy_
- f_status_t f_account_destroy(f_account_t *account) {
+ f_status_t f_account_destroy(f_account_t * const account) {
#ifndef _di_level_0_parameter_checking_
if (!account) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- return private_f_account_destroy(account);
- }
-#endif // _di_f_account_destroy_
+ f_status_t status = f_string_dynamic_adjust(0, &account->home);
+ if (F_status_is_error(status)) return status;
-#ifndef _di_f_accounts_adjust_
- f_status_t f_accounts_adjust(const f_number_unsigned_t length, f_accounts_t *accounts) {
- #ifndef _di_level_0_parameter_checking_
- if (!accounts) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ status = f_string_dynamic_adjust(0, &account->label);
+ if (F_status_is_error(status)) return status;
- return private_f_accounts_adjust(length, accounts);
- }
-#endif // _di_f_accounts_adjust_
+ status = f_string_dynamic_adjust(0, &account->name);
+ if (F_status_is_error(status)) return status;
-#ifndef _di_f_accounts_append_
- f_status_t f_accounts_append(const f_account_t source, f_accounts_t *destination) {
- #ifndef _di_level_0_parameter_checking_
- if (!destination) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ status = f_string_dynamic_adjust(0, &account->password);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_adjust(0, &account->shell);
+ if (F_status_is_error(status)) return status;
- return private_f_accounts_append(source, destination);
+ return F_none;
}
-#endif // _di_f_accounts_append_
+#endif // _di_f_account_destroy_
-#ifndef _di_f_accounts_append_all_
- f_status_t f_accounts_append_all(const f_accounts_t source, f_accounts_t *destination) {
- #ifndef _di_level_0_parameter_checking_
- if (!destination) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+#ifndef _di_f_accounts_adjust_callback_
+ f_status_t f_accounts_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) {
- if (!source.used) return F_data_not;
+ {
+ f_accounts_t * const array = (f_accounts_t *) void_array;
+ f_status_t status = F_none;
- return private_f_accounts_append_all(source, destination);
- }
-#endif // _di_f_accounts_append_all_
+ for (f_number_unsigned_t i = start; i < stop; ++i) {
-#ifndef _di_f_accounts_decimate_by_
- f_status_t f_accounts_decimate_by(const f_number_unsigned_t amount, f_accounts_t *accounts) {
- #ifndef _di_level_0_parameter_checking_
- if (!accounts) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ status = f_string_dynamic_adjust(0, &array->array[i].home);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_adjust(0, &array->array[i].label);
+ if (F_status_is_error(status)) return status;
- if (!amount) return F_data_not;
+ status = f_string_dynamic_adjust(0, &array->array[i].name);
+ if (F_status_is_error(status)) return status;
- if (accounts->size > amount) {
- return private_f_accounts_adjust(accounts->size - amount, accounts);
+ status = f_string_dynamic_adjust(0, &array->array[i].password);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_adjust(0, &array->array[i].shell);
+ if (F_status_is_error(status)) return status;
+ } // for
}
- return private_f_accounts_adjust(0, accounts);
+ return F_none;
}
-#endif // _di_f_accounts_decimate_by_
+#endif // _di_f_accounts_adjust_callback_
-#ifndef _di_f_accounts_decrease_by_
- f_status_t f_accounts_decrease_by(const f_number_unsigned_t amount, f_accounts_t *accounts) {
+#ifndef _di_f_accounts_append_
+ f_status_t f_accounts_append(const f_account_t source, f_accounts_t * const destination) {
#ifndef _di_level_0_parameter_checking_
- if (!accounts) return F_status_set_error(F_parameter);
+ if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
+ f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_account_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
- if (accounts->size > amount) {
- return private_f_accounts_resize(accounts->size - amount, accounts);
- }
+ destination->array[destination->used].home.used = 0;
+ destination->array[destination->used].label.used = 0;
+ destination->array[destination->used].name.used = 0;
+ destination->array[destination->used].password.used = 0;
+ destination->array[destination->used].shell.used = 0;
- return private_f_accounts_resize(0, accounts);
- }
-#endif // _di_f_accounts_decrease_by_
+ status = f_string_dynamic_append(source.home, &destination->array[destination->used].home);
+ if (F_status_is_error(status)) return status;
-#ifndef _di_f_accounts_increase_
- f_status_t f_accounts_increase(const f_number_unsigned_t step, f_accounts_t *accounts) {
- #ifndef _di_level_0_parameter_checking_
- if (!accounts) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ status = f_string_dynamic_append(source.label, &destination->array[destination->used].label);
+ if (F_status_is_error(status)) return status;
- if (step && accounts->used + 1 > accounts->size) {
- f_number_unsigned_t size = accounts->used + step;
+ status = f_string_dynamic_append(source.name, &destination->array[destination->used].name);
+ if (F_status_is_error(status)) return status;
- if (size > F_number_t_size_unsigned_d) {
- if (accounts->used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
+ status = f_string_dynamic_append(source.password, &destination->array[destination->used].password);
+ if (F_status_is_error(status)) return status;
- size = F_number_t_size_unsigned_d;
- }
+ status = f_string_dynamic_append(source.shell, &destination->array[destination->used].shell);
+ if (F_status_is_error(status)) return status;
- return private_f_accounts_resize(size, accounts);
- }
+ ++destination->used;
- return F_data_not;
+ return F_none;
}
-#endif // _di_f_accounts_increase_
+#endif // _di_f_accounts_append_
-#ifndef _di_f_accounts_increase_by_
- f_status_t f_accounts_increase_by(const f_number_unsigned_t amount, f_accounts_t *accounts) {
+#ifndef _di_f_accounts_append_all_
+ f_status_t f_accounts_append_all(const f_accounts_t source, f_accounts_t * const destination) {
#ifndef _di_level_0_parameter_checking_
- if (!accounts) return F_status_set_error(F_parameter);
+ if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
+ if (!source.used) return F_data_not;
- if (accounts->used + amount > accounts->size) {
- if (accounts->used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
+ return private_f_accounts_append_all(source, destination);
+ }
+#endif // _di_f_accounts_append_all_
- return private_f_accounts_resize(accounts->used + amount, accounts);
- }
+#ifndef _di_f_accounts_resize_callback_
+ f_status_t f_accounts_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) {
- return F_data_not;
- }
-#endif // _di_f_accounts_increase_by_
+ {
+ f_accounts_t * const array = (f_accounts_t *) void_array;
+ f_status_t status = F_none;
-#ifndef _di_f_accounts_resize_
- f_status_t f_accounts_resize(const f_number_unsigned_t length, f_accounts_t *accounts) {
- #ifndef _di_level_0_parameter_checking_
- if (!accounts) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ for (f_number_unsigned_t i = start; i < stop; ++i) {
- return private_f_accounts_resize(length, accounts);
- }
-#endif // _di_f_accounts_resize_
+ status = f_string_dynamic_resize(0, &array->array[i].home);
+ if (F_status_is_error(status)) return status;
-#ifndef _di_f_accountss_adjust_
- f_status_t f_accountss_adjust(const f_number_unsigned_t length, f_accountss_t *accountss) {
- #ifndef _di_level_0_parameter_checking_
- if (!accountss) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ status = f_string_dynamic_resize(0, &array->array[i].label);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_resize(0, &array->array[i].name);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_resize(0, &array->array[i].password);
+ if (F_status_is_error(status)) return status;
+
+ status = f_string_dynamic_resize(0, &array->array[i].shell);
+ if (F_status_is_error(status)) return status;
+ } // for
+ }
- return private_f_accountss_adjust(length, accountss);
+ return F_none;
}
-#endif // _di_f_accountss_adjust_
+#endif // _di_f_accounts_resize_callback_
#ifndef _di_f_accountss_append_
- f_status_t f_accountss_append(const f_accounts_t source, f_accountss_t *destination) {
+ f_status_t f_accountss_append(const f_accounts_t source, f_accountss_t * const destination) {
#ifndef _di_level_0_parameter_checking_
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
if (!source.used) return F_data_not;
- f_status_t status = F_none;
-
- if (destination->used + 1 > destination->size) {
- status = private_f_accountss_resize(destination->used + F_memory_default_allocation_small_d, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_accounts_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
status = private_f_accounts_append_all(source, &destination->array[destination->used]);
if (F_status_is_error(status)) return status;
#endif // _di_f_accountss_append_
#ifndef _di_f_accountss_append_all_
- f_status_t f_accountss_append_all(const f_accountss_t source, f_accountss_t *destination) {
+ f_status_t f_accountss_append_all(const f_accountss_t source, f_accountss_t * const destination) {
#ifndef _di_level_0_parameter_checking_
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
if (!source.used) return F_data_not;
- f_status_t status = F_none;
-
- if (destination->used + source.used > destination->size) {
- status = private_f_accountss_resize(destination->used + source.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_accounts_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
}
#endif // _di_f_accountss_append_all_
-#ifndef _di_f_accountss_decimate_by_
- f_status_t f_accountss_decimate_by(const f_number_unsigned_t amount, f_accountss_t *accountss) {
- #ifndef _di_level_0_parameter_checking_
- if (!accountss) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (accountss->size > amount) {
- return private_f_accountss_adjust(accountss->size - amount, accountss);
- }
-
- return private_f_accountss_adjust(0, accountss);
- }
-#endif // _di_f_accountss_decimate_by_
-
-#ifndef _di_f_accountss_decrease_by_
- f_status_t f_accountss_decrease_by(const f_number_unsigned_t amount, f_accountss_t *accountss) {
- #ifndef _di_level_0_parameter_checking_
- if (!accountss) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (accountss->size > amount) {
- return private_f_accountss_resize(accountss->size - amount, accountss);
- }
-
- return private_f_accountss_resize(0, accountss);
- }
-#endif // _di_f_accountss_decrease_by_
-
-#ifndef _di_f_accountss_increase_
- f_status_t f_accountss_increase(const f_number_unsigned_t step, f_accountss_t *accountss) {
- #ifndef _di_level_0_parameter_checking_
- if (!accountss) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && accountss->used + 1 > accountss->size) {
- f_number_unsigned_t size = accountss->used + step;
-
- if (size > F_number_t_size_unsigned_d) {
- if (accountss->used + 1 > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_number_t_size_unsigned_d;
- }
-
- return private_f_accountss_resize(size, accountss);
- }
-
- return F_data_not;
- }
-#endif // _di_f_accountss_increase_
-
-#ifndef _di_f_accountss_increase_by_
- f_status_t f_accountss_increase_by(const f_number_unsigned_t amount, f_accountss_t *accountss) {
- #ifndef _di_level_0_parameter_checking_
- if (!accountss) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (accountss->used + amount > accountss->size) {
- if (accountss->used + amount > F_number_t_size_unsigned_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_accountss_resize(accountss->used + amount, accountss);
- }
-
- return F_data_not;
- }
-#endif // _di_f_accountss_increase_by_
-
-#ifndef _di_f_accountss_resize_
- f_status_t f_accountss_resize(const f_number_unsigned_t length, f_accountss_t *accountss) {
- #ifndef _di_level_0_parameter_checking_
- if (!accountss) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_accountss_resize(length, accountss);
- }
-#endif // _di_f_accountss_resize_
-
#ifdef __cplusplus
} // extern "C"
#endif
* @see f_string_dynamic_resize()
*/
#ifndef _di_f_account_delete_
- extern f_status_t f_account_delete(f_account_t *account);
+ extern f_status_t f_account_delete(f_account_t * const account);
#endif // _di_f_account_delete_
/**
* @see f_string_dynamic_adjust()
*/
#ifndef _di_f_account_destroy_
- extern f_status_t f_account_destroy(f_account_t *account);
+ extern f_status_t f_account_destroy(f_account_t * const account);
#endif // _di_f_account_destroy_
/**
- * Resize the accounts array.
+ * A callback intended to be passed to f_memory_arrays_adjust() for an f_accountss_t structure.
*
- * @param length
- * The new size to use.
- * @param accounts
- * The accounts array to resize.
+ * This does not do parameter checking.
+ *
+ * @param start
+ * The inclusive start position in the array to start deleting.
+ * @param stop
+ * The exclusive stop position in the array to stop deleting.
+ * @param array
+ * The array structure to delete all values of.
+ * Must not be NULL.
*
* @return
* F_none on success.
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_string_dynamic_adjust().
+ * Errors (with error bit) from: f_memory_array_adjust().
*
- * @see f_memory_adjust()
- * @see f_string_dynamic_adjust()
+ * @see f_memory_array_adjust()
+ * @see f_memory_arrays_adjust()
*/
-#ifndef _di_f_accounts_adjust_
- extern f_status_t f_accounts_adjust(const f_number_unsigned_t length, f_accounts_t *accounts);
-#endif // _di_f_accounts_adjust_
+#ifndef _di_f_accounts_adjust_callback_
+ extern f_status_t f_accounts_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array);
+#endif // _di_f_accounts_adjust_callback_
/**
* Append the single source account onto the destination.
* @see f_string_dynamic_append()
*/
#ifndef _di_f_accounts_append_
- extern f_status_t f_accounts_append(const f_account_t source, f_accounts_t *destination);
+ extern f_status_t f_accounts_append(const f_account_t source, f_accounts_t * const destination);
#endif // _di_f_accounts_append_
/**
* @see f_string_dynamic_append()
*/
#ifndef _di_f_accounts_append_all_
- extern f_status_t f_accounts_append_all(const f_accounts_t source, f_accounts_t *destination);
+ extern f_status_t f_accounts_append_all(const f_accounts_t source, f_accounts_t * const destination);
#endif // _di_f_accounts_append_all_
/**
- * Resize the accounts array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to les than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param accounts
- * The accounts array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_string_dynamic_adjust().
- *
- * @see f_memory_adjust()
- * @see f_string_dynamic_adjust()
- */
-#ifndef _di_f_accounts_decimate_by_
- extern f_status_t f_accounts_decimate_by(const f_number_unsigned_t amount, f_accounts_t *accounts);
-#endif // _di_f_accounts_decimate_by_
-
-/**
- * Resize the accounts array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to les than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param accounts
- * The accounts array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- */
-#ifndef _di_f_accounts_decrease_by_
- extern f_status_t f_accounts_decrease_by(const f_number_unsigned_t amount, f_accounts_t *accounts);
-#endif // _di_f_accounts_decrease_by_
-
-/**
- * Increase the size of the accounts array, but only if necesary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param accounts
- * The accounts array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_parameter (with error bit) if a parameter is invalid.
+ * A callback intended to be passed to f_memory_arrays_resize() for an f_accountss_t structure.
*
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- */
-#ifndef _di_f_accounts_increase_
- extern f_status_t f_accounts_increase(const f_number_unsigned_t step, f_accounts_t *accounts);
-#endif // _di_f_accounts_increase_
-
-/**
- * Resize the accounts array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param accounts
- * The accounts array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- */
-#ifndef _di_f_accounts_increase_by_
- extern f_status_t f_accounts_increase_by(const f_number_unsigned_t amount, f_accounts_t *accounts);
-#endif // _di_f_accounts_increase_by_
-
-/**
- * Resize the accounts array.
- *
- * @param length
- * The new size to use.
- * @param accounts
- * The accounts array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- */
-#ifndef _di_f_accounts_resize_
- extern f_status_t f_accounts_resize(const f_number_unsigned_t length, f_accounts_t *accounts);
-#endif // _di_f_accounts_resize_
-
-/**
- * Resize the string accountss array.
+ * This does not do parameter checking.
*
- * @param length
- * The new size to use.
- * @param accountss
- * The string accountss array to resize.
+ * @param start
+ * The inclusive start position in the array to start deleting.
+ * @param stop
+ * The exclusive stop position in the array to stop deleting.
+ * @param array
+ * The array structure to delete all values of.
+ * Must not be NULL.
*
* @return
* F_none on success.
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_string_dynamic_adjust().
+ * Errors (with error bit) from: f_memory_array_resize().
*
- * @see f_memory_adjust()
- * @see f_string_dynamic_adjust()
+ * @see f_memory_array_resize()
+ * @see f_memory_arrays_resize()
*/
-#ifndef _di_f_accountss_adjust_
- extern f_status_t f_accountss_adjust(const f_number_unsigned_t length, f_accountss_t *accountss);
-#endif // _di_f_accountss_adjust_
+#ifndef _di_f_accounts_resize_callback_
+ extern f_status_t f_accounts_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array);
+#endif // _di_f_accounts_resize_callback_
/**
* Append the single source accounts onto the destination.
* @see f_string_dynamic_resize()
*/
#ifndef _di_f_accountss_append_
- extern f_status_t f_accountss_append(const f_accounts_t source, f_accountss_t *destination);
+ extern f_status_t f_accountss_append(const f_accounts_t source, f_accountss_t * const destination);
#endif // _di_f_accountss_append_
/**
* @see f_string_dynamic_resize()
*/
#ifndef _di_f_accountss_append_all_
- extern f_status_t f_accountss_append_all(const f_accountss_t source, f_accountss_t *destination);
+ extern f_status_t f_accountss_append_all(const f_accountss_t source, f_accountss_t * const destination);
#endif // _di_f_accountss_append_all_
-/**
- * Resize the string accountss array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param accountss
- * The string accountss array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_string_dynamic_adjust().
- *
- * @see f_memory_adjust()
- * @see f_string_dynamic_adjust()
- */
-#ifndef _di_f_accountss_decimate_by_
- extern f_status_t f_accountss_decimate_by(const f_number_unsigned_t amount, f_accountss_t *accountss);
-#endif // _di_f_accountss_decimate_by_
-
-/**
- * Resize the string accountss array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param accountss
- * The string accountss array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- */
-#ifndef _di_f_accountss_decrease_by_
- extern f_status_t f_accountss_decrease_by(const f_number_unsigned_t amount, f_accountss_t *accountss);
-#endif // _di_f_accountss_decrease_by_
-
-/**
- * Increase the size of the string accountss array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param accountss
- * The string accountss array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- */
-#ifndef _di_f_accountss_increase_
- extern f_status_t f_accountss_increase(const f_number_unsigned_t step, f_accountss_t *accountss);
-#endif // _di_f_accountss_increase_
-
-/**
- * Resize the string accountss array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param accountss
- * The string accountss array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- */
-#ifndef _di_f_accountss_increase_by_
- extern f_status_t f_accountss_increase_by(const f_number_unsigned_t amount, f_accountss_t *accountss);
-#endif // _di_f_accountss_increase_by_
-
-/**
- * Resize the string accountss array.
- *
- * @param length
- * The new size to use.
- * @param accountss
- * The accounts array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- */
-#ifndef _di_f_accountss_resize_
- extern f_status_t f_accountss_resize(const f_number_unsigned_t length, f_accountss_t *accountss);
-#endif // _di_f_accountss_resize_
-
#ifdef __cplusplus
} // extern "C"
#endif
#define macro_f_accounts_t_initialize_2(array, length) { array, length, length }
#define macro_f_accounts_t_clear(accounts) macro_f_memory_structures_clear(accounts)
-
- #define macro_f_accounts_t_resize(status, accounts, length) status = f_accounts_resize(length, &accounts);
- #define macro_f_accounts_t_adjust(status, accounts, length) status = f_accounts_adjust(length, &accounts);
-
- #define macro_f_accounts_t_delete_simple(accounts) f_accounts_resize(0, &accounts);
- #define macro_f_accounts_t_destroy_simple(accounts) f_accounts_adjust(0, &accounts);
-
- #define macro_f_accounts_t_increase(status, step, accounts) status = f_accounts_increase(step, &accounts);
- #define macro_f_accounts_t_increase_by(status, accounts, amount) status = f_accounts_increase_by(amount, &accounts);
- #define macro_f_accounts_t_decrease_by(status, accounts, amount) status = f_accounts_decrease_by(amount, &accounts);
- #define macro_f_accounts_t_decimate_by(status, accounts, amount) status = f_accounts_decimate_by(amount, &accounts);
#endif // _di_f_accounts_t_
/**
#define macro_f_accountss_t_initialize_2(array, length) { array, length, length }
#define macro_f_accountss_t_clear(accountss) macro_f_memory_structures_clear(accountss)
-
- #define macro_f_accountss_t_resize(status, accountss, length) status = f_accountss_resize(length, &accountss);
- #define macro_f_accountss_t_adjust(status, accountss, length) status = f_accountss_adjust(length, &accountss);
-
- #define macro_f_accountss_t_delete_simple(accountss) f_accountss_resize(0, &accountss);
- #define macro_f_accountss_t_destroy_simple(accountss) f_accountss_adjust(0, &accountss);
-
- #define macro_f_accountss_t_increase(status, step, accountss) status = f_accountss_increase(step, &accountss);
- #define macro_f_accountss_t_increase_by(status, accountss, amount) status = f_accountss_increase_by(amount, &accountss);
- #define macro_f_accountss_t_decrease_by(status, accountss, amount) status = f_accountss_decrease_by(amount, &accountss);
- #define macro_f_accountss_t_decimate_by(status, accountss, amount) status = f_accountss_decimate_by(amount, &accountss);
#endif // _di_f_accountss_t_
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(_di_f_account_delete_) || !defined(_di_f_accounts_resize_) || !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_append_) || !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
- f_status_t private_f_account_delete(f_account_t *account) {
-
- f_status_t status = f_string_dynamic_resize(0, &account->home);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_resize(0, &account->label);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_resize(0, &account->name);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_resize(0, &account->password);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_resize(0, &account->shell);
- if (F_status_is_error(status)) return status;
-
- return F_none;
- }
-#endif // !defined(_di_f_account_delete_) || !defined(_di_f_accounts_resize_) || !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_append_) || !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
-
-#if !defined(_di_f_account_destroy_) || !defined(_di_f_accounts_adjust_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
- f_status_t private_f_account_destroy(f_account_t *account) {
-
- f_status_t status = f_string_dynamic_adjust(0, &account->home);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_adjust(0, &account->label);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_adjust(0, &account->name);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_adjust(0, &account->password);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_adjust(0, &account->shell);
- if (F_status_is_error(status)) return status;
-
- return F_none;
- }
-#endif // !defined(_di_f_account_destroy_) || !defined(_di_f_accounts_adjust_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
-
-#if !defined(_di_f_accounts_adjust_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
- f_status_t private_f_accounts_adjust(const f_number_unsigned_t length, f_accounts_t *accounts) {
-
- f_status_t status = F_none;
-
- if (length < accounts->size) {
- for (f_number_unsigned_t i = length; i < accounts->size; ++i) {
-
- status = private_f_account_destroy(&accounts->array[i]);
- if (F_status_is_error(status)) return status;
- } // for
- }
-
- status = f_memory_adjust(accounts->size, length, sizeof(f_account_t), (void **) & accounts->array);
- if (F_status_is_error(status)) return status;
-
- accounts->size = length;
-
- if (accounts->used > accounts->size) {
- accounts->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_accounts_adjust_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
-
-#if !defined(_di_f_accounts_append_) || !defined(_di_f_accountss_append_)
- extern f_status_t private_f_accounts_append(const f_account_t source, f_accounts_t *destination) {
-
- f_status_t status = F_none;
-
- if (destination->used + 1 > destination->size) {
- status = private_f_accounts_resize(destination->used + F_memory_default_allocation_small_d, destination);
- if (F_status_is_error(status)) return status;
- }
-
- destination->array[destination->used].home.used = 0;
- destination->array[destination->used].label.used = 0;
- destination->array[destination->used].name.used = 0;
- destination->array[destination->used].password.used = 0;
- destination->array[destination->used].shell.used = 0;
-
- status = f_string_dynamic_append(source.home, &destination->array[destination->used].home);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_append(source.label, &destination->array[destination->used].label);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_append(source.name, &destination->array[destination->used].name);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_append(source.password, &destination->array[destination->used].password);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_append(source.shell, &destination->array[destination->used].shell);
- if (F_status_is_error(status)) return status;
-
- ++destination->used;
-
- return F_none;
- }
-#endif // !defined(_di_f_accounts_append_) || !defined(_di_f_accountss_append_)
-
#if !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_append_all_) || !defined(_di_f_accountss_append_all_)
- extern f_status_t private_f_accounts_append_all(const f_accounts_t source, f_accounts_t *destination) {
-
- f_status_t status = F_none;
+ extern f_status_t private_f_accounts_append_all(const f_accounts_t source, f_accounts_t * const destination) {
- if (destination->used + source.used > destination->size) {
- status = private_f_accounts_resize(destination->used + source.used, destination);
- if (F_status_is_error(status)) return status;
- }
+ f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_account_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
}
#endif // !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_append_all_) || !defined(_di_f_accountss_append_all_)
-#if !defined(_di_f_accounts_resize_) || !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_append_) || !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
- f_status_t private_f_accounts_resize(const f_number_unsigned_t length, f_accounts_t *accounts) {
-
- f_status_t status = F_none;
-
- if (length < accounts->size) {
- for (f_number_unsigned_t i = length; i < accounts->size; ++i) {
-
- status = f_string_dynamic_resize(0, &accounts->array[i].home);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_resize(0, &accounts->array[i].label);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_resize(0, &accounts->array[i].name);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_resize(0, &accounts->array[i].password);
- if (F_status_is_error(status)) return status;
-
- status = f_string_dynamic_resize(0, &accounts->array[i].shell);
- if (F_status_is_error(status)) return status;
- } // for
- }
-
- status = f_memory_resize(accounts->size, length, sizeof(f_account_t), (void **) & accounts->array);
- if (F_status_is_error(status)) return status;
-
- accounts->size = length;
-
- if (accounts->used > accounts->size) {
- accounts->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_accounts_resize_) || !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_append_) || !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
-
-#if !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
- f_status_t private_f_accountss_adjust(const f_number_unsigned_t length, f_accountss_t *accountss) {
-
- f_status_t status = F_none;
-
- for (f_number_unsigned_t i = length; i < accountss->size; ++i) {
-
- status = private_f_accounts_adjust(0, &accountss->array[i]);
- if (F_status_is_error(status)) return status;
-
- accountss->array[i].size = 0;
- accountss->array[i].used = 0;
- } // for
-
- status = f_memory_adjust(accountss->size, length, sizeof(f_accounts_t), (void **) & accountss->array);
- if (F_status_is_error(status)) return status;
-
- accountss->size = length;
-
- if (accountss->used > accountss->size) {
- accountss->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
-
-#if !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
- f_status_t private_f_accountss_resize(const f_number_unsigned_t length, f_accountss_t *accountss) {
-
- f_status_t status = F_none;
-
- for (f_number_unsigned_t i = length; i < accountss->size; ++i) {
-
- status = private_f_accounts_resize(0, &accountss->array[i]);
- if (F_status_is_error(status)) return status;
-
- accountss->array[i].size = 0;
- accountss->array[i].used = 0;
- } // for
-
- status = f_memory_resize(accountss->size, length, sizeof(f_accounts_t), (void **) & accountss->array);
- if (F_status_is_error(status)) return status;
-
- accountss->size = length;
-
- if (accountss->used > accountss->size) {
- accountss->used = length;
- }
-
- return F_none;
- }
-#endif // !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
-
#ifdef __cplusplus
} // extern "C"
#endif
#endif
/**
- * Private implementation for resizing the account.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param account
- * The account to delete.
- *
- * @return
- * F_none on success.
- *
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_string_dynamic_resize()
- *
- * @see f_account_delete()
- * @see f_accounts_append()
- * @see f_accounts_decimate_by()
- * @see f_accounts_resize()
- * @see f_accountss_append()
- * @see f_accountss_decrease_by()
- * @see f_accountss_increase()
- * @see f_accountss_increase_by()
- * @see f_accountss_resize()
- */
-#if !defined(_di_f_account_delete_) || !defined(_di_f_accounts_resize_) || !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_append_) || !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
- extern f_status_t private_f_account_delete(f_account_t *account) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_account_delete_) || !defined(_di_f_accounts_resize_) || !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_append_) || !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
-
-/**
- * Private implementation for resizing the account.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param account
- * The account to delete.
- *
- * @return
- * F_none on success.
- *
- * Errors (with error bit) from: f_string_dynamic_adjust().
- *
- * @see f_string_dynamic_adjust()
- *
- * @see f_account_destroy()
- * @see f_accounts_adjust()
- * @see f_accounts_decimate_by()
- * @see f_accountss_adjust()
- * @see f_accountss_decimate_by()
- */
-#if !defined(_di_f_account_destroy_) || !defined(_di_f_accounts_adjust_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
- extern f_status_t private_f_account_destroy(f_account_t *account) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_account_destroy_) || !defined(_di_f_accounts_adjust_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
-
-/**
- * Private implementation for resizing the accounts array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param accounts
- * The accounts array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_string_dynamic_adjust().
- *
- * @see f_memory_adjust()
- * @see f_string_dynamic_adjust()
- *
- * @see f_accounts_adjust()
- * @see f_accounts_decimate_by()
- * @see f_accountss_adjust()
- * @see f_accountss_decimate_by()
- */
-#if !defined(_di_f_accounts_adjust_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
- extern f_status_t private_f_accounts_adjust(const f_number_unsigned_t length, f_accounts_t *accounts) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_accounts_adjust_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
-
-/**
- * Private implementation for appending the account array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param source
- * The source account to append.
- * @param destination
- * The destination lengths the source is appended onto.
- *
- * @return
- * F_none on success.
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_append().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_append()
- *
- * @see f_accounts_append()
- * @see f_accountss_append()
- */
-#if !defined(_di_f_accounts_append_) || !defined(_di_f_accountss_append_)
- extern f_status_t private_f_accounts_append(const f_account_t source, f_accounts_t *destination) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_accounts_append_) || !defined(_di_f_accountss_append_)
-
-/**
* Private implementation for appending the account array.
*
* Intended to be shared to each of the different implementation variations.
* @see f_accountss_append_all()
*/
#if !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_append_all_) || !defined(_di_f_accountss_append_all_)
- extern f_status_t private_f_accounts_append_all(const f_accounts_t source, f_accounts_t *destination) F_attribute_visibility_internal_d;
+ extern f_status_t private_f_accounts_append_all(const f_accounts_t source, f_accounts_t * const destination) F_attribute_visibility_internal_d;
#endif // !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_append_all_) || !defined(_di_f_accountss_append_all_)
-/**
- * Private implementation for resizing the accounts array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param accounts
- * The accounts array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_dynamic_resize().
- *
- * @see f_memory_resize()
- * @see f_string_dynamic_resize()
- *
- * @see f_accounts_append()
- * @see f_accounts_decimate_by()
- * @see f_accounts_resize()
- * @see f_accountss_append()
- * @see f_accountss_decrease_by()
- * @see f_accountss_increase()
- * @see f_accountss_increase_by()
- * @see f_accountss_resize()
- */
-#if !defined(_di_f_accounts_resize_) || !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_append_) || !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
- extern f_status_t private_f_accounts_resize(const f_number_unsigned_t length, f_accounts_t *accounts) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_accounts_resize_) || !defined(_di_f_accounts_append_) || !defined(_di_f_accounts_decimate_by_) || !defined(_di_f_accountss_append_) || !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
-
-/**
- * Private implementation for resizing the accountss array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param accountss
- * The accountss array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if new length is larger than max array length.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_string_dynamic_adjust().
- *
- * @see f_memory_adjust()
- * @see f_string_dynamic_adjust()
- *
- * @see f_accountss_adjust()
- * @see f_accountss_decimate_by()
- */
-#if !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
- extern f_status_t private_f_accountss_adjust(const f_number_unsigned_t length, f_accountss_t *accountss) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_accountss_adjust_) || !defined(_di_f_accountss_decimate_by_)
-
-/**
- * Private implementation for resizing the accountss array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to resize to.
- * @param accountss
- * The accountss array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if new length is larger than max array length.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_delete().
- * Errors (with error bit) from: f_memory_resize().
- *
- * @see f_accountss_decrease_by()
- * @see f_accountss_increase()
- * @see f_accountss_increase_by()
- * @see f_accountss_resize()
- */
-#if !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
- extern f_status_t private_f_accountss_resize(const f_number_unsigned_t length, f_accountss_t *accountss) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_accountss_decrease_by_) || !defined(_di_f_accountss_increase_) || !defined(_di_f_accountss_increase_by_) || !defined(_di_f_accountss_resize_)
-
#ifdef __cplusplus
} // extern "C"
#endif
flags_library -fPIC
# Inject mocks.
+flags -Wl,--wrap=f_string_dynamic_adjust
+flags -Wl,--wrap=f_string_dynamic_resize
flags -Wl,--wrap=getpwnam_r
flags -Wl,--wrap=getpwuid_r
flags -Wl,--wrap=getgrnam_r
build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_account
build_sources_program test-account-by_id.c test-account-by_name.c test-account-group_name_by_id.c test-account-group_id_by_name.c test-account-id_by_name.c test-account-name_by_id.c
-build_sources_program test-account-s_adjust.c test-account-s_append.c test-account-s_append_all.c test-account-s_decimate_by.c test-account-s_decrease_by.c test-account-s_increase.c test-account-s_increase_by.c test-account-s_resize.c
-build_sources_program test-account-ss_adjust.c test-account-ss_append.c test-account-ss_append_all.c test-account-ss_decimate_by.c test-account-ss_decrease_by.c test-account-ss_increase.c test-account-ss_increase_by.c test-account-ss_resize.c
+build_sources_program test-account-s_adjust_callback.c test-account-s_append.c test-account-s_append_all.c test-account-s_resize_callback.c
+build_sources_program test-account-ss_append.c test-account-ss_append_all.c
build_sources_program test-account.c
build_script no
extern "C" {
#endif
+int mock_unwrap = 0;
+
+f_status_t __wrap_f_string_dynamic_adjust(const f_number_unsigned_t length, f_string_dynamic_t * const structure) {
+
+ if (mock_unwrap) {
+ return __real_f_string_dynamic_adjust(length, structure);
+ }
+
+ if (!structure) return F_status_set_error(F_parameter_not);
+
+ const bool failure = mock_type(bool);
+
+ if (failure) return mock_type(f_status_t);
+
+ structure->size = length;
+
+ return mock_type(f_status_t);
+}
+
+f_status_t __wrap_f_string_dynamic_resize(const f_number_unsigned_t length, f_string_dynamic_t * const structure) {
+
+ if (mock_unwrap) {
+ return __real_f_string_dynamic_resize(length, structure);
+ }
+
+ if (!structure) return F_status_set_error(F_parameter_not);
+
+ const bool failure = mock_type(bool);
+
+ if (failure) return mock_type(f_status_t);
+
+ structure->size = length;
+
+ return mock_type(f_status_t);
+}
+
int __wrap_getpwnam_r(const char * const name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result) {
const bool failure = mock_type(bool);
const static int mock_errno_generic = 32767;
+extern int mock_unwrap;
+
+extern f_status_t __real_f_string_dynamic_adjust(const f_number_unsigned_t length, f_string_dynamic_t * const structure);
+extern f_status_t __real_f_string_dynamic_resize(const f_number_unsigned_t length, f_string_dynamic_t * const structure);
+
+extern f_status_t __wrap_f_string_dynamic_adjust(const f_number_unsigned_t length, f_string_dynamic_t * const structure);
+extern f_status_t __wrap_f_string_dynamic_resize(const f_number_unsigned_t length, f_string_dynamic_t * const structure);
+
extern int __wrap_getpwnam_r(const char * const name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result);
extern int __wrap_getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result);
extern int __wrap_getgrgid_r(uid_t uid, struct group *grp, char *buf, size_t buflen, struct group **result);
void test__f_account_by_id__fails(void **state) {
+ mock_unwrap = 1;
+
const long size = 20;
uid_t uid = 0;
f_account_t account = f_account_t_initialize;
void test__f_account_by_id__not_found(void **state) {
+ mock_unwrap = 1;
+
const long size = 20;
struct passwd password;
uid_t uid = 0;
void test__f_account_by_id__works(void **state) {
+ mock_unwrap = 1;
+
const long size = 20;
struct passwd password;
struct passwd pointer;
void test__f_account_by_name__fails(void **state) {
+ mock_unwrap = 1;
+
const long size = 20;
f_account_t account = f_account_t_initialize;
void test__f_account_group_name_by_id__works(void **state) {
+ mock_unwrap = 0;
+
const long size = 20;
struct group group_data;
struct group pointer;
void test__f_account_name_by_id__works(void **state) {
+ mock_unwrap = 0;
+
const long size = 20;
struct passwd password;
struct passwd pointer;
+++ /dev/null
-#include "test-account.h"
-#include "test-account-s_adjust.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accounts_adjust__parameter_checking(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_adjust(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accounts_adjust__works(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_adjust(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_s_adjust
-#define _TEST__F_account_s_adjust
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accounts_adjust()
- */
-extern void test__f_accounts_adjust__parameter_checking(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accounts_adjust()
- */
-extern void test__f_accounts_adjust__works(void **state);
-
-#endif // _TEST__F_account_s_adjust
--- /dev/null
+#include "test-account.h"
+#include "test-account-s_adjust_callback.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_accounts_adjust_callback__fails(void **state) {
+
+ mock_unwrap = 0;
+
+ f_account_t data = f_account_t_initialize;
+ f_account_t data_array[] = { data };
+ f_accounts_t datas = { .array = data_array, .used = 1, .size = 1 };
+ f_accounts_t datass_array[] = { datas };
+
+ {
+ will_return(__wrap_f_string_dynamic_adjust, true);
+ will_return(__wrap_f_string_dynamic_adjust, F_status_set_error(F_failure));
+
+ const f_status_t status = f_accounts_adjust_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+}
+
+void test__f_accounts_adjust_callback__works(void **state) {
+
+ mock_unwrap = 0;
+
+ f_account_t data = f_account_t_initialize;
+ f_account_t data_array[] = { data };
+ f_accounts_t datas = { .array = data_array, .used = 1, .size = 1 };
+ f_accounts_t datass_array[] = { datas };
+ const f_number_unsigned_t length = 1;
+
+ {
+ will_return(__wrap_f_string_dynamic_adjust, false);
+ will_return(__wrap_f_string_dynamic_adjust, F_none);
+
+ will_return(__wrap_f_string_dynamic_adjust, false);
+ will_return(__wrap_f_string_dynamic_adjust, F_none);
+
+ will_return(__wrap_f_string_dynamic_adjust, false);
+ will_return(__wrap_f_string_dynamic_adjust, F_none);
+
+ will_return(__wrap_f_string_dynamic_adjust, false);
+ will_return(__wrap_f_string_dynamic_adjust, F_none);
+
+ will_return(__wrap_f_string_dynamic_adjust, false);
+ will_return(__wrap_f_string_dynamic_adjust, F_none);
+
+ const f_status_t status = f_accounts_adjust_callback(0, length, (void *) datass_array);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Account
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the array types in the type project.
+ */
+#ifndef _TEST__F_account__s_adjust_callback
+#define _TEST__F_account__s_adjust_callback
+
+/**
+ * Test that the function fails.
+ *
+ * @see f_accounts_adjust_callback()
+ */
+extern void test__f_accounts_adjust_callback__fails(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_accounts_adjust_callback()
+ */
+extern void test__f_accounts_adjust_callback__works(void **state);
+
+#endif // _TEST__F_account__s_adjust_callback
void test__f_accounts_append__works(void **state) {
+ mock_unwrap = 1;
+
f_string_static_t home = macro_f_string_static_t_initialize_1("home", 0, 4);
f_string_static_t label = macro_f_string_static_t_initialize_1("label", 0, 5);
f_string_static_t name = macro_f_string_static_t_initialize_1("name", 0, 4);
assert_int_equal(destination.array[0].shell.used, source.shell.used);
}
+ free((void *) destination.array[0].home.string);
+ free((void *) destination.array[0].label.string);
+ free((void *) destination.array[0].name.string);
+ free((void *) destination.array[0].password.string);
+ free((void *) destination.array[0].shell.string);
free((void *) destination.array);
}
/**
* FLL - Level 0
*
- * Project: Type
+ * Project: Account
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
f_accounts_t destination = f_accounts_t_initialize;
{
- const f_status_t status = f_accounts_resize(length, &source);
+ const f_status_t status = f_memory_array_resize(length, sizeof(f_account_t), (void **) &source.array, &source.used, &source.size);
assert_int_equal(status, F_none);
assert_int_equal(source.used, 0);
void test__f_accounts_append_all__works(void **state) {
+ mock_unwrap = 1;
+
const int length = 5;
f_accounts_t source = f_accounts_t_initialize;
f_accounts_t destination = f_accounts_t_initialize;
const f_account_t account_1 = { .home = home_1, .label = label_1, .name = name_1, .password = password_1, .shell = shell_1 };
{
- const f_status_t status = f_accounts_resize(length, &source);
+ const f_status_t status = f_memory_array_resize(length, sizeof(f_account_t), (void **) &source.array, &source.used, &source.size);
assert_int_equal(status, F_none);
assert_int_equal(source.used, 0);
}
free((void *) source.array);
+
+ free((void *) destination.array[0].home.string);
+ free((void *) destination.array[0].label.string);
+ free((void *) destination.array[0].name.string);
+ free((void *) destination.array[0].password.string);
+ free((void *) destination.array[0].shell.string);
+ free((void *) destination.array[1].home.string);
+ free((void *) destination.array[1].label.string);
+ free((void *) destination.array[1].name.string);
+ free((void *) destination.array[1].password.string);
+ free((void *) destination.array[1].shell.string);
free((void *) destination.array);
}
/**
* FLL - Level 0
*
- * Project: Type
+ * Project: Account
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
+++ /dev/null
-#include "test-account.h"
-#include "test-account-s_decimate_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accounts_decimate_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_decimate_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accounts_decimate_by__returns_data_not(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accounts_decimate_by(0, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accounts_decimate_by__works(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accounts_decimate_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_s_decimate_by
-#define _TEST__F_account_s_decimate_by
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accounts_decimate_by()
- */
-extern void test__f_accounts_decimate_by__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_data_not.
- *
- * @see f_accounts_decimate_by()
- */
-extern void test__f_accounts_decimate_by__returns_data_not(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accounts_decimate_by()
- */
-extern void test__f_accounts_decimate_by__works(void **state);
-
-#endif // _TEST__F_account_s_decimate_by
+++ /dev/null
-#include "test-account.h"
-#include "test-account-s_decrease_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accounts_decrease_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_decrease_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accounts_decrease_by__returns_data_not(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accounts_decrease_by(0, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accounts_decrease_by__works(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accounts_decrease_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_s_decrease_by
-#define _TEST__F_account_s_decrease_by
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accounts_decrease_by()
- */
-extern void test__f_accounts_decrease_by__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_data_not.
- *
- * @see f_accounts_decrease_by()
- */
-extern void test__f_accounts_decrease_by__returns_data_not(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accounts_decrease_by()
- */
-extern void test__f_accounts_decrease_by__works(void **state);
-
-#endif // _TEST__F_account_s_decrease_by
+++ /dev/null
-#include "test-account.h"
-#include "test-account-s_increase.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accounts_increase__parameter_checking(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_increase(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accounts_increase__returns_data_not(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accounts_increase(length, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accounts_increase__works(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- data.used = length;
-
- const f_status_t status = f_accounts_increase(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, length);
- assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_s_increase
-#define _TEST__F_account_s_increase
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accounts_increase()
- */
-extern void test__f_accounts_increase__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_data_not.
- *
- * @see f_accounts_increase()
- */
-extern void test__f_accounts_increase__returns_data_not(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accounts_increase()
- */
-extern void test__f_accounts_increase__works(void **state);
-
-#endif // _TEST__F_account_s_increase
+++ /dev/null
-#include "test-account.h"
-#include "test-account-s_increase_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accounts_increase_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_increase_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accounts_increase_by__returns_data_not(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accounts_increase_by(0, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accounts_increase_by__works(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- data.used = length;
-
- const f_status_t status = f_accounts_increase_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, length);
- assert_int_equal(data.size, length * 2);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_s_increase_by
-#define _TEST__F_account_s_increase_by
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accounts_increase_by()
- */
-extern void test__f_accounts_increase_by__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_data_not.
- *
- * @see f_accounts_increase_by()
- */
-extern void test__f_accounts_increase_by__returns_data_not(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accounts_increase_by()
- */
-extern void test__f_accounts_increase_by__works(void **state);
-
-#endif // _TEST__F_account_s_increase_by
+++ /dev/null
-#include "test-account.h"
-#include "test-account-s_resize.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accounts_resize__parameter_checking(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accounts_resize__works(void **state) {
-
- const int length = 5;
- f_accounts_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accounts_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_s_resize
-#define _TEST__F_account_s_resize
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accounts_resize()
- */
-extern void test__f_accounts_resize__parameter_checking(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accounts_resize()
- */
-extern void test__f_accounts_resize__works(void **state);
-
-#endif // _TEST__F_account_s_resize
--- /dev/null
+#include "test-account.h"
+#include "test-account-s_resize_callback.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_accounts_resize_callback__fails(void **state) {
+
+ mock_unwrap = 0;
+
+ f_account_t data = f_account_t_initialize;
+ f_account_t data_array[] = { data };
+ f_accounts_t datas = { .array = data_array, .used = 1, .size = 1 };
+ f_accounts_t datass_array[] = { datas };
+
+ {
+ will_return(__wrap_f_string_dynamic_resize, true);
+ will_return(__wrap_f_string_dynamic_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_accounts_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, true);
+ will_return(__wrap_f_string_dynamic_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_accounts_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, true);
+ will_return(__wrap_f_string_dynamic_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_accounts_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, true);
+ will_return(__wrap_f_string_dynamic_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_accounts_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, true);
+ will_return(__wrap_f_string_dynamic_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_accounts_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+}
+
+void test__f_accounts_resize_callback__works(void **state) {
+
+ mock_unwrap = 0;
+
+ f_account_t data = f_account_t_initialize;
+ f_account_t data_array[] = { data };
+ f_accounts_t datas = { .array = data_array, .used = 1, .size = 1 };
+ f_accounts_t datass_array[] = { datas };
+ const f_number_unsigned_t length = 1;
+
+ {
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ will_return(__wrap_f_string_dynamic_resize, false);
+ will_return(__wrap_f_string_dynamic_resize, F_none);
+
+ const f_status_t status = f_accounts_resize_callback(0, length, (void *) datass_array);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Account
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the array types in the type project.
+ */
+#ifndef _TEST__F_account__s_resize_callback
+#define _TEST__F_account__s_resize_callback
+
+/**
+ * Test that the function fails.
+ *
+ * @see f_accounts_resize_callback()
+ */
+extern void test__f_accounts_resize_callback__fails(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_accounts_resize_callback()
+ */
+extern void test__f_accounts_resize_callback__works(void **state);
+
+#endif // _TEST__F_account__s_resize_callback
+++ /dev/null
-#include "test-account.h"
-#include "test-account-ss_adjust.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accountss_adjust__parameter_checking(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accountss_t_initialize;
-
- {
- const f_status_t status = f_accountss_adjust(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accountss_adjust__works(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accountss_t_initialize;
-
- {
- const f_status_t status = f_accountss_adjust(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_ss_adjust
-#define _TEST__F_account_ss_adjust
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accountss_adjust()
- */
-extern void test__f_accountss_adjust__parameter_checking(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accountss_adjust()
- */
-extern void test__f_accountss_adjust__works(void **state);
-
-#endif // _TEST__F_account_ss_adjust
f_accountss_t destination = f_accountss_t_initialize;
{
- const f_status_t status = f_accounts_resize(length, &source);
+ const f_status_t status = f_memory_array_resize(length, sizeof(f_account_t), (void **) &source.array, &source.used, &source.size);
assert_int_equal(status, F_none);
assert_int_equal(source.used, 0);
void test__f_accountss_append__works(void **state) {
+ mock_unwrap = 1;
+
const int length = 5;
f_accounts_t sources = f_accounts_t_initialize;
f_accountss_t destination = f_accountss_t_initialize;
const f_account_t source = { .home = home, .label = label, .name = name, .password = password, .shell = shell };
{
- const f_status_t status = f_accounts_resize(length, &sources);
+ const f_status_t status = f_memory_array_resize(length, sizeof(f_account_t), (void **) &sources.array, &sources.used, &sources.size);
assert_int_equal(status, F_none);
assert_int_equal(sources.used, 0);
}
for (f_number_unsigned_t i = 0; i < destination.used; ++i) {
+
+ for (f_number_unsigned_t j = 0; j < destination.array[i].used; ++j) {
+
+ free((void *) destination.array[i].array[j].home.string);
+ free((void *) destination.array[i].array[j].label.string);
+ free((void *) destination.array[i].array[j].name.string);
+ free((void *) destination.array[i].array[j].password.string);
+ free((void *) destination.array[i].array[j].shell.string);
+ }
+
free((void *) destination.array[i].array);
} // for
/**
* FLL - Level 0
*
- * Project: Type
+ * Project: Account
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
f_accountss_t destination = f_accountss_t_initialize;
{
- const f_status_t status = f_accountss_resize(length, &source);
+ const f_status_t status = f_memory_arrays_resize(length, sizeof(f_accounts_t), (void **) &source.array, &source.used, &source.size, &f_accounts_resize_callback);
assert_int_equal(status, F_none);
assert_int_equal(source.used, 0);
void test__f_accountss_append_all__works(void **state) {
+ mock_unwrap = 1;
+
const int length = 5;
const int length_inner = 2;
f_accountss_t source = f_accountss_t_initialize;
const f_account_t account_1 = { .home = home_1, .label = label_1, .name = name_1, .password = password_1, .shell = shell_1 };
{
- const f_status_t status = f_accountss_resize(length, &source);
+ const f_status_t status = f_memory_arrays_resize(length, sizeof(f_accounts_t), (void **) &source.array, &source.used, &source.size, &f_accounts_resize_callback);
assert_int_equal(status, F_none);
assert_int_equal(source.used, 0);
{
for (; source.used < length; ++source.used) {
- const f_status_t status = f_accounts_resize(length_inner, &source.array[source.used]);
+ const f_status_t status = f_memory_array_resize(length_inner, sizeof(f_account_t), (void **) &source.array[source.used].array, &source.array[source.used].used, &source.array[source.used].size);
assert_int_equal(status, F_none);
} // for
for (f_number_unsigned_t i = 0; i < destination.used; ++i) {
+
+ for (f_number_unsigned_t j = 0; j < destination.array[i].used; ++j) {
+
+ free((void *) destination.array[i].array[j].home.string);
+ free((void *) destination.array[i].array[j].label.string);
+ free((void *) destination.array[i].array[j].name.string);
+ free((void *) destination.array[i].array[j].password.string);
+ free((void *) destination.array[i].array[j].shell.string);
+ }
+
free((void *) destination.array[i].array);
} // for
/**
* FLL - Level 0
*
- * Project: Type
+ * Project: Account
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
+++ /dev/null
-#include "test-account.h"
-#include "test-account-ss_decimate_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accountss_decimate_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_decimate_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accountss_decimate_by__returns_data_not(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accountss_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accountss_decimate_by(0, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accountss_decimate_by__works(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accountss_decimate_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_ss_decimate_by
-#define _TEST__F_account_ss_decimate_by
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accountss_decimate_by()
- */
-extern void test__f_accountss_decimate_by__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_data_not.
- *
- * @see f_accountss_decimate_by()
- */
-extern void test__f_accountss_decimate_by__returns_data_not(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accountss_decimate_by()
- */
-extern void test__f_accountss_decimate_by__works(void **state);
-
-#endif // _TEST__F_account_ss_decimate_by
+++ /dev/null
-#include "test-account.h"
-#include "test-account-ss_decrease_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accountss_decrease_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_decrease_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accountss_decrease_by__returns_data_not(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accountss_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accountss_decrease_by(0, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accountss_decrease_by__works(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accountss_decrease_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_ss_decrease_by
-#define _TEST__F_account_ss_decrease_by
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accountss_decrease_by()
- */
-extern void test__f_accountss_decrease_by__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_data_not.
- *
- * @see f_accountss_decrease_by()
- */
-extern void test__f_accountss_decrease_by__returns_data_not(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accountss_decrease_by()
- */
-extern void test__f_accountss_decrease_by__works(void **state);
-
-#endif // _TEST__F_account_ss_decrease_by
+++ /dev/null
-#include "test-account.h"
-#include "test-account-ss_increase.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accountss_increase__parameter_checking(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_increase(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accountss_increase__returns_data_not(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accountss_increase(length, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accountss_increase__works(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- data.used = length;
-
- const f_status_t status = f_accountss_increase(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, length);
- assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_ss_increase
-#define _TEST__F_account_ss_increase
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accountss_increase()
- */
-extern void test__f_accountss_increase__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_data_not.
- *
- * @see f_accountss_increase()
- */
-extern void test__f_accountss_increase__returns_data_not(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accountss_increase()
- */
-extern void test__f_accountss_increase__works(void **state);
-
-#endif // _TEST__F_account_ss_increase
+++ /dev/null
-#include "test-account.h"
-#include "test-account-ss_increase_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accountss_increase_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_increase_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accountss_increase_by__returns_data_not(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accountss_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accountss_increase_by(0, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accountss_increase_by(length, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_account_decrease_by__returns_data_not(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accountss_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_accountss_decrease_by(0, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_accountss_increase_by__works(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accounts_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- data.used = length;
-
- const f_status_t status = f_accountss_increase_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, length);
- assert_int_equal(data.size, length * 2);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_ss_increase_by
-#define _TEST__F_account_ss_increase_by
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accountss_increase_by()
- */
-extern void test__f_accountss_increase_by__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_data_not.
- *
- * @see f_accountss_increase_by()
- */
-extern void test__f_accountss_increase_by__returns_data_not(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accountss_increase_by()
- */
-extern void test__f_accountss_increase_by__works(void **state);
-
-#endif // _TEST__F_account_ss_increase_by
+++ /dev/null
-#include "test-account.h"
-#include "test-account-ss_resize.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_accountss_resize__parameter_checking(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accountss_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_accountss_resize__works(void **state) {
-
- const int length = 5;
- f_accountss_t data = f_accountss_t_initialize;
-
- {
- const f_status_t status = f_accountss_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_account_ss_resize
-#define _TEST__F_account_ss_resize
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_accountss_resize()
- */
-extern void test__f_accountss_resize__parameter_checking(void **state);
-
-/**
- * Test that the function works.
- *
- * @see f_accountss_resize()
- */
-extern void test__f_accountss_resize__works(void **state);
-
-#endif // _TEST__F_account_ss_resize
cmocka_unit_test(test__f_account_name_by_id__not_found),
cmocka_unit_test(test__f_account_name_by_id__works),
+ cmocka_unit_test(test__f_accounts_adjust_callback__fails),
+ cmocka_unit_test(test__f_accounts_resize_callback__fails),
+
+ cmocka_unit_test(test__f_accounts_adjust_callback__works),
+ cmocka_unit_test(test__f_accounts_resize_callback__works),
+
cmocka_unit_test(test__f_accounts_append_all__returns_data_not),
- cmocka_unit_test(test__f_accounts_decimate_by__returns_data_not),
- cmocka_unit_test(test__f_accounts_decrease_by__returns_data_not),
- cmocka_unit_test(test__f_accounts_increase__returns_data_not),
- cmocka_unit_test(test__f_accounts_increase_by__returns_data_not),
- cmocka_unit_test(test__f_accounts_adjust__works),
cmocka_unit_test(test__f_accounts_append__works),
cmocka_unit_test(test__f_accounts_append_all__works),
- cmocka_unit_test(test__f_accounts_decimate_by__works),
- cmocka_unit_test(test__f_accounts_decrease_by__works),
- cmocka_unit_test(test__f_accounts_increase__works),
- cmocka_unit_test(test__f_accounts_increase_by__works),
- cmocka_unit_test(test__f_accounts_resize__works),
cmocka_unit_test(test__f_accountss_append__returns_data_not),
cmocka_unit_test(test__f_accountss_append_all__returns_data_not),
- cmocka_unit_test(test__f_accountss_decimate_by__returns_data_not),
- cmocka_unit_test(test__f_accountss_decrease_by__returns_data_not),
- cmocka_unit_test(test__f_accountss_increase__returns_data_not),
- cmocka_unit_test(test__f_accountss_increase_by__returns_data_not),
- cmocka_unit_test(test__f_accountss_adjust__works),
cmocka_unit_test(test__f_accountss_append__works),
cmocka_unit_test(test__f_accountss_append_all__works),
- cmocka_unit_test(test__f_accountss_decimate_by__works),
- cmocka_unit_test(test__f_accountss_decrease_by__works),
- cmocka_unit_test(test__f_accountss_increase__works),
- cmocka_unit_test(test__f_accountss_increase_by__works),
- cmocka_unit_test(test__f_accountss_resize__works),
#ifndef _di_level_0_parameter_checking_
cmocka_unit_test(test__f_account_by_id__parameter_checking),
cmocka_unit_test(test__f_account_id_by_name__parameter_checking),
cmocka_unit_test(test__f_account_name_by_id__parameter_checking),
- cmocka_unit_test(test__f_accounts_adjust__parameter_checking),
+ // f_accounts_adjust_callback() doesn't use parameter checking.
+ // f_accounts_resize_callback() doesn't use parameter checking.
+
cmocka_unit_test(test__f_accounts_append__parameter_checking),
cmocka_unit_test(test__f_accounts_append_all__parameter_checking),
- cmocka_unit_test(test__f_accounts_decimate_by__parameter_checking),
- cmocka_unit_test(test__f_accounts_decrease_by__parameter_checking),
- cmocka_unit_test(test__f_accounts_increase__parameter_checking),
- cmocka_unit_test(test__f_accounts_increase_by__parameter_checking),
- cmocka_unit_test(test__f_accounts_resize__parameter_checking),
- cmocka_unit_test(test__f_accountss_adjust__parameter_checking),
cmocka_unit_test(test__f_accountss_append__parameter_checking),
cmocka_unit_test(test__f_accountss_append_all__parameter_checking),
- cmocka_unit_test(test__f_accountss_decimate_by__parameter_checking),
- cmocka_unit_test(test__f_accountss_decrease_by__parameter_checking),
- cmocka_unit_test(test__f_accountss_increase__parameter_checking),
- cmocka_unit_test(test__f_accountss_increase_by__parameter_checking),
- cmocka_unit_test(test__f_accountss_resize__parameter_checking),
#endif // _di_level_0_parameter_checking_
};
#include "test-account-group_name_by_id.h"
#include "test-account-id_by_name.h"
#include "test-account-name_by_id.h"
-#include "test-account-s_adjust.h"
+#include "test-account-s_adjust_callback.h"
#include "test-account-s_append.h"
#include "test-account-s_append_all.h"
-#include "test-account-s_decimate_by.h"
-#include "test-account-s_decrease_by.h"
-#include "test-account-s_increase.h"
-#include "test-account-s_increase_by.h"
-#include "test-account-s_resize.h"
-#include "test-account-ss_adjust.h"
+#include "test-account-s_resize_callback.h"
#include "test-account-ss_append.h"
#include "test-account-ss_append_all.h"
-#include "test-account-ss_decimate_by.h"
-#include "test-account-ss_decrease_by.h"
-#include "test-account-ss_increase.h"
-#include "test-account-ss_increase_by.h"
-#include "test-account-ss_resize.h"
#ifdef __cplusplus
extern "C" {
#define macro_f_iki_datas_t_initialize_1(content, size, used) { array, size, used }
#define macro_f_iki_datas_t_initialize_2(array, length) { array, length, length }
-
- #define macro_f_iki_datas_t_resize(status, datas, length) status = f_iki_datas_resize(length, &datas);
- #define macro_f_iki_datas_t_adjust(status, datas, length) status = f_iki_datas_adjust(length, &datas);
-
- #define macro_f_iki_datas_t_delete_simple(datas) status = f_iki_datas_resize(0, &datas);
- #define macro_f_iki_datas_t_destroy_simple(datas) status = f_iki_datas_adjust(0, &datas);
-
- #define macro_f_iki_datas_t_increase(status, step, datas) status = f_iki_datas_increase(step, &datas);
- #define macro_f_iki_datas_t_increase_by(status, datas, amount) status = f_iki_datas_increase_by(amount, &datas);
- #define macro_f_iki_datas_t_decrease_by(status, datas, amount) status = f_iki_datas_decrease_by(amount, &datas);
- #define macro_f_iki_datas_t_decimate_by(status, datas, amount) status = f_iki_datas_decimate_by(amount, &datas);
#endif // _di_f_iki_datas_t_
/**
#define macro_f_iki_datass_t_initialize_1(content, size, used) { array, size, used }
#define macro_f_iki_datass_t_initialize_2(array, length) { array, length, length }
-
- #define macro_f_iki_datass_t_resize(status, datas, length) status = f_iki_datass_resize(length, &datas);
- #define macro_f_iki_datass_t_adjust(status, datas, length) status = f_iki_datass_adjust(length, &datas);
-
- #define macro_f_iki_datass_t_delete_simple(datas) status = f_iki_datass_resize(0, &datas);
- #define macro_f_iki_datass_t_destroy_simple(datas) status = f_iki_datass_adjust(0, &datas);
-
- #define macro_f_iki_datass_t_increase(status, step, datas) status = f_iki_datass_increase(step, &datas);
- #define macro_f_iki_datass_t_increase_by(status, datas, amount) status = f_iki_datass_increase_by(amount, &datas);
- #define macro_f_iki_datass_t_decrease_by(status, datas, amount) status = f_iki_datass_decrease_by(amount, &datas);
- #define macro_f_iki_datass_t_decimate_by(status, datas, amount) status = f_iki_datass_decimate_by(amount, &datas);
#endif // _di_f_iki_datass_t_
#ifdef __cplusplus
}
#endif // _di_f_iki_data_destroy_
-#ifndef _di_f_iki_datas_adjust_
- f_status_t f_iki_datas_adjust(const f_number_unsigned_t length, f_iki_datas_t *datas) {
- #ifndef _di_level_0_parameter_checking_
- if (!datas) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_iki_datas_adjust(length, datas);
- }
-#endif // _di_f_iki_datas_adjust_
+#ifndef _di_f_iki_datas_adjust_callback_
+ f_status_t f_iki_datas_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) {
-#ifndef _di_f_iki_datas_append_
- f_status_t f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t *destination) {
- #ifndef _di_level_0_parameter_checking_
- if (!destination) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ {
+ f_iki_datas_t * const array = (f_iki_datas_t *) void_array;
+ f_status_t status = F_none;
- return private_f_iki_datas_append(source, destination);
- }
-#endif // _di_f_iki_datas_append_
+ for (f_number_unsigned_t i = start; i < stop; ++i) {
-#ifndef _di_f_iki_datas_append_all_
- f_status_t f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) {
- #ifndef _di_level_0_parameter_checking_
- if (!destination) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!source.used) return F_data_not;
+ status = f_string_ranges_adjust(0, &array->array[i].content);
+ if (F_status_is_error(status)) return status;
- return private_f_iki_datas_append_all(source, destination);
- }
-#endif // _di_f_iki_datas_append_all_
+ status = f_memory_array_adjust(0, sizeof(f_number_unsigned_t), (void **) &array->array[i].delimits.array, &array->array[i].delimits.used, &array->array[i].delimits.size);
+ if (F_status_is_error(status)) return status;
-#ifndef _di_f_iki_datas_decimate_by_
- f_status_t f_iki_datas_decimate_by(const f_number_unsigned_t amount, f_iki_datas_t *datas) {
- #ifndef _di_level_0_parameter_checking_
- if (!datas) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ status = f_string_ranges_adjust(0, &array->array[i].variable);
+ if (F_status_is_error(status)) return status;
- if (!amount) return F_data_not;
- if (datas->size > amount) return private_f_iki_datas_adjust(datas->size - amount, datas);
+ status = f_string_ranges_adjust(0, &array->array[i].vocabulary);
+ if (F_status_is_error(status)) return status;
+ } // for
+ }
- return private_f_iki_datas_adjust(0, datas);
+ return F_none;
}
-#endif // _di_f_iki_datas_decimate_by_
+#endif // _di_f_iki_datas_adjust_callback_
-#ifndef _di_f_iki_datas_decrease_by_
- f_status_t f_iki_datas_decrease_by(const f_number_unsigned_t amount, f_iki_datas_t *datas) {
+#ifndef _di_f_iki_datas_append_
+ f_status_t f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t *destination) {
#ifndef _di_level_0_parameter_checking_
- if (!datas) return F_status_set_error(F_parameter);
+ if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (!amount) return F_data_not;
- if (datas->size > amount) return private_f_iki_datas_resize(datas->size - amount, datas);
-
- return private_f_iki_datas_resize(0, datas);
- }
-#endif // _di_f_iki_datas_decrease_by_
+ f_status_t status = f_memory_array_increase(F_iki_default_allocation_small_d, sizeof(f_iki_data_t), (void **) &destination->array, &destination->used, &destination->size);
+ if (F_status_is_error(status)) return status;
-#ifndef _di_f_iki_datas_increase_
- f_status_t f_iki_datas_increase(const f_number_unsigned_t step, f_iki_datas_t *datas) {
- #ifndef _di_level_0_parameter_checking_
- if (!datas) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ destination->array[destination->used].content.used = 0;
+ destination->array[destination->used].delimits.used = 0;
+ destination->array[destination->used].variable.used = 0;
+ destination->array[destination->used].vocabulary.used = 0;
- if (step && datas->used + 1 > datas->size) {
- if (datas->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+ if (source.content.used) {
+ status = f_string_ranges_append_all(source.content, &destination->array[destination->used].content);
+ if (F_status_is_error(status)) return status;
+ }
- f_number_unsigned_t length = datas->used + step;
+ if (source.delimits.used) {
+ for (f_number_unsigned_t i = 0; i < source.delimits.used; ++i) {
- if (length > F_number_t_size_unsigned_d) {
- if (datas->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+ status = f_memory_array_append(source.delimits.array + i, sizeof(f_number_unsigned_t), (void **) &destination->array[destination->used].delimits.array, &destination->array[destination->used].delimits.used, &destination->array[destination->used].delimits.size);
+ if (F_status_is_error(status)) return status;
+ } // for
+ }
- length = F_number_t_size_unsigned_d;
- }
+ if (source.variable.used) {
+ status = f_string_ranges_append_all(source.variable, &destination->array[destination->used].variable);
+ if (F_status_is_error(status)) return status;
+ }
- return private_f_iki_datas_resize(length, datas);
+ if (source.vocabulary.used) {
+ status = f_string_ranges_append_all(source.vocabulary, &destination->array[destination->used].vocabulary);
+ if (F_status_is_error(status)) return status;
}
- return F_data_not;
+ ++destination->used;
+
+ return F_none;
}
-#endif // _di_f_iki_datas_increase_
+#endif // _di_f_iki_datas_append_
-#ifndef _di_f_iki_datas_increase_by_
- f_status_t f_iki_datas_increase_by(const f_number_unsigned_t amount, f_iki_datas_t *datas) {
+#ifndef _di_f_iki_datas_append_all_
+ f_status_t f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) {
#ifndef _di_level_0_parameter_checking_
- if (!datas) return F_status_set_error(F_parameter);
+ if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (amount) {
- if (datas->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+ if (!source.used) return F_data_not;
- const f_number_unsigned_t length = datas->used + amount;
+ return private_f_iki_datas_append_all(source, destination);
+ }
+#endif // _di_f_iki_datas_append_all_
- if (length > datas->size) {
- if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
+#ifndef _di_f_iki_datas_resize_callback_
+ f_status_t f_iki_datas_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) {
- return private_f_iki_datas_resize(length, datas);
- }
- }
+ {
+ f_iki_datas_t * const array = (f_iki_datas_t *) void_array;
+ f_status_t status = F_none;
- return F_data_not;
- }
-#endif // _di_f_iki_datas_increase_by_
+ for (f_number_unsigned_t i = start; i < stop; ++i) {
-#ifndef _di_f_iki_datas_resize_
- f_status_t f_iki_datas_resize(const f_number_unsigned_t length, f_iki_datas_t *datas) {
- #ifndef _di_level_0_parameter_checking_
- if (!datas) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ status = f_string_ranges_resize(0, &array->array[i].content);
+ if (F_status_is_error(status)) return status;
- return private_f_iki_datas_resize(length, datas);
- }
-#endif // _di_f_iki_datas_resize_
+ status = f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &array->array[i].delimits.array, &array->array[i].delimits.used, &array->array[i].delimits.size);
+ if (F_status_is_error(status)) return status;
-#ifndef _di_f_iki_datass_adjust_
- f_status_t f_iki_datass_adjust(const f_number_unsigned_t length, f_iki_datass_t *datass) {
- #ifndef _di_level_0_parameter_checking_
- if (!datass) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
+ status = f_string_ranges_resize(0, &array->array[i].variable);
+ if (F_status_is_error(status)) return status;
- return private_f_iki_datass_adjust(length, datass);
+ status = f_string_ranges_resize(0, &array->array[i].vocabulary);
+ if (F_status_is_error(status)) return status;
+ } // for
+ }
+
+ return F_none;
}
-#endif // _di_f_iki_datass_adjust_
+#endif // _di_f_iki_datas_resize_callback_
#ifndef _di_f_iki_datass_append_
f_status_t f_iki_datass_append(const f_iki_datas_t source, f_iki_datass_t *destination) {
}
#endif // _di_f_iki_datass_append_all_
-#ifndef _di_f_iki_datass_decimate_by_
- f_status_t f_iki_datass_decimate_by(const f_number_unsigned_t amount, f_iki_datass_t *datass) {
- #ifndef _di_level_0_parameter_checking_
- if (!datass) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- return private_f_iki_datass_adjust((datass->size > amount) ? datass->size - amount : 0, datass);
- }
-#endif // _di_f_iki_datass_decimate_by_
-
-#ifndef _di_f_iki_datass_decrease_by_
- f_status_t f_iki_datass_decrease_by(const f_number_unsigned_t amount, f_iki_datass_t *datass) {
- #ifndef _di_level_0_parameter_checking_
- if (!datass) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- return private_f_iki_datass_resize((datass->size > amount) ? datass->size - amount : 0, datass);
- }
-#endif // _di_f_iki_datass_decrease_by_
-
-#ifndef _di_f_iki_datass_increase_
- f_status_t f_iki_datass_increase(const f_number_unsigned_t step, f_iki_datass_t *datass) {
- #ifndef _di_level_0_parameter_checking_
- if (!datass) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && datass->used + 1 > datass->size) {
- if (datass->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
-
- f_number_unsigned_t length = datass->used + step;
-
- if (length > F_number_t_size_unsigned_d) {
- if (datass->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
-
- length = F_number_t_size_unsigned_d;
- }
-
- return private_f_iki_datass_resize(length, datass);
- }
-
- return F_data_not;
- }
-#endif // _di_f_iki_datass_increase_
-
-#ifndef _di_f_iki_datass_increase_by_
- f_status_t f_iki_datass_increase_by(const f_number_unsigned_t amount, f_iki_datass_t *datass) {
- #ifndef _di_level_0_parameter_checking_
- if (!datass) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (amount) {
- if (datass->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
-
- const f_number_unsigned_t length = datass->used + amount;
-
- if (length > datass->size) {
- if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large);
-
- return private_f_iki_datass_resize(length, datass);
- }
- }
-
- return F_data_not;
- }
-#endif // _di_f_iki_datass_increase_by_
-
-#ifndef _di_f_iki_datass_resize_
- f_status_t f_iki_datass_resize(const f_number_unsigned_t length, f_iki_datass_t *datass) {
- #ifndef _di_level_0_parameter_checking_
- if (!datass) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_iki_datass_resize(length, datass);
- }
-#endif // _di_f_iki_datass_resize_
-
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _di_f_iki_data_destroy_
/**
- * Resize the iki_datas array.
+ * A callback intended to be passed to f_memory_arrays_adjust() for an f_iki_datass_t structure.
*
- * @param length
- * The new size to use.
- * @param iki_datas
- * The iki_datas array to resize.
+ * This does not do parameter checking.
+ *
+ * @param start
+ * The inclusive start position in the array to start deleting.
+ * @param stop
+ * The exclusive stop position in the array to stop deleting.
+ * @param array
+ * The array structure to delete all values of.
+ * Must not be NULL.
*
* @return
* F_none on success.
* F_parameter (with error bit) if a parameter is invalid.
*
* Errors (with error bit) from: f_memory_array_adjust().
- * Errors (with error bit) from: f_string_ranges_adjust().
*
* @see f_memory_array_adjust()
- * @see f_string_ranges_adjust()
+ * @see f_memory_arrays_adjust()
*/
-#ifndef _di_f_iki_datas_adjust_
- extern f_status_t f_iki_datas_adjust(const f_number_unsigned_t length, f_iki_datas_t *datas);
-#endif // _di_f_iki_datas_adjust_
+#ifndef _di_f_iki_datas_adjust_callback_
+ extern f_status_t f_iki_datas_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array);
+#endif // _di_f_iki_datas_adjust_callback_
/**
* Append the single source iki_data onto the destination.
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_array_append_all().
+ * Errors (with error bit) from: f_memory_array_append().
* Errors (with error bit) from: f_memory_array_increase().
* Errors (with error bit) from: f_string_ranges_append_all().
*
- * @see f_memory_array_append_all()
+ * @see f_memory_array_append()
* @see f_memory_array_increase()
* @see f_string_ranges_append_all()
*/
*
* F_parameter (with error bit) if a parameter is invalid.
*
- * Errors (with error bit) from: f_memory_array_append_all().
+ * Errors (with error bit) from: f_memory_array_append().
* Errors (with error bit) from: f_memory_array_increase_by().
* Errors (with error bit) from: f_string_ranges_append_all().
*
- * @see f_memory_array_append_all()
+ * @see f_memory_array_append()
* @see f_memory_array_increase_by()
* @see f_string_ranges_append_all()
*/
#endif // _di_f_iki_datas_append_all_
/**
- * Resize the iki_datas array to a smaller size.
+ * A callback intended to be passed to f_memory_arrays_resize() for an f_iki_datass_t structure.
*
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to les than 0.
+ * This does not do parameter checking.
*
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param iki_datas
- * The iki_datas array to resize.
+ * @param start
+ * The inclusive start position in the array to start deleting.
+ * @param stop
+ * The exclusive stop position in the array to stop deleting.
+ * @param array
+ * The array structure to delete all values of.
+ * Must not be NULL.
*
* @return
* F_none on success.
- * F_data_not if amount is 0.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_adjust().
- * Errors (with error bit) from: f_string_ranges_adjust().
- *
- * @see f_memory_array_adjust()
- * @see f_string_ranges_adjust()
- */
-#ifndef _di_f_iki_datas_decimate_by_
- extern f_status_t f_iki_datas_decimate_by(const f_number_unsigned_t amount, f_iki_datas_t *datas);
-#endif // _di_f_iki_datas_decimate_by_
-
-/**
- * Resize the iki_datas array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to les than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param iki_datas
- * The iki_datas array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
*
* F_parameter (with error bit) if a parameter is invalid.
*
* Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
*
* @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- */
-#ifndef _di_f_iki_datas_decrease_by_
- extern f_status_t f_iki_datas_decrease_by(const f_number_unsigned_t amount, f_iki_datas_t *datas);
-#endif // _di_f_iki_datas_decrease_by_
-
-/**
- * Increase the size of the iki_datas array, but only if necesary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param iki_datas
- * The iki_datas array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- */
-#ifndef _di_f_iki_datas_increase_
- extern f_status_t f_iki_datas_increase(const f_number_unsigned_t step, f_iki_datas_t *datas);
-#endif // _di_f_iki_datas_increase_
-
-/**
- * Resize the iki_datas array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param iki_datas
- * The iki_datas array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- */
-#ifndef _di_f_iki_datas_increase_by_
- extern f_status_t f_iki_datas_increase_by(const f_number_unsigned_t amount, f_iki_datas_t *datas);
-#endif // _di_f_iki_datas_increase_by_
-
-/**
- * Resize the iki_datas array.
- *
- * @param length
- * The new size to use.
- * @param iki_datas
- * The iki_datas array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- */
-#ifndef _di_f_iki_datas_resize_
- extern f_status_t f_iki_datas_resize(const f_number_unsigned_t length, f_iki_datas_t *datas);
-#endif // _di_f_iki_datas_resize_
-
-/**
- * Resize the iki_datass array.
- *
- * @param length
- * The new size to use.
- * @param iki_datass
- * The iki_datass array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_adjust().
- * Errors (with error bit) from: f_string_ranges_adjust().
- *
- * @see f_memory_array_adjust()
- * @see f_string_ranges_adjust()
+ * @see f_memory_arrays_resize()
*/
-#ifndef _di_f_iki_datass_adjust_
- extern f_status_t f_iki_datass_adjust(const f_number_unsigned_t length, f_iki_datass_t *datass);
-#endif // _di_f_iki_datass_adjust_
+#ifndef _di_f_iki_datas_resize_callback_
+ extern f_status_t f_iki_datas_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array);
+#endif // _di_f_iki_datas_resize_callback_
/**
* Append the single source iki_datas onto the destination.
extern f_status_t f_iki_datass_append_all(const f_iki_datass_t source, f_iki_datass_t *destination);
#endif // _di_f_iki_datass_append_all_
-/**
- * Resize the iki_datass array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param iki_datass
- * The iki_datass array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_adjust().
- * Errors (with error bit) from: f_string_ranges_adjust().
- *
- * @see f_memory_array_adjust()
- * @see f_string_ranges_adjust()
- */
-#ifndef _di_f_iki_datass_decimate_by_
- extern f_status_t f_iki_datass_decimate_by(const f_number_unsigned_t amount, f_iki_datass_t *datass);
-#endif // _di_f_iki_datass_decimate_by_
-
-/**
- * Resize the iki_datass array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param iki_datass
- * The iki_datass array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- */
-#ifndef _di_f_iki_datass_decrease_by_
- extern f_status_t f_iki_datass_decrease_by(const f_number_unsigned_t amount, f_iki_datass_t *datass);
-#endif // _di_f_iki_datass_decrease_by_
-
-/**
- * Increase the size of the iki_datass array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param iki_datass
- * The iki_datass array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- */
-#ifndef _di_f_iki_datass_increase_
- extern f_status_t f_iki_datass_increase(const f_number_unsigned_t step, f_iki_datass_t *datass);
-#endif // _di_f_iki_datass_increase_
-
-/**
- * Resize the iki_datass array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param iki_datass
- * The iki_datass array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- */
-#ifndef _di_f_iki_datass_increase_by_
- extern f_status_t f_iki_datass_increase_by(const f_number_unsigned_t amount, f_iki_datass_t *datass);
-#endif // _di_f_iki_datass_increase_by_
-
-/**
- * Resize the iki_datass array.
- *
- * @param length
- * The new size to use.
- * @param iki_datass
- * The iki_datass array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- */
-#ifndef _di_f_iki_datass_resize_
- extern f_status_t f_iki_datass_resize(const f_number_unsigned_t length, f_iki_datass_t *datass);
-#endif // _di_f_iki_datass_resize_
-
#ifdef __cplusplus
} // extern "C"
#endif
extern "C" {
#endif
-#if !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_)
- f_status_t private_f_iki_datas_adjust(const f_number_unsigned_t length, f_iki_datas_t *structure) {
-
- f_status_t status = F_none;
-
- for (f_number_unsigned_t i = length; i < structure->size; ++i) {
-
- status = f_string_ranges_adjust(0, &structure->array[i].content);
- if (F_status_is_error(status)) return status;
-
- status = f_memory_array_adjust(0, sizeof(f_number_unsigned_t), (void **) &structure->array[i].delimits.array, &structure->array[i].delimits.used, &structure->array[i].delimits.size);
- if (F_status_is_error(status)) return status;
-
- status = f_string_ranges_adjust(0, &structure->array[i].variable);
- if (F_status_is_error(status)) return status;
-
- status = f_string_ranges_adjust(0, &structure->array[i].vocabulary);
- if (F_status_is_error(status)) return status;
- } // for
-
- return f_memory_array_adjust(length, sizeof(f_iki_data_t), (void **) &structure->array, &structure->used, &structure->size);
- }
-#endif // !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_)
-
-#if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datass_append_)
- extern f_status_t private_f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t *destination) {
-
- f_status_t status = f_memory_array_increase(F_iki_default_allocation_small_d, sizeof(f_iki_data_t), (void **) &destination->array, &destination->used, &destination->size);
- if (F_status_is_error(status)) return status;
-
- destination->array[destination->used].content.used = 0;
- destination->array[destination->used].delimits.used = 0;
- destination->array[destination->used].variable.used = 0;
- destination->array[destination->used].vocabulary.used = 0;
-
- if (source.content.used) {
- status = f_string_ranges_append_all(source.content, &destination->array[destination->used].content);
- if (F_status_is_error(status)) return status;
- }
-
- if (source.delimits.used) {
- for (f_number_unsigned_t i = 0; i < source.delimits.used; ++i) {
-
- status = f_memory_array_append(source.delimits.array + i, sizeof(f_number_unsigned_t), (void **) &destination->array[destination->used].delimits.array, &destination->array[destination->used].delimits.used, &destination->array[destination->used].delimits.size);
- if (F_status_is_error(status)) return status;
- } // for
- }
-
- if (source.variable.used) {
- status = f_string_ranges_append_all(source.variable, &destination->array[destination->used].variable);
- if (F_status_is_error(status)) return status;
- }
-
- if (source.vocabulary.used) {
- status = f_string_ranges_append_all(source.vocabulary, &destination->array[destination->used].vocabulary);
- if (F_status_is_error(status)) return status;
- }
-
- ++destination->used;
-
- return F_none;
- }
-#endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datass_append_)
-
#if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_)
extern f_status_t private_f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) {
}
#endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_)
-#if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_decrease_by_) || !defined(_di_f_iki_datas_increase_) || !defined(_di_f_iki_datas_increase_by_) || !defined(_di_f_iki_datas_resize_)
- f_status_t private_f_iki_datas_resize(const f_number_unsigned_t length, f_iki_datas_t *structure) {
-
- f_status_t status = F_none;
-
- for (f_number_unsigned_t i = length; i < structure->size; ++i) {
-
- status = f_string_ranges_resize(0, &structure->array[i].content);
- if (F_status_is_error(status)) return status;
-
- status = f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &structure->array[i].delimits.array, &structure->array[i].delimits.used, &structure->array[i].delimits.size);
- if (F_status_is_error(status)) return status;
-
- status = f_string_ranges_resize(0, &structure->array[i].variable);
- if (F_status_is_error(status)) return status;
-
- status = f_string_ranges_resize(0, &structure->array[i].vocabulary);
- if (F_status_is_error(status)) return status;
- } // for
-
- return f_memory_array_resize(length, sizeof(f_iki_data_t), (void **) &structure->array, &structure->used, &structure->size);
- }
-#endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_decrease_by_) || !defined(_di_f_iki_datas_increase_) || !defined(_di_f_iki_datas_increase_by_) || !defined(_di_f_iki_datas_resize_)
-
-#if !defined(_di_f_iki_datass_adjust_) || !defined(_di_f_iki_datass_decimate_by_)
- f_status_t private_f_iki_datass_adjust(const f_number_unsigned_t length, f_iki_datass_t *structure) {
-
- f_status_t status = F_none;
-
- for (f_number_unsigned_t i = length; i < structure->size; ++i) {
-
- status = private_f_iki_datas_adjust(0, &structure->array[i]);
- if (F_status_is_error(status)) return status;
- } // for
-
- return f_memory_array_adjust(length, sizeof(f_iki_datas_t), (void **) &structure->array, &structure->used, &structure->size);
- }
-#endif // !defined(_di_f_iki_datass_adjust_) || !defined(_di_f_iki_datass_decimate_by_)
-
-#if !defined(_di_f_iki_datass_decrease_by_) || !defined(_di_f_iki_datass_increase_) || !defined(_di_f_iki_datass_increase_by_) || !defined(_di_f_iki_datass_resize_)
- f_status_t private_f_iki_datass_resize(const f_number_unsigned_t length, f_iki_datass_t *structure) {
-
- f_status_t status = F_none;
-
- for (f_number_unsigned_t i = length; i < structure->size; ++i) {
-
- status = private_f_iki_datas_resize(0, &structure->array[i]);
- if (F_status_is_error(status)) return status;
- } // for
-
- return f_memory_array_resize(length, sizeof(f_iki_datas_t), (void **) &structure->array, &structure->used, &structure->size);
- }
-#endif // !defined(_di_f_iki_datass_decrease_by_) || !defined(_di_f_iki_datass_increase_) || !defined(_di_f_iki_datass_increase_by_) || !defined(_di_f_iki_datass_resize_)
-
#ifdef __cplusplus
} // extern "C"
#endif
#endif
/**
- * Private implementation for resizing the iki_datas array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param structure
- * The iki_datas array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_array_adjust().
- * Errors (with error bit) from: f_string_ranges_adjust().
- *
- * @see f_memory_array_adjust()
- * @see f_string_ranges_adjust()
- *
- * @see f_iki_datas_adjust()
- * @see f_iki_datas_decimate_by()
- */
-#if !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_)
- extern f_status_t private_f_iki_datas_adjust(const f_number_unsigned_t length, f_iki_datas_t *structure) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_)
-
-/**
- * Private implementation for appending the iki_data array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param source
- * The source iki_data to append.
- * @param destination
- * The iki_datas array the source is appended onto.
- *
- * @return
- * F_none on success.
- *
- * Errors (with error bit) from: f_memory_array_append_all().
- * Errors (with error bit) from: f_memory_array_increase().
- * Errors (with error bit) from: f_string_ranges_append_all().
- *
- * @see f_memory_array_append_all()
- * @see f_memory_array_increase()
- * @see f_string_ranges_append_all()
- *
- * @see f_iki_datas_append()
- * @see f_iki_datass_append()
- */
-#if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datass_append_)
- extern f_status_t private_f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t *destination) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datass_append_)
-
-/**
* Private implementation for appending the iki_data array.
*
* Intended to be shared to each of the different implementation variations.
* @return
* F_none on success.
*
- * Errors (with error bit) from: f_memory_array_append_all().
+ * Errors (with error bit) from: f_memory_array_append().
* Errors (with error bit) from: f_memory_array_increase_by().
* Errors (with error bit) from: f_string_ranges_append_all().
*
- * @see f_memory_array_append_all()
+ * @see f_memory_array_append()
* @see f_memory_array_increase_by()
* @see f_string_ranges_append_all()
*
extern f_status_t private_f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) F_attribute_visibility_internal_d;
#endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_)
-/**
- * Private implementation for resizing the iki_datas array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param structure
- * The iki_datas array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- *
- * @see f_iki_datas_resize()
- * @see f_iki_datas_append()
- * @see f_iki_datas_decimate_by()
- * @see f_iki_datass_append()
- */
-#if !defined(_di_f_iki_datas_resize_) || !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_decimate_by_) || !defined(_di_f_iki_datass_append_)
- extern f_status_t private_f_iki_datas_resize(const f_number_unsigned_t length, f_iki_datas_t *structure) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datas_resize_) || !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_decimate_by_) || !defined(_di_f_iki_datass_append_)
-
-/**
- * Private implementation for resizing the iki_datass array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param iki_datass
- * The iki_datass array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if new length is larger than max array length.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_adjust().
- * Errors (with error bit) from: f_string_ranges_adjust().
- *
- * @see f_memory_array_adjust()
- * @see f_string_ranges_adjust()
- *
- * @see f_iki_datass_adjust()
- * @see f_iki_datass_decimate_by()
- */
-#if !defined(_di_f_iki_datass_adjust_) || !defined(_di_f_iki_datass_decimate_by_)
- extern f_status_t private_f_iki_datass_adjust(const f_number_unsigned_t length, f_iki_datass_t *datass) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datass_adjust_) || !defined(_di_f_iki_datass_decimate_by_)
-
-/**
- * Private implementation for resizing the iki_datass array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to resize to.
- * @param iki_datass
- * The iki_datass array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if new length is larger than max array length.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_string_ranges_resize()
- *
- * @see f_iki_datass_decrease_by()
- * @see f_iki_datass_increase()
- * @see f_iki_datass_increase_by()
- * @see f_iki_datass_resize()
- */
-#if !defined(_di_f_iki_datass_decrease_by_) || !defined(_di_f_iki_datass_increase_) || !defined(_di_f_iki_datass_increase_by_) || !defined(_di_f_iki_datass_resize_)
- extern f_status_t private_f_iki_datass_resize(const f_number_unsigned_t length, f_iki_datass_t *datass) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datass_decrease_by_) || !defined(_di_f_iki_datass_increase_) || !defined(_di_f_iki_datass_increase_by_) || !defined(_di_f_iki_datass_resize_)
-
#ifdef __cplusplus
} // extern "C"
#endif
#endif // !defined(_di_f_iki_content_is_) || !defined(_di_f_iki_content_partial_is_)
/**
- * Private implementation for resizing the iki_datas array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param datas
- * The IKI datas array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_string_ranges_adjust().
- *
- * @see f_memory_adjust()
- * @see f_memory_array_resize()
- * @see f_string_ranges_adjust()
- */
-#if !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_)
- extern f_status_t private_f_iki_datas_adjust(const f_number_unsigned_t length, f_iki_datas_t *datas) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_)
-
-/**
- * Private implementation for appending the iki_data array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param source
- * The source iki_datas to append.
- * @param destination
- * The destination lengths the source is appended onto.
- *
- * @return
- * F_none on success.
- *
- * Errors (with error bit) from: f_memory_resize().
- *
- * @see f_memory_resize()
- * @see f_iki_datas_append_all()
- * @see f_iki_datass_append()
- * @see f_iki_datass_append_all()
- */
-#if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_)
- extern f_status_t private_f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_)
-
-/**
- * Private implementation for resizing the iki_datas array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param datas
- * The IKI datas array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * Errors (with error bit) from: f_memory_array_resize().
- * Errors (with error bit) from: f_memory_resize().
- * Errors (with error bit) from: f_string_ranges_resize().
- *
- * @see f_memory_array_resize()
- * @see f_memory_resize()
- * @see f_string_ranges_resize()
- */
-#if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_decrease_by_) || !defined(_di_f_iki_datas_increase_) || !defined(_di_f_iki_datas_increase_by_) || !defined(_di_f_iki_datas_resize_)
- extern f_status_t private_f_iki_datas_resize(const f_number_unsigned_t length, f_iki_datas_t *datas) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_decrease_by_) || !defined(_di_f_iki_datas_increase_) || !defined(_di_f_iki_datas_increase_by_) || !defined(_di_f_iki_datas_resize_)
-
-/**
- * Private implementation for resizing the iki_datass array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to adjust to.
- * @param iki_datass
- * The iki_datass array to adjust.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if new length is larger than max array length.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_adjust().
- * Errors (with error bit) from: f_memory_destroy().
- *
- * @see f_iki_datass_adjust()
- * @see f_iki_datass_decimate_by()
- */
-#if !defined(_di_f_iki_datass_adjust_) || !defined(_di_f_iki_datass_decimate_by_)
- extern f_status_t private_f_iki_datass_adjust(const f_number_unsigned_t length, f_iki_datass_t *datass) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datass_adjust_) || !defined(_di_f_iki_datass_decimate_by_)
-
-/**
- * Private implementation for resizing the iki_datass array.
- *
- * Intended to be shared to each of the different implementation variations.
- *
- * @param length
- * The length to resize to.
- * @param iki_datass
- * The iki_datass array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if new length is larger than max array length.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- *
- * Errors (with error bit) from: f_memory_delete().
- * Errors (with error bit) from: f_memory_resize().
- *
- * @see f_iki_datass_decrease_by()
- * @see f_iki_datass_increase()
- * @see f_iki_datass_increase_by()
- * @see f_iki_datass_resize()
- */
-#if !defined(_di_f_iki_datass_decrease_by_) || !defined(_di_f_iki_datass_increase_) || !defined(_di_f_iki_datass_increase_by_) || !defined(_di_f_iki_datass_resize_)
- extern f_status_t private_f_iki_datass_resize(const f_number_unsigned_t length, f_iki_datass_t *datass) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_iki_datass_decrease_by_) || !defined(_di_f_iki_datass_increase_) || !defined(_di_f_iki_datass_increase_by_) || !defined(_di_f_iki_datass_resize_)
-
-/**
* Private implementation of f_iki_object_partial_is().
*
* Intended to be shared to each of the different implementation variations.
--- /dev/null
+# fss-0001
+#
+# Build the project with appropriate mocks linked in via the dynamic linker's "--wrap" functionality.
+#
+# The -Wl,--wrap does not work across shared files.
+# Therefore, this file is a work-around to inject the mocks into the library for testing purposes.
+# This should exactly match the "settings" file, except for the additional "-Wl,--wrap" parts and the additional mock source file.
+#
+# The flags -o0 must be passed to prevent the compiler from optimizing away any functions being mocked (which results in the mock not happening and a real function being called).
+# Alternatively, figure out which optimization that is disabled by -o0 and have that specific optimization disabled.
+#
+
+build_name f_iki
+
+version_major 0
+version_minor 7
+version_micro 0
+version_file micro
+version_target minor
+
+modes individual clang test coverage
+modes_default individual test
+
+build_compiler gcc
+build_compiler-clang clang
+build_indexer ar
+build_indexer_arguments rcs
+build_language c
+
+build_libraries -lc
+build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_utf
+
+build_sources_library iki.c private-iki.c iki/common.c iki/private-data.c iki/data.c
+build_sources_library ../../tests/unit/c/mock-iki.c
+
+build_sources_headers iki.h iki/common.h iki/data.h
+
+build_script yes
+build_shared yes
+build_static no
+
+path_headers fll/level_0
+path_library_script script
+path_library_shared shared
+path_library_static static
+
+has_path_standard yes
+preserve_path_headers yes
+
+search_exclusive yes
+search_shared yes
+search_static yes
+
+environment PATH LD_LIBRARY_PATH
+environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH
+
+#defines -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_
+defines -D_pthread_sigqueue_unsupported_
+
+flags -O0 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses
+flags-clang -Wno-logical-op-parentheses
+flags-test -fstack-protector -Wall
+flags-coverage --coverage -fprofile-abs-path -fprofile-dir=build/coverage/
+
+flags_library -fPIC
+
+# Inject mocks.
+flags -Wl,--wrap=f_memory_array_adjust
+flags -Wl,--wrap=f_memory_array_resize
+flags -Wl,--wrap=f_string_ranges_adjust
+flags -Wl,--wrap=f_string_ranges_resize
build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_utf -lf_iki
build_sources_program test-iki-content_is.c test-iki-content_partial_is.c test-iki-object_is.c test-iki-object_partial_is.c test-iki-read.c
-build_sources_program test-iki-datas_adjust.c test-iki-datas_append.c test-iki-datas_append_all.c test-iki-datas_decimate_by.c test-iki-datas_decrease_by.c test-iki-datas_increase.c test-iki-datas_increase_by.c test-iki-datas_resize.c test-iki-datass_adjust.c test-iki-datass_append.c test-iki-datass_append_all.c test-iki-datass_decimate_by.c test-iki-datass_decrease_by.c test-iki-datass_increase.c test-iki-datass_increase_by.c test-iki-datass_resize.c
+build_sources_program test-iki-datas_adjust_callback.c test-iki-datas_append.c test-iki-datas_append_all.c test-iki-datas_resize_callback.c test-iki-datass_append.c test-iki-datass_append_all.c
build_sources_program test-iki.c
build_script no
#define CMOCKA_XML_FILE ./out.xml
main:
- build settings individual test
+ build settings-mocks individual test
build settings-tests individual test
operate build_path
--- /dev/null
+#include "mock-iki.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mock_unwrap = 0;
+
+f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+
+ if (mock_unwrap) {
+ return __real_f_memory_array_adjust(length, width, array, used, size);
+ }
+
+ if (!array || !used || !size) return F_status_set_error(F_parameter_not);
+
+ const bool failure = mock_type(bool);
+
+ if (failure) return mock_type(f_status_t);
+
+ *size = length;
+
+ return mock_type(f_status_t);
+}
+
+f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) {
+
+ if (mock_unwrap) {
+ return __real_f_memory_array_resize(length, width, array, used, size);
+ }
+
+ if (!array || !used || !size) return F_status_set_error(F_parameter_not);
+
+ const bool failure = mock_type(bool);
+
+ if (failure) return mock_type(f_status_t);
+
+ *size = length;
+
+ return mock_type(f_status_t);
+}
+
+f_status_t __wrap_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure) {
+
+ if (mock_unwrap) {
+ return __real_f_string_ranges_adjust(length, structure);
+ }
+
+ if (!structure) return F_status_set_error(F_parameter_not);
+
+ const bool failure = mock_type(bool);
+
+ if (failure) return mock_type(f_status_t);
+
+ structure->size = length;
+
+ return mock_type(f_status_t);
+}
+
+f_status_t __wrap_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure) {
+
+ if (mock_unwrap) {
+ return __real_f_string_ranges_resize(length, structure);
+ }
+
+ if (!structure) return F_status_set_error(F_parameter_not);
+
+ const bool failure = mock_type(bool);
+
+ if (failure) return mock_type(f_status_t);
+
+ structure->size = length;
+
+ return mock_type(f_status_t);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: IKI
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the iki project.
+ */
+#ifndef _MOCK__iki_h
+#define _MOCK__iki_h
+
+// Libc includes.
+#include <semaphore.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+
+// cmocka includes.
+#include <cmocka.h>
+
+// FLL-0 includes.
+#include <fll/level_0/iki.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const static int mock_errno_generic = 32767;
+
+extern int mock_unwrap;
+
+extern f_status_t __real_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+extern f_status_t __real_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+extern f_status_t __real_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure);
+extern f_status_t __real_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure);
+
+extern f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+extern f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size);
+extern f_status_t __wrap_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure);
+extern f_status_t __wrap_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _MOCK__iki_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datas_adjust.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datas_adjust__works(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_adjust(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datas_adjust__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_adjust(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datas_adjust_h
-#define _TEST__F_iki_datas_adjust_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datas_adjust()
- */
-extern void test__f_iki_datas_adjust__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datas_adjust()
- */
-extern void test__f_iki_datas_adjust__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datas_adjust_h
--- /dev/null
+#include "test-iki.h"
+#include "test-iki-datas_adjust_callback.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_iki_datas_adjust_callback__fails(void **state) {
+
+ mock_unwrap = 0;
+
+ f_iki_data_t data = f_iki_data_t_initialize;
+ f_iki_data_t data_array[] = { data };
+ f_iki_datas_t datas = { .array = data_array, .used = 1, .size = 1 };
+ f_iki_datas_t datass_array[] = { datas };
+
+ {
+ will_return(__wrap_f_string_ranges_adjust, true);
+ will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure));
+
+ const f_status_t status = f_iki_datas_adjust_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_ranges_adjust, false);
+ will_return(__wrap_f_string_ranges_adjust, F_none);
+
+ will_return(__wrap_f_memory_array_adjust, true);
+ will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure));
+
+ const f_status_t status = f_iki_datas_adjust_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_ranges_adjust, false);
+ will_return(__wrap_f_string_ranges_adjust, F_none);
+
+ will_return(__wrap_f_memory_array_adjust, false);
+ will_return(__wrap_f_memory_array_adjust, F_none);
+
+ will_return(__wrap_f_string_ranges_adjust, true);
+ will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure));
+
+ const f_status_t status = f_iki_datas_adjust_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_ranges_adjust, false);
+ will_return(__wrap_f_string_ranges_adjust, F_none);
+
+ will_return(__wrap_f_memory_array_adjust, false);
+ will_return(__wrap_f_memory_array_adjust, F_none);
+
+ will_return(__wrap_f_string_ranges_adjust, false);
+ will_return(__wrap_f_string_ranges_adjust, F_none);
+
+ will_return(__wrap_f_string_ranges_adjust, true);
+ will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure));
+
+ const f_status_t status = f_iki_datas_adjust_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+}
+
+void test__f_iki_datas_adjust_callback__works(void **state) {
+
+ mock_unwrap = 0;
+
+ f_iki_data_t data = f_iki_data_t_initialize;
+ f_iki_data_t data_array[] = { data };
+ f_iki_datas_t datas = { .array = data_array, .used = 1, .size = 1 };
+ f_iki_datas_t datass_array[] = { datas };
+ const f_number_unsigned_t length = 1;
+
+ {
+ will_return(__wrap_f_string_ranges_adjust, false);
+ will_return(__wrap_f_string_ranges_adjust, F_none);
+
+ will_return(__wrap_f_memory_array_adjust, false);
+ will_return(__wrap_f_memory_array_adjust, F_none);
+
+ will_return(__wrap_f_string_ranges_adjust, false);
+ will_return(__wrap_f_string_ranges_adjust, F_none);
+
+ will_return(__wrap_f_string_ranges_adjust, false);
+ will_return(__wrap_f_string_ranges_adjust, F_none);
+
+ const f_status_t status = f_iki_datas_adjust_callback(0, length, (void *) datass_array);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: IKI
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the array types in the type project.
+ */
+#ifndef _TEST__F_iki__datas_adjust_callback
+#define _TEST__F_iki__datas_adjust_callback
+
+/**
+ * Test that the function fails.
+ *
+ * @see f_iki_datas_adjust_callback()
+ */
+extern void test__f_iki_datas_adjust_callback__fails(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_iki_datas_adjust_callback()
+ */
+extern void test__f_iki_datas_adjust_callback__works(void **state);
+
+#endif // _TEST__F_iki__datas_adjust_callback
/**
* FLL - Level 0
*
- * Project: Type
+ * Project: IKI
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
f_iki_datas_t destination = f_iki_datas_t_initialize;
{
- f_status_t status = f_iki_datas_resize(2, &source);
+ f_status_t status = f_memory_array_resize(2, sizeof(f_iki_data_t), (void **) &source.array, &source.used, &source.size);
assert_int_equal(status, F_none);
assert_int_equal(source.size, 2);
f_iki_datas_t destination = f_iki_datas_t_initialize;
{
- const f_status_t status = f_iki_datas_resize(length, &source);
+ const f_status_t status = f_memory_array_resize(length, sizeof(f_iki_data_t), (void **) &source.array, &source.used, &source.size);
assert_int_equal(status, F_none);
assert_int_equal(source.used, 0);
/**
* FLL - Level 0
*
- * Project: Type
+ * Project: IKI
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datas_decimate_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datas_decimate_by__works(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_iki_datas_decimate_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_iki_datas_decimate_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_decimate_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datas_decimate_by_h
-#define _TEST__F_iki_datas_decimate_by_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datas_decimate_by()
- */
-extern void test__f_iki_datas_decimate_by__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datas_decimate_by()
- */
-extern void test__f_iki_datas_decimate_by__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datas_decimate_by_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datas_decrease_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datas_decrease_by__works(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_iki_datas_decrease_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_iki_datas_decrease_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_decrease_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datas_decrease_by_h
-#define _TEST__F_iki_datas_decrease_by_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datas_decrease_by()
- */
-extern void test__f_iki_datas_decrease_by__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datas_decrease_by()
- */
-extern void test__f_iki_datas_decrease_by__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datas_decrease_by_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datas_increase.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datas_increase__works(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- data.used = length;
-
- const f_status_t status = f_iki_datas_increase(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, length);
- assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datas_increase__returns_data_not(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_iki_datas_increase(length, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datas_increase__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_increase(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datas_increase_h
-#define _TEST__F_iki_datas_increase_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datas_increase()
- */
-extern void test__f_iki_datas_increase__works(void **state);
-
-/**
- * Test that the function returns F_data_not when asked to copy an empty structure.
- *
- * @see f_iki_datas_increase()
- */
-extern void test__f_iki_datas_increase__returns_data_not(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datas_increase()
- */
-extern void test__f_iki_datas_increase__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datas_increase_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datas_increase_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datas_increase_by__works(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- data.used = length;
-
- const f_status_t status = f_iki_datas_increase_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, length);
- assert_int_equal(data.size, length * 2);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datas_increase_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_increase_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datas_increase_by_h
-#define _TEST__F_iki_datas_increase_by_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datas_increase_by()
- */
-extern void test__f_iki_datas_increase_by__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datas_increase_by()
- */
-extern void test__f_iki_datas_increase_by__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datas_increase_by_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datas_resize.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datas_resize__works(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datas_resize__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datas_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datas_resize(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datas_resize_h
-#define _TEST__F_iki_datas_resize_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datas_resize()
- */
-extern void test__f_iki_datas_resize__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datas_resize()
- */
-extern void test__f_iki_datas_resize__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datas_resize_h
--- /dev/null
+#include "test-iki.h"
+#include "test-iki-datas_resize_callback.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__f_iki_datas_resize_callback__fails(void **state) {
+
+ mock_unwrap = 0;
+
+ f_iki_data_t data = f_iki_data_t_initialize;
+ f_iki_data_t data_array[] = { data };
+ f_iki_datas_t datas = { .array = data_array, .used = 1, .size = 1 };
+ f_iki_datas_t datass_array[] = { datas };
+
+ {
+ will_return(__wrap_f_string_ranges_resize, true);
+ will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_iki_datas_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_ranges_resize, false);
+ will_return(__wrap_f_string_ranges_resize, F_none);
+
+ will_return(__wrap_f_memory_array_resize, true);
+ will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_iki_datas_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_ranges_resize, false);
+ will_return(__wrap_f_string_ranges_resize, F_none);
+
+ will_return(__wrap_f_memory_array_resize, false);
+ will_return(__wrap_f_memory_array_resize, F_none);
+
+ will_return(__wrap_f_string_ranges_resize, true);
+ will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_iki_datas_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+
+ {
+ will_return(__wrap_f_string_ranges_resize, false);
+ will_return(__wrap_f_string_ranges_resize, F_none);
+
+ will_return(__wrap_f_memory_array_resize, false);
+ will_return(__wrap_f_memory_array_resize, F_none);
+
+ will_return(__wrap_f_string_ranges_resize, false);
+ will_return(__wrap_f_string_ranges_resize, F_none);
+
+ will_return(__wrap_f_string_ranges_resize, true);
+ will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure));
+
+ const f_status_t status = f_iki_datas_resize_callback(0, 1, (void *) datass_array);
+
+ assert_int_equal(status, F_status_set_error(F_failure));
+ }
+}
+
+void test__f_iki_datas_resize_callback__works(void **state) {
+
+ mock_unwrap = 0;
+
+ f_iki_data_t data = f_iki_data_t_initialize;
+ f_iki_data_t data_array[] = { data };
+ f_iki_datas_t datas = { .array = data_array, .used = 1, .size = 1 };
+ f_iki_datas_t datass_array[] = { datas };
+ const f_number_unsigned_t length = 1;
+
+ {
+ will_return(__wrap_f_string_ranges_resize, false);
+ will_return(__wrap_f_string_ranges_resize, F_none);
+
+ will_return(__wrap_f_memory_array_resize, false);
+ will_return(__wrap_f_memory_array_resize, F_none);
+
+ will_return(__wrap_f_string_ranges_resize, false);
+ will_return(__wrap_f_string_ranges_resize, F_none);
+
+ will_return(__wrap_f_string_ranges_resize, false);
+ will_return(__wrap_f_string_ranges_resize, F_none);
+
+ const f_status_t status = f_iki_datas_resize_callback(0, length, (void *) datass_array);
+
+ assert_int_equal(status, F_none);
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: IKI
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the array types in the type project.
+ */
+#ifndef _TEST__F_iki__datas_resize_callback
+#define _TEST__F_iki__datas_resize_callback
+
+/**
+ * Test that the function fails.
+ *
+ * @see f_iki_datas_resize_callback()
+ */
+extern void test__f_iki_datas_resize_callback__fails(void **state);
+
+/**
+ * Test that the function works.
+ *
+ * @see f_iki_datas_resize_callback()
+ */
+extern void test__f_iki_datas_resize_callback__works(void **state);
+
+#endif // _TEST__F_iki__datas_resize_callback
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datass_adjust.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datass_adjust__works(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datass_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_adjust(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datass_adjust__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datass_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_adjust(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datass_adjust_h
-#define _TEST__F_iki_datass_adjust_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datass_adjust()
- */
-extern void test__f_iki_datass_adjust__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datass_adjust()
- */
-extern void test__f_iki_datass_adjust__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datass_adjust_h
f_iki_datass_t destination = f_iki_datass_t_initialize;
{
- f_status_t status = f_iki_datas_resize(length_outer, &source);
+ f_status_t status = f_memory_array_resize(length_outer, sizeof(f_iki_data_t), (void **) &source.array, &source.used, &source.size);
assert_int_equal(status, F_none);
assert_int_equal(source.size, length_outer);
f_iki_datass_t destination = f_iki_datass_t_initialize;
{
- const f_status_t status = f_iki_datas_resize(length, &source);
+ f_status_t status = f_memory_array_resize(length, sizeof(f_iki_data_t), (void **) &source.array, &source.used, &source.size);
assert_int_equal(status, F_none);
assert_int_equal(source.used, 0);
/**
* FLL - Level 0
*
- * Project: Type
+ * Project: IKI
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
f_iki_datass_t destination = f_iki_datass_t_initialize;
{
- f_status_t status = f_iki_datass_resize(length_outer, &source);
+ f_status_t status = f_memory_arrays_resize(length_outer, sizeof(f_iki_data_t), (void **) &source.array, &source.used, &source.size, &f_iki_datas_resize_callback);
assert_int_equal(status, F_none);
assert_int_equal(source.size, length_outer);
for (; source.used < length_outer; ++source.used) {
- status = f_iki_datas_resize(length_inner, &source.array[source.used]);
+ status = f_memory_array_resize(length_inner, sizeof(f_iki_data_t), (void **) &source.array[source.used].array, &source.array[source.used].used, &source.array[source.used].size);
assert_int_equal(status, F_none);
assert_int_equal(source.array[source.used].size, length_inner);
f_iki_datass_t destination = f_iki_datass_t_initialize;
{
- const f_status_t status = f_iki_datass_resize(length, &source);
+ const f_status_t status = f_memory_arrays_resize(length, sizeof(f_iki_data_t), (void **) &source.array, &source.used, &source.size, &f_iki_datas_resize_callback);
assert_int_equal(status, F_none);
assert_int_equal(source.used, 0);
/**
* FLL - Level 0
*
- * Project: Type
+ * Project: IKI
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datass_decimate_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datass_decimate_by__works(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_iki_datass_decimate_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_iki_datass_decimate_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_decimate_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datass_decimate_by_h
-#define _TEST__F_iki_datass_decimate_by_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datass_decimate_by()
- */
-extern void test__f_iki_datass_decimate_by__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datass_decimate_by()
- */
-extern void test__f_iki_datass_decimate_by__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datass_decimate_by_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datass_decrease_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datass_decrease_by__works(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_iki_datass_decrease_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-void test__f_iki_datass_decrease_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_decrease_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datass_decrease_by_h
-#define _TEST__F_iki_datass_decrease_by_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datass_decrease_by()
- */
-extern void test__f_iki_datass_decrease_by__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datass_decrease_by()
- */
-extern void test__f_iki_datass_decrease_by__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datass_decrease_by_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datass_increase.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datass_increase__works(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- data.used = length;
-
- const f_status_t status = f_iki_datass_increase(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, length);
- assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datass_increase__returns_data_not(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- const f_status_t status = f_iki_datass_increase(length, &data);
-
- assert_int_equal(status, F_data_not);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datass_increase__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_increase(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- free((void *) data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datass_increase_h
-#define _TEST__F_iki_datass_increase_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datass_increase()
- */
-extern void test__f_iki_datass_increase__works(void **state);
-
-/**
- * Test that the function returns F_data_not when asked to copy an empty structure.
- *
- * @see f_iki_datass_increase()
- */
-extern void test__f_iki_datass_increase__returns_data_not(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datass_increase()
- */
-extern void test__f_iki_datass_increase__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datass_increase_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datass_increase_by.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datass_increase_by__works(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- {
- data.used = length;
-
- const f_status_t status = f_iki_datass_increase_by(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, length);
- assert_int_equal(data.size, length * 2);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datass_increase_by__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datas_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_increase_by(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datass_increase_by_h
-#define _TEST__F_iki_datass_increase_by_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datass_increase_by()
- */
-extern void test__f_iki_datass_increase_by__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datass_increase_by()
- */
-extern void test__f_iki_datass_increase_by__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datass_increase_by_h
+++ /dev/null
-#include "test-iki.h"
-#include "test-iki-datass_resize.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_iki_datass_resize__works(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datass_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_resize(length, &data);
-
- assert_int_equal(status, F_none);
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, length);
- }
-
- free((void *) data.array);
-}
-
-void test__f_iki_datass_resize__parameter_checking(void **state) {
-
- const int length = 5;
- f_iki_datass_t data = f_iki_datass_t_initialize;
-
- {
- const f_status_t status = f_iki_datass_resize(length, 0);
-
- assert_int_equal(status, F_status_set_error(F_parameter));
- assert_int_equal(data.used, 0);
- assert_int_equal(data.size, 0);
- }
-
- assert_null(data.array);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Type
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the type project.
- */
-#ifndef _TEST__F_iki_datass_resize_h
-#define _TEST__F_iki_datass_resize_h
-
-/**
- * Test that the function works.
- *
- * @see f_iki_datass_resize()
- */
-extern void test__f_iki_datass_resize__works(void **state);
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_iki_datass_resize()
- */
-extern void test__f_iki_datass_resize__parameter_checking(void **state);
-
-#endif // _TEST__F_iki_datass_resize_h
void test__f_iki_read__works(void **state) {
+ mock_unwrap = 1;
+
f_state_t state_data = f_state_t_initialize;
f_string_static_t empty = macro_f_string_static_t_initialize_1(f_string_empty_s.string, f_string_empty_s.size, f_string_empty_s.used);
f_string_static_t ascii_a = macro_f_string_static_t_initialize_1(f_string_ascii_a_s.string, f_string_ascii_a_s.size, f_string_ascii_a_s.used);
cmocka_unit_test(test__f_iki_content_partial_is__returns_false),
cmocka_unit_test(test__f_iki_content_partial_is__returns_true),
- cmocka_unit_test(test__f_iki_datas_adjust__works),
+ cmocka_unit_test(test__f_iki_datas_adjust_callback__fails),
+ cmocka_unit_test(test__f_iki_datas_resize_callback__fails),
+
+ cmocka_unit_test(test__f_iki_datas_adjust_callback__works),
+ cmocka_unit_test(test__f_iki_datas_resize_callback__works),
+
cmocka_unit_test(test__f_iki_datas_append__works),
cmocka_unit_test(test__f_iki_datas_append_all__works),
cmocka_unit_test(test__f_iki_datas_append_all__returns_data_not),
- cmocka_unit_test(test__f_iki_datas_decimate_by__works),
- cmocka_unit_test(test__f_iki_datas_decrease_by__works),
- cmocka_unit_test(test__f_iki_datas_increase__works),
- cmocka_unit_test(test__f_iki_datas_increase__returns_data_not),
- cmocka_unit_test(test__f_iki_datas_increase_by__works),
- cmocka_unit_test(test__f_iki_datas_resize__works),
-
- cmocka_unit_test(test__f_iki_datass_adjust__works),
+
cmocka_unit_test(test__f_iki_datass_append__works),
cmocka_unit_test(test__f_iki_datass_append__returns_data_not),
cmocka_unit_test(test__f_iki_datass_append_all__works),
cmocka_unit_test(test__f_iki_datass_append_all__returns_data_not),
- cmocka_unit_test(test__f_iki_datass_decimate_by__works),
- cmocka_unit_test(test__f_iki_datass_decrease_by__works),
- cmocka_unit_test(test__f_iki_datass_increase__works),
- cmocka_unit_test(test__f_iki_datass_increase__returns_data_not),
- cmocka_unit_test(test__f_iki_datass_increase_by__works),
- cmocka_unit_test(test__f_iki_datass_resize__works),
cmocka_unit_test(test__f_iki_object_is__returns_data_not),
cmocka_unit_test(test__f_iki_object_is__returns_false),
cmocka_unit_test(test__f_iki_content_is__parameter_checking),
cmocka_unit_test(test__f_iki_content_partial_is__parameter_checking),
- cmocka_unit_test(test__f_iki_datas_adjust__parameter_checking),
+ // f_iki_datas_adjust_callback() doesn't use parameter checking.
+ // f_iki_datas_resize_callback() doesn't use parameter checking.
+
cmocka_unit_test(test__f_iki_datas_append__parameter_checking),
cmocka_unit_test(test__f_iki_datas_append_all__parameter_checking),
- cmocka_unit_test(test__f_iki_datas_decimate_by__parameter_checking),
- cmocka_unit_test(test__f_iki_datas_decrease_by__parameter_checking),
- cmocka_unit_test(test__f_iki_datas_increase__parameter_checking),
- cmocka_unit_test(test__f_iki_datas_increase_by__parameter_checking),
- cmocka_unit_test(test__f_iki_datas_resize__parameter_checking),
- cmocka_unit_test(test__f_iki_datass_adjust__parameter_checking),
cmocka_unit_test(test__f_iki_datass_append__parameter_checking),
cmocka_unit_test(test__f_iki_datass_append_all__parameter_checking),
- cmocka_unit_test(test__f_iki_datass_decimate_by__parameter_checking),
- cmocka_unit_test(test__f_iki_datass_decrease_by__parameter_checking),
- cmocka_unit_test(test__f_iki_datass_increase__parameter_checking),
- cmocka_unit_test(test__f_iki_datass_increase_by__parameter_checking),
- cmocka_unit_test(test__f_iki_datass_resize__parameter_checking),
// f_iki_object_is() doesn't use parameter checking.
// f_iki_object_partial_is() doesn't use parameter checking.
#include <fll/level_0/iki.h>
// Mock includes.
-//#include "mock-iki.h"
+#include "mock-iki.h"
// Test includes.
#include "test-iki-content_is.h"
#include "test-iki-content_partial_is.h"
-#include "test-iki-datas_adjust.h"
+#include "test-iki-datas_adjust_callback.h"
#include "test-iki-datas_append.h"
#include "test-iki-datas_append_all.h"
-#include "test-iki-datas_decimate_by.h"
-#include "test-iki-datas_decrease_by.h"
-#include "test-iki-datas_increase.h"
-#include "test-iki-datas_increase_by.h"
-#include "test-iki-datas_resize.h"
-#include "test-iki-datass_adjust.h"
+#include "test-iki-datas_resize_callback.h"
#include "test-iki-datass_append.h"
#include "test-iki-datass_append_all.h"
-#include "test-iki-datass_decimate_by.h"
-#include "test-iki-datass_decrease_by.h"
-#include "test-iki-datass_increase.h"
-#include "test-iki-datass_increase_by.h"
-#include "test-iki-datass_resize.h"
#include "test-iki-object_is.h"
#include "test-iki-object_partial_is.h"
#include "test-iki-read.h"
void controller_rule_action_delete_simple(controller_rule_action_t * const action) {
f_string_dynamics_resize(0, &action->parameters);
- f_iki_datas_resize(0, &action->ikis);
+ f_memory_array_resize(0, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
}
#endif // _di_controller_rule_action_delete_simple_
}
if (content) {
- status = f_iki_datas_increase_by(content->used + 1, &action->ikis);
+ status = f_memory_array_increase_by(content->used + 1, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
}
else {
- status = f_iki_datas_increase(controller_common_allocation_small_d, &action->ikis);
+ status = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
}
if (F_status_is_error(status)) {
- controller_print_error(global.thread, global.main->error, F_status_set_fine(status), content ? "f_iki_datas_increase_by" : "f_iki_datas_increase", F_true);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), content ? "f_memory_array_increase_by" : "f_memory_array_increase", F_true);
return status;
}
return status;
}
- status = f_iki_datas_increase_by(content->used, &action->ikis);
+ status = f_memory_array_increase_by(content->used, sizeof(f_iki_data_t), (void **) &action->ikis.array, &action->ikis.used, &action->ikis.size);
if (F_status_is_error(status)) {
- controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_iki_datas_increase_by", F_true);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_memory_array_increase_by", F_true);
return status;
}
return status;
}
- status = f_iki_datas_increase(controller_common_allocation_small_d, &actions->array[actions->used].ikis);
+ status = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_iki_data_t), (void **) &actions->array[actions->used].ikis.array, &actions->array[actions->used].ikis.used, &actions->array[actions->used].ikis.size);
if (F_status_is_error(status)) {
- controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_iki_datas_increase", F_true);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_memory_array_increase", F_true);
return status;
}
return status;
}
- status = f_iki_datas_increase(controller_common_allocation_small_d, &actions->array[actions->used].ikis);
+ status = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_iki_data_t), (void **) &actions->array[actions->used].ikis.array, &actions->array[actions->used].ikis.used, &actions->array[actions->used].ikis.size);
if (F_status_is_error(status)) {
- controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_iki_datas_increase", F_true);
+ controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_memory_array_increase", F_true);
return status;
}
* F_none on success.
*
* Errors (with error bit) from: f_fss_count_lines().
- * Errors (with error bit) from: f_iki_datas_increase_by().
+ * Errors (with error bit) from: f_memory_array_increase().
+ * Errors (with error bit) from: f_memory_array_increase_by().
* Errors (with error bit) from: f_string_dynamic_partial_append_nulless().
* Errors (with error bit) from: f_string_dynamics_increase().
* Errors (with error bit) from: f_string_dynamics_increase_by().
* Errors (with error bit) from: fl_iki_read().
*
* @see f_fss_count_lines()
- * @see f_iki_datas_increase_by()
+ * @see f_memory_array_increase()
+ * @see f_memory_array_increase_by()
* @see f_string_dynamic_partial_append_nulless()
* @see f_string_dynamics_increase()
* @see f_string_dynamics_increase_by()