From: Kevin Day Date: Mon, 14 Mar 2022 03:10:17 +0000 (-0500) Subject: Update: Consistency improvements with *_append() and *_append_all(), add tests, and... X-Git-Tag: 0.5.9~82 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=a8622f6e1e3fb7b080bb1b0517838b515d149341;p=fll Update: Consistency improvements with *_append() and *_append_all(), add tests, and other clean ups. The array functions for managing structures needs to be consistent with the *_append() functions. This introduces the *_append() all across the board. The previous *_append() behavior is essentially refactored into *_append_all(). The *_append() now accepts a single type for a given structure rather than a set. (The single type can still be representative of a set itself.) Add a lot of tests. Add missing f_iki tests. The f_string tests are not fully implemented, the f_dynamic_* functions are only partially tested. All of the other f_string structures should be fully tested now. Make the macro_f_string_range_t_initialize() macro consistency with all other macros. That is, the macro initialize that does not have a digit initializes using all of the structures members. This effectively refactors macro_f_string_range_t_initialize() into macro_f_string_range_t_initialize2() and macro_f_string_range_t_initialize2() into macro_f_string_range_t_initialize(). Change the behavior of the *_resize() and *_adjust() functions to return F_none rather than a direct f_memory status code. Update some of the string functions to return F_data_not_eos. Restructure some of the code to be a bit more organized. Specifically, the f_iki_data_t is moved into its own source and header files. Reduce the clutter in some of the private source and header files by moving some of their content into separate individual files as appropriate. --- diff --git a/build/level_0/settings b/build/level_0/settings index fedeaeff3..bf18cfc13 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -43,7 +43,7 @@ build_sources_library environment.c build_sources_library execute.c build_sources_library file.c file/common.c private-file.c build_sources_library fss.c private-fss.c fss/common.c fss/named.c fss/nest.c fss/set.c -build_sources_library iki.c iki/common.c private-iki.c +build_sources_library iki.c iki/common.c iki/data.c private-iki.c iki/private-data.c build_sources_library limit.c build_sources_library memory.c private-memory.c memory/structure.c build_sources_library path.c private-path.c path/common.c @@ -53,9 +53,9 @@ build_sources_library serialize.c private-serialize.c serialize/common.c build_sources_library signal.c build_sources_library socket.c build_sources_library status_string.c -build_sources_library string.c private-string.c string/common.c string/dynamic.c string/map.c string/quantity.c string/range.c string/static.c string/triple.c -build_sources_library type_array/array_length.c type_array/cell.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/state.c type_array/status.c -build_sources_library type_array/private-array_length.c type_array/private-cell.c type_array/private-fll_id.c type_array/private-int8.c type_array/private-int16.c type_array/private-int32.c type_array/private-int64.c type_array/private-int128.c type_array/private-state.c type_array/private-status.c +build_sources_library string.c private-string.c string/common.c string/private-dynamic.c string/private-map.c string/private-map_multi.c string/private-quantity.c string/private-range.c string/private-triple.c string/dynamic.c string/map.c string/map_multi.c string/quantity.c string/range.c string/static.c string/triple.c +build_sources_library type_array/array_length.c type_array/cell.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c +build_sources_library type_array/private-array_length.c type_array/private-cell.c type_array/private-fll_id.c type_array/private-int8.c type_array/private-int16.c type_array/private-int32.c type_array/private-int64.c type_array/private-int128.c type_array/private-state.c type_array/private-status.c type_array/private-uint8.c type_array/private-uint16.c type_array/private-uint32.c type_array/private-uint64.c type_array/private-uint128.c build_sources_library utf.c private-utf.c utf/common.c utf/dynamic.c utf/map.c utf/private-is_unassigned.c utf/private-string.c utf/string.c utf/triple.c build_sources_library-level thread.c private-thread.c build_sources_library_shared @@ -77,7 +77,7 @@ build_sources_headers environment.h environment/common.h build_sources_headers execute.h execute/common.h build_sources_headers file.h file/common.h build_sources_headers fss.h fss/comment.h fss/common.h fss/delimit.h fss/named.h fss/nest.h fss/quote.h fss/set.h -build_sources_headers iki.h iki/common.h +build_sources_headers iki.h iki/common.h iki/data.h build_sources_headers limit.h limit/common.h build_sources_headers memory.h memory/structure.h memory/common.h build_sources_headers path.h path/common.h @@ -88,10 +88,10 @@ build_sources_headers signal.h signal/common.h build_sources_headers socket.h socket/common.h build_sources_headers status.h build_sources_headers status_string.h -build_sources_headers string.h string/common.h string/dynamic.h string/map.h string/quantity.h string/range.h string/static.h string/triple.h +build_sources_headers string.h string/common.h string/dynamic.h string/map.h string/map_multi.h string/quantity.h string/range.h string/static.h string/triple.h build_sources_headers type.h build_sources_headers type_array.h type_array/common.h -build_sources_headers type_array/array_length.h type_array/cell.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/state.h type_array/status.h +build_sources_headers type_array/array_length.h type_array/cell.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h build_sources_headers utf.h utf/common.h utf/dynamic.h utf/map.h utf/string.h utf/triple.h build_sources_headers-level thread.h thread/common.h build_sources_headers_shared diff --git a/build/monolithic/settings b/build/monolithic/settings index eb6c0fa83..6984a24ae 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -43,7 +43,7 @@ build_sources_library level_0/environment.c build_sources_library level_0/execute.c build_sources_library level_0/file.c level_0/file/common.c level_0/private-file.c build_sources_library level_0/fss.c level_0/private-fss.c level_0/fss/common.c level_0/fss/named.c level_0/fss/nest.c level_0/fss/set.c -build_sources_library level_0/iki.c level_0/iki/common.c level_0/private-iki.c +build_sources_library level_0/iki.c level_0/iki/common.c level_0/iki/data.c level_0/private-iki.c level_0/iki/private-data.c build_sources_library level_0/limit.c build_sources_library level_0/memory.c level_0/private-memory.c level_0/memory/structure.c build_sources_library level_0/path.c level_0/private-path.c level_0/path/common.c @@ -53,9 +53,9 @@ build_sources_library level_0/serialize.c level_0/private-serialize.c level_0/se build_sources_library level_0/signal.c build_sources_library level_0/socket.c build_sources_library level_0/status_string.c -build_sources_library level_0/string.c level_0/private-string.c level_0/string/common.c level_0/string/dynamic.c level_0/string/map.c level_0/string/quantity.c level_0/string/range.c level_0/string/static.c level_0/string/triple.c -build_sources_library level_0/type_array/array_length.c level_0/type_array/cell.c level_0/type_array/fll_id.c level_0/type_array/int8.c level_0/type_array/int16.c level_0/type_array/int32.c level_0/type_array/int64.c level_0/type_array/int128.c level_0/type_array/state.c level_0/type_array/status.c -build_sources_library level_0/type_array/private-array_length.c level_0/type_array/private-cell.c level_0/type_array/private-fll_id.c level_0/type_array/private-int8.c level_0/type_array/private-int16.c level_0/type_array/private-int32.c level_0/type_array/private-int64.c level_0/type_array/private-int128.c level_0/type_array/private-state.c level_0/type_array/private-status.c +build_sources_library level_0/string.c level_0/private-string.c level_0/string/common.c level_0/string/private-dynamic.c level_0/string/private-map.c level_0/string/private-map_multi.c level_0/string/private-quantity.c level_0/string/private-range.c level_0/string/private-triple.c level_0/string/dynamic.c level_0/string/map.c level_0/string/map_multi.c level_0/string/quantity.c level_0/string/range.c level_0/string/static.c level_0/string/triple.c +build_sources_library level_0/type_array/array_length.c level_0/type_array/cell.c level_0/type_array/fll_id.c level_0/type_array/int8.c level_0/type_array/int16.c level_0/type_array/int32.c level_0/type_array/int64.c level_0/type_array/int128.c level_0/type_array/state.c level_0/type_array/status.c level_0/type_array/uint8.c level_0/type_array/uint16.c level_0/type_array/uint32.c level_0/type_array/uint64.c level_0/type_array/uint128.c +build_sources_library level_0/type_array/private-array_length.c level_0/type_array/private-cell.c level_0/type_array/private-fll_id.c level_0/type_array/private-int8.c level_0/type_array/private-int16.c level_0/type_array/private-int32.c level_0/type_array/private-int64.c level_0/type_array/private-int128.c level_0/type_array/private-state.c level_0/type_array/private-status.c level_0/type_array/private-uint8.c level_0/type_array/private-uint16.c level_0/type_array/private-uint32.c level_0/type_array/private-uint64.c level_0/type_array/private-uint128.c build_sources_library level_0/utf.c level_0/private-utf.c level_0/utf/common.c level_0/utf/dynamic.c level_0/utf/map.c level_0/utf/string.c level_0/utf/triple.c level_0/utf/private-is_unassigned.c level_0/utf/private-string.c build_sources_library level_1/control_group.c build_sources_library level_1/conversion.c level_1/private-conversion.c @@ -99,7 +99,7 @@ build_sources_headers level_0/environment.h level_0/environment/common.h build_sources_headers level_0/execute.h level_0/execute/common.h build_sources_headers level_0/file.h level_0/file/common.h build_sources_headers level_0/fss.h level_0/fss/comment.h level_0/fss/common.h level_0/fss/delimit.h level_0/fss/named.h level_0/fss/nest.h level_0/fss/quote.h level_0/fss/set.h -build_sources_headers level_0/iki.h level_0/iki/common.h +build_sources_headers level_0/iki.h level_0/iki/common.h level_0/iki/data.h build_sources_headers level_0/limit.h level_0/limit/common.h build_sources_headers level_0/memory.h level_0/memory/structure.h level_0/memory/common.h build_sources_headers level_0/path.h level_0/path/common.h @@ -110,10 +110,10 @@ build_sources_headers level_0/signal.h level_0/signal/common.h build_sources_headers level_0/socket.h level_0/socket/common.h build_sources_headers level_0/status.h build_sources_headers level_0/status_string.h -build_sources_headers level_0/string.h level_0/string/common.h level_0/string/dynamic.h level_0/string/map.h level_0/string/quantity.h level_0/string/range.h level_0/string/static.h level_0/string/triple.h +build_sources_headers level_0/string.h level_0/string/common.h level_0/string/dynamic.h level_0/string/map.h level_0/string/map_multi.h level_0/string/quantity.h level_0/string/range.h level_0/string/static.h level_0/string/triple.h build_sources_headers level_0/type.h build_sources_headers level_0/type_array.h level_0/type_array/common.h -build_sources_headers level_0/type_array/array_length.h level_0/type_array/cell.h level_0/type_array/fll_id.h level_0/type_array/int8.h level_0/type_array/int16.h level_0/type_array/int32.h level_0/type_array/int64.h level_0/type_array/int128.h level_0/type_array/state.h level_0/type_array/status.h +build_sources_headers level_0/type_array/array_length.h level_0/type_array/cell.h level_0/type_array/fll_id.h level_0/type_array/int8.h level_0/type_array/int16.h level_0/type_array/int32.h level_0/type_array/int64.h level_0/type_array/int128.h level_0/type_array/state.h level_0/type_array/status.h level_0/type_array/uint8.h level_0/type_array/uint16.h level_0/type_array/uint32.h level_0/type_array/uint64.h level_0/type_array/uint128.h build_sources_headers level_0/utf.h level_0/utf/common.h level_0/utf/dynamic.h level_0/utf/map.h level_0/utf/string.h level_0/utf/triple.h build_sources_headers level_1/control_group.h build_sources_headers level_1/conversion.h diff --git a/level_0/f_control_group/c/control_group.c b/level_0/f_control_group/c/control_group.c index 1b55f6721..d947009ff 100644 --- a/level_0/f_control_group/c/control_group.c +++ b/level_0/f_control_group/c/control_group.c @@ -22,7 +22,7 @@ extern "C" { } if (source.groups.used) { - status = f_string_dynamics_append(source.groups, &destination->groups); + status = f_string_dynamics_append_all(source.groups, &destination->groups); if (F_status_is_error(status)) return status; } diff --git a/level_0/f_control_group/c/control_group.h b/level_0/f_control_group/c/control_group.h index f738f582f..629e8ddb1 100644 --- a/level_0/f_control_group/c/control_group.h +++ b/level_0/f_control_group/c/control_group.h @@ -45,10 +45,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_string_dynamic_append(). - * Errors (with error bit) from: f_string_dynamics_append(). + * Errors (with error bit) from: f_string_dynamics_append_all(). * * @see f_string_dynamic_append() - * @see f_string_dynamics_append() + * @see f_string_dynamics_append_all() */ #ifndef _di_f_control_group_copy_ extern f_status_t f_control_group_copy(const f_control_group_t source, f_control_group_t * const destination); diff --git a/level_0/f_fss/c/fss/comment.h b/level_0/f_fss/c/fss/comment.h index 399a4af58..bd258cbfc 100644 --- a/level_0/f_fss/c/fss/comment.h +++ b/level_0/f_fss/c/fss/comment.h @@ -24,7 +24,7 @@ extern "C" { #define f_fss_comment_t_initialize f_string_range_t_initialize - #define macro_f_fss_comment_t_initialize(length) macro_f_string_range_t_initialize(length) + #define macro_f_fss_comment_t_initialize(length) macro_f_string_range_t_initialize2(length) #define macro_f_fss_comment_t_clear(comment) macro_f_string_range_t_clear(comment) #endif // _di_f_fss_comment_t_ diff --git a/level_0/f_fss/c/fss/common.h b/level_0/f_fss/c/fss/common.h index 6fc61a79a..c3be49f29 100644 --- a/level_0/f_fss/c/fss/common.h +++ b/level_0/f_fss/c/fss/common.h @@ -268,7 +268,7 @@ enum { #define f_fss_object_t_initialize f_string_range_t_initialize - #define macro_f_fss_object_t_initialize(length) macro_f_string_range_t_initialize(length) + #define macro_f_fss_object_t_initialize(length) macro_f_string_range_t_initialize2(length) #define macro_f_fss_object_t_clear(object) macro_f_string_range_t_clear(object) #endif // _di_f_fss_object_t_ diff --git a/level_0/f_fss/c/fss/delimit.h b/level_0/f_fss/c/fss/delimit.h index 91a344250..ee9d09a6b 100644 --- a/level_0/f_fss/c/fss/delimit.h +++ b/level_0/f_fss/c/fss/delimit.h @@ -22,7 +22,7 @@ extern "C" { #ifndef _di_f_fss_delimit_t_ typedef f_array_length_t f_fss_delimit_t; - #define macro_f_fss_object_t_initialize(length) macro_f_string_range_t_initialize(length) + #define macro_f_fss_object_t_initialize(length) macro_f_string_range_t_initialize2(length) #endif // _di_f_fss_delimit_t_ /** diff --git a/level_0/f_fss/c/private-fss.c b/level_0/f_fss/c/private-fss.c index 5c952fad9..66ed67ea1 100644 --- a/level_0/f_fss/c/private-fss.c +++ b/level_0/f_fss/c/private-fss.c @@ -40,17 +40,14 @@ extern "C" { } // for status = f_memory_resize(items->size, length, sizeof(f_fss_item_t), (void **) & items->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - items->size = length; + items->size = length; - if (items->used > items->size) { - items->used = length; - } + if (items->used > items->size) { + items->used = length; } - if (F_status_is_error(status)) return status; - return F_none; } #endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_increase_) || !defined(_di_f_fss_items_increase_by_) || !defined(_di_f_fss_items_resize_) @@ -128,17 +125,14 @@ extern "C" { } // for status = f_memory_resize(nameds->size, length, sizeof(f_fss_named_t), (void **) & nameds->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - nameds->size = length; + nameds->size = length; - if (nameds->used > nameds->size) { - nameds->used = length; - } + if (nameds->used > nameds->size) { + nameds->used = length; } - if (F_status_is_error(status)) return status; - return F_none; } #endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) @@ -180,17 +174,14 @@ extern "C" { } // for status = f_memory_resize(nest->size, length, sizeof(f_fss_items_t), (void **) & nest->depth); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - nest->size = length; + nest->size = length; - if (nest->used > nest->size) { - nest->used = length; - } + if (nest->used > nest->size) { + nest->used = length; } - if (F_status_is_error(status)) return status; - return F_none; } #endif // !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_increase_) || !defined(_di_f_fss_nest_increase_by_) || !defined(_di_f_fss_nest_resize_) @@ -232,17 +223,14 @@ extern "C" { } // for status = f_memory_resize(nests->size, length, sizeof(f_fss_nest_t), (void **) & nests->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - nests->size = length; + nests->size = length; - if (nests->used > nests->size) { - nests->used = length; - } + if (nests->used > nests->size) { + nests->used = length; } - if (F_status_is_error(status)) return status; - return F_none; } #endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) @@ -375,17 +363,14 @@ extern "C" { } // for status = f_memory_resize(set_quotes->size, length, sizeof(f_fss_set_quote_t), (void **) & set_quotes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - set_quotes->size = length; + set_quotes->size = length; - if (set_quotes->used > set_quotes->size) { - set_quotes->used = length; - } + if (set_quotes->used > set_quotes->size) { + set_quotes->used = length; } - if (F_status_is_error(status)) return status; - return F_none; } #endif // !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_increase_) || !defined(_di_f_fss_set_quotes_increase_by_) || !defined(_di_f_fss_set_quotes_resize_) @@ -435,17 +420,14 @@ extern "C" { } // for status = f_memory_resize(sets->size, length, sizeof(f_fss_set_t), (void **) & sets->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - sets->size = length; + sets->size = length; - if (sets->used > sets->size) { - sets->used = length; - } + if (sets->used > sets->size) { + sets->used = length; } - if (F_status_is_error(status)) return status; - return F_none; } #endif // !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_increase_) || !defined(_di_f_fss_sets_increase_by_) || !defined(_di_f_fss_sets_resize_) diff --git a/level_0/f_iki/c/iki.h b/level_0/f_iki/c/iki.h index fd79afb43..ded0ee5d2 100644 --- a/level_0/f_iki/c/iki.h +++ b/level_0/f_iki/c/iki.h @@ -27,6 +27,7 @@ // FLL-0 iki includes. #include +#include #ifdef __cplusplus extern "C" { diff --git a/level_0/f_iki/c/iki/common.c b/level_0/f_iki/c/iki/common.c index 6fc486989..566a314e6 100644 --- a/level_0/f_iki/c/iki/common.c +++ b/level_0/f_iki/c/iki/common.c @@ -32,191 +32,6 @@ extern "C" { const f_string_static_t f_iki_vocabulary_0002_parameter_s = macro_f_string_static_t_initialize(F_iki_vocabulary_0002_parameter_s, 0, F_iki_vocabulary_0002_parameter_s_length); #endif // _di_f_iki_vocabulary_0002_s_ -#ifndef _di_f_iki_data_delete_ - f_status_t f_iki_data_delete(f_iki_data_t *data) { - #ifndef _di_level_0_parameter_checking_ - if (!data) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - f_status_t status = f_string_ranges_resize(0, &data->content); - if (F_status_is_error(status)) return status; - - status = f_array_lengths_resize(0, &data->delimits); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_resize(0, &data->variable); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_resize(0, &data->vocabulary); - if (F_status_is_error(status)) return status; - - return F_none; - } -#endif // _di_f_iki_data_delete_ - -#ifndef _di_f_iki_data_destroy_ - f_status_t f_iki_data_destroy(f_iki_data_t *data) { - #ifndef _di_level_0_parameter_checking_ - if (!data) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - f_status_t status = f_string_ranges_adjust(0, &data->content); - if (F_status_is_error(status)) return status; - - status = f_array_lengths_adjust(0, &data->delimits); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_adjust(0, &data->variable); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_adjust(0, &data->vocabulary); - if (F_status_is_error(status)) return status; - - return F_none; - } -#endif // _di_f_iki_data_destroy_ - -#ifndef _di_f_iki_datas_adjust_ - f_status_t f_iki_datas_adjust(const f_array_length_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_append_ - f_status_t f_iki_datas_append(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; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_iki_datas_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - 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; - - status = f_string_ranges_append(source.array[i].content, &destination->array[destination->used].content); - if (F_status_is_error(status)) return status; - - status = f_array_lengths_append(source.array[i].delimits, &destination->array[destination->used].delimits); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_append(source.array[i].variable, &destination->array[destination->used].variable); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_append(source.array[i].vocabulary, &destination->array[destination->used].vocabulary); - if (F_status_is_error(status)) return status; - } // for - - return F_none; - } -#endif // _di_f_iki_datas_append_ - -#ifndef _di_f_iki_datas_decimate_by_ - f_status_t f_iki_datas_decimate_by(const f_array_length_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_ - - if (!amount) { - return F_data_not; - } - - if (datas->size - amount > 0) { - return private_f_iki_datas_adjust(datas->size - amount, datas); - } - - return private_f_iki_datas_adjust(0, datas); - } -#endif // _di_f_iki_datas_decimate_by_ - -#ifndef _di_f_iki_datas_decrease_by_ - f_status_t f_iki_datas_decrease_by(const f_array_length_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_ - - if (!amount) { - return F_data_not; - } - - if (datas->size - amount > 0) { - 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_ - -#ifndef _di_f_iki_datas_increase_ - f_status_t f_iki_datas_increase(const f_array_length_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_ - - if (step && datas->used + 1 > datas->size) { - f_array_length_t size = datas->used + step; - - if (size > F_array_length_t_size_d) { - if (datas->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_iki_datas_resize(size, datas); - } - - return F_data_not; - } -#endif // _di_f_iki_datas_increase_ - -#ifndef _di_f_iki_datas_increase_by_ - f_status_t f_iki_datas_increase_by(const f_array_length_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_ - - if (!amount) { - return F_data_not; - } - - if (datas->used + amount > datas->size) { - if (datas->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_iki_datas_resize(datas->used + amount, datas); - } - - return F_data_not; - } -#endif // _di_f_iki_datas_increase_by_ - -#ifndef _di_f_iki_datas_resize_ - f_status_t f_iki_datas_resize(const f_array_length_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_resize(length, datas); - } -#endif // _di_f_iki_datas_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_iki/c/iki/common.h b/level_0/f_iki/c/iki/common.h index c0e25aeb1..38a56ac52 100644 --- a/level_0/f_iki/c/iki/common.h +++ b/level_0/f_iki/c/iki/common.h @@ -343,7 +343,7 @@ extern "C" { /** * An array of f_iki_data_t. * - * array: The array of fss quotes. + * array: The array of IKI data. * size: Total amount of allocated space. * used: Total number of allocated spaces used. */ @@ -355,231 +355,72 @@ extern "C" { f_array_length_t used; } f_iki_datas_t; - #define f_fss_iki_datas_t_initialize { 0, 0, 0 } + #define f_iki_datas_t_initialize { 0, 0, 0 } #define macro_f_iki_datas_t_initialize(content, size, used) { array, size, used } #define macro_f_iki_datas_t_initialize2(array, length) { array, length, length } - #define macro_f_fss_iki_datas_t_clear(datas) macro_f_memory_structure_clear(datas) + #define macro_f_iki_datas_t_clear(datas) macro_f_memory_structure_clear(datas) - #define macro_f_fss_iki_datas_t_resize(status, datas, length) status = f_iki_datas_resize(length, &datas); - #define macro_f_fss_iki_datas_t_adjust(status, datas, length) status = f_iki_datas_adjust(length, &datas); + #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_fss_iki_datas_t_delete_simple(datas) status = f_iki_datas_resize(0, &datas); - #define macro_f_fss_iki_datas_t_destroy_simple(datas) status = f_iki_datas_adjust(0, &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_fss_iki_datas_t_increase(status, step, datas) status = f_iki_datas_increase(step, &datas); - #define macro_f_fss_iki_datas_t_increase_by(status, datas, amount) status = f_iki_datas_increase_by(amount, &datas); - #define macro_f_fss_iki_datas_t_decrease_by(status, datas, amount) status = f_iki_datas_decrease_by(amount, &datas); - #define macro_f_fss_iki_datas_t_decimate_by(status, datas, amount) status = f_iki_datas_decimate_by(amount, &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_ /** - * Provide a default allocation step. - * - * For a UTF-8 friendly allocation step, set to at least 4. - */ -#ifndef _di_f_iki_default_allocation_step_ - #define F_iki_default_allocation_step_d 4 -#endif // _di_f_iki_default_allocation_step_ - -/** - * Delete the IKI data. - * - * @param data - * The IKI data to delete. + * An array of f_iki_datas_t. * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_array_lengths_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * - * @see f_array_lengths_resize() - * @see f_string_ranges_resize() + * array: The array of IKI datas. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. */ -#ifndef _di_f_iki_data_delete_ - extern f_status_t f_iki_data_delete(f_iki_data_t *data); -#endif // _di_f_iki_data_delete_ +#ifndef _di_f_iki_datass_t_ + typedef struct { + f_iki_datas_t *array; -/** - * Destroy the IKI data. - * - * @param data - * The IKI data to destroy. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_array_lengths_adjust(). - * Errors (with error bit) from: f_string_ranges_adjust(). - * - * @see f_array_lengths_adjust() - * @see f_string_ranges_adjust() - */ -#ifndef _di_f_iki_data_destroy_ - extern f_status_t f_iki_data_destroy(f_iki_data_t *data); -#endif // _di_f_iki_data_destroy_ + f_array_length_t size; + f_array_length_t used; + } f_iki_datass_t; -/** - * Resize the string lengths array. - * - * @param length - * The new size to use. - * @param lengths - * The string lengths 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(). - */ -#ifndef _di_f_iki_datas_adjust_ - extern f_status_t f_iki_datas_adjust(const f_array_length_t length, f_iki_datas_t *datas); -#endif // _di_f_iki_datas_adjust_ + #define f_iki_datass_t_initialize { 0, 0, 0 } -/** - * Append the source lengths onto the destination. - * - * @param source - * The source lengths to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_iki_datas_append_ - extern f_status_t f_iki_datas_append(const f_iki_datas_t source, f_iki_datas_t *destination); -#endif // _di_f_iki_datas_append_ + #define macro_f_iki_datass_t_initialize(content, size, used) { array, size, used } + #define macro_f_iki_datass_t_initialize2(array, length) { array, length, length } -/** - * Resize the string lengths 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 lengths - * The string lengths 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(). - */ -#ifndef _di_f_iki_datas_decimate_by_ - extern f_status_t f_iki_datas_decimate_by(const f_array_length_t amount, f_iki_datas_t *datas); -#endif // _di_f_iki_datas_decimate_by_ + #define macro_f_iki_datass_t_clear(datas) macro_f_memory_structure_clear(datas) -/** - * Resize the string lengths 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 lengths - * The string lengths 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(). - */ -#ifndef _di_f_iki_datas_decrease_by_ - extern f_status_t f_iki_datas_decrease_by(const f_array_length_t amount, f_iki_datas_t *datas); -#endif // _di_f_iki_datas_decrease_by_ + #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); -/** - * Increase the size of the string lengths array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 lengths - * The string lengths 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(). - */ -#ifndef _di_f_iki_datas_increase_ - extern f_status_t f_iki_datas_increase(const f_array_length_t step, f_iki_datas_t *datas); -#endif // _di_f_iki_datas_increase_ + #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); -/** - * Resize the string lengths array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 lengths - * The string lengths 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(). - */ -#ifndef _di_f_iki_datas_increase_by_ - extern f_status_t f_iki_datas_increase_by(const f_array_length_t amount, f_iki_datas_t *datas); -#endif // _di_f_iki_datas_increase_by_ + #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_ /** - * Resize the string lengths array. - * - * @param length - * The new size to use. - * @param lengths - * The string lengths array to adjust. - * - * @return - * F_none on success. + * Provide a default allocation step. * - * F_parameter (with error bit) if a parameter is invalid. + * For a UTF-8 friendly allocation step, set to at least 4. * - * Errors (with error bit) from: f_memory_resize(). + * F_iki_default_allocation_*: + * - large: The large allocation size. + * - small: The small allocation size, in particular used for allocation iki strings. */ -#ifndef _di_f_iki_datas_resize_ - extern f_status_t f_iki_datas_resize(const f_array_length_t length, f_iki_datas_t *datas); -#endif // _di_f_iki_datas_resize_ +#ifndef _di_f_iki_default_allocation_step_ + #define F_iki_default_allocation_large_d F_memory_default_allocation_large_d + #define F_iki_default_allocation_small_d 4 +#endif // _di_f_iki_default_allocation_step_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_iki/c/iki/data.c b/level_0/f_iki/c/iki/data.c new file mode 100644 index 000000000..d25f6d312 --- /dev/null +++ b/level_0/f_iki/c/iki/data.c @@ -0,0 +1,334 @@ +#include "../iki.h" +#include "data.h" +#include "private-data.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_iki_data_delete_ + f_status_t f_iki_data_delete(f_iki_data_t *data) { + #ifndef _di_level_0_parameter_checking_ + if (!data) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_status_t status = f_string_ranges_resize(0, &data->content); + if (F_status_is_error(status)) return status; + + status = f_array_lengths_resize(0, &data->delimits); + if (F_status_is_error(status)) return status; + + status = f_string_ranges_resize(0, &data->variable); + if (F_status_is_error(status)) return status; + + status = f_string_ranges_resize(0, &data->vocabulary); + if (F_status_is_error(status)) return status; + + return F_none; + } +#endif // _di_f_iki_data_delete_ + +#ifndef _di_f_iki_data_destroy_ + f_status_t f_iki_data_destroy(f_iki_data_t *data) { + #ifndef _di_level_0_parameter_checking_ + if (!data) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_status_t status = f_string_ranges_adjust(0, &data->content); + if (F_status_is_error(status)) return status; + + status = f_array_lengths_adjust(0, &data->delimits); + if (F_status_is_error(status)) return status; + + status = f_string_ranges_adjust(0, &data->variable); + if (F_status_is_error(status)) return status; + + status = f_string_ranges_adjust(0, &data->vocabulary); + if (F_status_is_error(status)) return status; + + return F_none; + } +#endif // _di_f_iki_data_destroy_ + +#ifndef _di_f_iki_datas_adjust_ + f_status_t f_iki_datas_adjust(const f_array_length_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_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_ + + return private_f_iki_datas_append(source, destination); + } +#endif // _di_f_iki_datas_append_ + +#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; + + return private_f_iki_datas_append_all(source, destination); + } +#endif // _di_f_iki_datas_append_all_ + +#ifndef _di_f_iki_datas_decimate_by_ + f_status_t f_iki_datas_decimate_by(const f_array_length_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_ + + if (!amount) { + return F_data_not; + } + + if (datas->size - amount > 0) { + return private_f_iki_datas_adjust(datas->size - amount, datas); + } + + return private_f_iki_datas_adjust(0, datas); + } +#endif // _di_f_iki_datas_decimate_by_ + +#ifndef _di_f_iki_datas_decrease_by_ + f_status_t f_iki_datas_decrease_by(const f_array_length_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_ + + if (!amount) { + return F_data_not; + } + + if (datas->size - amount > 0) { + 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_ + +#ifndef _di_f_iki_datas_increase_ + f_status_t f_iki_datas_increase(const f_array_length_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_ + + if (step && datas->used + 1 > datas->size) { + f_array_length_t size = datas->used + step; + + if (size > F_array_length_t_size_d) { + if (datas->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_iki_datas_resize(size, datas); + } + + return F_data_not; + } +#endif // _di_f_iki_datas_increase_ + +#ifndef _di_f_iki_datas_increase_by_ + f_status_t f_iki_datas_increase_by(const f_array_length_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_ + + if (!amount) { + return F_data_not; + } + + if (datas->used + amount > datas->size) { + if (datas->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_iki_datas_resize(datas->used + amount, datas); + } + + return F_data_not; + } +#endif // _di_f_iki_datas_increase_by_ + +#ifndef _di_f_iki_datas_resize_ + f_status_t f_iki_datas_resize(const f_array_length_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_resize(length, datas); + } +#endif // _di_f_iki_datas_resize_ + +#ifndef _di_f_iki_datass_adjust_ + f_status_t f_iki_datass_adjust(const f_array_length_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_adjust(length, datass); + } +#endif // _di_f_iki_datass_adjust_ + +#ifndef _di_f_iki_datass_append_ + f_status_t f_iki_datass_append(const f_iki_datas_t source, f_iki_datass_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_iki_datass_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_iki_datas_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_iki_datass_append_ + +#ifndef _di_f_iki_datass_append_all_ + f_status_t f_iki_datass_append_all(const f_iki_datass_t source, f_iki_datass_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_iki_datass_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_iki_datas_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_iki_datass_append_all_ + +#ifndef _di_f_iki_datass_decimate_by_ + f_status_t f_iki_datass_decimate_by(const f_array_length_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; + } + + if (datass->size - amount > 0) { + return private_f_iki_datass_adjust(datass->size - amount, datass); + } + + return private_f_iki_datass_adjust(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_array_length_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; + } + + if (datass->size - amount > 0) { + return private_f_iki_datass_resize(datass->size - amount, datass); + } + + return private_f_iki_datass_resize(0, datass); + } +#endif // _di_f_iki_datass_decrease_by_ + +#ifndef _di_f_iki_datass_increase_ + f_status_t f_iki_datass_increase(const f_array_length_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) { + f_array_length_t size = datass->used + step; + + if (size > F_array_length_t_size_d) { + if (datass->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_iki_datass_resize(size, 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_array_length_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; + } + + if (datass->used + amount > datass->size) { + if (datass->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_iki_datass_resize(datass->used + amount, 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_array_length_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 diff --git a/level_0/f_iki/c/iki/data.h b/level_0/f_iki/c/iki/data.h new file mode 100644 index 000000000..5fd8d563c --- /dev/null +++ b/level_0/f_iki/c/iki/data.h @@ -0,0 +1,421 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines data to be used for/by type (array) related functionality. + * + * This is auto-included by type_array.h and should not need to be explicitly included. + */ +#ifndef _F_iki_data_h +#define _F_iki_data_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Delete the IKI data. + * + * @param data + * The IKI data to delete. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_array_lengths_resize(). + * Errors (with error bit) from: f_string_ranges_resize(). + * + * @see f_array_lengths_resize() + * @see f_string_ranges_resize() + */ +#ifndef _di_f_iki_data_delete_ + extern f_status_t f_iki_data_delete(f_iki_data_t *data); +#endif // _di_f_iki_data_delete_ + +/** + * Destroy the IKI data. + * + * @param data + * The IKI data to destroy. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_array_lengths_adjust(). + * Errors (with error bit) from: f_string_ranges_adjust(). + * + * @see f_array_lengths_adjust() + * @see f_string_ranges_adjust() + */ +#ifndef _di_f_iki_data_destroy_ + extern f_status_t f_iki_data_destroy(f_iki_data_t *data); +#endif // _di_f_iki_data_destroy_ + +/** + * Resize the iki_datas array. + * + * @param length + * The new size to use. + * @param iki_datas + * The iki_datas 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(). + */ +#ifndef _di_f_iki_datas_adjust_ + extern f_status_t f_iki_datas_adjust(const f_array_length_t length, f_iki_datas_t *datas); +#endif // _di_f_iki_datas_adjust_ + +/** + * Append the single source iki_data onto the destination. + * + * @param source + * The source iki_data to append. + * @param destination + * The destination iki_datas the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_iki_datas_append_ + extern f_status_t f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t *destination); +#endif // _di_f_iki_datas_append_ + +/** + * Append the source iki_datas onto the destination. + * + * @param source + * The source iki_datas to append. + * @param destination + * The destination iki_datas the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_iki_datas_append_all_ + extern f_status_t f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination); +#endif // _di_f_iki_datas_append_all_ + +/** + * 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 decimate 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_adjust(). + */ +#ifndef _di_f_iki_datas_decimate_by_ + extern f_status_t f_iki_datas_decimate_by(const f_array_length_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_resize(). + */ +#ifndef _di_f_iki_datas_decrease_by_ + extern f_status_t f_iki_datas_decrease_by(const f_array_length_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_array_length_t_size_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_resize(). + */ +#ifndef _di_f_iki_datas_increase_ + extern f_status_t f_iki_datas_increase(const f_array_length_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 string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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_resize(). + */ +#ifndef _di_f_iki_datas_increase_by_ + extern f_status_t f_iki_datas_increase_by(const f_array_length_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_resize(). + */ +#ifndef _di_f_iki_datas_resize_ + extern f_status_t f_iki_datas_resize(const f_array_length_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_adjust(). + * Errors (with error bit) from: f_memory_destroy(). + */ +#ifndef _di_f_iki_datass_adjust_ + extern f_status_t f_iki_datass_adjust(const f_array_length_t length, f_iki_datass_t *datass); +#endif // _di_f_iki_datass_adjust_ + +/** + * Append the single source iki_datas onto the destination. + * + * @param source + * The source iki_datas to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_iki_datass_append_ + extern f_status_t f_iki_datass_append(const f_iki_datas_t source, f_iki_datass_t *destination); +#endif // _di_f_iki_datass_append_ + +/** + * Append the source iki_datass onto the destination. + * + * @param source + * The source iki_datass to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_iki_datass_append_all_ + 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_adjust(). + * Errors (with error bit) from: f_memory_destroy(). + */ +#ifndef _di_f_iki_datass_decimate_by_ + extern f_status_t f_iki_datass_decimate_by(const f_array_length_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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_iki_datass_decrease_by_ + extern f_status_t f_iki_datass_decrease_by(const f_array_length_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_array_length_t_size_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_resize(). + */ +#ifndef _di_f_iki_datass_increase_ + extern f_status_t f_iki_datass_increase(const f_array_length_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 string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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_resize(). + */ +#ifndef _di_f_iki_datass_increase_by_ + extern f_status_t f_iki_datass_increase_by(const f_array_length_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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_iki_datass_resize_ + extern f_status_t f_iki_datass_resize(const f_array_length_t length, f_iki_datass_t *datass); +#endif // _di_f_iki_datass_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_iki_data_h diff --git a/level_0/f_iki/c/iki/private-data.c b/level_0/f_iki/c/iki/private-data.c new file mode 100644 index 000000000..9be4bc31b --- /dev/null +++ b/level_0/f_iki/c/iki/private-data.c @@ -0,0 +1,221 @@ +#include "../iki.h" +#include "private-data.h" + +#ifdef __cplusplus +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_array_length_t length, f_iki_datas_t *datas) { + + if (datas->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < datas->size; ++i) { + + status = f_string_ranges_adjust(0, &datas->array[i].content); + if (F_status_is_error(status)) return status; + + status = f_array_lengths_adjust(0, &datas->array[i].delimits); + if (F_status_is_error(status)) return status; + + status = f_string_ranges_adjust(0, &datas->array[i].variable); + if (F_status_is_error(status)) return status; + + status = f_string_ranges_adjust(0, &datas->array[i].vocabulary); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(datas->size, length, sizeof(f_iki_data_t), (void **) & datas->array); + if (F_status_is_error(status)) return status; + + datas->size = length; + + if (datas->used > datas->size) { + datas->used = length; + } + + return F_none; + } +#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_none; + + if (destination->used + 1 > destination->size) { + status = private_f_iki_datas_resize(destination->used + F_iki_default_allocation_small_d, destination); + 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) { + status = f_array_lengths_append_all(source.delimits, &destination->array[destination->used].delimits); + if (F_status_is_error(status)) return status; + } + + 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) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_iki_datas_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + 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.array[i].content.used) { + status = f_string_ranges_append_all(source.array[i].content, &destination->array[destination->used].content); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].delimits.used) { + status = f_array_lengths_append_all(source.array[i].delimits, &destination->array[destination->used].delimits); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].variable.used) { + status = f_string_ranges_append_all(source.array[i].variable, &destination->array[destination->used].variable); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].vocabulary.used) { + status = f_string_ranges_append_all(source.array[i].vocabulary, &destination->array[destination->used].vocabulary); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#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_array_length_t length, f_iki_datas_t *datas) { + + if (datas->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < datas->size; ++i) { + + status = f_string_ranges_resize(0, &datas->array[i].content); + if (F_status_is_error(status)) return status; + + status = f_array_lengths_resize(0, &datas->array[i].delimits); + if (F_status_is_error(status)) return status; + + status = f_string_ranges_resize(0, &datas->array[i].variable); + if (F_status_is_error(status)) return status; + + status = f_string_ranges_resize(0, &datas->array[i].vocabulary); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(datas->size, length, sizeof(f_iki_data_t), (void **) & datas->array); + if (F_status_is_error(status)) return status; + + datas->size = length; + + if (datas->used > datas->size) { + datas->used = length; + } + + return F_none; + } +#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_array_length_t length, f_iki_datass_t *datass) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < datass->size; ++i) { + + status = f_memory_destroy(datass->array[i].size, sizeof(f_iki_datas_t), (void **) & datass->array[i].array); + if (F_status_is_error(status)) return status; + + datass->array[i].size = 0; + datass->array[i].used = 0; + } // for + + status = f_memory_adjust(datass->size, length, sizeof(f_iki_datas_t), (void **) & datass->array); + if (F_status_is_error(status)) return status; + + datass->size = length; + + if (datass->used > datass->size) { + datass->used = length; + } + + return F_none; + } +#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_array_length_t length, f_iki_datass_t *datass) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < datass->size; ++i) { + + status = f_memory_delete(datass->array[i].size, sizeof(f_iki_datas_t), (void **) & datass->array[i].array); + if (F_status_is_error(status)) return status; + + datass->array[i].size = 0; + datass->array[i].used = 0; + } // for + + status = f_memory_resize(datass->size, length, sizeof(f_iki_datas_t), (void **) & datass->array); + if (F_status_is_error(status)) return status; + + datass->size = length; + + if (datass->used > datass->size) { + datass->used = length; + } + + return F_none; + } +#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 diff --git a/level_0/f_iki/c/iki/private-data.h b/level_0/f_iki/c/iki/private-data.h new file mode 100644 index 000000000..bac0cb7a7 --- /dev/null +++ b/level_0/f_iki/c/iki/private-data.h @@ -0,0 +1,175 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_iki_data_h +#define _PRIVATE_F_iki_data_h + +#ifdef __cplusplus +extern "C" { +#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 iki_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(). + * + * @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_array_length_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_data 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() + * @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. + * + * @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 iki_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_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_array_length_t length, f_iki_datas_t *datas) 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_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_array_length_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_array_length_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 // _PRIVATE_F_iki_data_h diff --git a/level_0/f_iki/c/private-iki.c b/level_0/f_iki/c/private-iki.c index dba7008c1..d972285f8 100644 --- a/level_0/f_iki/c/private-iki.c +++ b/level_0/f_iki/c/private-iki.c @@ -5,82 +5,6 @@ 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_array_length_t length, f_iki_datas_t *datas) { - - if (datas->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < datas->size; ++i) { - - status = f_string_ranges_adjust(0, &datas->array[i].content); - if (F_status_is_error(status)) return status; - - status = f_array_lengths_adjust(0, &datas->array[i].delimits); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_adjust(0, &datas->array[i].variable); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_adjust(0, &datas->array[i].vocabulary); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(datas->size, length, sizeof(f_iki_data_t), (void **) & datas->array); - - if (F_status_is_error_not(status)) { - datas->size = length; - - if (datas->used > datas->size) { - datas->used = length; - } - } - - return status; - } -#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_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_array_length_t length, f_iki_datas_t *datas) { - - if (datas->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < datas->size; ++i) { - - status = f_string_ranges_resize(0, &datas->array[i].content); - if (F_status_is_error(status)) return status; - - status = f_array_lengths_resize(0, &datas->array[i].delimits); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_resize(0, &datas->array[i].variable); - if (F_status_is_error(status)) return status; - - status = f_string_ranges_resize(0, &datas->array[i].vocabulary); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(datas->size, length, sizeof(f_iki_data_t), (void **) & datas->array); - - if (F_status_is_error_not(status)) { - datas->size = length; - - if (datas->used > datas->size) { - datas->used = length; - } - } - - return status; - } -#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_content_is_) || !defined(_di_f_iki_content_partial_is_) f_status_t private_f_iki_content_partial_is(const f_string_t buffer, const f_array_length_t length, const f_char_t quote) { diff --git a/level_0/f_iki/c/private-iki.h b/level_0/f_iki/c/private-iki.h index 6fed8605c..bed8a0ae2 100644 --- a/level_0/f_iki/c/private-iki.h +++ b/level_0/f_iki/c/private-iki.h @@ -15,6 +15,34 @@ extern "C" { #endif +/** + * Private implementation of f_iki_content_partial_is(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param buffer + * The string to validate as an content name. + * @param length + * The length of the string to validate. + * @param range + * The range within the buffer that represents the content name. + * @param quote + * The quote character in use. + * This must be either a single (') or double (") quote. + * + * @return + * F_true on success and string is a valid content name. + * F_false on success and string is not a valid content name. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * @see f_iki_content_is() + * @see f_iki_content_partial_is() + */ +#if !defined(_di_f_iki_content_is_) || !defined(_di_f_iki_content_partial_is_) + extern f_status_t private_f_iki_content_partial_is(const f_string_t buffer, const f_array_length_t length, const f_char_t quote) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_iki_content_is_) || !defined(_di_f_iki_content_partial_is_) + /** * Private implementation for resizing the iki_datas array. * @@ -41,6 +69,30 @@ extern "C" { extern f_status_t private_f_iki_datas_adjust(const f_array_length_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. * @@ -68,32 +120,62 @@ extern "C" { #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 of f_iki_content_partial_is(). + * Private implementation for resizing the iki_datass array. * * Intended to be shared to each of the different implementation variations. * - * @param buffer - * The string to validate as an content name. * @param length - * The length of the string to validate. - * @param range - * The range within the buffer that represents the content name. - * @param quote - * The quote character in use. - * This must be either a single (') or double (") quote. + * The length to adjust to. + * @param iki_datass + * The iki_datass array to adjust. * * @return - * F_true on success and string is a valid content name. - * F_false on success and string is not a valid content name. + * 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. * - * @see f_iki_content_is() - * @see f_iki_content_partial_is() + * 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_content_is_) || !defined(_di_f_iki_content_partial_is_) - extern f_status_t private_f_iki_content_partial_is(const f_string_t buffer, const f_array_length_t length, const f_char_t quote) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_iki_content_is_) || !defined(_di_f_iki_content_partial_is_) +#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_array_length_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_array_length_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(). diff --git a/level_0/f_iki/data/build/settings b/level_0/f_iki/data/build/settings index f185d9719..74a91ce02 100644 --- a/level_0/f_iki/data/build/settings +++ b/level_0/f_iki/data/build/settings @@ -31,7 +31,7 @@ build_objects_library_static build_objects_program build_objects_program_shared build_objects_program_static -build_sources_library iki.c private-iki.c iki/common.c +build_sources_library iki.c private-iki.c iki/common.c iki/private-data.c iki/data.c build_sources_library_shared build_sources_library_static build_sources_object @@ -40,7 +40,7 @@ build_sources_object_static build_sources_program build_sources_program_shared build_sources_program_static -build_sources_headers iki.h iki/common.h +build_sources_headers iki.h iki/common.h iki/data.h build_sources_headers_shared build_sources_headers_static build_sources_script diff --git a/level_0/f_iki/data/build/settings-tests b/level_0/f_iki/data/build/settings-tests index 4a1264a12..e015d5378 100644 --- a/level_0/f_iki/data/build/settings-tests +++ b/level_0/f_iki/data/build/settings-tests @@ -20,7 +20,9 @@ build_libraries -lc -lcmocka build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_utf -lf_iki build_libraries-level -lfll_0 build_libraries-monolithic -lfll -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 test-iki.c +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.c build_script no build_shared yes build_static no diff --git a/level_0/f_iki/tests/unit/c/test-iki-content_partial_is.c b/level_0/f_iki/tests/unit/c/test-iki-content_partial_is.c index 96ba57966..5e135bd75 100644 --- a/level_0/f_iki/tests/unit/c/test-iki-content_partial_is.c +++ b/level_0/f_iki/tests/unit/c/test-iki-content_partial_is.c @@ -24,17 +24,17 @@ void test__f_iki_content_partial_is__returns_false(void **state) { }; const f_string_range_t ranges[] = { - macro_f_string_range_t_initialize2(4, 10), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 10), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 5), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 10), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 5), + macro_f_string_range_t_initialize(4, 10), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 10), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 5), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 10), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 5), }; const f_string_static_t quotes[] = { @@ -86,7 +86,7 @@ void test__f_iki_content_partial_is__returns_data_not(void **state) { void test__f_iki_content_partial_is__returns_data_not_eos(void **state) { { - const f_string_range_t range = macro_f_string_range_t_initialize2(f_string_ascii_a_s.used, f_string_ascii_a_s.used); + const f_string_range_t range = macro_f_string_range_t_initialize(f_string_ascii_a_s.used, f_string_ascii_a_s.used); const f_status_t status = f_iki_content_partial_is(f_string_ascii_a_s, range, f_string_ascii_quote_single_s); @@ -121,14 +121,14 @@ void test__f_iki_content_partial_is__returns_true(void **state) { }; const f_string_range_t ranges[] = { - macro_f_string_range_t_initialize2(4, 8), - macro_f_string_range_t_initialize2(4, 13), - macro_f_string_range_t_initialize2(4, 12), - macro_f_string_range_t_initialize2(4, 13), - macro_f_string_range_t_initialize2(4, 14), - macro_f_string_range_t_initialize2(4, 12), - macro_f_string_range_t_initialize2(4, 13), - macro_f_string_range_t_initialize2(4, 14), + macro_f_string_range_t_initialize(4, 8), + macro_f_string_range_t_initialize(4, 13), + macro_f_string_range_t_initialize(4, 12), + macro_f_string_range_t_initialize(4, 13), + macro_f_string_range_t_initialize(4, 14), + macro_f_string_range_t_initialize(4, 12), + macro_f_string_range_t_initialize(4, 13), + macro_f_string_range_t_initialize(4, 14), }; const f_string_static_t quotes[] = { diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_adjust.c b/level_0/f_iki/tests/unit/c/test-iki-datas_adjust.c new file mode 100644 index 000000000..e52863071 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_adjust.c @@ -0,0 +1,42 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_adjust.h b/level_0/f_iki/tests/unit/c/test-iki-datas_adjust.h new file mode 100644 index 000000000..69d3c547e --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_append.c b/level_0/f_iki/tests/unit/c/test-iki-datas_append.c new file mode 100644 index 000000000..f81780f6d --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_append.c @@ -0,0 +1,111 @@ +#include "test-iki.h" +#include "test-iki-datas_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_iki_datas_append__works(void **state) { + + const f_array_length_t length = 5; + f_iki_data_t source = f_iki_data_t_initialize; + f_iki_datas_t destination = f_iki_datas_t_initialize; + + { + f_array_length_t i = 1; + + f_status_t status = f_string_ranges_resize(length, &source.content); + + assert_int_equal(status, F_none); + assert_int_equal(source.content.size, length); + + status = f_array_lengths_resize(length, &source.delimits); + + assert_int_equal(status, F_none); + assert_int_equal(source.delimits.size, length); + + status = f_string_ranges_resize(length, &source.variable); + + assert_int_equal(status, F_none); + assert_int_equal(source.variable.size, length); + + status = f_string_ranges_resize(length, &source.vocabulary); + + assert_int_equal(status, F_none); + assert_int_equal(source.vocabulary.size, length); + + for (; source.content.used < length; ++i) { + + source.content.array[source.content.used].start = i - 1; + source.content.array[source.content.used++].stop = i; + } // for + + for (; source.delimits.used < length; ++i) { + source.delimits.array[source.delimits.used++] = i; + } // for + + for (; source.variable.used < length; ++i) { + + source.variable.array[source.variable.used].start = i - 1; + source.variable.array[source.variable.used++].stop = i; + } // for + + for (; source.vocabulary.used < length; ++i) { + + source.vocabulary.array[source.vocabulary.used].start = i - 1; + source.vocabulary.array[source.vocabulary.used++].stop = i; + } // for + } + + { + const f_status_t status = f_iki_datas_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].content.used, source.content.used); + assert_int_equal(destination.array[0].delimits.used, source.delimits.used); + assert_int_equal(destination.array[0].variable.used, source.variable.used); + assert_int_equal(destination.array[0].vocabulary.used, source.vocabulary.used); + + for (f_array_length_t i = 0; i < length; ++i) { + + assert_int_equal(destination.array[0].content.array[i].start, source.content.array[i].start); + assert_int_equal(destination.array[0].content.array[i].stop, source.content.array[i].stop); + + assert_int_equal(destination.array[0].delimits.array[i], source.delimits.array[i]); + + assert_int_equal(destination.array[0].variable.array[i].start, source.variable.array[i].start); + assert_int_equal(destination.array[0].variable.array[i].stop, source.variable.array[i].stop); + + assert_int_equal(destination.array[0].vocabulary.array[i].start, source.vocabulary.array[i].start); + assert_int_equal(destination.array[0].vocabulary.array[i].stop, source.vocabulary.array[i].stop); + } // for + } + + free((void *) source.content.array); + free((void *) source.delimits.array); + free((void *) source.variable.array); + free((void *) source.vocabulary.array); + + free((void *) destination.array[0].content.array); + free((void *) destination.array[0].delimits.array); + free((void *) destination.array[0].variable.array); + free((void *) destination.array[0].vocabulary.array); + + free((void *) destination.array); +} + +void test__f_iki_datas_append__parameter_checking(void **state) { + + const f_iki_data_t data = f_iki_data_t_initialize; + + { + const f_status_t status = f_iki_datas_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_append.h b/level_0/f_iki/tests/unit/c/test-iki-datas_append.h new file mode 100644 index 000000000..1467f37f7 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_iki_datas_append_h +#define _TEST__F_iki_datas_append_h + +/** + * Test that the function works. + * + * @see f_iki_datas_append() + */ +extern void test__f_iki_datas_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_iki_datas_append() + */ +extern void test__f_iki_datas_append__parameter_checking(void **state); + +#endif // _TEST__F_iki_datas_append_h diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_append_all.c b/level_0/f_iki/tests/unit/c/test-iki-datas_append_all.c new file mode 100644 index 000000000..e01ec3ca8 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_append_all.c @@ -0,0 +1,161 @@ +#include "test-iki.h" +#include "test-iki-datas_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_iki_datas_append_all__works(void **state) { + + const int length = 5; + f_iki_datas_t source = f_iki_datas_t_initialize; + f_iki_datas_t destination = f_iki_datas_t_initialize; + + { + f_status_t status = f_iki_datas_resize(2, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, 2); + + f_array_length_t i = 1; + f_array_length_t j = 0; + + for (; j < 2; ++j) { + + status = f_string_ranges_resize(length, &source.array[j].content); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[j].content.size, length); + + status = f_array_lengths_resize(length, &source.array[j].delimits); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[j].delimits.size, length); + + status = f_string_ranges_resize(length, &source.array[j].variable); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[j].variable.size, length); + + status = f_string_ranges_resize(length, &source.array[j].vocabulary); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[j].vocabulary.size, length); + + for (; source.array[j].content.used < length; ++i) { + + source.array[j].content.array[source.array[j].content.used].start = i - 1; + source.array[j].content.array[source.array[j].content.used++].stop = i; + } // for + + for (; source.array[j].delimits.used < length; ++i) { + + source.array[j].delimits.array[source.array[j].delimits.used++] = i; + } // for + + for (; source.array[j].variable.used < length; ++i) { + + source.array[j].variable.array[source.array[j].variable.used].start = i - 1; + source.array[j].variable.array[source.array[j].variable.used++].stop = i; + } // for + + for (; source.array[j].vocabulary.used < length; ++i) { + + source.array[j].vocabulary.array[source.array[j].vocabulary.used].start = i - 1; + source.array[j].vocabulary.array[source.array[j].vocabulary.used++].stop = i; + } // for + } // for + + source.used = 2; + } + + { + const f_status_t status = f_iki_datas_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t j = 0; j < 2; ++j) { + + assert_int_equal(destination.array[j].content.used, source.array[j].content.used); + assert_int_equal(destination.array[j].delimits.used, source.array[j].delimits.used); + assert_int_equal(destination.array[j].variable.used, source.array[j].variable.used); + assert_int_equal(destination.array[j].vocabulary.used, source.array[j].vocabulary.used); + + for (f_array_length_t i = 0; i < length; ++i) { + + assert_int_equal(destination.array[j].content.array[i].start, source.array[j].content.array[i].start); + assert_int_equal(destination.array[j].content.array[i].stop, source.array[j].content.array[i].stop); + + assert_int_equal(destination.array[j].delimits.array[i], source.array[j].delimits.array[i]); + + assert_int_equal(destination.array[j].variable.array[i].start, source.array[j].variable.array[i].start); + assert_int_equal(destination.array[j].variable.array[i].stop, source.array[j].variable.array[i].stop); + + assert_int_equal(destination.array[j].vocabulary.array[i].start, source.array[j].vocabulary.array[i].start); + assert_int_equal(destination.array[j].vocabulary.array[i].stop, source.array[j].vocabulary.array[i].stop); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].content.array); + free((void *) source.array[i].delimits.array); + free((void *) source.array[i].variable.array); + free((void *) source.array[i].vocabulary.array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + free((void *) destination.array[i].content.array); + free((void *) destination.array[i].delimits.array); + free((void *) destination.array[i].variable.array); + free((void *) destination.array[i].vocabulary.array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_iki_datas_append_all__returns_data_not(void **state) { + + const int length = 5; + f_iki_datas_t source = f_iki_datas_t_initialize; + f_iki_datas_t destination = f_iki_datas_t_initialize; + + { + const f_status_t status = f_iki_datas_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_iki_datas_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_iki_datas_append_all__parameter_checking(void **state) { + + const f_iki_datas_t data = f_iki_datas_t_initialize; + + { + const f_status_t status = f_iki_datas_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_append_all.h b/level_0/f_iki/tests/unit/c/test-iki-datas_append_all.h new file mode 100644 index 000000000..35c22e3e6 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_iki_datas_append_all_h +#define _TEST__F_iki_datas_append_all_h + +/** + * Test that the function works. + * + * @see f_iki_datas_append_all() + */ +extern void test__f_iki_datas_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_iki_datas_append_all() + */ +extern void test__f_iki_datas_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_iki_datas_append_all() + */ +extern void test__f_iki_datas_append_all__parameter_checking(void **state); + +#endif // _TEST__F_iki_datas_append_all_h diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_decimate_by.c b/level_0/f_iki/tests/unit/c/test-iki-datas_decimate_by.c new file mode 100644 index 000000000..d0dbd0e19 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_decimate_by.c @@ -0,0 +1,50 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_decimate_by.h b/level_0/f_iki/tests/unit/c/test-iki-datas_decimate_by.h new file mode 100644 index 000000000..820682255 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_decrease_by.c b/level_0/f_iki/tests/unit/c/test-iki-datas_decrease_by.c new file mode 100644 index 000000000..3bd186572 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_decrease_by.c @@ -0,0 +1,50 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_decrease_by.h b/level_0/f_iki/tests/unit/c/test-iki-datas_decrease_by.h new file mode 100644 index 000000000..fe3375565 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_increase.c b/level_0/f_iki/tests/unit/c/test-iki-datas_increase.c new file mode 100644 index 000000000..16fe9970a --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_increase.c @@ -0,0 +1,76 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_increase.h b/level_0/f_iki/tests/unit/c/test-iki-datas_increase.h new file mode 100644 index 000000000..289e2ba9b --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_increase_by.c b/level_0/f_iki/tests/unit/c/test-iki-datas_increase_by.c new file mode 100644 index 000000000..ba533940f --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_increase_by.c @@ -0,0 +1,52 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_increase_by.h b/level_0/f_iki/tests/unit/c/test-iki-datas_increase_by.h new file mode 100644 index 000000000..2c8ddb903 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_resize.c b/level_0/f_iki/tests/unit/c/test-iki-datas_resize.c new file mode 100644 index 000000000..e647f00cf --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_resize.c @@ -0,0 +1,42 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_resize.h b/level_0/f_iki/tests/unit/c/test-iki-datas_resize.h new file mode 100644 index 000000000..915f83565 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_adjust.c b/level_0/f_iki/tests/unit/c/test-iki-datass_adjust.c new file mode 100644 index 000000000..d6f562d73 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_adjust.c @@ -0,0 +1,42 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_adjust.h b/level_0/f_iki/tests/unit/c/test-iki-datass_adjust.h new file mode 100644 index 000000000..304ea4190 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_append.c b/level_0/f_iki/tests/unit/c/test-iki-datass_append.c new file mode 100644 index 000000000..e69b5e03b --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_append.c @@ -0,0 +1,166 @@ +#include "test-iki.h" +#include "test-iki-datass_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_iki_datass_append__works(void **state) { + + const int length = 5; + const int length_outer = 2; + f_iki_datas_t source = f_iki_datas_t_initialize; + f_iki_datass_t destination = f_iki_datass_t_initialize; + + { + f_status_t status = f_iki_datas_resize(length_outer, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_outer); + + f_array_length_t i = 1; + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + status = f_string_ranges_resize(length, &source.array[j].content); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[j].content.size, length); + + status = f_array_lengths_resize(length, &source.array[j].delimits); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[j].delimits.size, length); + + status = f_string_ranges_resize(length, &source.array[j].variable); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[j].variable.size, length); + + status = f_string_ranges_resize(length, &source.array[j].vocabulary); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[j].vocabulary.size, length); + + for (; source.array[j].content.used < length; ++i) { + + source.array[j].content.array[source.array[j].content.used].start = i - 1; + source.array[j].content.array[source.array[j].content.used++].stop = i; + } // for + + for (; source.array[j].delimits.used < length; ++i) { + + source.array[j].delimits.array[source.array[j].delimits.used++] = i; + } // for + + for (; source.array[j].variable.used < length; ++i) { + + source.array[j].variable.array[source.array[j].variable.used].start = i - 1; + source.array[j].variable.array[source.array[j].variable.used++].stop = i; + } // for + + for (; source.array[j].vocabulary.used < length; ++i) { + + source.array[j].vocabulary.array[source.array[j].vocabulary.used].start = i - 1; + source.array[j].vocabulary.array[source.array[j].vocabulary.used++].stop = i; + } // for + } // for + + source.used = length_outer; + } + + { + const f_status_t status = f_iki_datass_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + assert_int_equal(destination.array[0].array[j].content.used, source.array[j].content.used); + assert_int_equal(destination.array[0].array[j].delimits.used, source.array[j].delimits.used); + assert_int_equal(destination.array[0].array[j].variable.used, source.array[j].variable.used); + assert_int_equal(destination.array[0].array[j].vocabulary.used, source.array[j].vocabulary.used); + + for (f_array_length_t i = 0; i < length; ++i) { + + assert_int_equal(destination.array[0].array[j].content.array[i].start, source.array[j].content.array[i].start); + assert_int_equal(destination.array[0].array[j].content.array[i].stop, source.array[j].content.array[i].stop); + + assert_int_equal(destination.array[0].array[j].delimits.array[i], source.array[j].delimits.array[i]); + + assert_int_equal(destination.array[0].array[j].variable.array[i].start, source.array[j].variable.array[i].start); + assert_int_equal(destination.array[0].array[j].variable.array[i].stop, source.array[j].variable.array[i].stop); + + assert_int_equal(destination.array[0].array[j].vocabulary.array[i].start, source.array[j].vocabulary.array[i].start); + assert_int_equal(destination.array[0].array[j].vocabulary.array[i].stop, source.array[j].vocabulary.array[i].stop); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].content.array); + free((void *) source.array[i].delimits.array); + free((void *) source.array[i].variable.array); + free((void *) source.array[i].vocabulary.array); + } // for + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + + free((void *) destination.array[j].array[i].content.array); + free((void *) destination.array[j].array[i].delimits.array); + free((void *) destination.array[j].array[i].variable.array); + free((void *) destination.array[j].array[i].vocabulary.array); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_iki_datass_append__returns_data_not(void **state) { + + const int length = 5; + f_iki_datas_t source = f_iki_datass_t_initialize; + f_iki_datass_t destination = f_iki_datass_t_initialize; + + { + const f_status_t status = f_iki_datas_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_iki_datass_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_iki_datass_append__parameter_checking(void **state) { + + f_iki_datas_t data = f_iki_datas_t_initialize; + + { + const f_status_t status = f_iki_datass_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_append.h b/level_0/f_iki/tests/unit/c/test-iki-datass_append.h new file mode 100644 index 000000000..924d4a210 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_iki_datass_append_h +#define _TEST__F_iki_datass_append_h + +/** + * Test that the function works. + * + * @see f_iki_datass_append() + */ +extern void test__f_iki_datass_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_iki_datass_append() + */ +extern void test__f_iki_datass_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_iki_datass_append() + */ +extern void test__f_iki_datass_append__parameter_checking(void **state); + +#endif // _TEST__F_iki_datass_append_h diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_append_all.c b/level_0/f_iki/tests/unit/c/test-iki-datass_append_all.c new file mode 100644 index 000000000..935191948 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_append_all.c @@ -0,0 +1,182 @@ +#include "test-iki.h" +#include "test-iki-datass_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_iki_datass_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + const int length_outer = 2; + f_iki_datass_t source = f_iki_datass_t_initialize; + f_iki_datass_t destination = f_iki_datass_t_initialize; + + { + f_status_t status = f_iki_datass_resize(length_outer, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_outer); + + f_array_length_t i = 1; + f_array_length_t j = 0; + + for (; source.used < length_outer; ++source.used) { + + status = f_iki_datas_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].size, length_inner); + + for (j = 0; j < length_inner; ++j) { + + status = f_string_ranges_resize(length, &source.array[source.used].array[j].content); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].array[j].content.size, length); + + status = f_array_lengths_resize(length, &source.array[source.used].array[j].delimits); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].array[j].delimits.size, length); + + status = f_string_ranges_resize(length, &source.array[source.used].array[j].variable); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].array[j].variable.size, length); + + status = f_string_ranges_resize(length, &source.array[source.used].array[j].vocabulary); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].array[j].vocabulary.size, length); + + for (; source.array[source.used].array[j].content.used < length; ++i) { + + source.array[source.used].array[j].content.array[source.array[source.used].array[j].content.used].start = i - 1; + source.array[source.used].array[j].content.array[source.array[source.used].array[j].content.used++].stop = i; + } // for + + for (; source.array[source.used].array[j].delimits.used < length; ++i) { + source.array[source.used].array[j].delimits.array[source.array[source.used].array[j].delimits.used++] = i; + } // for + + for (; source.array[source.used].array[j].variable.used < length; ++i) { + + source.array[source.used].array[j].variable.array[source.array[source.used].array[j].variable.used].start = i - 1; + source.array[source.used].array[j].variable.array[source.array[source.used].array[j].variable.used++].stop = i; + } // for + + for (; source.array[source.used].array[j].vocabulary.used < length; ++i) { + + source.array[source.used].array[j].vocabulary.array[source.array[source.used].array[j].vocabulary.used].start = i - 1; + source.array[source.used].array[j].vocabulary.array[source.array[source.used].array[j].vocabulary.used++].stop = i; + } // for + } // for + + source.array[source.used].used = length_inner; + } // for + } + + { + const f_status_t status = f_iki_datass_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t k = 0; k < length_outer; ++k) { + + for (f_array_length_t j = 0; j < length_inner; ++j) { + + assert_int_equal(destination.array[k].array[j].content.used, source.array[k].array[j].content.used); + assert_int_equal(destination.array[k].array[j].delimits.used, source.array[k].array[j].delimits.used); + assert_int_equal(destination.array[k].array[j].variable.used, source.array[k].array[j].variable.used); + assert_int_equal(destination.array[k].array[j].vocabulary.used, source.array[k].array[j].vocabulary.used); + + for (f_array_length_t i = 0; i < length; ++i) { + + assert_int_equal(destination.array[k].array[j].content.array[i].start, source.array[k].array[j].content.array[i].start); + assert_int_equal(destination.array[k].array[j].content.array[i].stop, source.array[k].array[j].content.array[i].stop); + + assert_int_equal(destination.array[k].array[j].delimits.array[i], source.array[k].array[j].delimits.array[i]); + + assert_int_equal(destination.array[k].array[j].variable.array[i].start, source.array[k].array[j].variable.array[i].start); + assert_int_equal(destination.array[k].array[j].variable.array[i].stop, source.array[k].array[j].variable.array[i].stop); + + assert_int_equal(destination.array[k].array[j].vocabulary.array[i].start, source.array[k].array[j].vocabulary.array[i].start); + assert_int_equal(destination.array[k].array[j].vocabulary.array[i].stop, source.array[k].array[j].vocabulary.array[i].stop); + } // for + } // for + } // for + } + + for (f_array_length_t j = 0; j < source.used; ++j) { + + for (f_array_length_t i = 0; i < source.array[j].used; ++i) { + + free((void *) source.array[j].array[i].content.array); + free((void *) source.array[j].array[i].delimits.array); + free((void *) source.array[j].array[i].variable.array); + free((void *) source.array[j].array[i].vocabulary.array); + } // for + + free((void *) source.array[j].array); + } // for + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + + free((void *) destination.array[j].array[i].content.array); + free((void *) destination.array[j].array[i].delimits.array); + free((void *) destination.array[j].array[i].variable.array); + free((void *) destination.array[j].array[i].vocabulary.array); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_iki_datass_append_all__returns_data_not(void **state) { + + const int length = 5; + f_iki_datass_t source = f_iki_datass_t_initialize; + f_iki_datass_t destination = f_iki_datass_t_initialize; + + { + const f_status_t status = f_iki_datass_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_iki_datass_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_iki_datass_append_all__parameter_checking(void **state) { + + const f_iki_datass_t data = f_iki_datass_t_initialize; + + { + const f_status_t status = f_iki_datass_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_append_all.h b/level_0/f_iki/tests/unit/c/test-iki-datass_append_all.h new file mode 100644 index 000000000..688b57362 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_iki_datass_append_all_h +#define _TEST__F_iki_datass_append_all_h + +/** + * Test that the function works. + * + * @see f_iki_datass_append_all() + */ +extern void test__f_iki_datass_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_iki_datass_append_all() + */ +extern void test__f_iki_datass_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_iki_datass_append_all() + */ +extern void test__f_iki_datass_append_all__parameter_checking(void **state); + +#endif // _TEST__F_iki_datass_append_all_h diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_decimate_by.c b/level_0/f_iki/tests/unit/c/test-iki-datass_decimate_by.c new file mode 100644 index 000000000..8866b8a2b --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_decimate_by.c @@ -0,0 +1,50 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_decimate_by.h b/level_0/f_iki/tests/unit/c/test-iki-datass_decimate_by.h new file mode 100644 index 000000000..764227529 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_decrease_by.c b/level_0/f_iki/tests/unit/c/test-iki-datass_decrease_by.c new file mode 100644 index 000000000..dea8c3f1a --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_decrease_by.c @@ -0,0 +1,50 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_decrease_by.h b/level_0/f_iki/tests/unit/c/test-iki-datass_decrease_by.h new file mode 100644 index 000000000..c022ce7b2 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_increase.c b/level_0/f_iki/tests/unit/c/test-iki-datass_increase.c new file mode 100644 index 000000000..a2e39120b --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_increase.c @@ -0,0 +1,76 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_increase.h b/level_0/f_iki/tests/unit/c/test-iki-datass_increase.h new file mode 100644 index 000000000..43b7f66f1 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_increase_by.c b/level_0/f_iki/tests/unit/c/test-iki-datass_increase_by.c new file mode 100644 index 000000000..24e07c4ff --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_increase_by.c @@ -0,0 +1,52 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_increase_by.h b/level_0/f_iki/tests/unit/c/test-iki-datass_increase_by.h new file mode 100644 index 000000000..f77e1963c --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_resize.c b/level_0/f_iki/tests/unit/c/test-iki-datass_resize.c new file mode 100644 index 000000000..852ef542f --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_resize.c @@ -0,0 +1,42 @@ +#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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_resize.h b/level_0/f_iki/tests/unit/c/test-iki-datass_resize.h new file mode 100644 index 000000000..9ee0a01f5 --- /dev/null +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * 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 diff --git a/level_0/f_iki/tests/unit/c/test-iki-object_partial_is.c b/level_0/f_iki/tests/unit/c/test-iki-object_partial_is.c index 562d548b3..63a39c61c 100644 --- a/level_0/f_iki/tests/unit/c/test-iki-object_partial_is.c +++ b/level_0/f_iki/tests/unit/c/test-iki-object_partial_is.c @@ -27,20 +27,20 @@ void test__f_iki_object_partial_is__returns_false(void **state) { }; const f_string_range_t ranges[] = { - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 10), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 10), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 10), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 10), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 10), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 10), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 10), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 10), }; for (uint8_t i = 0; i < 14; ++i) { @@ -65,7 +65,7 @@ void test__f_iki_object_partial_is__returns_data_not(void **state) { void test__f_iki_object_partial_is__returns_data_not_eos(void **state) { { - const f_string_range_t range = macro_f_string_range_t_initialize2(f_string_ascii_a_s.used, f_string_ascii_a_s.used); + const f_string_range_t range = macro_f_string_range_t_initialize(f_string_ascii_a_s.used, f_string_ascii_a_s.used); const f_status_t status = f_iki_object_partial_is(f_string_ascii_a_s, range); @@ -97,11 +97,11 @@ void test__f_iki_object_partial_is__returns_true(void **state) { }; const f_string_range_t ranges[] = { - macro_f_string_range_t_initialize2(4, 8), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 9), - macro_f_string_range_t_initialize2(4, 10), - macro_f_string_range_t_initialize2(4, 8), + macro_f_string_range_t_initialize(4, 8), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 9), + macro_f_string_range_t_initialize(4, 10), + macro_f_string_range_t_initialize(4, 8), }; for (uint8_t i = 0; i < 5; ++i) { diff --git a/level_0/f_iki/tests/unit/c/test-iki-read.c b/level_0/f_iki/tests/unit/c/test-iki-read.c index a96c4c2b5..163c262cb 100644 --- a/level_0/f_iki/tests/unit/c/test-iki-read.c +++ b/level_0/f_iki/tests/unit/c/test-iki-read.c @@ -59,7 +59,7 @@ void test__f_iki_read__returns_data_not_eos(void **state) { f_string_static_t ascii_a = macro_f_string_static_t_initialize(f_string_ascii_a_s.string, f_string_ascii_a_s.size, f_string_ascii_a_s.used); { - f_string_range_t range = macro_f_string_range_t_initialize2(f_string_ascii_a_s.used, f_string_ascii_a_s.used); + f_string_range_t range = macro_f_string_range_t_initialize(f_string_ascii_a_s.used, f_string_ascii_a_s.used); f_iki_data_t iki = f_iki_data_t_initialize; const f_status_t status = f_iki_read(the_state, &ascii_a, &range, &iki); @@ -167,81 +167,81 @@ void test__f_iki_read__works(void **state) { const f_string_range_t variables[][22] = { { f_string_range_t_initialize, f_string_range_t_initialize }, { f_string_range_t_initialize, f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(0, 8), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 12), macro_f_string_range_t_initialize2(14, 33) }, - { macro_f_string_range_t_initialize2(0, 8), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 12), macro_f_string_range_t_initialize2(14, 33) }, - { macro_f_string_range_t_initialize2(24, 36), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(24, 36), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 22), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 22), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 23), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 21), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 22), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 22), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 23), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 21), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 42), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 42), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 43), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 43), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(0, 66), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(0, 66), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 8), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 12), macro_f_string_range_t_initialize(14, 33) }, + { macro_f_string_range_t_initialize(0, 8), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 12), macro_f_string_range_t_initialize(14, 33) }, + { macro_f_string_range_t_initialize(24, 36), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(24, 36), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 22), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 22), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 23), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 21), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 22), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 22), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 23), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 21), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 42), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 42), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 43), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 43), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 66), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 66), f_string_range_t_initialize }, }; const f_string_range_t vocabularys[][22] = { { f_string_range_t_initialize, f_string_range_t_initialize }, { f_string_range_t_initialize, f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(0, 2), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 6), macro_f_string_range_t_initialize2(14, 16) }, - { macro_f_string_range_t_initialize2(0, 2), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 6), macro_f_string_range_t_initialize2(14, 16) }, - { macro_f_string_range_t_initialize2(24, 27), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(24, 27), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 10), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 10), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 11), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 9), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 10), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 10), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 11), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 9), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 10), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 10), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 10), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(4, 10), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(0, 2), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(0, 2), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 2), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 6), macro_f_string_range_t_initialize(14, 16) }, + { macro_f_string_range_t_initialize(0, 2), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 6), macro_f_string_range_t_initialize(14, 16) }, + { macro_f_string_range_t_initialize(24, 27), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(24, 27), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 10), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 10), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 11), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 9), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 10), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 10), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 11), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 9), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 10), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 10), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 10), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(4, 10), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 2), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 2), f_string_range_t_initialize }, }; const f_string_range_t contents[][22] = { { f_string_range_t_initialize, f_string_range_t_initialize }, { f_string_range_t_initialize, f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 7), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(9, 11), macro_f_string_range_t_initialize2(19, 32) }, - { macro_f_string_range_t_initialize2(5, 7), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(9, 11), macro_f_string_range_t_initialize2(19, 32) }, - { macro_f_string_range_t_initialize2(30, 35), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(30, 35), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(13, 21), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(13, 21), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(14, 22), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(12, 20), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(13, 21), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(13, 21), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(14, 22), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(12, 20), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(13, 41), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(13, 41), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(13, 42), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(13, 42), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 65), f_string_range_t_initialize }, - { macro_f_string_range_t_initialize2(5, 65), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 7), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(9, 11), macro_f_string_range_t_initialize(19, 32) }, + { macro_f_string_range_t_initialize(5, 7), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(9, 11), macro_f_string_range_t_initialize(19, 32) }, + { macro_f_string_range_t_initialize(30, 35), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(30, 35), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(13, 21), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(13, 21), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(14, 22), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(12, 20), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(13, 21), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(13, 21), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(14, 22), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(12, 20), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(13, 41), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(13, 41), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(13, 42), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(13, 42), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 65), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 65), f_string_range_t_initialize }, }; for (uint8_t i = 0; i < 22; ++i) { - f_string_range_t range = macro_f_string_range_t_initialize(buffers[i].used); + f_string_range_t range = macro_f_string_range_t_initialize2(buffers[i].used); f_iki_data_t iki = f_iki_data_t_initialize; const f_status_t status = f_iki_read(the_state, &buffers[i], &range, &iki); diff --git a/level_0/f_iki/tests/unit/c/test-iki.c b/level_0/f_iki/tests/unit/c/test-iki.c index 633c3801b..8e46be3e3 100644 --- a/level_0/f_iki/tests/unit/c/test-iki.c +++ b/level_0/f_iki/tests/unit/c/test-iki.c @@ -29,6 +29,29 @@ int main(void) { 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_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_object_is__returns_true), @@ -47,8 +70,28 @@ int main(void) { #ifndef _di_level_0_parameter_checking_ 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), + 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. + cmocka_unit_test(test__f_iki_read__parameter_checking), #endif // _di_level_0_parameter_checking_ }; diff --git a/level_0/f_iki/tests/unit/c/test-iki.h b/level_0/f_iki/tests/unit/c/test-iki.h index c1bc15e00..4e5c148c6 100644 --- a/level_0/f_iki/tests/unit/c/test-iki.h +++ b/level_0/f_iki/tests/unit/c/test-iki.h @@ -28,6 +28,22 @@ // 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_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-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" diff --git a/level_0/f_memory/c/private-memory.c b/level_0/f_memory/c/private-memory.c index a4cea4508..7a3aef33c 100644 --- a/level_0/f_memory/c/private-memory.c +++ b/level_0/f_memory/c/private-memory.c @@ -131,16 +131,15 @@ extern "C" { f_status_t private_f_memory_structure_resize(const size_t length_new, const size_t type_size, void ** const structure, f_array_length_t * const used, f_array_length_t * const size) { const f_status_t status = private_f_memory_resize(*size, length_new, type_size, structure); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - *size = length_new; + *size = length_new; - if (*used > *size) { - *used = *size; - } + if (*used > *size) { + *used = *size; } - return status; + return F_none; } #endif // !defined(_di_memory_structure_decrease_by_) || !defined(_di_memory_structure_increase_) || !defined(_di_memory_structure_increase_by_) || !defined(_di_f_memory_structure_resize_) diff --git a/level_0/f_string/c/private-string.c b/level_0/f_string/c/private-string.c index 10710c3b6..8636c9790 100644 --- a/level_0/f_string/c/private-string.c +++ b/level_0/f_string/c/private-string.c @@ -1,5 +1,6 @@ #include "string.h" #include "private-string.h" +#include "string/private-dynamic.h" #ifdef __cplusplus extern "C" { @@ -72,581 +73,6 @@ extern "C" { } #endif // !defined(_di_f_string_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) -#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - f_status_t private_f_string_dynamic_adjust(const f_array_length_t length, f_string_dynamic_t * const dynamic) { - - f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_char_t), (void **) & dynamic->string); - - if (F_status_is_error_not(status)) { - dynamic->size = length; - - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - -#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - f_status_t private_f_string_dynamic_increase_by(const f_array_length_t amount, f_string_dynamic_t * const dynamic) { - - if (dynamic->used + amount > dynamic->size) { - if (dynamic->used + amount > F_string_t_size_d) { - return F_status_set_error(F_string_too_large); - } - - return private_f_string_dynamic_resize(dynamic->used + amount, dynamic); - } - - return F_data_not; - } -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - -#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - f_status_t private_f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t * const dynamic) { - - const f_status_t status = f_memory_resize(dynamic->size, length, sizeof(f_char_t), (void **) & dynamic->string); - - if (F_status_is_error_not(status)) { - dynamic->size = length; - - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - -#if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) - f_status_t private_f_string_dynamics_adjust(const f_array_length_t length, f_string_dynamics_t * const dynamics) { - - if (dynamics->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamics->size; ++i) { - - status = private_f_string_dynamic_adjust(0, &dynamics->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(dynamics->size, length, sizeof(f_string_dynamic_t), (void **) & dynamics->array); - - if (F_status_is_error_not(status)) { - dynamics->size = length; - - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) - -#if !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) - f_status_t private_f_string_dynamics_append(const f_string_dynamics_t source, f_string_dynamics_t * const destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_string_dynamics_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_string_append(source.array[i].string, source.array[i].used, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) - -#if !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) - f_status_t private_f_string_dynamics_resize(const f_array_length_t length, f_string_dynamics_t * const dynamics) { - - if (dynamics->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamics->size; ++i) { - - status = private_f_string_dynamic_resize(0, &dynamics->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(dynamics->size, length, sizeof(f_string_dynamic_t), (void **) & dynamics->array); - - if (F_status_is_error_not(status)) { - dynamics->size = length; - - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) - -#if !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) - f_status_t private_f_string_dynamicss_adjust(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) { - - if (dynamicss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamicss->size; ++i) { - - status = private_f_string_dynamics_adjust(0, &dynamicss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(dynamicss->size, length, sizeof(f_string_dynamics_t), (void **) & dynamicss->array); - - if (F_status_is_error_not(status)) { - dynamicss->size = length; - - if (dynamicss->used > dynamicss->size) { - dynamicss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) - -#if !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_map_multis_append_) - f_status_t private_f_string_dynamicss_append(const f_string_dynamicss_t source, f_string_dynamicss_t *destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_string_dynamicss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_string_dynamics_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_map_multis_append_) - -#if !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) - f_status_t private_f_string_dynamicss_resize(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) { - - if (dynamicss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamicss->size; ++i) { - - status = private_f_string_dynamics_resize(0, &dynamicss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(dynamicss->size, length, sizeof(f_string_dynamics_t), (void **) & dynamicss->array); - - if (F_status_is_error_not(status)) { - dynamicss->size = length; - - if (dynamicss->used > dynamicss->size) { - dynamicss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) - -#if !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) - f_status_t private_f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t * const map_multis) { - - if (map_multis->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < map_multis->size; ++i) { - - status = private_f_string_dynamic_adjust(0, &map_multis->array[i].name); - if (F_status_is_error(status)) return status; - - status = private_f_string_dynamics_adjust(0, &map_multis->array[i].value); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(map_multis->size, length, sizeof(f_string_map_multi_t), (void **) & map_multis->array); - - if (F_status_is_error_not(status)) { - map_multis->size = length; - - if (map_multis->used > map_multis->size) { - map_multis->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) - -#if !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multis_append_) - f_status_t private_f_string_map_multis_append(const f_string_map_multi_t source, f_string_map_multis_t * const destination) { - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_string_map_multis_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; - - if (source.name.used) { - status = private_f_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } - - if (source.value.used) { - status = private_f_string_dynamics_append(source.value, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multis_append_) - -#if !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multis_append_all_) - f_status_t private_f_string_map_multis_append_all(const f_string_map_multis_t source, f_string_map_multis_t * const destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_string_map_multis_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; - - if (source.array[i].name.used) { - status = private_f_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } - - if (source.array[i].value.used) { - status = private_f_string_dynamics_append(source.array[i].value, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multis_append_all_) - -#if !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) - f_status_t private_f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t * const map_multis) { - - if (map_multis->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < map_multis->size; ++i) { - - status = private_f_string_dynamic_resize(0, &map_multis->array[i].name); - if (F_status_is_error(status)) return status; - - status = private_f_string_dynamics_resize(0, &map_multis->array[i].value); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(map_multis->size, length, sizeof(f_string_map_multi_t), (void **) & map_multis->array); - - if (F_status_is_error_not(status)) { - map_multis->size = length; - - if (map_multis->used > map_multis->size) { - map_multis->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) - -#if !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) - f_status_t private_f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { - - if (map_multiss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < map_multiss->size; ++i) { - - status = private_f_string_map_multis_adjust(0, &map_multiss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(map_multiss->size, length, sizeof(f_string_map_multis_t), (void **) & map_multiss->array); - - if (F_status_is_error_not(status)) { - map_multiss->size = length; - - if (map_multiss->used > map_multiss->size) { - map_multiss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) - -#if !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) - f_status_t private_f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { - - if (map_multiss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < map_multiss->size; ++i) { - - status = private_f_string_map_multis_resize(0, &map_multiss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(map_multiss->size, length, sizeof(f_string_map_multis_t), (void **) & map_multiss->array); - - if (F_status_is_error_not(status)) { - map_multiss->size = length; - - if (map_multiss->used > map_multiss->size) { - map_multiss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) - -#if !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) - f_status_t private_f_string_maps_adjust(const f_array_length_t length, f_string_maps_t * const maps) { - - if (maps->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < maps->size; ++i) { - - status = private_f_string_dynamic_adjust(0, &maps->array[i].name); - if (F_status_is_error(status)) return status; - - status = private_f_string_dynamic_adjust(0, &maps->array[i].value); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(maps->size, length, sizeof(f_string_map_t), (void **) & maps->array); - - if (F_status_is_error_not(status)) { - maps->size = length; - - if (maps->used > maps->size) { - maps->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) - -#if !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_maps_append_) - f_status_t private_f_string_maps_append(const f_string_map_t source, f_string_maps_t * const destination) { - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_string_maps_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; - - if (source.name.used) { - status = private_f_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } - - if (source.value.used) { - status = private_f_string_append(source.value.string, source.value.used, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_maps_append_) - -#if !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_maps_append_all_) - f_status_t private_f_string_maps_append_all(const f_string_maps_t source, f_string_maps_t * const destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_string_maps_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; - - if (source.array[i].name.used) { - status = private_f_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } - - if (source.array[i].value.used) { - status = private_f_string_append(source.array[i].value.string, source.array[i].value.used, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_maps_append_all_) - -#if !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) - f_status_t private_f_string_maps_resize(const f_array_length_t length, f_string_maps_t * const maps) { - - if (maps->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < maps->size; ++i) { - - status = private_f_string_dynamic_resize(0, &maps->array[i].name); - if (F_status_is_error(status)) return status; - - status = private_f_string_dynamic_resize(0, &maps->array[i].value); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(maps->size, length, sizeof(f_string_map_t), (void **) & maps->array); - - if (F_status_is_error_not(status)) { - maps->size = length; - - if (maps->used > maps->size) { - maps->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) - -#if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) - f_status_t private_f_string_mapss_adjust(const f_array_length_t length, f_string_mapss_t * const mapss) { - - if (mapss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < mapss->size; ++i) { - - status = private_f_string_maps_adjust(0, &mapss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(mapss->size, length, sizeof(f_string_maps_t), (void **) & mapss->array); - - if (F_status_is_error_not(status)) { - mapss->size = length; - - if (mapss->used > mapss->size) { - mapss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) - -#if !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) - f_status_t private_f_string_mapss_resize(const f_array_length_t length, f_string_mapss_t * const mapss) { - - if (mapss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < mapss->size; ++i) { - - status = private_f_string_maps_resize(0, &mapss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(mapss->size, length, sizeof(f_string_maps_t), (void **) & mapss->array); - - if (F_status_is_error_not(status)) { - mapss->size = length; - - if (mapss->used > mapss->size) { - mapss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) - #if !defined(_di_f_string_dynamic_mish_) || !defined(_di_f_string_dynamic_partial_mish_) || !defined(_di_f_string_dynamic_partial_prepend_assure_) || !defined(_di_f_string_dynamic_partial_prepend_) || !defined(_di_f_string_dynamic_prepend_assure_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_mish_) || !defined(_di_f_string_prepend_assure_) || !defined(_di_f_string_prepend_) f_status_t private_f_string_prepend(const f_string_t source, const f_array_length_t length, f_string_dynamic_t * const destination) { @@ -738,334 +164,6 @@ extern "C" { } #endif // !defined(_di_f_string_dynamic_mish_nulless_) || !defined(_di_f_string_dynamic_partial_mish_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_mish_nulless_) || !defined(_di_f_string_prepend_assure_nulless_) || !defined(_di_f_string_prepend_nulless_) -#if !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) - f_status_t private_f_string_quantitys_adjust(const f_array_length_t length, f_string_quantitys_t * const quantitys) { - - if (quantitys->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_adjust(quantitys->size, length, sizeof(f_string_quantity_t), (void **) & quantitys->array); - - if (F_status_is_error_not(status)) { - quantitys->size = length; - - if (quantitys->used > quantitys->size) { - quantitys->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) - -#if !defined(_di_f_string_quantitys_decrease_) || !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) || !defined(_di_f_string_quantitys_terminate_) || !defined(_di_f_string_quantitys_terminate_after_) - f_status_t private_f_string_quantitys_resize(const f_array_length_t length, f_string_quantitys_t * const quantitys) { - - if (quantitys->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_resize(quantitys->size, length, sizeof(f_string_quantity_t), (void **) & quantitys->array); - - if (F_status_is_error_not(status)) { - quantitys->size = length; - - if (quantitys->used > quantitys->size) { - quantitys->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_quantitys_decrease_) || !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) || !defined(_di_f_string_quantitys_terminate_) || !defined(_di_f_string_quantitys_terminate_after_) - -#if !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) - f_status_t private_f_string_quantityss_adjust(const f_array_length_t length, f_string_quantityss_t * const quantityss) { - - if (quantityss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < quantityss->size; ++i) { - - status = private_f_string_quantitys_adjust(0, &quantityss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(quantityss->size, length, sizeof(f_string_quantitys_t), (void **) & quantityss->array); - - if (F_status_is_error_not(status)) { - quantityss->size = length; - - if (quantityss->used > quantityss->size) { - quantityss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) - -#if !defined(_di_f_string_quantityss_decrease_) || !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) || !defined(_di_f_string_quantityss_terminate_) || !defined(_di_f_string_quantityss_terminate_after_) - f_status_t private_f_string_quantityss_resize(const f_array_length_t length, f_string_quantityss_t * const quantityss) { - - if (quantityss->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < quantityss->size; ++i) { - - status = private_f_string_quantitys_resize(0, &quantityss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(quantityss->size, length, sizeof(f_string_quantitys_t), (void **) & quantityss->array); - - if (F_status_is_error_not(status)) { - quantityss->size = length; - - if (quantityss->used > quantityss->size) { - quantityss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_quantityss_decrease_) || !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) || !defined(_di_f_string_quantityss_terminate_) || !defined(_di_f_string_quantityss_terminate_after_) - -#if !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) - f_status_t private_f_string_ranges_adjust(const f_array_length_t length, f_string_ranges_t * const ranges) { - - if (ranges->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_adjust(ranges->size, length, sizeof(f_string_range_t), (void **) & ranges->array); - - if (F_status_is_error_not(status)) { - ranges->size = length; - - if (ranges->used > ranges->size) { - ranges->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) - -#if !defined(_di_f_string_ranges_decrease_) || !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_terminate_) || !defined(_di_f_string_ranges_terminate_after_) - f_status_t private_f_string_ranges_resize(const f_array_length_t length, f_string_ranges_t * const ranges) { - - if (ranges->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_resize(ranges->size, length, sizeof(f_string_range_t), (void **) & ranges->array); - - if (F_status_is_error_not(status)) { - ranges->size = length; - - if (ranges->used > ranges->size) { - ranges->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_ranges_decrease_) || !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_terminate_) || !defined(_di_f_string_ranges_terminate_after_) - -#if !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) - f_status_t private_f_string_rangess_adjust(const f_array_length_t length, f_string_rangess_t * const rangess) { - - if (rangess->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < rangess->size; ++i) { - - status = private_f_string_ranges_adjust(0, &rangess->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(rangess->size, length, sizeof(f_string_ranges_t), (void **) & rangess->array); - - if (F_status_is_error_not(status)) { - rangess->size = length; - - if (rangess->used > rangess->size) { - rangess->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) - -#if !defined(_di_f_string_rangess_decrease_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) || !defined(_di_f_string_rangess_terminate_) || !defined(_di_f_string_rangess_terminate_after_) - f_status_t private_f_string_rangess_resize(const f_array_length_t length, f_string_rangess_t * const rangess) { - - if (rangess->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < rangess->size; ++i) { - - status = private_f_string_ranges_resize(0, &rangess->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(rangess->size, length, sizeof(f_string_ranges_t), (void **) & rangess->array); - - if (F_status_is_error_not(status)) { - rangess->size = length; - - if (rangess->used > rangess->size) { - rangess->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_rangess_decrease_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) || !defined(_di_f_string_rangess_terminate_) || !defined(_di_f_string_rangess_terminate_after_) - -#if !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - f_status_t private_f_string_triples_adjust(const f_array_length_t length, f_string_triples_t * const triples) { - - if (triples->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < triples->size; ++i) { - - status = private_f_string_dynamic_adjust(0, &triples->array[i].a); - if (F_status_is_error(status)) return status; - - status = private_f_string_dynamic_adjust(0, &triples->array[i].b); - if (F_status_is_error(status)) return status; - - status = private_f_string_dynamic_adjust(0, &triples->array[i].c); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(triples->size, length, sizeof(f_string_triple_t), (void **) & triples->array); - - if (F_status_is_error_not(status)) { - triples->size = length; - - if (triples->used > triples->size) { - triples->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - -#if !defined(_di_f_string_triples_decrease_) || !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) - f_status_t private_f_string_triples_resize(const f_array_length_t length, f_string_triples_t * const triples) { - - if (triples->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < triples->size; ++i) { - - status = private_f_string_dynamic_resize(0, &triples->array[i].a); - if (F_status_is_error(status)) return status; - - status = private_f_string_dynamic_resize(0, &triples->array[i].b); - if (F_status_is_error(status)) return status; - - status = private_f_string_dynamic_resize(0, &triples->array[i].c); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(triples->size, length, sizeof(f_string_triple_t), (void **) & triples->array); - - if (F_status_is_error_not(status)) { - triples->size = length; - - if (triples->used > triples->size) { - triples->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_triples_decrease_) || !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) - -#if !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) - f_status_t private_f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless) { - - if (tripless->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < tripless->size; ++i) { - - status = private_f_string_triples_adjust(0, &tripless->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(tripless->size, length, sizeof(f_string_triples_t), (void **) & tripless->array); - - if (F_status_is_error_not(status)) { - tripless->size = length; - - if (tripless->used > tripless->size) { - tripless->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) - -#if !defined(_di_f_string_tripless_decrease_) || !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) - f_status_t private_f_string_tripless_resize(const f_array_length_t length, f_string_tripless_t * const tripless) { - - if (tripless->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < tripless->size; ++i) { - - status = private_f_string_triples_resize(0, &tripless->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(tripless->size, length, sizeof(f_string_triples_t), (void **) & tripless->array); - - if (F_status_is_error_not(status)) { - tripless->size = length; - - if (tripless->used > tripless->size) { - tripless->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_tripless_decrease_) || !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/private-string.h b/level_0/f_string/c/private-string.h index c76fce003..8217b5f83 100644 --- a/level_0/f_string/c/private-string.h +++ b/level_0/f_string/c/private-string.h @@ -87,602 +87,6 @@ extern "C" { extern f_status_t private_f_string_append_nulless(const f_string_t source, const f_array_length_t length, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_string_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamic - * The string to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_dynamic_adjust() - * @see f_string_dynamic_decimate_by() - * @see f_string_dynamics_adjust() - * @see f_string_dynamics_append() - * @see f_string_dynamics_decimate_by() - * @see f_string_map_multis_adjust() - * @see f_string_map_multis_append() - * @see f_string_triples_adjust() - * @see f_string_triples_decimate_by() - */ -#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - extern f_status_t private_f_string_dynamic_adjust(const f_array_length_t length, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - -/** - * Private implementation of f_string_dynamic_increase_by(). - * - * Intended to be shared to each of the different implementation variations. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param dynamic - * The string to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see memcpy() - * - * @see f_string_append() - * @see f_string_append_assure() - * @see f_string_append_mash() - * @see f_string_append_nulless() - * @see f_string_dynamic_append() - * @see f_string_dynamic_append_assure() - * @see f_string_dynamic_append_nulless() - * @see f_string_dynamic_increase_by() - * @see f_string_dynamic_mash() - * @see f_string_dynamic_mash_nulless() - * @see f_string_dynamic_partial_append) - * @see f_string_dynamic_partial_append_assure() - * @see f_string_dynamic_partial_mash() - * @see f_string_dynamic_prepend() - * @see f_string_dynamic_prepend_nulless() - * @see f_string_dynamics_append() - * @see f_string_map_multis_append() - * @see f_string_mash() - * @see f_string_mash_nulless() - * @see f_string_maps_append() - * @see f_string_prepend() - * @see f_string_prepend_nulless() - * @see f_string_triples_append() - */ -#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - extern f_status_t private_f_string_dynamic_increase_by(const f_array_length_t amount, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamic - * The string to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_append() - * @see f_string_append_assure() - * @see f_string_append_mash() - * @see f_string_append_nulless() - * @see f_string_dynamic_append() - * @see f_string_dynamic_append_assure() - * @see f_string_dynamic_append_nulless() - * @see f_string_dynamic_decrease_by() - * @see f_string_dynamic_increase() - * @see f_string_dynamic_increase_by() - * @see f_string_dynamic_mash() - * @see f_string_dynamic_mash_nulless() - * @see f_string_dynamic_partial_append) - * @see f_string_dynamic_partial_append_assure() - * @see f_string_dynamic_partial_mash() - * @see f_string_dynamic_prepend() - * @see f_string_dynamic_prepend_nulless() - * @see f_string_dynamic_terminate() - * @see f_string_dynamic_terminate_after() - * @see f_string_dynamics_append() - * @see f_string_map_multis_append() - * @see f_string_mash_nulless() - * @see f_string_mash() - * @see f_string_maps_append() - * @see f_string_prepend() - * @see f_string_prepend_nulless() - * @see f_string_triples_append() - */ -#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - extern f_status_t private_f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamics - * The strings to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_dynamics_adjust() - * @see f_string_dynamics_append() - * @see f_string_dynamics_decimate_by() - * @see f_string_map_multis_adjust() - * @see f_string_map_multis_append() - */ -#if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) - extern f_status_t private_f_string_dynamics_adjust(const f_array_length_t length, f_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source strings to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_dynamics_append() - * @see f_string_map_multis_append() - */ -#if !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) - extern f_status_t private_f_string_dynamics_append(const f_string_dynamics_t source, f_string_dynamics_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamics - * The strings to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_dynamics_decrease_by() - * @see f_string_dynamics_increase() - * @see f_string_dynamics_increase_by() - */ -#if !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) - extern f_status_t private_f_string_dynamics_resize(const f_array_length_t length, f_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamicss - * The strings to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_dynamicss_adjust() - * @see f_string_dynamicss_append() - * @see f_string_dynamicss_decimate_by() - * @see f_string_map_multis_adjust() - * @see f_string_map_multis_append() - */ -#if !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) - extern f_status_t private_f_string_dynamicss_adjust(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source strings to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_dynamicss_append() - * @see f_string_map_multis_append() - */ -#if !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_map_multis_append_) - extern f_status_t private_f_string_dynamicss_append(const f_string_dynamicss_t source, f_string_dynamicss_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_map_multis_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamicss - * The strings to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_dynamicss_decrease_by() - * @see f_string_dynamicss_increase() - * @see f_string_dynamicss_increase_by() - */ -#if !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) - extern f_status_t private_f_string_dynamicss_resize(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param map_multis - * The map_multis to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_map_multis_adjust() - */ -#if !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) - extern f_status_t private_f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t * const map_multis) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source multi-map to append. - * @param destination - * The destination multi-maps the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: f_string_map_multis_append(). - * Errors (with error bit) from: f_string_map_multiss_append(). - * - * @see f_memory_resize() - * @see f_string_map_multis_append() - * @see f_string_map_multiss_append() - */ -#if !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multis_append_) - extern f_status_t private_f_string_map_multis_append(const f_string_map_multi_t source, f_string_map_multis_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multis_append_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source multi-maps to append. - * @param destination - * The destination multi-maps the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: f_string_map_multis_append(). - * Errors (with error bit) from: f_string_map_multiss_append(). - * - * @see f_memory_resize() - * @see f_string_map_multis_append() - * @see f_string_map_multiss_append() - */ -#if !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multis_append_all_) - extern f_status_t private_f_string_map_multis_append_all(const f_string_map_multis_t source, f_string_map_multis_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multis_append_all_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param map_multis - * The map_multis to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_string_map_multis_decrease_by() - * @see f_string_map_multis_increase() - * @see f_string_map_multis_increase_by() - * @see f_string_map_multis_terminate() - * @see f_string_map_multis_terminate_after() - */ -#if !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) - extern f_status_t private_f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t * const map_multis) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param map_multiss - * The map_multiss to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_map_multiss_adjust() - */ -#if !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) - extern f_status_t private_f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param map_multiss - * The map_multiss to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_string_map_multiss_decrease_by() - * @see f_string_map_multiss_increase() - * @see f_string_map_multiss_increase_by() - * @see f_string_map_multiss_terminate() - * @see f_string_map_multiss_terminate_after() - */ -#if !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) - extern f_status_t private_f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param maps - * The maps to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_maps_adjust() - */ -#if !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) - extern f_status_t private_f_string_maps_adjust(const f_array_length_t length, f_string_maps_t * const maps) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source map to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_maps_append() - * @see f_string_mapss_append() - */ -#if !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_maps_append_) - extern f_status_t private_f_string_maps_append(const f_string_map_t source, f_string_maps_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_maps_append_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_maps_append() - * @see f_string_mapss_append() - */ -#if !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_maps_append_all_) - extern f_status_t private_f_string_maps_append_all(const f_string_maps_t source, f_string_maps_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_maps_append_all_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param maps - * The maps to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_string_maps_decrease_by() - * @see f_string_maps_increase() - * @see f_string_maps_increase_by() - * @see f_string_maps_terminate() - * @see f_string_maps_terminate_after() - */ -#if !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) - extern f_status_t private_f_string_maps_resize(const f_array_length_t length, f_string_maps_t * const maps) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param mapss - * The mapss to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_mapss_adjust() - */ -#if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) - extern f_status_t private_f_string_mapss_adjust(const f_array_length_t length, f_string_mapss_t * const mapss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param mapss - * The mapss to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_string_mapss_decrease_by() - * @see f_string_mapss_increase() - * @see f_string_mapss_increase_by() - * @see f_string_mapss_terminate() - * @see f_string_mapss_terminate_after() - */ -#if !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) - extern f_status_t private_f_string_mapss_resize(const f_array_length_t length, f_string_mapss_t * const mapss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) - /** * Private implementation of f_string_prepend(). * @@ -755,324 +159,6 @@ extern "C" { extern f_status_t private_f_string_prepend_nulless(const f_string_t source, f_array_length_t length, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_string_dynamic_mish_nulless_) || !defined(_di_f_string_dynamic_partial_mish_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_mish_nulless_) || !defined(_di_f_string_prepend_assure_nulless_) || !defined(_di_f_string_prepend_nulless_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantitys - * The quantitys to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_quantitys_adjust() - * @see f_string_quantitys_decimate_by() - */ -#if !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) - extern f_status_t private_f_string_quantitys_adjust(const f_array_length_t length, f_string_quantitys_t * const quantitys) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantitys - * The quantitys to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_quantitys_decrease_by() - * @see f_string_quantitys_increase() - * @see f_string_quantitys_increase_by() - * @see f_string_quantitys_terminate() - * @see f_string_quantitys_terminate_after() - */ -#if !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) || !defined(_di_f_string_quantitys_terminate_) || !defined(_di_f_string_quantitys_terminate_after_) - extern f_status_t private_f_string_quantitys_resize(const f_array_length_t length, f_string_quantitys_t * const quantitys) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) || !defined(_di_f_string_quantitys_terminate_) || !defined(_di_f_string_quantitys_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantityss - * The quantityss to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_quantityss_adjust() - * @see f_string_quantityss_decimate_by() - */ -#if !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) - extern f_status_t private_f_string_quantityss_adjust(const f_array_length_t length, f_string_quantityss_t * const quantityss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantityss - * The quantityss to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_quantityss_decrease_by() - * @see f_string_quantityss_increase() - * @see f_string_quantityss_increase_by() - * @see f_string_quantityss_terminate() - * @see f_string_quantityss_terminate_after() - */ -#if !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) || !defined(_di_f_string_quantityss_terminate_) || !defined(_di_f_string_quantityss_terminate_after_) - extern f_status_t private_f_string_quantityss_resize(const f_array_length_t length, f_string_quantityss_t * const quantityss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) || !defined(_di_f_string_quantityss_terminate_) || !defined(_di_f_string_quantityss_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param ranges - * The ranges to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_ranges_adjust() - * @see f_string_ranges_decimate_by() - */ -#if !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) - extern f_status_t private_f_string_ranges_adjust(const f_array_length_t length, f_string_ranges_t * const ranges) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param ranges - * The ranges to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_ranges_decrease_by() - * @see f_string_ranges_increase() - * @see f_string_ranges_increase_by() - * @see f_string_ranges_terminate() - * @see f_string_ranges_terminate_after() - */ -#if !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_terminate_) || !defined(_di_f_string_ranges_terminate_after_) - extern f_status_t private_f_string_ranges_resize(const f_array_length_t length, f_string_ranges_t * const ranges) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_terminate_) || !defined(_di_f_string_ranges_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param rangess - * The rangess to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_rangess_adjust() - * @see f_string_rangess_decimate_by() - */ -#if !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) - extern f_status_t private_f_string_rangess_adjust(const f_array_length_t length, f_string_rangess_t * const rangess) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param rangess - * The rangess to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_rangess_decrease_by() - * @see f_string_rangess_increase() - * @see f_string_rangess_increase_by() - * @see f_string_rangess_terminate() - * @see f_string_rangess_terminate_after() - */ -#if !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) || !defined(_di_f_string_rangess_terminate_) || !defined(_di_f_string_rangess_terminate_after_) - extern f_status_t private_f_string_rangess_resize(const f_array_length_t length, f_string_rangess_t * const rangess) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) || !defined(_di_f_string_rangess_terminate_) || !defined(_di_f_string_rangess_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param triples - * The triples to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_triples_adjust() - * @see f_string_triples_decimate_by() - */ -#if !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - extern f_status_t private_f_string_triples_adjust(const f_array_length_t length, f_string_triples_t * const triples) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param triples - * The triples to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_triples_decrease_by() - * @see f_string_triples_increase() - * @see f_string_triples_increase_by() - * @see f_string_triples_terminate() - * @see f_string_triples_terminate_after() - */ -#if !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) - extern f_status_t private_f_string_triples_resize(const f_array_length_t length, f_string_triples_t * const triples) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param tripless - * The tripless to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_tripless_adjust() - * @see f_string_tripless_decimate_by() - */ -#if !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) - extern f_status_t private_f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param tripless - * The tripless to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_tripless_decrease_by() - * @see f_string_tripless_increase() - * @see f_string_tripless_increase_by() - * @see f_string_tripless_terminate() - * @see f_string_tripless_terminate_after() - */ -#if !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) - extern f_status_t private_f_string_tripless_resize(const f_array_length_t length, f_string_tripless_t * const tripless) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string.h b/level_0/f_string/c/string.h index 8a853eca8..19746fa13 100644 --- a/level_0/f_string/c/string.h +++ b/level_0/f_string/c/string.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/level_0/f_string/c/string/dynamic.c b/level_0/f_string/c/string/dynamic.c index fc1cee043..c462b0ef5 100644 --- a/level_0/f_string/c/string/dynamic.c +++ b/level_0/f_string/c/string/dynamic.c @@ -1,5 +1,6 @@ #include "../string.h" #include "../private-string.h" +#include "private-dynamic.h" #ifdef __cplusplus extern "C" { @@ -21,9 +22,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; return private_f_string_append(source.string, source.used, destination); } @@ -35,9 +34,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; if (destination->used < source.used) { return private_f_string_append(source.string, source.used, destination); @@ -78,9 +75,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; if (destination->used < source.used) { return private_f_string_append_nulless(source.string, source.used, destination); @@ -121,9 +116,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; return private_f_string_append_nulless(source.string, source.used, destination); } @@ -135,9 +128,7 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (dynamic->size - amount > 0) { return private_f_string_dynamic_adjust(dynamic->size - amount, dynamic); @@ -153,9 +144,7 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (dynamic->size - amount > 0) { return private_f_string_dynamic_resize(dynamic->size - amount, dynamic); @@ -195,9 +184,7 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; return private_f_string_dynamic_increase_by(amount, dynamic); } @@ -209,9 +196,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; if (glue.used && destination->used) { const f_status_t status = private_f_string_append(glue.string, glue.used, destination); @@ -228,9 +213,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; if (glue.used && destination->used) { const f_status_t status = private_f_string_append_nulless(glue.string, glue.used, destination); @@ -247,9 +230,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; if (glue.used && destination->used) { const f_status_t status = private_f_string_prepend(glue.string, glue.used, destination); @@ -266,9 +247,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; if (glue.used && destination->used) { const f_status_t status = private_f_string_prepend_nulless(glue.string, glue.used, destination); @@ -282,16 +261,15 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_append_ f_status_t f_string_dynamic_partial_append(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (range.stop >= source.used) { + return private_f_string_append(source.string + range.start, source.used - range.start, destination); } return private_f_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -301,19 +279,14 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_append_assure_ f_status_t f_string_dynamic_partial_append_assure(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - const f_array_length_t length = (range.stop - range.start) + 1; + const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; if (destination->used < length) { return private_f_string_append(source.string + range.start, length, destination); @@ -351,19 +324,14 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_append_assure_nulless_ f_status_t f_string_dynamic_partial_append_assure_nulless(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - const f_array_length_t length = (range.stop - range.start) + 1; + const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; if (destination->used < length) { return private_f_string_append_nulless(source.string + range.start, length, destination); @@ -401,16 +369,15 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_append_nulless_ f_status_t f_string_dynamic_partial_append_nulless(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (range.stop >= source.used) { + return private_f_string_append_nulless(source.string + range.start, source.used - range.start, destination); } return private_f_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -420,23 +387,22 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_mash_ f_status_t f_string_dynamic_partial_mash(const f_string_static_t glue, const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; if (glue.used && destination->used) { - f_status_t status = private_f_string_append(glue.string, glue.used, destination); + const f_status_t status = private_f_string_append(glue.string, glue.used, destination); if (F_status_is_error(status)) return status; } + if (range.stop >= source.used) { + return private_f_string_append(source.string + range.start, source.used - range.start, destination); + } + return private_f_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); } #endif // _di_f_string_dynamic_partial_mash_ @@ -444,23 +410,22 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_mash_nulless_ f_status_t f_string_dynamic_partial_mash_nulless(const f_string_static_t glue, const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; if (glue.used && destination->used) { - f_status_t status = private_f_string_append_nulless(glue.string, glue.used, destination); + const f_status_t status = private_f_string_append_nulless(glue.string, glue.used, destination); if (F_status_is_error(status)) return status; } + if (range.stop >= source.used) { + return private_f_string_append(source.string + range.start, source.used - range.start, destination); + } + return private_f_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); } #endif // _di_f_string_dynamic_partial_mash_nulless_ @@ -468,23 +433,22 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_mish_ f_status_t f_string_partial_dynamic_mish(const f_string_static_t glue, const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; if (glue.used && destination->used) { - f_status_t status = private_f_string_prepend(glue.string, glue.used, destination); + const f_status_t status = private_f_string_prepend(glue.string, glue.used, destination); if (F_status_is_error(status)) return status; } + if (range.stop >= source.used) { + return private_f_string_append(source.string + range.start, source.used - range.start, destination); + } + return private_f_string_prepend(source.string + range.start, (range.stop - range.start) + 1, destination); } #endif // _di_f_string_dynamic_partial_mish_ @@ -492,23 +456,22 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_mish_nulless_ f_status_t f_string_dynamic_partial_mish_nulless(const f_string_static_t glue, const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; if (glue.used && destination->used) { - f_status_t status = private_f_string_prepend_nulless(glue.string, glue.used, destination); + const f_status_t status = private_f_string_prepend_nulless(glue.string, glue.used, destination); if (F_status_is_error(status)) return status; } + if (range.stop >= source.used) { + return private_f_string_append(source.string + range.start, source.used - range.start, destination); + } + return private_f_string_prepend_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); } #endif // _di_f_string_dynamic_partial_mish_nulless_ @@ -516,16 +479,15 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_prepend_ f_status_t f_string_dynamic_partial_prepend(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (range.stop >= source.used) { + return private_f_string_append(source.string + range.start, source.used - range.start, destination); } return private_f_string_prepend(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -535,19 +497,14 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_prepend_assure_ f_status_t f_string_dynamic_partial_prepend_assure(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - const f_array_length_t length = (range.stop - range.start) + 1; + const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; if (destination->used < length) { return private_f_string_prepend(source.string + range.start, length, destination); @@ -585,19 +542,14 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_prepend_assure_nulless_ f_status_t f_string_dynamic_partial_prepend_assure_nulless(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - const f_array_length_t length = (range.stop - range.start) + 1; + const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; if (destination->used < length) { return private_f_string_prepend_nulless(source.string + range.start, length, destination); @@ -635,17 +587,12 @@ extern "C" { #ifndef _di_f_string_dynamic_partial_prepend_nulless_ f_status_t f_string_dynamic_partial_prepend_nulless(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; return private_f_string_prepend_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); } @@ -657,9 +604,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; return private_f_string_prepend(source.string, source.used, destination); } @@ -671,9 +616,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; if (destination->used < source.used) { return private_f_string_prepend(source.string, source.used, destination); @@ -714,9 +657,7 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; - } + if (!source.used) return F_data_not; if (destination->used < source.used) { return private_f_string_prepend_nulless(source.string, source.used, destination); @@ -901,28 +842,36 @@ extern "C" { #endif // _di_f_string_dynamics_adjust_ #ifndef _di_f_string_dynamics_append_ - f_status_t f_string_dynamics_append(const f_string_dynamics_t source, f_string_dynamics_t * const destination) { + f_status_t f_string_dynamics_append(const f_string_dynamic_t source, f_string_dynamics_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; - } + if (!source.used) return F_data_not; return private_f_string_dynamics_append(source, destination); } #endif // _di_f_string_dynamics_append_ +#ifndef _di_f_string_dynamics_append_all_ + f_status_t f_string_dynamics_append_all(const f_string_dynamics_t source, f_string_dynamics_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; + + return private_f_string_dynamics_append_all(source, destination); + } +#endif // _di_f_string_dynamics_append_all_ + #ifndef _di_f_string_dynamics_decimate_by_ f_status_t f_string_dynamics_decimate_by(const f_array_length_t amount, f_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (dynamics->size - amount > 0) { return private_f_string_dynamics_adjust(dynamics->size - amount, dynamics); @@ -938,9 +887,7 @@ extern "C" { if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (dynamics->size - amount > 0) { return private_f_string_dynamics_resize(dynamics->size - amount, dynamics); @@ -956,9 +903,7 @@ extern "C" { if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!step) { - return F_data_not; - } + if (!step) return F_data_not; if (dynamics->used + 1 > dynamics->size) { f_array_length_t size = dynamics->used + step; @@ -1017,28 +962,69 @@ extern "C" { #endif // _di_f_string_dynamicss_adjust_ #ifndef _di_f_string_dynamicss_append_ - f_status_t f_string_dynamicss_append(const f_string_dynamicss_t source, f_string_dynamicss_t * const destination) { + f_status_t f_string_dynamicss_append(const f_string_dynamics_t source, f_string_dynamicss_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; + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_string_dynamicss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_string_dynamics_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; } - return private_f_string_dynamicss_append(source, destination); + ++destination->used; + + return F_none; } #endif // _di_f_string_dynamicss_append_ +#ifndef _di_f_string_dynamicss_append_all_ + f_status_t f_string_dynamicss_append_all(const f_string_dynamicss_t source, f_string_dynamicss_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_string_dynamicss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_string_dynamics_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_string_dynamicss_append_all_ + #ifndef _di_f_string_dynamicss_decimate_by_ f_status_t f_string_dynamicss_decimate_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss) { #ifndef _di_level_0_parameter_checking_ if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (dynamicss->size - amount > 0) { return private_f_string_dynamicss_adjust(dynamicss->size - amount, dynamicss); @@ -1054,9 +1040,7 @@ extern "C" { if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (dynamicss->size - amount > 0) { return private_f_string_dynamicss_resize(dynamicss->size - amount, dynamicss); @@ -1072,9 +1056,7 @@ extern "C" { if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!step) { - return F_data_not; - } + if (!step) return F_data_not; if (dynamicss->used + 1 > dynamicss->size) { f_array_length_t size = dynamicss->used + step; @@ -1100,9 +1082,7 @@ extern "C" { if (!dynamicss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (dynamicss->used + amount > dynamicss->size) { if (dynamicss->used + amount > F_array_length_t_size_d) { diff --git a/level_0/f_string/c/string/dynamic.h b/level_0/f_string/c/string/dynamic.h index 126bfa3ab..be5e8aa61 100644 --- a/level_0/f_string/c/string/dynamic.h +++ b/level_0/f_string/c/string/dynamic.h @@ -422,6 +422,8 @@ extern "C" { /** * Append the source string onto the destination, but restricted to the given range. * + * If range.stop is on or after source.used, then source.used - 1 is used as the stopping point. + * * @param source * The source string to append. * @param range @@ -432,6 +434,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -458,6 +461,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -486,6 +490,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -512,6 +517,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -540,6 +546,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -570,6 +577,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -598,6 +606,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -628,6 +637,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -654,6 +664,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -682,6 +693,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -710,6 +722,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -736,6 +749,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -760,7 +774,6 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -786,7 +799,6 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -812,7 +824,6 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -836,7 +847,6 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -1010,10 +1020,10 @@ extern "C" { #endif // _di_f_string_dynamics_adjust_ /** - * Append the source strings onto the destination. + * Append the single source string onto the destination. * * @param source - * The source strings to append. + * The source string to append. * @param destination * The destination strings the source is appended onto. * @@ -1027,9 +1037,30 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_dynamics_append_ - extern f_status_t f_string_dynamics_append(const f_string_dynamics_t source, f_string_dynamics_t * const destination); + extern f_status_t f_string_dynamics_append(const f_string_dynamic_t source, f_string_dynamics_t * const destination); #endif // _di_f_string_dynamics_append_ +/** + * Append the source strings onto the destination. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_dynamics_append_all_ + extern f_status_t f_string_dynamics_append_all(const f_string_dynamics_t source, f_string_dynamics_t * const destination); +#endif // _di_f_string_dynamics_append_all_ + /** * Resize the dynamic string array to a smaller size. * @@ -1167,10 +1198,10 @@ extern "C" { #endif // _di_f_string_dynamicss_adjust_ /** - * Append the source strings onto the destination. + * Append the single source string onto the destination. * * @param source - * The source strings to append. + * The source string to append. * @param destination * The destination strings the source is appended onto. * @@ -1184,9 +1215,30 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_dynamicss_append_ - extern f_status_t f_string_dynamicss_append(const f_string_dynamicss_t source, f_string_dynamicss_t * const destination); + extern f_status_t f_string_dynamicss_append(const f_string_dynamics_t source, f_string_dynamicss_t * const destination); #endif // _di_f_string_dynamicss_append_ +/** + * Append the source strings onto the destination. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_dynamicss_append_all_ + extern f_status_t f_string_dynamicss_append_all(const f_string_dynamicss_t source, f_string_dynamicss_t * const destination); +#endif // _di_f_string_dynamicss_append_all_ + /** * Resize the dynamics string array to a smaller size. * diff --git a/level_0/f_string/c/string/map.c b/level_0/f_string/c/string/map.c index 7bcfb7d29..a3ea79710 100644 --- a/level_0/f_string/c/string/map.c +++ b/level_0/f_string/c/string/map.c @@ -1,22 +1,23 @@ #include "../string.h" #include "../private-string.h" +#include "private-map.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_map_multis_adjust_ - f_status_t f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t * const map_multis) { +#ifndef _di_f_string_maps_adjust_ + f_status_t f_string_maps_adjust(const f_array_length_t length, f_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_map_multis_adjust(length, map_multis); + return private_f_string_maps_adjust(length, maps); } -#endif // _di_f_string_map_multis_adjust_ +#endif // _di_f_string_maps_adjust_ -#ifndef _di_f_string_map_multis_append_ - f_status_t f_string_map_multis_append(const f_string_map_multi_t source, f_string_map_multis_t * const destination) { +#ifndef _di_f_string_maps_append_ + f_status_t f_string_maps_append(const f_string_map_t source, f_string_maps_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -24,7 +25,7 @@ extern "C" { f_status_t status = F_none; if (destination->used + 1 > destination->size) { - status = private_f_string_map_multis_resize(destination->used + F_memory_default_allocation_small_d, destination); + status = private_f_string_maps_resize(destination->used + F_memory_default_allocation_small_d, destination); if (F_status_is_error(status)) return status; } @@ -37,168 +38,7 @@ extern "C" { } if (source.value.used) { - status = private_f_string_dynamics_append(source.value, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - - ++destination->used; - - return F_none; - } -#endif // _di_f_string_map_multis_append_ - -#ifndef _di_f_string_map_multis_append_all_ - f_status_t f_string_map_multis_append_all(const f_string_map_multis_t source, f_string_map_multis_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_string_map_multis_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; - - if (source.array[i].name.used) { - status = private_f_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } - - if (source.array[i].value.used) { - status = private_f_string_dynamics_append(source.array[i].value, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // _di_f_string_map_multis_append_all_ - -#ifndef _di_f_string_map_multis_decimate_by_ - f_status_t f_string_map_multis_decimate_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (map_multis->size - amount > 0) { - return private_f_string_map_multis_adjust(map_multis->size - amount, map_multis); - } - - return private_f_string_map_multis_adjust(0, map_multis); - } -#endif // _di_f_string_map_multis_decimate_by_ - -#ifndef _di_f_string_map_multis_decrease_by_ - f_status_t f_string_map_multis_decrease_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (map_multis->size - amount > 0) { - return private_f_string_map_multis_resize(map_multis->size - amount, map_multis); - } - - return private_f_string_map_multis_resize(0, map_multis); - } -#endif // _di_f_string_map_multis_decrease_by_ - -#ifndef _di_f_string_map_multis_increase_ - f_status_t f_string_map_multis_increase(const f_array_length_t step, f_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && map_multis->used + 1 > map_multis->size) { - f_array_length_t size = map_multis->used + step; - - if (size > F_array_length_t_size_d) { - if (map_multis->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_string_map_multis_resize(size, map_multis); - } - - return F_data_not; - } -#endif // _di_f_string_map_multis_increase_ - -#ifndef _di_f_string_map_multis_increase_by_ - f_status_t f_string_map_multis_increase_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (map_multis->used + amount > map_multis->size) { - if (map_multis->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_string_map_multis_resize(map_multis->used + amount, map_multis); - } - - return F_data_not; - } -#endif // _di_f_string_map_multis_increase_by_ - -#ifndef _di_f_string_map_multis_resize_ - f_status_t f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t * const map_multis) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_map_multis_resize(length, map_multis); - } -#endif // _di_f_string_map_multis_resize_ - -#ifndef _di_f_string_map_multiss_adjust_ - f_status_t f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_map_multiss_adjust(length, map_multiss); - } -#endif // _di_f_string_map_multiss_adjust_ - -#ifndef _di_f_string_map_multiss_append_ - f_status_t f_string_map_multiss_append(const f_string_map_multis_t source, f_string_map_multiss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - f_status_t status = F_none; - - if (destination->used + 1 > destination->size) { - status = private_f_string_map_multiss_resize(destination->used + F_memory_default_allocation_small_d, destination); - if (F_status_is_error(status)) return status; - } - - destination->array[destination->used].used = 0; - - if (source.used) { - status = private_f_string_map_multis_append_all(source, &destination->array[destination->used]); + status = private_f_string_append(source.value.string, source.value.used, &destination->array[destination->used].value); if (F_status_is_error(status)) return status; } @@ -206,145 +46,6 @@ extern "C" { return F_none; } -#endif // _di_f_string_map_multiss_append_ - -#ifndef _di_f_string_map_multiss_append_all_ - f_status_t f_string_map_multiss_append_all(const f_string_map_multiss_t source, f_string_map_multiss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_string_map_multiss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_string_map_multis_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // _di_f_string_map_multiss_append_all_ - -#ifndef _di_f_string_map_multiss_decimate_by_ - f_status_t f_string_map_multiss_decimate_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (map_multiss->size - amount > 0) { - return private_f_string_map_multiss_adjust(map_multiss->size - amount, map_multiss); - } - - return private_f_string_map_multiss_adjust(0, map_multiss); - } -#endif // _di_f_string_map_multiss_decimate_by_ - -#ifndef _di_f_string_map_multiss_decrease_by_ - f_status_t f_string_map_multiss_decrease_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (map_multiss->size - amount > 0) { - return private_f_string_map_multiss_resize(map_multiss->size - amount, map_multiss); - } - - return private_f_string_map_multiss_resize(0, map_multiss); - } -#endif // _di_f_string_map_multiss_decrease_by_ - -#ifndef _di_f_string_map_multiss_increase_ - f_status_t f_string_map_multiss_increase(const f_array_length_t step, f_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && map_multiss->used + 1 > map_multiss->size) { - f_array_length_t size = map_multiss->used + step; - - if (size > F_array_length_t_size_d) { - if (map_multiss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_string_map_multiss_resize(size, map_multiss); - } - - return F_data_not; - } -#endif // _di_f_string_map_multiss_increase_ - -#ifndef _di_f_string_map_multiss_increase_by_ - f_status_t f_string_map_multiss_increase_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (map_multiss->used + amount > map_multiss->size) { - if (map_multiss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_string_map_multiss_resize(map_multiss->used + amount, map_multiss); - } - - return F_data_not; - } -#endif // _di_f_string_map_multiss_increase_by_ - -#ifndef _di_f_string_map_multiss_resize_ - f_status_t f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { - #ifndef _di_level_0_parameter_checking_ - if (!map_multiss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_map_multiss_resize(length, map_multiss); - } -#endif // _di_f_string_map_multiss_resize_ - -#ifndef _di_f_string_maps_adjust_ - f_status_t f_string_maps_adjust(const f_array_length_t length, f_string_maps_t * const maps) { - #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_maps_adjust(length, maps); - } -#endif // _di_f_string_maps_adjust_ - -#ifndef _di_f_string_maps_append_ - f_status_t f_string_maps_append(const f_string_map_t source, f_string_maps_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_maps_append(source, destination); - } #endif // _di_f_string_maps_append_ #ifndef _di_f_string_maps_append_all_ @@ -365,9 +66,7 @@ extern "C" { if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (maps->size - amount > 0) { return private_f_string_maps_adjust(maps->size - amount, maps); @@ -383,9 +82,7 @@ extern "C" { if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (maps->size - amount > 0) { return private_f_string_maps_resize(maps->size - amount, maps); @@ -425,9 +122,7 @@ extern "C" { if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (maps->used + amount > maps->size) { if (maps->used + amount > F_array_length_t_size_d) { @@ -524,9 +219,7 @@ extern "C" { if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (mapss->size - amount > 0) { return private_f_string_mapss_adjust(mapss->size - amount, mapss); @@ -542,9 +235,7 @@ extern "C" { if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (mapss->size - amount > 0) { return private_f_string_mapss_resize(mapss->size - amount, mapss); @@ -584,9 +275,7 @@ extern "C" { if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (mapss->used + amount > mapss->size) { if (mapss->used + amount > F_array_length_t_size_d) { diff --git a/level_0/f_string/c/string/map.h b/level_0/f_string/c/string/map.h index c54d47ddd..2f7e3914b 100644 --- a/level_0/f_string/c/string/map.h +++ b/level_0/f_string/c/string/map.h @@ -113,279 +113,6 @@ extern "C" { #define macro_f_string_mapss_t_decimate_by(status, maps, amount) status = f_string_mapss_decimate_by(amount, maps); #endif // _di_f_string_mapss_t_ -/** - * A string map consisting of a name and multiple values. - * - * name: A string representing the map name. - * value: An array of strings representing the map value. - */ -#ifndef _di_f_string_map_multi_t_ - typedef struct { - f_string_dynamic_t name; - f_string_dynamics_t value; - } f_string_map_multi_t; - - #define f_string_map_multi_t_initialize { f_string_dynamic_t_initialize, f_string_dynamics_t_initialize } - - #define macro_f_string_map_t_initialize(name, value) { name, value } - - #define macro_f_string_map_multi_t_clear(map) \ - macro_f_string_dynamic_t_clear(map.name) \ - macro_f_string_dynamics_t_clear(map.value) - - #define macro_f_string_map_multi_t_delete_simple(map) \ - macro_f_string_dynamic_t_delete_simple(map.name) \ - macro_f_string_dynamics_t_delete_simple(map.value) - - #define macro_f_string_map_multi_t_destroy_simple(map) \ - macro_f_string_dynamic_t_destroy_simple(map.name) \ - macro_f_string_dynamics_t_destroy_simple(map.value) -#endif // _di_f_string_map_multi_t_ - -/** - * An array of string maps. - * - * array: the array of string maps. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_string_map_multis_t_ - typedef struct { - f_string_map_multi_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_string_map_multis_t; - - #define f_string_map_multis_t_initialize f_string_statics_t_initialize - - #define macro_f_string_map_multis_t_initialize(array, size, used) { array, size, used } - #define macro_f_string_map_multis_t_initialize2(array, length) { array, length, length } - - #define macro_f_string_map_multis_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) - - #define macro_f_string_map_multis_t_resize(status, map_multis, length) status = f_string_map_multis_resize(length, &map_multis); - #define macro_f_string_map_multis_t_adjust(status, map_multis, length) status = f_string_map_multis_adjust(length, &map_multis); - - #define macro_f_string_map_multis_t_delete_simple(map_multis) f_string_map_multis_resize(0, &map_multis); - #define macro_f_string_map_multis_t_destroy_simple(map_multis) f_string_map_multis_adjust(0, &map_multis); - - #define macro_f_string_map_multis_t_increase(status, step, map_multis) status = f_string_map_multis_increase(step, &map_multis); - #define macro_f_string_map_multis_t_increase_by(status, map_multis, amount) status = f_string_map_multis_increase_by(amount, &map_multis); - #define macro_f_string_map_multis_t_decrease_by(status, map_multis, amount) status = f_string_map_multis_decrease_by(amount, &map_multis); - #define macro_f_string_map_multis_t_decimate_by(status, map_multis, amount) status = f_string_map_multis_decimate_by(amount, &map_multis); -#endif // _di_f_string_map_multis_t_ - -/** - * An array of string maps. - * - * array: the array of an array of string maps. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_string_map_multiss_t_ - typedef struct { - f_string_map_multis_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_string_map_multiss_t; - - #define f_string_map_multiss_t_initialize f_string_statics_t_initialize - - #define macro_f_string_map_multiss_t_initialize(array, size, used) { array, size, used } - #define macro_f_string_map_multiss_t_initialize2(array, length) { array, length, length } - - #define macro_f_string_map_multiss_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) - - #define macro_f_string_map_multiss_t_resize(status, map_multis, length) status = f_string_map_multiss_resize(length, &map_multis); - #define macro_f_string_map_multiss_t_adjust(status, map_multis, length) status = f_string_map_multiss_adjust(length, &map_multis); - - #define macro_f_string_map_multiss_t_delete_simple(map_multis) f_string_map_multiss_resize(0, &map_multis); - #define macro_f_string_map_multiss_t_destroy_simple(map_multis) f_string_map_multiss_adjust(0, &map_multis); - - #define macro_f_string_map_multiss_t_increase(status, step, map_multis) status = f_string_map_multiss_increase(step, &map_multis); - #define macro_f_string_map_multiss_t_increase_by(status, map_multis, amount) status = f_string_map_multiss_increase_by(amount, &map_multis); - #define macro_f_string_map_multiss_t_decrease_by(status, map_multis, amount) status = f_string_map_multiss_decrease_by(amount, &map_multis); - #define macro_f_string_map_multiss_t_decimate_by(status, map_multis, amount) status = f_string_map_multiss_decimate_by(amount, &map_multis); -#endif // _di_f_string_map_multiss_t_ - -/** - * Resize the map_multis array. - * - * @param length - * The new size to use. - * @param map_multis - * The map_multis 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(). - */ -#ifndef _di_f_string_map_multis_adjust_ - extern f_status_t f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t * const map_multis); -#endif // _di_f_string_map_multis_adjust_ - -/** - * Append a single source map_multi onto the destination. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_map_multis_append_ - f_status_t f_string_map_multis_append(const f_string_map_multi_t source, f_string_map_multis_t *destination); -#endif // _di_f_string_map_multis_append_ - -/** - * Append the source map_multis onto the destination. - * - * @param source - * The source maps to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_map_multis_append_all_ - f_status_t f_string_map_multis_append_all(const f_string_map_multis_t source, f_string_map_multis_t *destination); -#endif // _di_f_string_map_multis_append_all_ - -/** - * Resize the map_multis 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 map_multis - * The map_multis 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(). - */ -#ifndef _di_f_string_map_multis_decimate_by_ - extern f_status_t f_string_map_multis_decimate_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis); -#endif // _di_f_string_map_multis_decimate_by_ - -/** - * Resize the map_multis 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 map_multis - * The map_multis 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(). - */ -#ifndef _di_f_string_map_multis_decrease_by_ - extern f_status_t f_string_map_multis_decrease_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis); -#endif // _di_f_string_map_multis_decrease_by_ - -/** - * Increase the size of the map_multis array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 map_multis - * The map_multis 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(). - */ -#ifndef _di_f_string_map_multis_increase_ - extern f_status_t f_string_map_multis_increase(const f_array_length_t step, f_string_map_multis_t * const map_multis); -#endif // _di_f_string_map_multis_increase_ - -/** - * Resize the map_multis array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 map_multis - * The map_multis 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(). - */ -#ifndef _di_f_string_map_multis_increase_by_ - extern f_status_t f_string_map_multis_increase_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis); -#endif // _di_f_string_map_multis_increase_by_ - -/** - * Resize the map_multis array. - * - * @param length - * The new size to use. - * @param map_multis - * The map_multis 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(). - */ -#ifndef _di_f_string_map_multis_resize_ - extern f_status_t f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t * const map_multis); -#endif // _di_f_string_map_multis_resize_ - /** * Resize the string maps array. * diff --git a/level_0/f_string/c/string/map_multi.c b/level_0/f_string/c/string/map_multi.c new file mode 100644 index 000000000..27faa0ca0 --- /dev/null +++ b/level_0/f_string/c/string/map_multi.c @@ -0,0 +1,305 @@ +#include "../string.h" +#include "../private-string.h" +#include "private-dynamic.h" +#include "private-map_multi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_string_map_multis_adjust_ + f_status_t f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_map_multis_adjust(length, map_multis); + } +#endif // _di_f_string_map_multis_adjust_ + +#ifndef _di_f_string_map_multis_append_ + f_status_t f_string_map_multis_append(const f_string_map_multi_t source, f_string_map_multis_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_string_map_multis_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.name.used) { + status = private_f_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.value.used) { + status = private_f_string_dynamics_append_all(source.value, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_string_map_multis_append_ + +#ifndef _di_f_string_map_multis_append_all_ + f_status_t f_string_map_multis_append_all(const f_string_map_multis_t source, f_string_map_multis_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; + + return private_f_string_map_multis_append_all(source, destination); + } +#endif // _di_f_string_map_multis_append_all_ + +#ifndef _di_f_string_map_multis_decimate_by_ + f_status_t f_string_map_multis_decimate_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->size - amount > 0) { + return private_f_string_map_multis_adjust(map_multis->size - amount, map_multis); + } + + return private_f_string_map_multis_adjust(0, map_multis); + } +#endif // _di_f_string_map_multis_decimate_by_ + +#ifndef _di_f_string_map_multis_decrease_by_ + f_status_t f_string_map_multis_decrease_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->size - amount > 0) { + return private_f_string_map_multis_resize(map_multis->size - amount, map_multis); + } + + return private_f_string_map_multis_resize(0, map_multis); + } +#endif // _di_f_string_map_multis_decrease_by_ + +#ifndef _di_f_string_map_multis_increase_ + f_status_t f_string_map_multis_increase(const f_array_length_t step, f_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && map_multis->used + 1 > map_multis->size) { + f_array_length_t size = map_multis->used + step; + + if (size > F_array_length_t_size_d) { + if (map_multis->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_string_map_multis_resize(size, map_multis); + } + + return F_data_not; + } +#endif // _di_f_string_map_multis_increase_ + +#ifndef _di_f_string_map_multis_increase_by_ + f_status_t f_string_map_multis_increase_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->used + amount > map_multis->size) { + if (map_multis->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_string_map_multis_resize(map_multis->used + amount, map_multis); + } + + return F_data_not; + } +#endif // _di_f_string_map_multis_increase_by_ + +#ifndef _di_f_string_map_multis_resize_ + f_status_t f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_map_multis_resize(length, map_multis); + } +#endif // _di_f_string_map_multis_resize_ + +#ifndef _di_f_string_map_multiss_adjust_ + f_status_t f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_map_multiss_adjust(length, map_multiss); + } +#endif // _di_f_string_map_multiss_adjust_ + +#ifndef _di_f_string_map_multiss_append_ + f_status_t f_string_map_multiss_append(const f_string_map_multis_t source, f_string_map_multiss_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_string_map_multiss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_string_map_multis_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_string_map_multiss_append_ + +#ifndef _di_f_string_map_multiss_append_all_ + f_status_t f_string_map_multiss_append_all(const f_string_map_multiss_t source, f_string_map_multiss_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_string_map_multiss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_string_map_multis_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_string_map_multiss_append_all_ + +#ifndef _di_f_string_map_multiss_decimate_by_ + f_status_t f_string_map_multiss_decimate_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->size - amount > 0) { + return private_f_string_map_multiss_adjust(map_multiss->size - amount, map_multiss); + } + + return private_f_string_map_multiss_adjust(0, map_multiss); + } +#endif // _di_f_string_map_multiss_decimate_by_ + +#ifndef _di_f_string_map_multiss_decrease_by_ + f_status_t f_string_map_multiss_decrease_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->size - amount > 0) { + return private_f_string_map_multiss_resize(map_multiss->size - amount, map_multiss); + } + + return private_f_string_map_multiss_resize(0, map_multiss); + } +#endif // _di_f_string_map_multiss_decrease_by_ + +#ifndef _di_f_string_map_multiss_increase_ + f_status_t f_string_map_multiss_increase(const f_array_length_t step, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && map_multiss->used + 1 > map_multiss->size) { + f_array_length_t size = map_multiss->used + step; + + if (size > F_array_length_t_size_d) { + if (map_multiss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_string_map_multiss_resize(size, map_multiss); + } + + return F_data_not; + } +#endif // _di_f_string_map_multiss_increase_ + +#ifndef _di_f_string_map_multiss_increase_by_ + f_status_t f_string_map_multiss_increase_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->used + amount > map_multiss->size) { + if (map_multiss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_string_map_multiss_resize(map_multiss->used + amount, map_multiss); + } + + return F_data_not; + } +#endif // _di_f_string_map_multiss_increase_by_ + +#ifndef _di_f_string_map_multiss_resize_ + f_status_t f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_map_multiss_resize(length, map_multiss); + } +#endif // _di_f_string_map_multiss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/c/string/map_multi.h b/level_0/f_string/c/string/map_multi.h new file mode 100644 index 000000000..afcb054e1 --- /dev/null +++ b/level_0/f_string/c/string/map_multi.h @@ -0,0 +1,472 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines map string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_string_map_multi_h +#define _F_string_map_multi_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A string map consisting of a name and multiple values. + * + * name: A string representing the map name. + * value: An array of strings representing the map value. + */ +#ifndef _di_f_string_map_multi_t_ + typedef struct { + f_string_dynamic_t name; + f_string_dynamics_t value; + } f_string_map_multi_t; + + #define f_string_map_multi_t_initialize { f_string_dynamic_t_initialize, f_string_dynamics_t_initialize } + + #define macro_f_string_map_t_initialize(name, value) { name, value } + + #define macro_f_string_map_multi_t_clear(map) \ + macro_f_string_dynamic_t_clear(map.name) \ + macro_f_string_dynamics_t_clear(map.value) + + #define macro_f_string_map_multi_t_delete_simple(map) \ + macro_f_string_dynamic_t_delete_simple(map.name) \ + macro_f_string_dynamics_t_delete_simple(map.value) + + #define macro_f_string_map_multi_t_destroy_simple(map) \ + macro_f_string_dynamic_t_destroy_simple(map.name) \ + macro_f_string_dynamics_t_destroy_simple(map.value) +#endif // _di_f_string_map_multi_t_ + +/** + * An array of string maps. + * + * array: the array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_string_map_multis_t_ + typedef struct { + f_string_map_multi_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_string_map_multis_t; + + #define f_string_map_multis_t_initialize f_string_statics_t_initialize + + #define macro_f_string_map_multis_t_initialize(array, size, used) { array, size, used } + #define macro_f_string_map_multis_t_initialize2(array, length) { array, length, length } + + #define macro_f_string_map_multis_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) + + #define macro_f_string_map_multis_t_resize(status, map_multis, length) status = f_string_map_multis_resize(length, &map_multis); + #define macro_f_string_map_multis_t_adjust(status, map_multis, length) status = f_string_map_multis_adjust(length, &map_multis); + + #define macro_f_string_map_multis_t_delete_simple(map_multis) f_string_map_multis_resize(0, &map_multis); + #define macro_f_string_map_multis_t_destroy_simple(map_multis) f_string_map_multis_adjust(0, &map_multis); + + #define macro_f_string_map_multis_t_increase(status, step, map_multis) status = f_string_map_multis_increase(step, &map_multis); + #define macro_f_string_map_multis_t_increase_by(status, map_multis, amount) status = f_string_map_multis_increase_by(amount, &map_multis); + #define macro_f_string_map_multis_t_decrease_by(status, map_multis, amount) status = f_string_map_multis_decrease_by(amount, &map_multis); + #define macro_f_string_map_multis_t_decimate_by(status, map_multis, amount) status = f_string_map_multis_decimate_by(amount, &map_multis); +#endif // _di_f_string_map_multis_t_ + +/** + * An array of string maps. + * + * array: the array of an array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_string_map_multiss_t_ + typedef struct { + f_string_map_multis_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_string_map_multiss_t; + + #define f_string_map_multiss_t_initialize f_string_statics_t_initialize + + #define macro_f_string_map_multiss_t_initialize(array, size, used) { array, size, used } + #define macro_f_string_map_multiss_t_initialize2(array, length) { array, length, length } + + #define macro_f_string_map_multiss_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) + + #define macro_f_string_map_multiss_t_resize(status, map_multis, length) status = f_string_map_multiss_resize(length, &map_multis); + #define macro_f_string_map_multiss_t_adjust(status, map_multis, length) status = f_string_map_multiss_adjust(length, &map_multis); + + #define macro_f_string_map_multiss_t_delete_simple(map_multis) f_string_map_multiss_resize(0, &map_multis); + #define macro_f_string_map_multiss_t_destroy_simple(map_multis) f_string_map_multiss_adjust(0, &map_multis); + + #define macro_f_string_map_multiss_t_increase(status, step, map_multis) status = f_string_map_multiss_increase(step, &map_multis); + #define macro_f_string_map_multiss_t_increase_by(status, map_multis, amount) status = f_string_map_multiss_increase_by(amount, &map_multis); + #define macro_f_string_map_multiss_t_decrease_by(status, map_multis, amount) status = f_string_map_multiss_decrease_by(amount, &map_multis); + #define macro_f_string_map_multiss_t_decimate_by(status, map_multis, amount) status = f_string_map_multiss_decimate_by(amount, &map_multis); +#endif // _di_f_string_map_multiss_t_ + +/** + * Resize the map_multis array. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis 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(). + */ +#ifndef _di_f_string_map_multis_adjust_ + extern f_status_t f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t * const map_multis); +#endif // _di_f_string_map_multis_adjust_ + +/** + * Append a single source map_multi onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_map_multis_append_ + f_status_t f_string_map_multis_append(const f_string_map_multi_t source, f_string_map_multis_t *destination); +#endif // _di_f_string_map_multis_append_ + +/** + * Append the source map_multis onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_map_multis_append_all_ + f_status_t f_string_map_multis_append_all(const f_string_map_multis_t source, f_string_map_multis_t *destination); +#endif // _di_f_string_map_multis_append_all_ + +/** + * Resize the map_multis 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 map_multis + * The map_multis 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(). + */ +#ifndef _di_f_string_map_multis_decimate_by_ + extern f_status_t f_string_map_multis_decimate_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis); +#endif // _di_f_string_map_multis_decimate_by_ + +/** + * Resize the map_multis 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 map_multis + * The map_multis 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(). + */ +#ifndef _di_f_string_map_multis_decrease_by_ + extern f_status_t f_string_map_multis_decrease_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis); +#endif // _di_f_string_map_multis_decrease_by_ + +/** + * Increase the size of the map_multis array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 map_multis + * The map_multis 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(). + */ +#ifndef _di_f_string_map_multis_increase_ + extern f_status_t f_string_map_multis_increase(const f_array_length_t step, f_string_map_multis_t * const map_multis); +#endif // _di_f_string_map_multis_increase_ + +/** + * Resize the map_multis array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 map_multis + * The map_multis 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(). + */ +#ifndef _di_f_string_map_multis_increase_by_ + extern f_status_t f_string_map_multis_increase_by(const f_array_length_t amount, f_string_map_multis_t * const map_multis); +#endif // _di_f_string_map_multis_increase_by_ + +/** + * Resize the map_multis array. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis 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(). + */ +#ifndef _di_f_string_map_multis_resize_ + extern f_status_t f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t * const map_multis); +#endif // _di_f_string_map_multis_resize_ + +/** + * Resize the map_multiss array. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss 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(). + */ +#ifndef _di_f_string_map_multiss_adjust_ + extern f_status_t f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t * const map_multiss); +#endif // _di_f_string_map_multiss_adjust_ + +/** + * Append a single source map_multis onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_map_multiss_append_ + f_status_t f_string_map_multiss_append(const f_string_map_multis_t source, f_string_map_multiss_t *destination); +#endif // _di_f_string_map_multiss_append_ + +/** + * Append the source map_multiss onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_map_multiss_append_all_ + f_status_t f_string_map_multiss_append_all(const f_string_map_multiss_t source, f_string_map_multiss_t *destination); +#endif // _di_f_string_map_multiss_append_all_ + +/** + * Resize the map_multiss 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 map_multiss + * The map_multiss 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(). + */ +#ifndef _di_f_string_map_multiss_decimate_by_ + extern f_status_t f_string_map_multiss_decimate_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss); +#endif // _di_f_string_map_multiss_decimate_by_ + +/** + * Resize the map_multiss 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 map_multiss + * The map_multiss 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(). + */ +#ifndef _di_f_string_map_multiss_decrease_by_ + extern f_status_t f_string_map_multiss_decrease_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss); +#endif // _di_f_string_map_multiss_decrease_by_ + +/** + * Increase the size of the map_multiss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 map_multiss + * The map_multiss 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(). + */ +#ifndef _di_f_string_map_multiss_increase_ + extern f_status_t f_string_map_multiss_increase(const f_array_length_t step, f_string_map_multiss_t * const map_multiss); +#endif // _di_f_string_map_multiss_increase_ + +/** + * Resize the map_multiss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 map_multiss + * The map_multiss 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(). + */ +#ifndef _di_f_string_map_multiss_increase_by_ + extern f_status_t f_string_map_multiss_increase_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss); +#endif // _di_f_string_map_multiss_increase_by_ + +/** + * Resize the map_multiss array. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss 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(). + */ +#ifndef _di_f_string_map_multiss_resize_ + extern f_status_t f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t * const map_multiss); +#endif // _di_f_string_map_multiss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_string_map_multi_h diff --git a/level_0/f_string/c/string/private-dynamic.c b/level_0/f_string/c/string/private-dynamic.c new file mode 100644 index 000000000..b4520665a --- /dev/null +++ b/level_0/f_string/c/string/private-dynamic.c @@ -0,0 +1,218 @@ +#include "../string.h" +#include "../private-string.h" +#include "private-dynamic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) + f_status_t private_f_string_dynamic_adjust(const f_array_length_t length, f_string_dynamic_t * const dynamic) { + + const f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_char_t), (void **) & dynamic->string); + if (F_status_is_error(status)) return status; + + dynamic->size = length; + + if (dynamic->used > dynamic->size) { + dynamic->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) + +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) + f_status_t private_f_string_dynamic_increase_by(const f_array_length_t amount, f_string_dynamic_t * const dynamic) { + + if (dynamic->used + amount > dynamic->size) { + if (dynamic->used + amount > F_string_t_size_d) { + return F_status_set_error(F_string_too_large); + } + + return private_f_string_dynamic_resize(dynamic->used + amount, dynamic); + } + + return F_data_not; + } +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) + +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) + f_status_t private_f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t * const dynamic) { + + const f_status_t status = f_memory_resize(dynamic->size, length, sizeof(f_char_t), (void **) & dynamic->string); + if (F_status_is_error(status)) return status; + + dynamic->size = length; + + if (dynamic->used > dynamic->size) { + dynamic->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) + +#if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + f_status_t private_f_string_dynamics_adjust(const f_array_length_t length, f_string_dynamics_t * const dynamics) { + + if (dynamics->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamics->size; ++i) { + + status = private_f_string_dynamic_adjust(0, &dynamics->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(dynamics->size, length, sizeof(f_string_dynamic_t), (void **) & dynamics->array); + if (F_status_is_error(status)) return status; + + dynamics->size = length; + + if (dynamics->used > dynamics->size) { + dynamics->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + +#if !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) + f_status_t private_f_string_dynamics_append(const f_string_dynamic_t source, f_string_dynamics_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_string_dynamics_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_string_append(source.string, source.used, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) + + +#if !defined(_di_f_string_dynamics_append_all_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) + f_status_t private_f_string_dynamics_append_all(const f_string_dynamics_t source, f_string_dynamics_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_string_dynamics_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_string_append(source.array[i].string, source.array[i].used, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_string_dynamics_append_all_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) + +#if !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) || !defined(f_string_map_multis_append) + f_status_t private_f_string_dynamics_resize(const f_array_length_t length, f_string_dynamics_t * const dynamics) { + + if (dynamics->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamics->size; ++i) { + + status = private_f_string_dynamic_resize(0, &dynamics->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(dynamics->size, length, sizeof(f_string_dynamic_t), (void **) & dynamics->array); + if (F_status_is_error(status)) return status; + + dynamics->size = length; + + if (dynamics->used > dynamics->size) { + dynamics->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) || !defined(f_string_map_multis_append) + +#if !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + f_status_t private_f_string_dynamicss_adjust(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) { + + if (dynamicss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamicss->size; ++i) { + + status = private_f_string_dynamics_adjust(0, &dynamicss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(dynamicss->size, length, sizeof(f_string_dynamics_t), (void **) & dynamicss->array); + if (F_status_is_error(status)) return status; + + dynamicss->size = length; + + if (dynamicss->used > dynamicss->size) { + dynamicss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + +#if !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) || !defined(_di_f_string_dynamicss_append_all_) || !defined(_di_f_string_map_multis_append_all_) + f_status_t private_f_string_dynamicss_resize(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) { + + if (dynamicss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamicss->size; ++i) { + + status = private_f_string_dynamics_resize(0, &dynamicss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(dynamicss->size, length, sizeof(f_string_dynamics_t), (void **) & dynamicss->array); + if (F_status_is_error(status)) return status; + + dynamicss->size = length; + + if (dynamicss->used > dynamicss->size) { + dynamicss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) || !defined(_di_f_string_dynamicss_append_all_) || !defined(_di_f_string_map_multis_append_all_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/c/string/private-dynamic.h b/level_0/f_string/c/string/private-dynamic.h new file mode 100644 index 000000000..582dd3ace --- /dev/null +++ b/level_0/f_string/c/string/private-dynamic.h @@ -0,0 +1,382 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_string_dynamic_h +#define _PRIVATE_F_string_dynamic_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation of f_string_append(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param length + * Length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see memcpy() + * + * @see f_string_append() + * @see f_string_append_assure() + * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() + * @see f_string_dynamic_mash() + * @see f_string_dynamic_partial_append) + * @see f_string_dynamic_partial_append_assure() + * @see f_string_dynamic_partial_mash() + * @see f_string_dynamics_append() + * @see f_string_map_multis_append() + * @see f_string_mash() + * @see f_string_maps_append() + * @see f_string_triples_append() + */ +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_mash_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_triples_append_) + extern f_status_t private_f_string_append(const f_string_t source, const f_array_length_t length, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_mash_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_triples_append_) + +/** + * Private implementation of f_string_append_nulless(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param length + * Length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * + * F_string_too_large (with error bit) if the combined string is too large. + * + * @see memcpy() + * + * @see f_string_append_assure_nulless() + * @see f_string_append_nulless() + * @see f_string_dynamic_append_assure_nulless() + * @see f_string_dynamic_append_nulless() + * @see f_string_dynamic_mash_nulless() + * @see f_string_dynamic_partial_append_assure_nulless() + * @see f_string_dynamic_partial_append_nulless() + * @see f_string_dynamic_partial_mash_nulless() + * @see f_string_mash_nulless() + */ +#if !defined(_di_f_string_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) + extern f_status_t private_f_string_append_nulless(const f_string_t source, const f_array_length_t length, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamic + * The string to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_dynamic_adjust() + * @see f_string_dynamic_decimate_by() + * @see f_string_dynamics_adjust() + * @see f_string_dynamics_append() + * @see f_string_dynamics_decimate_by() + * @see f_string_map_multis_adjust() + * @see f_string_map_multis_append() + * @see f_string_triples_adjust() + * @see f_string_triples_decimate_by() + */ +#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) + extern f_status_t private_f_string_dynamic_adjust(const f_array_length_t length, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) + +/** + * Private implementation of f_string_dynamic_increase_by(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see memcpy() + * + * @see f_string_append() + * @see f_string_append_assure() + * @see f_string_append_mash() + * @see f_string_append_nulless() + * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() + * @see f_string_dynamic_append_nulless() + * @see f_string_dynamic_increase_by() + * @see f_string_dynamic_mash() + * @see f_string_dynamic_mash_nulless() + * @see f_string_dynamic_partial_append) + * @see f_string_dynamic_partial_append_assure() + * @see f_string_dynamic_partial_mash() + * @see f_string_dynamic_prepend() + * @see f_string_dynamic_prepend_nulless() + * @see f_string_dynamics_append() + * @see f_string_map_multis_append() + * @see f_string_mash() + * @see f_string_mash_nulless() + * @see f_string_maps_append() + * @see f_string_prepend() + * @see f_string_prepend_nulless() + * @see f_string_triples_append() + */ +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) + extern f_status_t private_f_string_dynamic_increase_by(const f_array_length_t amount, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_append() + * @see f_string_append_assure() + * @see f_string_append_mash() + * @see f_string_append_nulless() + * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() + * @see f_string_dynamic_append_nulless() + * @see f_string_dynamic_decrease_by() + * @see f_string_dynamic_increase() + * @see f_string_dynamic_increase_by() + * @see f_string_dynamic_mash() + * @see f_string_dynamic_mash_nulless() + * @see f_string_dynamic_partial_append) + * @see f_string_dynamic_partial_append_assure() + * @see f_string_dynamic_partial_mash() + * @see f_string_dynamic_prepend() + * @see f_string_dynamic_prepend_nulless() + * @see f_string_dynamic_terminate() + * @see f_string_dynamic_terminate_after() + * @see f_string_dynamics_append() + * @see f_string_map_multis_append() + * @see f_string_mash_nulless() + * @see f_string_mash() + * @see f_string_maps_append() + * @see f_string_prepend() + * @see f_string_prepend_nulless() + * @see f_string_triples_append() + */ +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) + extern f_status_t private_f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamics + * The strings to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_dynamics_adjust() + * @see f_string_dynamics_append() + * @see f_string_dynamics_decimate_by() + * @see f_string_map_multis_adjust() + * @see f_string_map_multis_append() + */ +#if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + extern f_status_t private_f_string_dynamics_adjust(const f_array_length_t length, f_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamics_append() + * @see f_string_map_multis_append() + * @see f_string_map_multis_append_all() + */ +#if !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) + extern f_status_t private_f_string_dynamics_append(const f_string_dynamic_t source, f_string_dynamics_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamics_append_all() + * @see f_string_map_multis_append() + * @see f_string_map_multis_append_all() + */ +#if !defined(_di_f_string_dynamics_append_all_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) + extern f_status_t private_f_string_dynamics_append_all(const f_string_dynamics_t source, f_string_dynamics_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamics_append_all_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamics + * The strings to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamics_decrease_by() + * @see f_string_dynamics_increase() + * @see f_string_dynamics_increase_by() + */ +#if !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) + extern f_status_t private_f_string_dynamics_resize(const f_array_length_t length, f_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamicss + * The strings to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_dynamicss_adjust() + * @see f_string_dynamicss_append() + * @see f_string_dynamicss_decimate_by() + * @see f_string_map_multis_adjust() + * @see f_string_map_multis_append() + */ +#if !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + extern f_status_t private_f_string_dynamicss_adjust(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamicss + * The strings to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamicss_append_all() + * @see f_string_dynamicss_decrease_by() + * @see f_string_dynamicss_increase() + * @see f_string_dynamicss_increase_by() + * @see f_string_map_multis_append_all() + */ +#if !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) || !defined(_di_f_string_dynamicss_append_all_) || !defined(_di_f_string_map_multis_append_all_) + extern f_status_t private_f_string_dynamicss_resize(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) || !defined(_di_f_string_dynamicss_append_all_) || !defined(_di_f_string_map_multis_append_all_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_string_dynamic_h diff --git a/level_0/f_string/c/string/private-map.c b/level_0/f_string/c/string/private-map.c new file mode 100644 index 000000000..da7a9b17a --- /dev/null +++ b/level_0/f_string/c/string/private-map.c @@ -0,0 +1,160 @@ +#include "../string.h" +#include "../private-string.h" +#include "private-dynamic.h" +#include "private-map.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) + f_status_t private_f_string_maps_adjust(const f_array_length_t length, f_string_maps_t * const maps) { + + if (maps->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < maps->size; ++i) { + + status = private_f_string_dynamic_adjust(0, &maps->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_string_dynamic_adjust(0, &maps->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(maps->size, length, sizeof(f_string_map_t), (void **) & maps->array); + if (F_status_is_error(status)) return status; + + maps->size = length; + + if (maps->used > maps->size) { + maps->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) + +#if !defined(_di_f_string_maps_append_all_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) + f_status_t private_f_string_maps_append_all(const f_string_maps_t source, f_string_maps_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_string_maps_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.array[i].name.used) { + status = private_f_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].value.used) { + status = private_f_string_append(source.array[i].value.string, source.array[i].value.used, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_string_maps_append_all_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) + +#if !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) + f_status_t private_f_string_maps_resize(const f_array_length_t length, f_string_maps_t * const maps) { + + if (maps->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < maps->size; ++i) { + + status = private_f_string_dynamic_resize(0, &maps->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_string_dynamic_resize(0, &maps->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(maps->size, length, sizeof(f_string_map_t), (void **) & maps->array); + if (F_status_is_error(status)) return status; + + maps->size = length; + + if (maps->used > maps->size) { + maps->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) + +#if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) + f_status_t private_f_string_mapss_adjust(const f_array_length_t length, f_string_mapss_t * const mapss) { + + if (mapss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < mapss->size; ++i) { + + status = private_f_string_maps_adjust(0, &mapss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(mapss->size, length, sizeof(f_string_maps_t), (void **) & mapss->array); + if (F_status_is_error(status)) return status; + + mapss->size = length; + + if (mapss->used > mapss->size) { + mapss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) + +#if !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) + f_status_t private_f_string_mapss_resize(const f_array_length_t length, f_string_mapss_t * const mapss) { + + if (mapss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < mapss->size; ++i) { + + status = private_f_string_maps_resize(0, &mapss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(mapss->size, length, sizeof(f_string_maps_t), (void **) & mapss->array); + if (F_status_is_error(status)) return status; + + mapss->size = length; + + if (mapss->used > mapss->size) { + mapss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/c/string/private-map.h b/level_0/f_string/c/string/private-map.h new file mode 100644 index 000000000..e5de81d3b --- /dev/null +++ b/level_0/f_string/c/string/private-map.h @@ -0,0 +1,152 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_string_map_h +#define _PRIVATE_F_string_map_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param maps + * The maps to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_maps_adjust() + */ +#if !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) + extern f_status_t private_f_string_maps_adjust(const f_array_length_t length, f_string_maps_t * const maps) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_maps_append_all() + * @see f_string_mapss_append() + * @see f_string_mapss_append_all() + */ +#if !defined(_di_f_string_maps_append_all_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) + extern f_status_t private_f_string_maps_append_all(const f_string_maps_t source, f_string_maps_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_maps_append_all_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param maps + * The maps to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_maps_decrease_by() + * @see f_string_maps_increase() + * @see f_string_maps_increase_by() + * @see f_string_maps_terminate() + * @see f_string_maps_terminate_after() + */ +#if !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) + extern f_status_t private_f_string_maps_resize(const f_array_length_t length, f_string_maps_t * const maps) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mapss + * The mapss to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_mapss_adjust() + */ +#if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) + extern f_status_t private_f_string_mapss_adjust(const f_array_length_t length, f_string_mapss_t * const mapss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mapss + * The mapss to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_mapss_decrease_by() + * @see f_string_mapss_increase() + * @see f_string_mapss_increase_by() + * @see f_string_mapss_terminate() + * @see f_string_mapss_terminate_after() + */ +#if !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) + extern f_status_t private_f_string_mapss_resize(const f_array_length_t length, f_string_mapss_t * const mapss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_string_map_h diff --git a/level_0/f_string/c/string/private-map_multi.c b/level_0/f_string/c/string/private-map_multi.c new file mode 100644 index 000000000..b7f9604f1 --- /dev/null +++ b/level_0/f_string/c/string/private-map_multi.c @@ -0,0 +1,160 @@ +#include "../string.h" +#include "../private-string.h" +#include "private-dynamic.h" +#include "private-map_multi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) + f_status_t private_f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t * const map_multis) { + + if (map_multis->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multis->size; ++i) { + + status = private_f_string_dynamic_adjust(0, &map_multis->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_string_dynamics_adjust(0, &map_multis->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(map_multis->size, length, sizeof(f_string_map_multi_t), (void **) & map_multis->array); + if (F_status_is_error(status)) return status; + + map_multis->size = length; + + if (map_multis->used > map_multis->size) { + map_multis->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) + +#if !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) + f_status_t private_f_string_map_multis_append_all(const f_string_map_multis_t source, f_string_map_multis_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_string_map_multis_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.array[i].name.used) { + status = private_f_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].value.used) { + status = private_f_string_dynamics_append_all(source.array[i].value, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) + +#if !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) + f_status_t private_f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t * const map_multis) { + + if (map_multis->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multis->size; ++i) { + + status = private_f_string_dynamic_resize(0, &map_multis->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_string_dynamics_resize(0, &map_multis->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(map_multis->size, length, sizeof(f_string_map_multi_t), (void **) & map_multis->array); + if (F_status_is_error(status)) return status; + + map_multis->size = length; + + if (map_multis->used > map_multis->size) { + map_multis->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) + +#if !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) + f_status_t private_f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { + + if (map_multiss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multiss->size; ++i) { + + status = private_f_string_map_multis_adjust(0, &map_multiss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(map_multiss->size, length, sizeof(f_string_map_multis_t), (void **) & map_multiss->array); + if (F_status_is_error(status)) return status; + + map_multiss->size = length; + + if (map_multiss->used > map_multiss->size) { + map_multiss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) + +#if !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) + f_status_t private_f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { + + if (map_multiss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multiss->size; ++i) { + + status = private_f_string_map_multis_resize(0, &map_multiss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(map_multiss->size, length, sizeof(f_string_map_multis_t), (void **) & map_multiss->array); + if (F_status_is_error(status)) return status; + + map_multiss->size = length; + + if (map_multiss->used > map_multiss->size) { + map_multiss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/c/string/private-map_multi.h b/level_0/f_string/c/string/private-map_multi.h new file mode 100644 index 000000000..da722db3d --- /dev/null +++ b/level_0/f_string/c/string/private-map_multi.h @@ -0,0 +1,152 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_string_map_multi_h +#define _PRIVATE_F_string_map_multi_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_map_multis_adjust() + */ +#if !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) + extern f_status_t private_f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t * const map_multis) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source map_multis to append. + * @param destination + * The destination map_multis the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_map_multis_append_all() + * @see f_string_map_multiss_append() + * @see f_string_map_multiss_append_all() + */ +#if !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) + extern f_status_t private_f_string_map_multis_append_all(const f_string_map_multis_t source, f_string_map_multis_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_map_multis_decrease_by() + * @see f_string_map_multis_increase() + * @see f_string_map_multis_increase_by() + * @see f_string_map_multis_terminate() + * @see f_string_map_multis_terminate_after() + */ +#if !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) + extern f_status_t private_f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t * const map_multis) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_map_multiss_adjust() + */ +#if !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) + extern f_status_t private_f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_map_multiss_decrease_by() + * @see f_string_map_multiss_increase() + * @see f_string_map_multiss_increase_by() + * @see f_string_map_multiss_terminate() + * @see f_string_map_multiss_terminate_after() + */ +#if !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) + extern f_status_t private_f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_string_map_multi_h diff --git a/level_0/f_string/c/string/private-quantity.c b/level_0/f_string/c/string/private-quantity.c new file mode 100644 index 000000000..905666374 --- /dev/null +++ b/level_0/f_string/c/string/private-quantity.c @@ -0,0 +1,125 @@ +#include "../string.h" +#include "../private-string.h" +#include "private-quantity.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) + f_status_t private_f_string_quantitys_adjust(const f_array_length_t length, f_string_quantitys_t * const quantitys) { + + if (quantitys->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + const f_status_t status = f_memory_adjust(quantitys->size, length, sizeof(f_string_quantity_t), (void **) & quantitys->array); + if (F_status_is_error(status)) return status; + + quantitys->size = length; + + if (quantitys->used > quantitys->size) { + quantitys->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) + +#if !defined(_di_f_string_quantitys_append_all_) || !defined(_di_f_string_quantityss_append_) || !defined(_di_f_string_quantityss_append_all_) + f_status_t private_f_string_quantitys_append_all(const f_string_quantitys_t source, f_string_quantitys_t * const destination) { + + if (destination->used + source.used > destination->size) { + const f_status_t status = private_f_string_quantitys_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + destination->array[destination->used].start = source.array[i].start; + destination->array[destination->used++].total = source.array[i].total; + } // for + + return F_none; + } +#endif // !defined(_di_f_string_quantitys_append_all_) || !defined(_di_f_string_quantityss_append_) || !defined(_di_f_string_quantityss_append_all_) + +#if !defined(_di_f_string_quantitys_decrease_) || !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) || !defined(_di_f_string_quantitys_terminate_) || !defined(_di_f_string_quantitys_terminate_after_) + f_status_t private_f_string_quantitys_resize(const f_array_length_t length, f_string_quantitys_t * const quantitys) { + + if (quantitys->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + const f_status_t status = f_memory_resize(quantitys->size, length, sizeof(f_string_quantity_t), (void **) & quantitys->array); + if (F_status_is_error(status)) return status; + + quantitys->size = length; + + if (quantitys->used > quantitys->size) { + quantitys->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_quantitys_decrease_) || !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) || !defined(_di_f_string_quantitys_terminate_) || !defined(_di_f_string_quantitys_terminate_after_) + +#if !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) + f_status_t private_f_string_quantityss_adjust(const f_array_length_t length, f_string_quantityss_t * const quantityss) { + + if (quantityss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < quantityss->size; ++i) { + + status = private_f_string_quantitys_adjust(0, &quantityss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(quantityss->size, length, sizeof(f_string_quantitys_t), (void **) & quantityss->array); + if (F_status_is_error(status)) return status; + + quantityss->size = length; + + if (quantityss->used > quantityss->size) { + quantityss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) + +#if !defined(_di_f_string_quantityss_decrease_) || !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) || !defined(_di_f_string_quantityss_terminate_) || !defined(_di_f_string_quantityss_terminate_after_) + f_status_t private_f_string_quantityss_resize(const f_array_length_t length, f_string_quantityss_t * const quantityss) { + + if (quantityss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < quantityss->size; ++i) { + + status = private_f_string_quantitys_resize(0, &quantityss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(quantityss->size, length, sizeof(f_string_quantitys_t), (void **) & quantityss->array); + if (F_status_is_error(status)) return status; + + quantityss->size = length; + + if (quantityss->used > quantityss->size) { + quantityss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_quantityss_decrease_) || !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) || !defined(_di_f_string_quantityss_terminate_) || !defined(_di_f_string_quantityss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/c/string/private-quantity.h b/level_0/f_string/c/string/private-quantity.h new file mode 100644 index 000000000..069978680 --- /dev/null +++ b/level_0/f_string/c/string/private-quantity.h @@ -0,0 +1,152 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_string_quantity_h +#define _PRIVATE_F_string_quantity_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param quantitys + * The quantitys to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_quantitys_adjust() + */ +#if !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) + extern f_status_t private_f_string_quantitys_adjust(const f_array_length_t length, f_string_quantitys_t * const quantitys) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source quantitys to append. + * @param destination + * The destination quantitys the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_quantitys_append_all() + * @see f_string_quantityss_append() + * @see f_string_quantityss_append_all() + */ +#if !defined(_di_f_string_quantitys_append_all_) || !defined(_di_f_string_quantityss_append_) || !defined(_di_f_string_quantityss_append_all_) + extern f_status_t private_f_string_quantitys_append_all(const f_string_quantitys_t source, f_string_quantitys_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_quantitys_append_all_) || !defined(_di_f_string_quantityss_append_) || !defined(_di_f_string_quantityss_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param quantitys + * The quantitys to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_quantitys_decrease_by() + * @see f_string_quantitys_increase() + * @see f_string_quantitys_increase_by() + * @see f_string_quantitys_terminate() + * @see f_string_quantitys_terminate_after() + */ +#if !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) || !defined(_di_f_string_quantitys_terminate_) || !defined(_di_f_string_quantitys_terminate_after_) + extern f_status_t private_f_string_quantitys_resize(const f_array_length_t length, f_string_quantitys_t * const quantitys) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) || !defined(_di_f_string_quantitys_terminate_) || !defined(_di_f_string_quantitys_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param quantityss + * The quantityss to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_quantityss_adjust() + */ +#if !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) + extern f_status_t private_f_string_quantityss_adjust(const f_array_length_t length, f_string_quantityss_t * const quantityss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param quantityss + * The quantityss to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_quantityss_decrease_by() + * @see f_string_quantityss_increase() + * @see f_string_quantityss_increase_by() + * @see f_string_quantityss_terminate() + * @see f_string_quantityss_terminate_after() + */ +#if !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) || !defined(_di_f_string_quantityss_terminate_) || !defined(_di_f_string_quantityss_terminate_after_) + extern f_status_t private_f_string_quantityss_resize(const f_array_length_t length, f_string_quantityss_t * const quantityss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) || !defined(_di_f_string_quantityss_terminate_) || !defined(_di_f_string_quantityss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_string_quantity_h diff --git a/level_0/f_string/c/string/private-range.c b/level_0/f_string/c/string/private-range.c new file mode 100644 index 000000000..2091fa3f3 --- /dev/null +++ b/level_0/f_string/c/string/private-range.c @@ -0,0 +1,125 @@ +#include "../string.h" +#include "../private-string.h" +#include "private-range.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) + f_status_t private_f_string_ranges_adjust(const f_array_length_t length, f_string_ranges_t * const ranges) { + + if (ranges->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + const f_status_t status = f_memory_adjust(ranges->size, length, sizeof(f_string_range_t), (void **) & ranges->array); + if (F_status_is_error(status)) return status; + + ranges->size = length; + + if (ranges->used > ranges->size) { + ranges->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) + +#if !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) + f_status_t private_f_string_ranges_append_all(const f_string_ranges_t source, f_string_ranges_t * const destination) { + + if (destination->used + source.used > destination->size) { + const f_status_t status = private_f_string_ranges_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + destination->array[destination->used].start = source.array[i].start; + destination->array[destination->used++].stop = source.array[i].stop; + } // for + + return F_none; + } +#endif // !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) + +#if !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_terminate_) || !defined(_di_f_string_ranges_terminate_after_) + f_status_t private_f_string_ranges_resize(const f_array_length_t length, f_string_ranges_t * const ranges) { + + if (ranges->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + const f_status_t status = f_memory_resize(ranges->size, length, sizeof(f_string_range_t), (void **) & ranges->array); + if (F_status_is_error(status)) return status; + + ranges->size = length; + + if (ranges->used > ranges->size) { + ranges->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_terminate_) || !defined(_di_f_string_ranges_terminate_after_) + +#if !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) + f_status_t private_f_string_rangess_adjust(const f_array_length_t length, f_string_rangess_t * const rangess) { + + if (rangess->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < rangess->size; ++i) { + + status = private_f_string_ranges_adjust(0, &rangess->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(rangess->size, length, sizeof(f_string_ranges_t), (void **) & rangess->array); + if (F_status_is_error(status)) return status; + + rangess->size = length; + + if (rangess->used > rangess->size) { + rangess->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) + +#if !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) || !defined(_di_f_string_rangess_terminate_) || !defined(_di_f_string_rangess_terminate_after_) + f_status_t private_f_string_rangess_resize(const f_array_length_t length, f_string_rangess_t * const rangess) { + + if (rangess->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < rangess->size; ++i) { + + status = private_f_string_ranges_resize(0, &rangess->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(rangess->size, length, sizeof(f_string_ranges_t), (void **) & rangess->array); + if (F_status_is_error(status)) return status; + + rangess->size = length; + + if (rangess->used > rangess->size) { + rangess->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) || !defined(_di_f_string_rangess_terminate_) || !defined(_di_f_string_rangess_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/c/string/private-range.h b/level_0/f_string/c/string/private-range.h new file mode 100644 index 000000000..6449c3b9c --- /dev/null +++ b/level_0/f_string/c/string/private-range.h @@ -0,0 +1,152 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_string_range_h +#define _PRIVATE_F_string_range_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param ranges + * The ranges to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_ranges_adjust() + */ +#if !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) + extern f_status_t private_f_string_ranges_adjust(const f_array_length_t length, f_string_ranges_t * const ranges) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source ranges to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_ranges_append_all() + * @see f_string_rangess_append() + * @see f_string_rangess_append_all() + */ +#if !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) + extern f_status_t private_f_string_ranges_append_all(const f_string_ranges_t source, f_string_ranges_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param ranges + * The ranges to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_ranges_decrease_by() + * @see f_string_ranges_increase() + * @see f_string_ranges_increase_by() + * @see f_string_ranges_terminate() + * @see f_string_ranges_terminate_after() + */ +#if !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_terminate_) || !defined(_di_f_string_ranges_terminate_after_) + extern f_status_t private_f_string_ranges_resize(const f_array_length_t length, f_string_ranges_t * const ranges) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_terminate_) || !defined(_di_f_string_ranges_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param rangess + * The rangess to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_rangess_adjust() + */ +#if !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) + extern f_status_t private_f_string_rangess_adjust(const f_array_length_t length, f_string_rangess_t * const rangess) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param rangess + * The rangess to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_rangess_decrease_by() + * @see f_string_rangess_increase() + * @see f_string_rangess_increase_by() + * @see f_string_rangess_terminate() + * @see f_string_rangess_terminate_after() + */ +#if !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) || !defined(_di_f_string_rangess_terminate_) || !defined(_di_f_string_rangess_terminate_after_) + extern f_status_t private_f_string_rangess_resize(const f_array_length_t length, f_string_rangess_t * const rangess) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) || !defined(_di_f_string_rangess_terminate_) || !defined(_di_f_string_rangess_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_string_range_h diff --git a/level_0/f_string/c/string/private-triple.c b/level_0/f_string/c/string/private-triple.c new file mode 100644 index 000000000..3f46a3e0f --- /dev/null +++ b/level_0/f_string/c/string/private-triple.c @@ -0,0 +1,172 @@ +#include "../string.h" +#include "../private-string.h" +#include "private-dynamic.h" +#include "private-triple.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) + f_status_t private_f_string_triples_adjust(const f_array_length_t length, f_string_triples_t * const triples) { + + if (triples->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < triples->size; ++i) { + + status = private_f_string_dynamic_adjust(0, &triples->array[i].a); + if (F_status_is_error(status)) return status; + + status = private_f_string_dynamic_adjust(0, &triples->array[i].b); + if (F_status_is_error(status)) return status; + + status = private_f_string_dynamic_adjust(0, &triples->array[i].c); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(triples->size, length, sizeof(f_string_triple_t), (void **) & triples->array); + if (F_status_is_error(status)) return status; + + triples->size = length; + + if (triples->used > triples->size) { + triples->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) + +#if !defined(_di_f_string_triples_append_all_) || !defined(_di_f_string_tripless_append_) || !defined(_di_f_string_tripless_append_all_) + f_status_t private_f_string_triples_append_all(const f_string_triples_t source, f_string_triples_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_string_triples_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].a.used = 0; + destination->array[destination->used].b.used = 0; + destination->array[destination->used].c.used = 0; + + if (source.array[i].a.used) { + status = private_f_string_append(source.array[i].a.string, source.array[i].a.used, &destination->array[destination->used].a); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].b.used) { + status = private_f_string_append(source.array[i].b.string, source.array[i].b.used, &destination->array[destination->used].b); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].c.used) { + status = private_f_string_append(source.array[i].c.string, source.array[i].c.used, &destination->array[destination->used].c); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_string_triples_append_all_) || !defined(_di_f_string_tripless_append_) || !defined(_di_f_string_tripless_append_all_) + +#if !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) + f_status_t private_f_string_triples_resize(const f_array_length_t length, f_string_triples_t * const triples) { + + if (triples->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < triples->size; ++i) { + + status = private_f_string_dynamic_resize(0, &triples->array[i].a); + if (F_status_is_error(status)) return status; + + status = private_f_string_dynamic_resize(0, &triples->array[i].b); + if (F_status_is_error(status)) return status; + + status = private_f_string_dynamic_resize(0, &triples->array[i].c); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(triples->size, length, sizeof(f_string_triple_t), (void **) & triples->array); + if (F_status_is_error(status)) return status; + + triples->size = length; + + if (triples->used > triples->size) { + triples->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) + +#if !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) + f_status_t private_f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless) { + + if (tripless->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < tripless->size; ++i) { + + status = private_f_string_triples_adjust(0, &tripless->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(tripless->size, length, sizeof(f_string_triples_t), (void **) & tripless->array); + if (F_status_is_error(status)) return status; + + tripless->size = length; + + if (tripless->used > tripless->size) { + tripless->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) + +#if !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) + f_status_t private_f_string_tripless_resize(const f_array_length_t length, f_string_tripless_t * const tripless) { + + if (tripless->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < tripless->size; ++i) { + + status = private_f_string_triples_resize(0, &tripless->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(tripless->size, length, sizeof(f_string_triples_t), (void **) & tripless->array); + if (F_status_is_error(status)) return status; + + tripless->size = length; + + if (tripless->used > tripless->size) { + tripless->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/c/string/private-triple.h b/level_0/f_string/c/string/private-triple.h new file mode 100644 index 000000000..a8b2878de --- /dev/null +++ b/level_0/f_string/c/string/private-triple.h @@ -0,0 +1,152 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_string_triple_h +#define _PRIVATE_F_string_triple_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param triples + * The triples to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_triples_adjust() + */ +#if !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) + extern f_status_t private_f_string_triples_adjust(const f_array_length_t length, f_string_triples_t * const triples) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source triples to append. + * @param destination + * The destination triples the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_string_triples_append_all() + * @see f_string_tripless_append() + * @see f_string_tripless_append_all() + */ +#if !defined(_di_f_string_triples_append_all_) || !defined(_di_f_string_tripless_append_) || !defined(_di_f_string_tripless_append_all_) + extern f_status_t private_f_string_triples_append_all(const f_string_triples_t source, f_string_triples_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_triples_append_all_) || !defined(_di_f_string_tripless_append_) || !defined(_di_f_string_tripless_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param triples + * The triples to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_triples_decrease_by() + * @see f_string_triples_increase() + * @see f_string_triples_increase_by() + * @see f_string_triples_terminate() + * @see f_string_triples_terminate_after() + */ +#if !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) + extern f_status_t private_f_string_triples_resize(const f_array_length_t length, f_string_triples_t * const triples) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) || !defined(_di_f_string_triples_terminate_) || !defined(_di_f_string_triples_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param tripless + * The tripless to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_tripless_adjust() + */ +#if !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) + extern f_status_t private_f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param tripless + * The tripless to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_string_tripless_decrease_by() + * @see f_string_tripless_increase() + * @see f_string_tripless_increase_by() + * @see f_string_tripless_terminate() + * @see f_string_tripless_terminate_after() + */ +#if !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) + extern f_status_t private_f_string_tripless_resize(const f_array_length_t length, f_string_tripless_t * const tripless) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) || !defined(_di_f_string_tripless_terminate_) || !defined(_di_f_string_tripless_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_string_triple_h diff --git a/level_0/f_string/c/string/quantity.c b/level_0/f_string/c/string/quantity.c index a19230021..7a6c12d2c 100644 --- a/level_0/f_string/c/string/quantity.c +++ b/level_0/f_string/c/string/quantity.c @@ -1,5 +1,6 @@ #include "../string.h" #include "../private-string.h" +#include "private-quantity.h" #ifdef __cplusplus extern "C" { @@ -16,41 +17,42 @@ extern "C" { #endif // _di_f_string_quantitys_adjust_ #ifndef _di_f_string_quantitys_append_ - f_status_t f_string_quantitys_append(const f_string_quantitys_t source, f_string_quantitys_t * const destination) { + f_status_t f_string_quantitys_append(const f_string_quantity_t source, f_string_quantitys_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_string_quantitys_adjust(destination->used + source.used, destination); + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_string_quantitys_adjust(destination->used + F_memory_default_allocation_small_d, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].start = source.array[i].start; - destination->array[destination->used].total = source.array[i].total; - } // for + destination->array[destination->used].start = source.start; + destination->array[destination->used++].total = source.total; return F_none; } #endif // _di_f_string_quantitys_append_ +#ifndef _di_f_string_quantitys_append_all_ + f_status_t f_string_quantitys_append_all(const f_string_quantitys_t source, f_string_quantitys_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; + + return private_f_string_quantitys_append_all(source, destination); + } +#endif // _di_f_string_quantitys_append_all_ + #ifndef _di_f_string_quantitys_decimate_by_ f_status_t f_string_quantitys_decimate_by(const f_array_length_t amount, f_string_quantitys_t * const quantitys) { #ifndef _di_level_0_parameter_checking_ if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (quantitys->size - amount > 0) { return private_f_string_quantitys_adjust(quantitys->size - amount, quantitys); @@ -66,9 +68,7 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (quantitys->size - amount > 0) { return private_f_string_quantitys_resize(quantitys->size - amount, quantitys); @@ -108,9 +108,7 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (quantitys->used + amount > quantitys->size) { if (quantitys->used + amount > F_array_length_t_size_d) { @@ -144,15 +142,70 @@ extern "C" { } #endif // _di_f_string_quantityss_adjust_ +#ifndef _di_f_string_quantityss_append_ + f_status_t f_string_quantityss_append(const f_string_quantitys_t source, f_string_quantityss_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_string_quantityss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_string_quantitys_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_string_quantityss_append_ + +#ifndef _di_f_string_quantityss_append_all_ + f_status_t f_string_quantityss_append_all(const f_string_quantityss_t source, f_string_quantityss_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_string_quantityss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_string_quantitys_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_string_quantityss_append_all_ + #ifndef _di_f_string_quantityss_decimate_by_ f_status_t f_string_quantityss_decimate_by(const f_array_length_t amount, f_string_quantityss_t * const quantityss) { #ifndef _di_level_0_parameter_checking_ if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (quantityss->size - amount > 0) { return private_f_string_quantityss_adjust(quantityss->size - amount, quantityss); @@ -168,9 +221,7 @@ extern "C" { if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (quantityss->size - amount > 0) { return private_f_string_quantityss_resize(quantityss->size - amount, quantityss); @@ -210,9 +261,7 @@ extern "C" { if (!quantityss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (quantityss->used + amount > quantityss->size) { if (quantityss->used + amount > F_array_length_t_size_d) { diff --git a/level_0/f_string/c/string/quantity.h b/level_0/f_string/c/string/quantity.h index f3603e759..fc1b92566 100644 --- a/level_0/f_string/c/string/quantity.h +++ b/level_0/f_string/c/string/quantity.h @@ -131,10 +131,10 @@ extern "C" { #endif // _di_f_string_quantitys_adjust_ /** - * Append the source quantitys onto the destination. + * Append the single source quantity onto the destination. * * @param source - * The source quantitys to append. + * The source quantity to append. * @param destination * The destination quantitys the source is appended onto. * @@ -147,9 +147,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_quantitys_append_ - extern f_status_t f_string_quantitys_append(const f_string_quantitys_t source, f_string_quantitys_t * const destination); + extern f_status_t f_string_quantitys_append(const f_string_quantity_t source, f_string_quantitys_t * const destination); #endif // _di_f_string_quantitys_append_ +/** + * Append the source quantitys onto the destination. + * + * @param source + * The source quantitys to append. + * @param destination + * The destination quantitys the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_quantitys_append_all_ + extern f_status_t f_string_quantitys_append_all(const f_string_quantitys_t source, f_string_quantitys_t * const destination); +#endif // _di_f_string_quantitys_append_all_ + /** * Resize the string quantitys array to a smaller size. * @@ -283,6 +303,46 @@ extern "C" { extern f_status_t f_string_quantityss_adjust(const f_array_length_t length, f_string_quantityss_t * const quantityss); #endif // _di_f_string_quantityss_adjust_ +/** + * Append the single source quantitys onto the destination. + * + * @param source + * The source quantitys to append. + * @param destination + * The destination quantityss the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_quantityss_append_ + extern f_status_t f_string_quantityss_append(const f_string_quantitys_t source, f_string_quantityss_t * const destination); +#endif // _di_f_string_quantityss_append_ + +/** + * Append the source quantityss onto the destination. + * + * @param source + * The source quantityss to append. + * @param destination + * The destination quantityss the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_quantityss_append_all_ + extern f_status_t f_string_quantityss_append_all(const f_string_quantityss_t source, f_string_quantityss_t * const destination); +#endif // _di_f_string_quantityss_append_all_ + /** * Resize the string quantityss array to a smaller size. * diff --git a/level_0/f_string/c/string/range.c b/level_0/f_string/c/string/range.c index 8daf267b5..b1caca5fa 100644 --- a/level_0/f_string/c/string/range.c +++ b/level_0/f_string/c/string/range.c @@ -1,5 +1,6 @@ #include "../string.h" #include "../private-string.h" +#include "private-range.h" #ifdef __cplusplus extern "C" { @@ -16,31 +17,45 @@ extern "C" { #endif // _di_f_string_ranges_adjust_ #ifndef _di_f_string_ranges_append_ - f_status_t f_string_ranges_append(const f_string_ranges_t source, f_string_ranges_t * const destination) { + f_status_t f_string_ranges_append(const f_string_range_t source, f_string_ranges_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; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_string_ranges_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; } - f_status_t status = F_none; + destination->array[destination->used].start = source.start; + destination->array[destination->used++].stop = source.stop; + + return F_none; + } +#endif // _di_f_string_ranges_append_ + +#ifndef _di_f_string_ranges_append_all_ + f_status_t f_string_ranges_append_all(const f_string_ranges_t source, f_string_ranges_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; if (destination->used + source.used > destination->size) { - status = private_f_string_ranges_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_string_ranges_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + for (f_array_length_t i = 0; i < source.used; ++i) { destination->array[destination->used].start = source.array[i].start; - destination->array[destination->used].stop = source.array[i].stop; + destination->array[destination->used++].stop = source.array[i].stop; } // for return F_none; } -#endif // _di_f_string_ranges_append_ +#endif // _di_f_string_ranges_append_all_ #ifndef _di_f_string_ranges_decimate_by_ f_status_t f_string_ranges_decimate_by(const f_array_length_t amount, f_string_ranges_t * const ranges) { @@ -48,9 +63,7 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (ranges->size - amount > 0) { return private_f_string_ranges_adjust(ranges->size - amount, ranges); @@ -66,9 +79,7 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (ranges->size - amount > 0) { return private_f_string_ranges_resize(ranges->size - amount, ranges); @@ -108,9 +119,7 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (ranges->used + amount > ranges->size) { if (ranges->used + amount > F_array_length_t_size_d) { @@ -144,15 +153,70 @@ extern "C" { } #endif // _di_f_string_rangess_adjust_ +#ifndef _di_f_string_rangess_append_ + f_status_t f_string_rangess_append(const f_string_ranges_t source, f_string_rangess_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_string_rangess_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_string_ranges_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_string_rangess_append_ + +#ifndef _di_f_string_rangess_append_all_ + f_status_t f_string_rangess_append_all(const f_string_rangess_t source, f_string_rangess_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_string_rangess_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_string_ranges_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_string_rangess_append_all_ + #ifndef _di_f_string_rangess_decimate_by_ f_status_t f_string_rangess_decimate_by(const f_array_length_t amount, f_string_rangess_t * const rangess) { #ifndef _di_level_0_parameter_checking_ if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (rangess->size - amount > 0) { return private_f_string_rangess_adjust(rangess->size - amount, rangess); @@ -168,9 +232,7 @@ extern "C" { if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (rangess->size - amount > 0) { return private_f_string_rangess_resize(rangess->size - amount, rangess); @@ -210,9 +272,7 @@ extern "C" { if (!rangess) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (rangess->used + amount > rangess->size) { if (rangess->used + amount > F_array_length_t_size_d) { diff --git a/level_0/f_string/c/string/range.h b/level_0/f_string/c/string/range.h index 44db0cebe..b241e812b 100644 --- a/level_0/f_string/c/string/range.h +++ b/level_0/f_string/c/string/range.h @@ -34,8 +34,8 @@ extern "C" { #define f_string_range_t_initialize { 1, 0 } - #define macro_f_string_range_t_initialize(length) { length ? 0 : 1, length ? length - 1 : 0 } - #define macro_f_string_range_t_initialize2(start, stop) { start, stop } + #define macro_f_string_range_t_initialize(start, stop) { start, stop } + #define macro_f_string_range_t_initialize2(length) { length ? 0 : 1, length ? length - 1 : 0 } #define macro_f_string_range_t_clear(range) \ range.start = 1; \ @@ -129,10 +129,10 @@ extern "C" { #endif // _di_f_string_ranges_adjust_ /** - * Append the source ranges onto the destination. + * Append the single source range onto the destination. * * @param source - * The source ranges to append. + * The source range to append. * @param destination * The destination ranges the source is appended onto. * @@ -145,9 +145,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_ranges_append_ - extern f_status_t f_string_ranges_append(const f_string_ranges_t source, f_string_ranges_t * const destination); + extern f_status_t f_string_ranges_append(const f_string_range_t source, f_string_ranges_t * const destination); #endif // _di_f_string_ranges_append_ +/** + * Append the source ranges onto the destination. + * + * @param source + * The source ranges to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_ranges_append_all_ + extern f_status_t f_string_ranges_append_all(const f_string_ranges_t source, f_string_ranges_t * const destination); +#endif // _di_f_string_ranges_append_all_ + /** * Resize the string ranges array to a smaller size. * @@ -284,6 +304,46 @@ extern "C" { extern f_status_t f_string_rangess_adjust(const f_array_length_t length, f_string_rangess_t * const rangess); #endif // _di_f_string_rangess_adjust_ +/** + * Append the single source ranges onto the destination. + * + * @param source + * The source ranges to append. + * @param destination + * The destination rangess the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_rangess_append_ + extern f_status_t f_string_rangess_append(const f_string_ranges_t source, f_string_rangess_t * const destination); +#endif // _di_f_string_rangess_append_ + +/** + * Append the source rangess onto the destination. + * + * @param source + * The source rangess to append. + * @param destination + * The destination rangess the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_rangess_append_all_ + extern f_status_t f_string_rangess_append_all(const f_string_rangess_t source, f_string_rangess_t * const destination); +#endif // _di_f_string_rangess_append_all_ + /** * Resize the string rangess array to a smaller size. * diff --git a/level_0/f_string/c/string/triple.c b/level_0/f_string/c/string/triple.c index d2ba928d0..76aba190d 100644 --- a/level_0/f_string/c/string/triple.c +++ b/level_0/f_string/c/string/triple.c @@ -1,5 +1,6 @@ #include "../string.h" #include "../private-string.h" +#include "private-triple.h" #ifdef __cplusplus extern "C" { @@ -16,15 +17,51 @@ extern "C" { #endif // _di_f_string_triples_adjust_ #ifndef _di_f_string_triples_append_ - f_status_t f_string_triples_append(const f_string_triples_t source, f_string_triples_t * const destination) { + f_status_t f_string_triples_append(const f_string_triple_t source, f_string_triples_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_string_triples_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; } + destination->array[destination->used].a.used = 0; + destination->array[destination->used].b.used = 0; + destination->array[destination->used].c.used = 0; + + if (source.a.used) { + status = private_f_string_append(source.a.string, source.a.used, &destination->array[destination->used].a); + if (F_status_is_error(status)) return status; + } + + if (source.b.used) { + status = private_f_string_append(source.b.string, source.b.used, &destination->array[destination->used].b); + if (F_status_is_error(status)) return status; + } + + if (source.c.used) { + status = private_f_string_append(source.c.string, source.c.used, &destination->array[destination->used].c); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_string_triples_append_ + +#ifndef _di_f_string_triples_append_all_ + f_status_t f_string_triples_append_all(const f_string_triples_t source, f_string_triples_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) { @@ -56,12 +93,11 @@ extern "C" { return F_none; } -#endif // _di_f_string_triples_append_ +#endif // _di_f_string_triples_append_all_ #ifndef _di_f_string_triples_decimate_by_ f_status_t f_string_triples_decimate_by(const f_array_length_t amount, f_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -79,9 +115,7 @@ extern "C" { if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (triples->size - amount > 0) { return private_f_string_triples_resize(triples->size - amount, triples); @@ -121,9 +155,7 @@ extern "C" { if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (triples->used + amount > triples->size) { if (triples->used + amount > F_array_length_t_size_d) { @@ -147,6 +179,63 @@ extern "C" { } #endif // _di_f_string_triples_resize_ +#ifndef _di_f_string_tripless_append_ + f_status_t f_string_tripless_append(const f_string_triples_t source, f_string_tripless_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_string_tripless_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_string_triples_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_string_tripless_append_ + +#ifndef _di_f_string_tripless_append_all_ + f_status_t f_string_tripless_append_all(const f_string_tripless_t source, f_string_tripless_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_string_tripless_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_string_triples_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_string_tripless_append_all_ + #ifndef _di_f_string_tripless_adjust_ f_status_t f_string_tripless_adjust(const f_array_length_t length, f_string_tripless_t * const tripless) { #ifndef _di_level_0_parameter_checking_ @@ -163,9 +252,7 @@ extern "C" { if (!tripless) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (tripless->size - amount > 0) { return private_f_string_tripless_adjust(tripless->size - amount, tripless); @@ -181,9 +268,7 @@ extern "C" { if (!tripless) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (tripless->size - amount > 0) { return private_f_string_tripless_resize(tripless->size - amount, tripless); @@ -223,9 +308,7 @@ extern "C" { if (!tripless) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (tripless->used + amount > tripless->size) { if (tripless->used + amount > F_array_length_t_size_d) { diff --git a/level_0/f_string/c/string/triple.h b/level_0/f_string/c/string/triple.h index dea8f0422..442e05bc0 100644 --- a/level_0/f_string/c/string/triple.h +++ b/level_0/f_string/c/string/triple.h @@ -143,10 +143,10 @@ extern "C" { #endif // _di_f_string_triples_adjust_ /** - * Append the source triples onto the destination. + * Append the single source triples onto the destination. * * @param source - * The source triples to append. + * The source triple to append. * @param destination * The destination triples the source is appended onto. * @@ -160,9 +160,30 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_triples_append_ - extern f_status_t f_string_triples_append(const f_string_triples_t source, f_string_triples_t * const destination); + extern f_status_t f_string_triples_append(const f_string_triple_t source, f_string_triples_t * const destination); #endif // _di_f_string_triples_append_ +/** + * Append the source triples onto the destination. + * + * @param source + * The source triples to append. + * @param destination + * The destination triples the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_triples_append_all_ + extern f_status_t f_string_triples_append_all(const f_string_triples_t source, f_string_triples_t * const destination); +#endif // _di_f_string_triples_append_all_ + /** * Resize the string triples array to a smaller size. * @@ -299,10 +320,10 @@ extern "C" { #endif // _di_f_string_tripless_adjust_ /** - * Append the source tripless onto the destination. + * Append the single source triples onto the destination. * * @param source - * The source tripless to append. + * The source triples to append. * @param destination * The destination tripless the source is appended onto. * @@ -316,9 +337,30 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_tripless_append_ - extern f_status_t f_string_tripless_append(const f_string_tripless_t source, f_string_tripless_t * const destination); + extern f_status_t f_string_tripless_append(const f_string_triples_t source, f_string_tripless_t * const destination); #endif // _di_f_string_tripless_append_ +/** + * Append the source tripless onto the destination. + * + * @param source + * The source tripless to append. + * @param destination + * The destination tripless the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_tripless_append_all_ + extern f_status_t f_string_tripless_append_all(const f_string_tripless_t source, f_string_tripless_t * const destination); +#endif // _di_f_string_tripless_append_all_ + /** * Resize the string tripless array to a smaller size. * diff --git a/level_0/f_string/data/build/settings b/level_0/f_string/data/build/settings index 23297648b..bb29b47a2 100644 --- a/level_0/f_string/data/build/settings +++ b/level_0/f_string/data/build/settings @@ -31,7 +31,7 @@ build_objects_library_static build_objects_program build_objects_program_shared build_objects_program_static -build_sources_library string.c private-string.c string/common.c string/dynamic.c string/map.c string/quantity.c string/range.c string/static.c string/triple.c +build_sources_library string.c private-string.c string/common.c string/private-dynamic.c string/private-map.c string/private-map_multi.c string/private-quantity.c string/private-range.c string/private-triple.c string/dynamic.c string/map.c string/map_multi.c string/quantity.c string/range.c string/static.c string/triple.c build_sources_library_shared build_sources_library_static build_sources_object @@ -40,7 +40,7 @@ build_sources_object_static build_sources_program build_sources_program_shared build_sources_program_static -build_sources_headers string.h string/common.h string/dynamic.h string/map.h string/quantity.h string/range.h string/static.h string/triple.h +build_sources_headers string.h string/common.h string/dynamic.h string/map.h string/map_multi.h string/quantity.h string/range.h string/static.h string/triple.h build_sources_headers_shared build_sources_headers_static build_sources_script diff --git a/level_0/f_string/data/build/settings-tests b/level_0/f_string/data/build/settings-tests new file mode 100644 index 000000000..db3478f39 --- /dev/null +++ b/level_0/f_string/data/build/settings-tests @@ -0,0 +1,56 @@ +# fss-0001 + +build_name test-f_string + +version_major 0 +version_minor 5 +version_micro 9 +version_file major +version_target major + +modes individual level monolithic clang test +modes_default individual + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c +build_libraries -lc -lcmocka +build_libraries-individual -lf_memory -lf_string +build_libraries-level -lfll_0 +build_libraries-monolithic -lfll +build_sources_program test-string-dynamics_adjust.c test-string-dynamics_append.c test-string-dynamics_append_all.c test-string-dynamics_decimate_by.c test-string-dynamics_decrease_by.c test-string-dynamics_increase.c test-string-dynamics_increase_by.c test-string-dynamics_resize.c test-string-dynamicss_adjust.c test-string-dynamicss_append.c test-string-dynamicss_append_all.c test-string-dynamicss_decimate_by.c test-string-dynamicss_decrease_by.c test-string-dynamicss_increase.c test-string-dynamicss_increase_by.c test-string-dynamicss_resize.c +build_sources_program test-string-maps_adjust.c test-string-maps_append.c test-string-maps_append_all.c test-string-maps_decimate_by.c test-string-maps_decrease_by.c test-string-maps_increase.c test-string-maps_increase_by.c test-string-maps_resize.c test-string-mapss_adjust.c test-string-mapss_append.c test-string-mapss_append_all.c test-string-mapss_decimate_by.c test-string-mapss_decrease_by.c test-string-mapss_increase.c test-string-mapss_increase_by.c test-string-mapss_resize.c +build_sources_program test-string-map_multis_adjust.c test-string-map_multis_append.c test-string-map_multis_append_all.c test-string-map_multis_decimate_by.c test-string-map_multis_decrease_by.c test-string-map_multis_increase.c test-string-map_multis_increase_by.c test-string-map_multis_resize.c test-string-map_multiss_adjust.c test-string-map_multiss_append.c test-string-map_multiss_append_all.c test-string-map_multiss_decimate_by.c test-string-map_multiss_decrease_by.c test-string-map_multiss_increase.c test-string-map_multiss_increase_by.c test-string-map_multiss_resize.c +build_sources_program test-string-quantitys_adjust.c test-string-quantitys_append.c test-string-quantitys_append_all.c test-string-quantitys_decimate_by.c test-string-quantitys_decrease_by.c test-string-quantitys_increase.c test-string-quantitys_increase_by.c test-string-quantitys_resize.c test-string-quantityss_adjust.c test-string-quantityss_append.c test-string-quantityss_append_all.c test-string-quantityss_decimate_by.c test-string-quantityss_decrease_by.c test-string-quantityss_increase.c test-string-quantityss_increase_by.c test-string-quantityss_resize.c +build_sources_program test-string-ranges_adjust.c test-string-ranges_append.c test-string-ranges_append_all.c test-string-ranges_decimate_by.c test-string-ranges_decrease_by.c test-string-ranges_increase.c test-string-ranges_increase_by.c test-string-ranges_resize.c test-string-rangess_adjust.c test-string-rangess_append.c test-string-rangess_append_all.c test-string-rangess_decimate_by.c test-string-rangess_decrease_by.c test-string-rangess_increase.c test-string-rangess_increase_by.c test-string-rangess_resize.c +build_sources_program test-string-triples_adjust.c test-string-triples_append.c test-string-triples_append_all.c test-string-triples_decimate_by.c test-string-triples_decrease_by.c test-string-triples_increase.c test-string-triples_increase_by.c test-string-triples_resize.c test-string-tripless_adjust.c test-string-tripless_append.c test-string-tripless_append_all.c test-string-tripless_decimate_by.c test-string-tripless_decrease_by.c test-string-tripless_increase.c test-string-tripless_increase_by.c test-string-tripless_resize.c +build_sources_program test-string.c +build_script no +build_shared yes +build_static no + +path_headers tests/unit/c +path_sources tests/unit/c + +has_path_standard no +preserve_path_headers no + +search_exclusive yes +search_shared yes +search_static yes + +defines +defines -Ibuild/includes +defines_static -Lbuild/libraries/static +defines_shared -Lbuild/libraries/shared + +flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses +flags-clang -Wno-logical-op-parentheses +flags-test -fstack-protector +flags_program -fPIE +flags_program_shared +flags_program_static +flags_shared +flags_static diff --git a/level_0/f_string/data/build/testfile b/level_0/f_string/data/build/testfile new file mode 100644 index 000000000..263cfb4cd --- /dev/null +++ b/level_0/f_string/data/build/testfile @@ -0,0 +1,45 @@ +# fss-0005 iki-0002 + +settings: + load_build yes + fail exit + + environment LD_LIBRARY_PATH + +main: + build settings + build settings-tests + + operate ld_library_path + + if exists build/programs/shared/test-f_string + shell build/programs/shared/test-f_string + + if exists build/programs/static/test-f_string + shell build/programs/static/test-f_string + + if not exists build/programs/shared/test-f_string + and not exists build/programs/static/test-f_string + operate not_created + +not_created: + print + print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"' + + exit failure + +ld_library_path: + if defined environment LD_LIBRARY_PATH + and defined parameter work + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared:define:"LD_LIBRARY_PATH"' + + else + if defined environment LD_LIBRARY_PATH + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:define:"LD_LIBRARY_PATH"' + + else + if defined parameter work + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared' + + else + define LD_LIBRARY_PATH build/libraries/shared diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_adjust.c b/level_0/f_string/tests/unit/c/test-string-dynamics_adjust.c new file mode 100644 index 000000000..bababe12b --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-dynamics_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_adjust__works(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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_string_dynamics_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_adjust.h b/level_0/f_string/tests/unit/c/test-string-dynamics_adjust.h new file mode 100644 index 000000000..0ec0a1b23 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__string_dynamics_adjust +#define _TEST__F_string__string_dynamics_adjust + +/** + * Test that the function works. + * + * @see f_string_dynamics_adjust() + */ +extern void test__f_string_dynamics_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamics_adjust() + */ +extern void test__f_string_dynamics_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string__string_dynamics_adjust diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_append.c b/level_0/f_string/tests/unit/c/test-string-dynamics_append.c new file mode 100644 index 000000000..8f05603f7 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_append.c @@ -0,0 +1,40 @@ +#include "test-string.h" +#include "test-string-dynamics_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_append__works(void **state) { + + const f_string_static_t source = macro_f_string_static_t_initialize("test", 0, 4); + f_string_dynamics_t destination = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + + assert_string_equal(destination.array[0].string, source.string); + } + + free((void *) destination.array[0].string); + free((void *) destination.array); +} + +void test__f_string_dynamics_append__parameter_checking(void **state) { + + const f_string_dynamic_t data = f_string_dynamic_t_initialize; + + { + const f_status_t status = f_string_dynamics_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_append.h b/level_0/f_string/tests/unit/c/test-string-dynamics_append.h new file mode 100644 index 000000000..aa9476f6d --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamics_append_h +#define _TEST__F_string_dynamics_append_h + +/** + * Test that the function works. + * + * @see f_string_dynamics_append() + */ +extern void test__f_string_dynamics_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamics_append() + */ +extern void test__f_string_dynamics_append__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamics_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_append_all.c b/level_0/f_string/tests/unit/c/test-string-dynamics_append_all.c new file mode 100644 index 000000000..6f75af57a --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_append_all.c @@ -0,0 +1,101 @@ +#include "test-string.h" +#include "test-string-dynamics_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_append_all__works(void **state) { + + const int length_inner = 2; + f_string_dynamics_t source = f_string_dynamics_t_initialize; + f_string_dynamics_t destination = f_string_dynamics_t_initialize; + + const f_string_static_t test_sources[] = { + macro_f_string_static_t_initialize("test1", 0, 5), + macro_f_string_static_t_initialize("test2", 0, 5), + }; + + { + f_status_t status = f_string_dynamics_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_string_dynamic_append(test_sources[source.used], &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].string, test_sources[source.used].string); + assert_int_equal(source.array[source.used].used, test_sources[source.used].used); + } // for + } + + { + const f_status_t status = f_string_dynamics_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[i].used, source.array[i].used); + + assert_string_equal(destination.array[i].string, source.array[i].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].string); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].string); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_string_dynamics_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_dynamics_t source = f_string_dynamics_t_initialize; + f_string_dynamics_t destination = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_dynamics_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_dynamics_append_all__parameter_checking(void **state) { + + const f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_append_all.h b/level_0/f_string/tests/unit/c/test-string-dynamics_append_all.h new file mode 100644 index 000000000..bdc6e26db --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamics_append_all_h +#define _TEST__F_string_dynamics_append_all_h + +/** + * Test that the function works. + * + * @see f_string_dynamics_append_all() + */ +extern void test__f_string_dynamics_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_dynamics_append_all() + */ +extern void test__f_string_dynamics_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamics_append_all() + */ +extern void test__f_string_dynamics_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamics_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-dynamics_decimate_by.c new file mode 100644 index 000000000..65f5200eb --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-dynamics_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_decimate_by__works(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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_string_dynamics_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_string_dynamics_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-dynamics_decimate_by.h new file mode 100644 index 000000000..4bb48590b --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_dynamics_decimate_by_h +#define _TEST__F_dynamics_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_dynamics_decimate_by() + */ +extern void test__f_string_dynamics_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamics_decimate_by() + */ +extern void test__f_string_dynamics_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_dynamics_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-dynamics_decrease_by.c new file mode 100644 index 000000000..310399742 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-dynamics_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_decrease_by__works(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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_string_dynamics_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_string_dynamics_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-dynamics_decrease_by.h new file mode 100644 index 000000000..ac932c59f --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamics_decrease_by_h +#define _TEST__F_string_dynamics_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_dynamics_decrease_by() + */ +extern void test__f_string_dynamics_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamics_decrease_by() + */ +extern void test__f_string_dynamics_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamics_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_increase.c b/level_0/f_string/tests/unit/c/test-string-dynamics_increase.c new file mode 100644 index 000000000..90ab94ea2 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-dynamics_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_increase__works(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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_string_dynamics_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_string_dynamics_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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_string_dynamics_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_string_dynamics_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_increase.h b/level_0/f_string/tests/unit/c/test-string-dynamics_increase.h new file mode 100644 index 000000000..ef937df9f --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamics_increase_h +#define _TEST__F_string_dynamics_increase_h + +/** + * Test that the function works. + * + * @see f_string_dynamics_increase() + */ +extern void test__f_string_dynamics_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_dynamics_increase() + */ +extern void test__f_string_dynamics_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamics_increase() + */ +extern void test__f_string_dynamics_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamics_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_increase_by.c b/level_0/f_string/tests/unit/c/test-string-dynamics_increase_by.c new file mode 100644 index 000000000..e781c22d5 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-dynamics_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_increase_by__works(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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_string_dynamics_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_string_dynamics_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_increase_by.h b/level_0/f_string/tests/unit/c/test-string-dynamics_increase_by.h new file mode 100644 index 000000000..2d4caedc3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamics_increase_by_h +#define _TEST__F_string_dynamics_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_dynamics_increase_by() + */ +extern void test__f_string_dynamics_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamics_increase_by() + */ +extern void test__f_string_dynamics_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamics_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_resize.c b/level_0/f_string/tests/unit/c/test-string-dynamics_resize.c new file mode 100644 index 000000000..8f0cb8da4 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-dynamics_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_resize__works(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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_string_dynamics_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamics_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_resize.h b/level_0/f_string/tests/unit/c/test-string-dynamics_resize.h new file mode 100644 index 000000000..89a08973f --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamics_resize_h +#define _TEST__F_string_dynamics_resize_h + +/** + * Test that the function works. + * + * @see f_string_dynamics_resize() + */ +extern void test__f_string_dynamics_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamics_resize() + */ +extern void test__f_string_dynamics_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamics_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_adjust.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_adjust.c new file mode 100644 index 000000000..6c316ef34 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-dynamicss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_adjust__works(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamicss_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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_string_dynamicss_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamicss_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_adjust.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_adjust.h new file mode 100644 index 000000000..a3f62a105 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamicss_adjust_h +#define _TEST__F_string_dynamicss_adjust_h + +/** + * Test that the function works. + * + * @see f_string_dynamicss_adjust() + */ +extern void test__f_string_dynamicss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamicss_adjust() + */ +extern void test__f_string_dynamicss_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamicss_adjust_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_append.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_append.c new file mode 100644 index 000000000..47e47df5c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_append.c @@ -0,0 +1,102 @@ +#include "test-string.h" +#include "test-string-dynamicss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_append__works(void **state) { + + const int length_inner = 2; + f_string_dynamics_t source = f_string_dynamics_t_initialize; + f_string_dynamicss_t destination = f_string_dynamicss_t_initialize; + + const f_string_static_t test_names[] = { + macro_f_string_static_t_initialize("test1", 0, 5), + macro_f_string_static_t_initialize("test2", 0, 5), + }; + + { + f_status_t status = f_string_dynamics_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_string_dynamic_append(test_names[source.used], &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].string, test_names[source.used].string); + assert_int_equal(source.array[source.used].used, test_names[source.used].used); + } // for + } + + { + const f_status_t status = f_string_dynamicss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_inner); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[0].array[i].used, test_names[i].used); + assert_string_equal(destination.array[0].array[i].string, test_names[i].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].string); + } // for + + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + free((void *) destination.array[0].array[i].string); + } // for + + free((void *) destination.array[0].array); + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_string_dynamicss_append__returns_data_not(void **state) { + + const int length = 5; + f_string_dynamics_t source = f_string_dynamicss_t_initialize; + f_string_dynamicss_t destination = f_string_dynamicss_t_initialize; + + { + const f_status_t status = f_string_dynamics_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_dynamicss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_dynamicss_append__parameter_checking(void **state) { + + f_string_dynamics_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_append.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_append.h new file mode 100644 index 000000000..7bbd5d90c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamicss_append_h +#define _TEST__F_string_dynamicss_append_h + +/** + * Test that the function works. + * + * @see f_string_dynamicss_append() + */ +extern void test__f_string_dynamicss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_dynamicss_append() + */ +extern void test__f_string_dynamicss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamicss_append() + */ +extern void test__f_string_dynamicss_append__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamicss_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_append_all.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_append_all.c new file mode 100644 index 000000000..6b55e4685 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_append_all.c @@ -0,0 +1,130 @@ +#include "test-string.h" +#include "test-string-dynamicss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + const int length_outer = 2; + f_string_dynamicss_t source = f_string_dynamicss_t_initialize; + f_string_dynamicss_t destination = f_string_dynamicss_t_initialize; + + const f_string_static_t test_names[] = { + macro_f_string_static_t_initialize("test1", 0, 5), + macro_f_string_static_t_initialize("test2", 0, 5), + }; + + { + f_status_t status = f_string_dynamicss_resize(length_outer, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length_outer); + + f_array_length_t i = 0; + f_array_length_t j = 0; + + for (; source.used < length_outer; ++source.used) { + + status = f_string_dynamics_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].used, 0); + assert_int_equal(source.array[source.used].size, length_inner); + + for (i = 0; i < length_inner; ++i) { + + status = f_string_dynamic_append(test_names[i], &source.array[source.used].array[i]); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].array[i].string, test_names[i].string); + assert_int_equal(source.array[source.used].array[i].used, test_names[i].used); + } // for + + source.array[source.used].used = length_inner; + } // for + } + + { + const f_status_t status = f_string_dynamicss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[j].array[i].used, test_names[i].used); + + assert_string_equal(destination.array[j].array[i].string, test_names[i].string); + } // for + } // for + } + + for (f_array_length_t j = 0; j < source.used; ++j) { + + for (f_array_length_t i = 0; i < source.array[j].used; ++i) { + free((void *) source.array[j].array[i].string); + } // for + + free((void *) source.array[j].array); + } // for + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + free((void *) destination.array[j].array[i].string); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_string_dynamicss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_dynamicss_t source = f_string_dynamicss_t_initialize; + f_string_dynamicss_t destination = f_string_dynamicss_t_initialize; + + { + const f_status_t status = f_string_dynamicss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_dynamicss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_dynamicss_append_all__parameter_checking(void **state) { + + const f_string_dynamicss_t data = f_string_dynamicss_t_initialize; + + { + const f_status_t status = f_string_dynamicss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_append_all.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_append_all.h new file mode 100644 index 000000000..d578deb94 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamicss_append_all_h +#define _TEST__F_string_dynamicss_append_all_h + +/** + * Test that the function works. + * + * @see f_string_dynamicss_append_all() + */ +extern void test__f_string_dynamicss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_dynamicss_append_all() + */ +extern void test__f_string_dynamicss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamicss_append_all() + */ +extern void test__f_string_dynamicss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamicss_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_decimate_by.c new file mode 100644 index 000000000..e4b27bd58 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-dynamicss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_decimate_by__works(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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_string_dynamicss_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_string_dynamicss_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_decimate_by.h new file mode 100644 index 000000000..21c20ab82 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamicss_decimate_by_h +#define _TEST__F_string_dynamicss_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_dynamicss_decimate_by() + */ +extern void test__f_string_dynamicss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamicss_decimate_by() + */ +extern void test__f_string_dynamicss_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamicss_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_decrease_by.c new file mode 100644 index 000000000..f824afb28 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-dynamicss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_decrease_by__works(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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_string_dynamicss_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_string_dynamicss_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_decrease_by.h new file mode 100644 index 000000000..d73380039 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamicss_decrease_by_h +#define _TEST__F_string_dynamicss_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_dynamicss_decrease_by() + */ +extern void test__f_string_dynamicss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamicss_decrease_by() + */ +extern void test__f_string_dynamicss_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamicss_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_increase.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_increase.c new file mode 100644 index 000000000..251c02101 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-dynamicss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_increase__works(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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_string_dynamicss_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_string_dynamicss_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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_string_dynamicss_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_string_dynamicss_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_increase.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_increase.h new file mode 100644 index 000000000..e75f05cb7 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamicss_increase_h +#define _TEST__F_string_dynamicss_increase_h + +/** + * Test that the function works. + * + * @see f_string_dynamicss_increase() + */ +extern void test__f_string_dynamicss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_dynamicss_increase() + */ +extern void test__f_string_dynamicss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamicss_increase() + */ +extern void test__f_string_dynamicss_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamicss_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_increase_by.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_increase_by.c new file mode 100644 index 000000000..dec5bba4b --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-dynamicss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_increase_by__works(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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_string_dynamicss_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_string_dynamicss_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamics_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_increase_by.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_increase_by.h new file mode 100644 index 000000000..a9f080488 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamicss_increase_by_h +#define _TEST__F_string_dynamicss_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_dynamicss_increase_by() + */ +extern void test__f_string_dynamicss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamicss_increase_by() + */ +extern void test__f_string_dynamicss_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamicss_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_resize.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_resize.c new file mode 100644 index 000000000..f80e04dd7 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-dynamicss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_resize__works(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamicss_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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_string_dynamicss_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_dynamicss_t data = f_string_dynamicss_t_initialize; + + { + const f_status_t status = f_string_dynamicss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_resize.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_resize.h new file mode 100644 index 000000000..d9b0ed5f1 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_dynamicss_resize_h +#define _TEST__F_string_dynamicss_resize_h + +/** + * Test that the function works. + * + * @see f_string_dynamicss_resize() + */ +extern void test__f_string_dynamicss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_dynamicss_resize() + */ +extern void test__f_string_dynamicss_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_dynamicss_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_adjust.c b/level_0/f_string/tests/unit/c/test-string-map_multis_adjust.c new file mode 100644 index 000000000..54f12b448 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-map_multis_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_adjust__works(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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_string_map_multis_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_adjust.h b/level_0/f_string/tests/unit/c/test-string-map_multis_adjust.h new file mode 100644 index 000000000..423ce7aba --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__string_map_multis_adjust +#define _TEST__F_string__string_map_multis_adjust + +/** + * Test that the function works. + * + * @see f_string_map_multis_adjust() + */ +extern void test__f_string_map_multis_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multis_adjust() + */ +extern void test__f_string_map_multis_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string__string_map_multis_adjust diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_append.c b/level_0/f_string/tests/unit/c/test-string-map_multis_append.c new file mode 100644 index 000000000..e73635940 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_append.c @@ -0,0 +1,81 @@ +#include "test-string.h" +#include "test-string-map_multis_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_append__works(void **state) { + + const int length_values = 2; + f_string_map_multi_t source = f_string_map_multi_t_initialize; + f_string_map_multis_t destination = f_string_map_multis_t_initialize; + + f_string_static_t test_value_array[] = { + macro_f_string_static_t_initialize("test_value1", 0, 11), + macro_f_string_static_t_initialize("test_value2", 0, 11), + }; + + const f_string_static_t test_name = macro_f_string_static_t_initialize("test_name", 0, 9); + const f_string_statics_t test_value = macro_f_string_statics_t_initialize(test_value_array, 0, length_values); + + { + f_status_t status = f_string_dynamic_append(test_name, &source.name); + + assert_int_equal(status, F_none); + assert_int_equal(source.name.used, test_name.used); + assert_string_equal(source.name.string, test_name.string); + + status = f_string_dynamics_append_all(test_value, &source.value); + + assert_int_equal(status, F_none); + assert_int_equal(source.value.used, test_value.used); + assert_int_equal(source.value.array[0].used, test_value.array[0].used); + assert_int_equal(source.value.array[1].used, test_value.array[1].used); + + assert_string_equal(source.value.array[0].string, test_value.array[0].string); + assert_string_equal(source.value.array[1].string, test_value.array[1].string); + } + + { + const f_status_t status = f_string_map_multis_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].name.used, source.name.used); + assert_int_equal(destination.array[0].value.used, source.value.used); + assert_int_equal(destination.array[0].value.array[0].used, source.value.array[0].used); + assert_int_equal(destination.array[0].value.array[1].used, source.value.array[1].used); + + assert_string_equal(destination.array[0].name.string, source.name.string); + assert_string_equal(destination.array[0].value.array[0].string, source.value.array[0].string); + assert_string_equal(destination.array[0].value.array[1].string, source.value.array[1].string); + } + + free((void *) source.name.string); + free((void *) source.value.array[0].string); + free((void *) source.value.array[1].string); + free((void *) source.value.array); + + free((void *) destination.array[0].name.string); + free((void *) destination.array[0].value.array[0].string); + free((void *) destination.array[0].value.array[1].string); + free((void *) destination.array[0].value.array); + + free((void *) destination.array); +} + +void test__f_string_map_multis_append__parameter_checking(void **state) { + + const f_string_map_multi_t data = f_string_map_multi_t_initialize; + + { + const f_status_t status = f_string_map_multis_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_append.h b/level_0/f_string/tests/unit/c/test-string-map_multis_append.h new file mode 100644 index 000000000..80b548f0a --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multis_append_h +#define _TEST__F_string_map_multis_append_h + +/** + * Test that the function works. + * + * @see f_string_map_multis_append() + */ +extern void test__f_string_map_multis_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multis_append() + */ +extern void test__f_string_map_multis_append__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multis_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_append_all.c b/level_0/f_string/tests/unit/c/test-string-map_multis_append_all.c new file mode 100644 index 000000000..573203eae --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_append_all.c @@ -0,0 +1,126 @@ +#include "test-string.h" +#include "test-string-map_multis_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_append_all__works(void **state) { + + const int length_values = 2; + const int length_inner = 2; + f_string_map_multis_t source = f_string_map_multis_t_initialize; + f_string_map_multis_t destination = f_string_map_multis_t_initialize; + + f_string_static_t test_value_array[] = { + macro_f_string_static_t_initialize("test_value1", 0, 11), + macro_f_string_static_t_initialize("test_value2", 0, 11), + }; + + const f_string_static_t test_name = macro_f_string_static_t_initialize("test_name", 0, 9); + const f_string_statics_t test_value = macro_f_string_statics_t_initialize(test_value_array, 0, length_values); + + { + f_status_t status = f_string_map_multis_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_string_dynamic_append(test_name, &source.array[source.used].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].name.string, test_name.string); + assert_int_equal(source.array[source.used].name.used, test_name.used); + + status = f_string_dynamics_append_all(test_value, &source.array[source.used].value); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].value.array[0].used, test_value.array[0].used); + assert_int_equal(source.array[source.used].value.array[1].used, test_value.array[1].used); + assert_string_equal(source.array[source.used].value.array[0].string, test_value.array[0].string); + assert_string_equal(source.array[source.used].value.array[1].string, test_value.array[1].string); + } // for + } + + { + const f_status_t status = f_string_map_multis_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[i].name.used, source.array[i].name.used); + assert_int_equal(destination.array[i].value.used, source.array[i].value.used); + assert_int_equal(destination.array[i].value.array[0].used, source.array[i].value.array[0].used); + assert_int_equal(destination.array[i].value.array[1].used, source.array[i].value.array[1].used); + + assert_string_equal(destination.array[i].name.string, source.array[i].name.string); + assert_string_equal(destination.array[i].value.array[0].string, source.array[i].value.array[0].string); + assert_string_equal(destination.array[i].value.array[1].string, source.array[i].value.array[1].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].name.string); + free((void *) source.array[i].value.array[0].string); + free((void *) source.array[i].value.array[1].string); + free((void *) source.array[i].value.array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + free((void *) destination.array[i].name.string); + free((void *) destination.array[i].value.array[0].string); + free((void *) destination.array[i].value.array[1].string); + free((void *) destination.array[i].value.array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_string_map_multis_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_map_multis_t source = f_string_map_multis_t_initialize; + f_string_map_multis_t destination = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_map_multis_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_map_multis_append_all__parameter_checking(void **state) { + + const f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_append_all.h b/level_0/f_string/tests/unit/c/test-string-map_multis_append_all.h new file mode 100644 index 000000000..35b98d618 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multis_append_all_h +#define _TEST__F_string_map_multis_append_all_h + +/** + * Test that the function works. + * + * @see f_string_map_multis_append_all() + */ +extern void test__f_string_map_multis_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_map_multis_append_all() + */ +extern void test__f_string_map_multis_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multis_append_all() + */ +extern void test__f_string_map_multis_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multis_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.c new file mode 100644 index 000000000..2af96958f --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-map_multis_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_decimate_by__works(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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_string_map_multis_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_string_map_multis_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.h new file mode 100644 index 000000000..c34a755d5 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_map_multis_decimate_by_h +#define _TEST__F_map_multis_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_map_multis_decimate_by() + */ +extern void test__f_string_map_multis_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multis_decimate_by() + */ +extern void test__f_string_map_multis_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_map_multis_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.c new file mode 100644 index 000000000..faf283cdd --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-map_multis_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_decrease_by__works(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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_string_map_multis_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_string_map_multis_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.h new file mode 100644 index 000000000..f74795771 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multis_decrease_by_h +#define _TEST__F_string_map_multis_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_map_multis_decrease_by() + */ +extern void test__f_string_map_multis_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multis_decrease_by() + */ +extern void test__f_string_map_multis_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multis_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_increase.c b/level_0/f_string/tests/unit/c/test-string-map_multis_increase.c new file mode 100644 index 000000000..ad9c765ae --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-map_multis_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_increase__works(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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_string_map_multis_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_string_map_multis_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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_string_map_multis_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_string_map_multis_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_increase.h b/level_0/f_string/tests/unit/c/test-string-map_multis_increase.h new file mode 100644 index 000000000..ee42b96c3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multis_increase_h +#define _TEST__F_string_map_multis_increase_h + +/** + * Test that the function works. + * + * @see f_string_map_multis_increase() + */ +extern void test__f_string_map_multis_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_map_multis_increase() + */ +extern void test__f_string_map_multis_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multis_increase() + */ +extern void test__f_string_map_multis_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multis_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.c b/level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.c new file mode 100644 index 000000000..875ab3b24 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-map_multis_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_increase_by__works(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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_string_map_multis_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_string_map_multis_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.h b/level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.h new file mode 100644 index 000000000..2996ae828 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multis_increase_by_h +#define _TEST__F_string_map_multis_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_map_multis_increase_by() + */ +extern void test__f_string_map_multis_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multis_increase_by() + */ +extern void test__f_string_map_multis_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multis_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_resize.c b/level_0/f_string/tests/unit/c/test-string-map_multis_resize.c new file mode 100644 index 000000000..e24648852 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-map_multis_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_resize__works(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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_string_map_multis_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multis_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_resize.h b/level_0/f_string/tests/unit/c/test-string-map_multis_resize.h new file mode 100644 index 000000000..ba2a4ac99 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multis_resize_h +#define _TEST__F_string_map_multis_resize_h + +/** + * Test that the function works. + * + * @see f_string_map_multis_resize() + */ +extern void test__f_string_map_multis_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multis_resize() + */ +extern void test__f_string_map_multis_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multis_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.c new file mode 100644 index 000000000..ee7956fd3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-map_multiss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_adjust__works(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multiss_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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_string_map_multiss_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multiss_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.h new file mode 100644 index 000000000..65d2820e4 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multiss_adjust_h +#define _TEST__F_string_map_multiss_adjust_h + +/** + * Test that the function works. + * + * @see f_string_map_multiss_adjust() + */ +extern void test__f_string_map_multiss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multiss_adjust() + */ +extern void test__f_string_map_multiss_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multiss_adjust_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_append.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_append.c new file mode 100644 index 000000000..8fb8580a9 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_append.c @@ -0,0 +1,142 @@ +#include "test-string.h" +#include "test-string-map_multiss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_append__works(void **state) { + + const int length_values = 2; + const int length_values_set = 2; + const int length_inner = 2; + f_string_map_multis_t source = f_string_map_multis_t_initialize; + f_string_map_multiss_t destination = f_string_map_multiss_t_initialize; + + f_string_static_t test_value_array1[] = { + macro_f_string_static_t_initialize("test_value1", 0, 11), + macro_f_string_static_t_initialize("test_value2", 0, 11), + }; + + f_string_static_t test_value_array2[] = { + macro_f_string_static_t_initialize("test_value3", 0, 11), + macro_f_string_static_t_initialize("test_value4", 0, 11), + }; + + const f_string_static_t test_names[] = { + macro_f_string_static_t_initialize("test_name1", 0, 10), + macro_f_string_static_t_initialize("test_name2", 0, 10), + }; + + const f_string_statics_t test_values[] = { + macro_f_string_statics_t_initialize(test_value_array1, 0, length_values), + macro_f_string_statics_t_initialize(test_value_array2, 0, length_values), + }; + + { + f_status_t status = f_string_map_multis_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_string_dynamic_append(test_names[source.used], &source.array[source.used].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].name.string, test_names[source.used].string); + assert_int_equal(source.array[source.used].name.used, test_names[source.used].used); + + status = f_string_dynamics_append_all(test_values[source.used], &source.array[source.used].value); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].value.used, test_values[source.used].used); + assert_int_equal(source.array[source.used].value.array[0].used, test_values[source.used].array[0].used); + assert_int_equal(source.array[source.used].value.array[1].used, test_values[source.used].array[1].used); + + assert_string_equal(source.array[source.used].value.array[0].string, test_values[source.used].array[0].string); + assert_string_equal(source.array[source.used].value.array[1].string, test_values[source.used].array[1].string); + } // for + } + + { + const f_status_t status = f_string_map_multiss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_inner); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[0].array[i].name.used, test_names[i].used); + assert_int_equal(destination.array[0].array[i].value.used, test_values[i].used); + assert_int_equal(destination.array[0].array[i].value.array[0].used, test_values[i].array[0].used); + assert_int_equal(destination.array[0].array[i].value.array[1].used, test_values[i].array[1].used); + + assert_string_equal(destination.array[0].array[i].name.string, test_names[i].string); + assert_string_equal(destination.array[0].array[i].value.array[0].string, test_values[i].array[0].string); + assert_string_equal(destination.array[0].array[i].value.array[1].string, test_values[i].array[1].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].name.string); + free((void *) source.array[i].value.array[0].string); + free((void *) source.array[i].value.array[1].string); + free((void *) source.array[i].value.array); + } // for + + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + + free((void *) destination.array[0].array[i].name.string); + free((void *) destination.array[0].array[i].value.array[0].string); + free((void *) destination.array[0].array[i].value.array[1].string); + free((void *) destination.array[0].array[i].value.array); + } // for + + free((void *) source.array); + free((void *) destination.array[0].array); + free((void *) destination.array); +} + +void test__f_string_map_multiss_append__returns_data_not(void **state) { + + const int length = 5; + f_string_map_multis_t source = f_string_map_multiss_t_initialize; + f_string_map_multiss_t destination = f_string_map_multiss_t_initialize; + + { + const f_status_t status = f_string_map_multis_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_map_multiss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_map_multiss_append__parameter_checking(void **state) { + + f_string_map_multis_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_append.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_append.h new file mode 100644 index 000000000..84505b885 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multiss_append_h +#define _TEST__F_string_map_multiss_append_h + +/** + * Test that the function works. + * + * @see f_string_map_multiss_append() + */ +extern void test__f_string_map_multiss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_map_multiss_append() + */ +extern void test__f_string_map_multiss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multiss_append() + */ +extern void test__f_string_map_multiss_append__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multiss_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_append_all.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_append_all.c new file mode 100644 index 000000000..cdec36bdc --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_append_all.c @@ -0,0 +1,169 @@ +#include "test-string.h" +#include "test-string-map_multiss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_append_all__works(void **state) { + + const int length_values = 2; + const int length_values_set = 2; + const int length_inner = 2; + const int length_outer = 2; + f_string_map_multiss_t source = f_string_map_multiss_t_initialize; + f_string_map_multiss_t destination = f_string_map_multiss_t_initialize; + + f_string_static_t test_value_array1[] = { + macro_f_string_static_t_initialize("test_value1", 0, 11), + macro_f_string_static_t_initialize("test_value2", 0, 11), + }; + + f_string_static_t test_value_array2[] = { + macro_f_string_static_t_initialize("test_value3", 0, 11), + macro_f_string_static_t_initialize("test_value4", 0, 11), + }; + + const f_string_static_t test_names[] = { + macro_f_string_static_t_initialize("test_name1", 0, 10), + macro_f_string_static_t_initialize("test_name2", 0, 10), + }; + + const f_string_statics_t test_values[] = { + macro_f_string_statics_t_initialize(test_value_array1, 0, length_values), + macro_f_string_statics_t_initialize(test_value_array2, 0, length_values), + }; + + { + f_status_t status = f_string_map_multiss_resize(length_outer, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length_outer); + + f_array_length_t i = 0; + f_array_length_t j = 0; + + for (; source.used < length_outer; ++source.used) { + + status = f_string_map_multis_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].used, 0); + assert_int_equal(source.array[source.used].size, length_inner); + + for (i = 0; i < length_inner; ++i) { + + status = f_string_dynamic_append(test_names[i], &source.array[source.used].array[i].name); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].array[i].name.used, test_names[i].used); + assert_string_equal(source.array[source.used].array[i].name.string, test_names[i].string); + + status = f_string_dynamics_append_all(test_values[i], &source.array[source.used].array[i].value); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].array[i].value.used, test_values[i].used); + assert_int_equal(source.array[source.used].array[i].value.array[0].used, test_values[i].array[0].used); + assert_int_equal(source.array[source.used].array[i].value.array[1].used, test_values[i].array[1].used); + + assert_string_equal(source.array[source.used].array[i].value.array[0].string, test_values[i].array[0].string); + assert_string_equal(source.array[source.used].array[i].value.array[1].string, test_values[i].array[1].string); + } // for + + source.array[source.used].used = length_inner; + } // for + } + + { + const f_status_t status = f_string_map_multiss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[j].array[i].name.used, test_names[i].used); + assert_int_equal(destination.array[j].array[i].value.used, test_values[i].used); + assert_int_equal(destination.array[j].array[i].value.array[0].used, test_values[i].array[0].used); + assert_int_equal(destination.array[j].array[i].value.array[1].used, test_values[i].array[1].used); + + assert_string_equal(destination.array[j].array[i].name.string, test_names[i].string); + assert_string_equal(destination.array[j].array[i].value.array[0].string, test_values[i].array[0].string); + assert_string_equal(destination.array[j].array[i].value.array[1].string, test_values[i].array[1].string); + } // for + } // for + } + + for (f_array_length_t j = 0; j < source.used; ++j) { + + for (f_array_length_t i = 0; i < source.array[j].used; ++i) { + + free((void *) source.array[j].array[i].name.string); + free((void *) source.array[j].array[i].value.array[0].string); + free((void *) source.array[j].array[i].value.array[1].string); + free((void *) source.array[j].array[i].value.array); + } // for + + free((void *) source.array[j].array); + } // for + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + + free((void *) destination.array[j].array[i].name.string); + free((void *) destination.array[j].array[i].value.array[0].string); + free((void *) destination.array[j].array[i].value.array[1].string); + free((void *) destination.array[j].array[i].value.array); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_string_map_multiss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_map_multiss_t source = f_string_map_multiss_t_initialize; + f_string_map_multiss_t destination = f_string_map_multiss_t_initialize; + + { + const f_status_t status = f_string_map_multiss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_map_multiss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_map_multiss_append_all__parameter_checking(void **state) { + + const f_string_map_multiss_t data = f_string_map_multiss_t_initialize; + + { + const f_status_t status = f_string_map_multiss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_append_all.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_append_all.h new file mode 100644 index 000000000..b33f80e39 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multiss_append_all_h +#define _TEST__F_string_map_multiss_append_all_h + +/** + * Test that the function works. + * + * @see f_string_map_multiss_append_all() + */ +extern void test__f_string_map_multiss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_map_multiss_append_all() + */ +extern void test__f_string_map_multiss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multiss_append_all() + */ +extern void test__f_string_map_multiss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multiss_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.c new file mode 100644 index 000000000..53746a0d9 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-map_multiss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_decimate_by__works(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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_string_map_multiss_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_string_map_multiss_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.h new file mode 100644 index 000000000..340986970 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multiss_decimate_by_h +#define _TEST__F_string_map_multiss_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_map_multiss_decimate_by() + */ +extern void test__f_string_map_multiss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multiss_decimate_by() + */ +extern void test__f_string_map_multiss_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multiss_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.c new file mode 100644 index 000000000..1c018c2ee --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-map_multiss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_decrease_by__works(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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_string_map_multiss_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_string_map_multiss_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.h new file mode 100644 index 000000000..336e94486 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multiss_decrease_by_h +#define _TEST__F_string_map_multiss_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_map_multiss_decrease_by() + */ +extern void test__f_string_map_multiss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multiss_decrease_by() + */ +extern void test__f_string_map_multiss_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multiss_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_increase.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_increase.c new file mode 100644 index 000000000..f87c902d9 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-map_multiss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_increase__works(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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_string_map_multiss_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_string_map_multiss_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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_string_map_multiss_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_string_map_multiss_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_increase.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_increase.h new file mode 100644 index 000000000..3a658b894 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multiss_increase_h +#define _TEST__F_string_map_multiss_increase_h + +/** + * Test that the function works. + * + * @see f_string_map_multiss_increase() + */ +extern void test__f_string_map_multiss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_map_multiss_increase() + */ +extern void test__f_string_map_multiss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multiss_increase() + */ +extern void test__f_string_map_multiss_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multiss_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.c new file mode 100644 index 000000000..14b0e8743 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-map_multiss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_increase_by__works(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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_string_map_multiss_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_string_map_multiss_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multis_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.h new file mode 100644 index 000000000..ec3489c13 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multiss_increase_by_h +#define _TEST__F_string_map_multiss_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_map_multiss_increase_by() + */ +extern void test__f_string_map_multiss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multiss_increase_by() + */ +extern void test__f_string_map_multiss_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multiss_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_resize.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_resize.c new file mode 100644 index 000000000..31f6b1ab6 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-map_multiss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_resize__works(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multiss_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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_string_map_multiss_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_map_multiss_t data = f_string_map_multiss_t_initialize; + + { + const f_status_t status = f_string_map_multiss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_resize.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_resize.h new file mode 100644 index 000000000..a6420ecb8 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_map_multiss_resize_h +#define _TEST__F_string_map_multiss_resize_h + +/** + * Test that the function works. + * + * @see f_string_map_multiss_resize() + */ +extern void test__f_string_map_multiss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_map_multiss_resize() + */ +extern void test__f_string_map_multiss_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_map_multiss_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-maps_adjust.c b/level_0/f_string/tests/unit/c/test-string-maps_adjust.c new file mode 100644 index 000000000..700a7e3f5 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-maps_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_adjust__works(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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_string_maps_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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 diff --git a/level_0/f_string/tests/unit/c/test-string-maps_adjust.h b/level_0/f_string/tests/unit/c/test-string-maps_adjust.h new file mode 100644 index 000000000..ae45a656e --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__string_maps_adjust +#define _TEST__F_string__string_maps_adjust + +/** + * Test that the function works. + * + * @see f_string_maps_adjust() + */ +extern void test__f_string_maps_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_maps_adjust() + */ +extern void test__f_string_maps_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string__string_maps_adjust diff --git a/level_0/f_string/tests/unit/c/test-string-maps_append.c b/level_0/f_string/tests/unit/c/test-string-maps_append.c new file mode 100644 index 000000000..226ce3491 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_append.c @@ -0,0 +1,63 @@ +#include "test-string.h" +#include "test-string-maps_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_append__works(void **state) { + + f_string_map_t source = f_string_map_t_initialize; + f_string_maps_t destination = f_string_maps_t_initialize; + + const f_string_static_t test_name = macro_f_string_static_t_initialize("test_name", 0, 9); + const f_string_static_t test_value = macro_f_string_static_t_initialize("test_value", 0, 10); + + { + f_status_t status = f_string_dynamic_append(test_name, &source.name); + + assert_int_equal(status, F_none); + assert_string_equal(source.name.string, test_name.string); + assert_int_equal(source.name.used, test_name.used); + + status = f_string_dynamic_append(test_value, &source.value); + + assert_int_equal(status, F_none); + assert_string_equal(source.value.string, test_value.string); + assert_int_equal(source.value.used, test_value.used); + } + + { + const f_status_t status = f_string_maps_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].name.used, source.name.used); + assert_int_equal(destination.array[0].value.used, source.value.used); + assert_string_equal(destination.array[0].name.string, source.name.string); + assert_string_equal(destination.array[0].value.string, source.value.string); + } + + free((void *) source.name.string); + free((void *) source.value.string); + + free((void *) destination.array[0].name.string); + free((void *) destination.array[0].value.string); + + free((void *) destination.array); +} + +void test__f_string_maps_append__parameter_checking(void **state) { + + const f_string_map_t data = f_string_map_t_initialize; + + { + const f_status_t status = f_string_maps_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-maps_append.h b/level_0/f_string/tests/unit/c/test-string-maps_append.h new file mode 100644 index 000000000..8cac92fb5 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_maps_append_h +#define _TEST__F_string_maps_append_h + +/** + * Test that the function works. + * + * @see f_string_maps_append() + */ +extern void test__f_string_maps_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_maps_append() + */ +extern void test__f_string_maps_append__parameter_checking(void **state); + +#endif // _TEST__F_string_maps_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-maps_append_all.c b/level_0/f_string/tests/unit/c/test-string-maps_append_all.c new file mode 100644 index 000000000..d985f05da --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_append_all.c @@ -0,0 +1,112 @@ +#include "test-string.h" +#include "test-string-maps_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_string_maps_t source = f_string_maps_t_initialize; + f_string_maps_t destination = f_string_maps_t_initialize; + + const f_string_static_t test_name = macro_f_string_static_t_initialize("test_name", 0, 9); + const f_string_static_t test_value = macro_f_string_static_t_initialize("test_value", 0, 10); + + { + f_status_t status = f_string_maps_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_string_dynamic_append(test_name, &source.array[source.used].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].name.string, test_name.string); + assert_int_equal(source.array[source.used].name.used, test_name.used); + + status = f_string_dynamic_append(test_value, &source.array[source.used].value); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].value.string, test_value.string); + assert_int_equal(source.array[source.used].value.used, test_value.used); + } // for + } + + { + const f_status_t status = f_string_maps_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[i].name.used, source.array[i].name.used); + assert_int_equal(destination.array[i].value.used, source.array[i].value.used); + + assert_string_equal(destination.array[i].name.string, source.array[i].name.string); + assert_string_equal(destination.array[i].value.string, source.array[i].value.string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].name.string); + free((void *) source.array[i].value.string); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + free((void *) destination.array[i].name.string); + free((void *) destination.array[i].value.string); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_string_maps_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_maps_t source = f_string_maps_t_initialize; + f_string_maps_t destination = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_maps_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_maps_append_all__parameter_checking(void **state) { + + const f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-maps_append_all.h b/level_0/f_string/tests/unit/c/test-string-maps_append_all.h new file mode 100644 index 000000000..aa6ae7039 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_maps_append_all_h +#define _TEST__F_string_maps_append_all_h + +/** + * Test that the function works. + * + * @see f_string_maps_append_all() + */ +extern void test__f_string_maps_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_maps_append_all() + */ +extern void test__f_string_maps_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_maps_append_all() + */ +extern void test__f_string_maps_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_maps_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-maps_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-maps_decimate_by.c new file mode 100644 index 000000000..ee9cd18ef --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-maps_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_decimate_by__works(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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_string_maps_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_string_maps_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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 diff --git a/level_0/f_string/tests/unit/c/test-string-maps_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-maps_decimate_by.h new file mode 100644 index 000000000..bfe898b7a --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_maps_decimate_by_h +#define _TEST__F_maps_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_maps_decimate_by() + */ +extern void test__f_string_maps_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_maps_decimate_by() + */ +extern void test__f_string_maps_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_maps_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-maps_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-maps_decrease_by.c new file mode 100644 index 000000000..cd6f88e74 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-maps_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_decrease_by__works(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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_string_maps_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_string_maps_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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 diff --git a/level_0/f_string/tests/unit/c/test-string-maps_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-maps_decrease_by.h new file mode 100644 index 000000000..669c78291 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_maps_decrease_by_h +#define _TEST__F_string_maps_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_maps_decrease_by() + */ +extern void test__f_string_maps_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_maps_decrease_by() + */ +extern void test__f_string_maps_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_maps_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-maps_increase.c b/level_0/f_string/tests/unit/c/test-string-maps_increase.c new file mode 100644 index 000000000..fa1e369de --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-maps_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_increase__works(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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_string_maps_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_string_maps_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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_string_maps_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_string_maps_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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 diff --git a/level_0/f_string/tests/unit/c/test-string-maps_increase.h b/level_0/f_string/tests/unit/c/test-string-maps_increase.h new file mode 100644 index 000000000..459fbdfc3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_maps_increase_h +#define _TEST__F_string_maps_increase_h + +/** + * Test that the function works. + * + * @see f_string_maps_increase() + */ +extern void test__f_string_maps_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_maps_increase() + */ +extern void test__f_string_maps_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_maps_increase() + */ +extern void test__f_string_maps_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_maps_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-maps_increase_by.c b/level_0/f_string/tests/unit/c/test-string-maps_increase_by.c new file mode 100644 index 000000000..0d0cd23cf --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-maps_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_increase_by__works(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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_string_maps_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_string_maps_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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 diff --git a/level_0/f_string/tests/unit/c/test-string-maps_increase_by.h b/level_0/f_string/tests/unit/c/test-string-maps_increase_by.h new file mode 100644 index 000000000..70f17dd99 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_maps_increase_by_h +#define _TEST__F_string_maps_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_maps_increase_by() + */ +extern void test__f_string_maps_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_maps_increase_by() + */ +extern void test__f_string_maps_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_maps_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-maps_resize.c b/level_0/f_string/tests/unit/c/test-string-maps_resize.c new file mode 100644 index 000000000..38f41e771 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-maps_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_resize__works(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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_string_maps_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_maps_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 diff --git a/level_0/f_string/tests/unit/c/test-string-maps_resize.h b/level_0/f_string/tests/unit/c/test-string-maps_resize.h new file mode 100644 index 000000000..347deef85 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_maps_resize_h +#define _TEST__F_string_maps_resize_h + +/** + * Test that the function works. + * + * @see f_string_maps_resize() + */ +extern void test__f_string_maps_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_maps_resize() + */ +extern void test__f_string_maps_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_maps_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_adjust.c b/level_0/f_string/tests/unit/c/test-string-mapss_adjust.c new file mode 100644 index 000000000..5bf50cb36 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-mapss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_adjust__works(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_mapss_t_initialize; + + { + const f_status_t status = f_string_mapss_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_string_mapss_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_mapss_t_initialize; + + { + const f_status_t status = f_string_mapss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_adjust.h b/level_0/f_string/tests/unit/c/test-string-mapss_adjust.h new file mode 100644 index 000000000..379910416 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_mapss_adjust_h +#define _TEST__F_string_mapss_adjust_h + +/** + * Test that the function works. + * + * @see f_string_mapss_adjust() + */ +extern void test__f_string_mapss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_mapss_adjust() + */ +extern void test__f_string_mapss_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string_mapss_adjust_h diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_append.c b/level_0/f_string/tests/unit/c/test-string-mapss_append.c new file mode 100644 index 000000000..1c5f2fea0 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_append.c @@ -0,0 +1,120 @@ +#include "test-string.h" +#include "test-string-mapss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_append__works(void **state) { + + const int length_inner = 2; + f_string_maps_t source = f_string_maps_t_initialize; + f_string_mapss_t destination = f_string_mapss_t_initialize; + + const f_string_static_t test_names[] = { + macro_f_string_static_t_initialize("test_name1", 0, 10), + macro_f_string_static_t_initialize("test_name2", 0, 10), + }; + + const f_string_static_t test_values[] = { + macro_f_string_static_t_initialize("test_value1", 0, 11), + macro_f_string_static_t_initialize("test_value2", 0, 11), + }; + + { + f_status_t status = f_string_maps_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_string_dynamic_append(test_names[source.used], &source.array[source.used].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].name.string, test_names[source.used].string); + assert_int_equal(source.array[source.used].name.used, test_names[source.used].used); + + status = f_string_dynamic_append(test_values[source.used], &source.array[source.used].value); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].value.string, test_values[source.used].string); + assert_int_equal(source.array[source.used].value.used, test_values[source.used].used); + } // for + } + + { + const f_status_t status = f_string_mapss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_inner); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[0].array[i].name.used, test_names[i].used); + assert_int_equal(destination.array[0].array[i].value.used, test_values[i].used); + + assert_string_equal(destination.array[0].array[i].name.string, test_names[i].string); + assert_string_equal(destination.array[0].array[i].value.string, test_values[i].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].name.string); + free((void *) source.array[i].value.string); + } // for + + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + + free((void *) destination.array[0].array[i].name.string); + free((void *) destination.array[0].array[i].value.string); + } // for + + free((void *) destination.array[0].array); + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_string_mapss_append__returns_data_not(void **state) { + + const int length = 5; + f_string_maps_t source = f_string_mapss_t_initialize; + f_string_mapss_t destination = f_string_mapss_t_initialize; + + { + const f_status_t status = f_string_maps_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_mapss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_mapss_append__parameter_checking(void **state) { + + f_string_maps_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_append.h b/level_0/f_string/tests/unit/c/test-string-mapss_append.h new file mode 100644 index 000000000..b2f64cd00 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_mapss_append_h +#define _TEST__F_string_mapss_append_h + +/** + * Test that the function works. + * + * @see f_string_mapss_append() + */ +extern void test__f_string_mapss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_mapss_append() + */ +extern void test__f_string_mapss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_mapss_append() + */ +extern void test__f_string_mapss_append__parameter_checking(void **state); + +#endif // _TEST__F_string_mapss_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_append_all.c b/level_0/f_string/tests/unit/c/test-string-mapss_append_all.c new file mode 100644 index 000000000..d1639cc40 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_append_all.c @@ -0,0 +1,147 @@ +#include "test-string.h" +#include "test-string-mapss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + const int length_outer = 2; + f_string_mapss_t source = f_string_mapss_t_initialize; + f_string_mapss_t destination = f_string_mapss_t_initialize; + + const f_string_static_t test_names[] = { + macro_f_string_static_t_initialize("test_name1", 0, 10), + macro_f_string_static_t_initialize("test_name2", 0, 10), + }; + + const f_string_static_t test_values[] = { + macro_f_string_static_t_initialize("test_value1", 0, 11), + macro_f_string_static_t_initialize("test_value2", 0, 11), + }; + + { + f_status_t status = f_string_mapss_resize(length_outer, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length_outer); + + f_array_length_t i = 0; + f_array_length_t j = 0; + + for (; source.used < length_outer; ++source.used) { + + status = f_string_maps_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].used, 0); + assert_int_equal(source.array[source.used].size, length_inner); + + for (i = 0; i < length_inner; ++i) { + + status = f_string_dynamic_append(test_names[i], &source.array[source.used].array[i].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].array[i].name.string, test_names[i].string); + assert_int_equal(source.array[source.used].array[i].name.used, test_names[i].used); + + status = f_string_dynamic_append(test_values[i], &source.array[source.used].array[i].value); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].array[i].value.string, test_values[i].string); + assert_int_equal(source.array[source.used].array[i].value.used, test_values[i].used); + } // for + + source.array[source.used].used = length_inner; + } // for + } + + { + const f_status_t status = f_string_mapss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[j].array[i].name.used, test_names[i].used); + assert_int_equal(destination.array[j].array[i].value.used, test_values[i].used); + + assert_string_equal(destination.array[j].array[i].name.string, test_names[i].string); + assert_string_equal(destination.array[j].array[i].value.string, test_values[i].string); + } // for + } // for + } + + for (f_array_length_t j = 0; j < source.used; ++j) { + + for (f_array_length_t i = 0; i < source.array[j].used; ++i) { + + free((void *) source.array[j].array[i].name.string); + free((void *) source.array[j].array[i].value.string); + } // for + + free((void *) source.array[j].array); + } // for + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + + free((void *) destination.array[j].array[i].name.string); + free((void *) destination.array[j].array[i].value.string); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_string_mapss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_mapss_t source = f_string_mapss_t_initialize; + f_string_mapss_t destination = f_string_mapss_t_initialize; + + { + const f_status_t status = f_string_mapss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_mapss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_mapss_append_all__parameter_checking(void **state) { + + const f_string_mapss_t data = f_string_mapss_t_initialize; + + { + const f_status_t status = f_string_mapss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_append_all.h b/level_0/f_string/tests/unit/c/test-string-mapss_append_all.h new file mode 100644 index 000000000..9ef0fb955 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_mapss_append_all_h +#define _TEST__F_string_mapss_append_all_h + +/** + * Test that the function works. + * + * @see f_string_mapss_append_all() + */ +extern void test__f_string_mapss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_mapss_append_all() + */ +extern void test__f_string_mapss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_mapss_append_all() + */ +extern void test__f_string_mapss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_mapss_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.c new file mode 100644 index 000000000..705868396 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-mapss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_decimate_by__works(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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_string_mapss_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_string_mapss_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.h new file mode 100644 index 000000000..41796e65c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_mapss_decimate_by_h +#define _TEST__F_string_mapss_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_mapss_decimate_by() + */ +extern void test__f_string_mapss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_mapss_decimate_by() + */ +extern void test__f_string_mapss_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_string_mapss_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.c new file mode 100644 index 000000000..1af9f57c2 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-mapss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_decrease_by__works(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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_string_mapss_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_string_mapss_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.h new file mode 100644 index 000000000..05900c41a --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_mapss_decrease_by_h +#define _TEST__F_string_mapss_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_mapss_decrease_by() + */ +extern void test__f_string_mapss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_mapss_decrease_by() + */ +extern void test__f_string_mapss_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_mapss_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_increase.c b/level_0/f_string/tests/unit/c/test-string-mapss_increase.c new file mode 100644 index 000000000..60cfcccf4 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-mapss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_increase__works(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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_string_mapss_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_string_mapss_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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_string_mapss_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_string_mapss_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_increase.h b/level_0/f_string/tests/unit/c/test-string-mapss_increase.h new file mode 100644 index 000000000..37f3aa876 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_mapss_increase_h +#define _TEST__F_string_mapss_increase_h + +/** + * Test that the function works. + * + * @see f_string_mapss_increase() + */ +extern void test__f_string_mapss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_mapss_increase() + */ +extern void test__f_string_mapss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_mapss_increase() + */ +extern void test__f_string_mapss_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_mapss_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_increase_by.c b/level_0/f_string/tests/unit/c/test-string-mapss_increase_by.c new file mode 100644 index 000000000..b208f85d2 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-mapss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_increase_by__works(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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_string_mapss_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_string_mapss_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_maps_t_initialize; + + { + const f_status_t status = f_string_mapss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_increase_by.h b/level_0/f_string/tests/unit/c/test-string-mapss_increase_by.h new file mode 100644 index 000000000..697e5e286 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_mapss_increase_by_h +#define _TEST__F_string_mapss_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_mapss_increase_by() + */ +extern void test__f_string_mapss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_mapss_increase_by() + */ +extern void test__f_string_mapss_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_mapss_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_resize.c b/level_0/f_string/tests/unit/c/test-string-mapss_resize.c new file mode 100644 index 000000000..bf99ffe00 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-mapss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_resize__works(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_mapss_t_initialize; + + { + const f_status_t status = f_string_mapss_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_string_mapss_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_mapss_t data = f_string_mapss_t_initialize; + + { + const f_status_t status = f_string_mapss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_resize.h b/level_0/f_string/tests/unit/c/test-string-mapss_resize.h new file mode 100644 index 000000000..b12fedaa6 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_mapss_resize_h +#define _TEST__F_string_mapss_resize_h + +/** + * Test that the function works. + * + * @see f_string_mapss_resize() + */ +extern void test__f_string_mapss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_mapss_resize() + */ +extern void test__f_string_mapss_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_mapss_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_adjust.c b/level_0/f_string/tests/unit/c/test-string-quantitys_adjust.c new file mode 100644 index 000000000..cb9562f8a --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-quantitys_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantitys_adjust__works(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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_string_quantitys_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_adjust.h b/level_0/f_string/tests/unit/c/test-string-quantitys_adjust.h new file mode 100644 index 000000000..ef22e013c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__string_quantitys_adjust +#define _TEST__F_string__string_quantitys_adjust + +/** + * Test that the function works. + * + * @see f_string_quantitys_adjust() + */ +extern void test__f_string_quantitys_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantitys_adjust() + */ +extern void test__f_string_quantitys_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string__string_quantitys_adjust diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_append.c b/level_0/f_string/tests/unit/c/test-string-quantitys_append.c new file mode 100644 index 000000000..61101fbcc --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_append.c @@ -0,0 +1,38 @@ +#include "test-string.h" +#include "test-string-quantitys_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantitys_append__works(void **state) { + + const f_string_quantity_t source = macro_f_string_quantity_t_initialize(1, 2); + f_string_quantitys_t destination = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].start, source.start); + assert_int_equal(destination.array[0].total, source.total); + } + + free((void *) destination.array); +} + +void test__f_string_quantitys_append__parameter_checking(void **state) { + + const f_string_quantity_t data = f_string_quantity_t_initialize; + + { + const f_status_t status = f_string_quantitys_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_append.h b/level_0/f_string/tests/unit/c/test-string-quantitys_append.h new file mode 100644 index 000000000..34bf1f868 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantitys_append_h +#define _TEST__F_string_quantitys_append_h + +/** + * Test that the function works. + * + * @see f_string_quantitys_append() + */ +extern void test__f_string_quantitys_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantitys_append() + */ +extern void test__f_string_quantitys_append__parameter_checking(void **state); + +#endif // _TEST__F_string_quantitys_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_append_all.c b/level_0/f_string/tests/unit/c/test-string-quantitys_append_all.c new file mode 100644 index 000000000..5d761c5b6 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_append_all.c @@ -0,0 +1,77 @@ +#include "test-string.h" +#include "test-string-quantitys_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantitys_append_all__works(void **state) { + + const int length = 5; + const int length_sources = 2; + + f_string_quantity_t sources_array[] = { + macro_f_string_quantity_t_initialize(1, 2), + macro_f_string_quantity_t_initialize(3, 4), + }; + + const f_string_quantitys_t source = macro_f_string_quantitys_t_initialize(sources_array, 0, length_sources); + f_string_quantitys_t destination = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[i].start, source.array[i].start); + assert_int_equal(destination.array[i].total, source.array[i].total); + } // for + } + + free((void *) destination.array); +} + +void test__f_string_quantitys_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_quantitys_t source = f_string_quantitys_t_initialize; + f_string_quantitys_t destination = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_quantitys_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_quantitys_append_all__parameter_checking(void **state) { + + const f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_append_all.h b/level_0/f_string/tests/unit/c/test-string-quantitys_append_all.h new file mode 100644 index 000000000..d79e2e2ce --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantitys_append_all_h +#define _TEST__F_string_quantitys_append_all_h + +/** + * Test that the function works. + * + * @see f_string_quantitys_append_all() + */ +extern void test__f_string_quantitys_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_quantitys_append_all() + */ +extern void test__f_string_quantitys_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantitys_append_all() + */ +extern void test__f_string_quantitys_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_quantitys_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.c new file mode 100644 index 000000000..f83ab4917 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-quantitys_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantitys_decimate_by__works(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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_string_quantitys_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_string_quantitys_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.h new file mode 100644 index 000000000..c691a9f9c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_quantitys_decimate_by_h +#define _TEST__F_quantitys_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_quantitys_decimate_by() + */ +extern void test__f_string_quantitys_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantitys_decimate_by() + */ +extern void test__f_string_quantitys_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_quantitys_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.c new file mode 100644 index 000000000..fe517a0ca --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-quantitys_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantitys_decrease_by__works(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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_string_quantitys_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_string_quantitys_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.h new file mode 100644 index 000000000..f867bee72 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantitys_decrease_by_h +#define _TEST__F_string_quantitys_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_quantitys_decrease_by() + */ +extern void test__f_string_quantitys_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantitys_decrease_by() + */ +extern void test__f_string_quantitys_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_quantitys_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_increase.c b/level_0/f_string/tests/unit/c/test-string-quantitys_increase.c new file mode 100644 index 000000000..c319869d9 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-quantitys_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantitys_increase__works(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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_string_quantitys_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_string_quantitys_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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_string_quantitys_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_string_quantitys_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_increase.h b/level_0/f_string/tests/unit/c/test-string-quantitys_increase.h new file mode 100644 index 000000000..7631810f4 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantitys_increase_h +#define _TEST__F_string_quantitys_increase_h + +/** + * Test that the function works. + * + * @see f_string_quantitys_increase() + */ +extern void test__f_string_quantitys_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_quantitys_increase() + */ +extern void test__f_string_quantitys_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantitys_increase() + */ +extern void test__f_string_quantitys_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_quantitys_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.c b/level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.c new file mode 100644 index 000000000..6e77fc4ff --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-quantitys_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantitys_increase_by__works(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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_string_quantitys_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_string_quantitys_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.h b/level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.h new file mode 100644 index 000000000..02e9da12d --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantitys_increase_by_h +#define _TEST__F_string_quantitys_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_quantitys_increase_by() + */ +extern void test__f_string_quantitys_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantitys_increase_by() + */ +extern void test__f_string_quantitys_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_quantitys_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_resize.c b/level_0/f_string/tests/unit/c/test-string-quantitys_resize.c new file mode 100644 index 000000000..76bd355e3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-quantitys_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantitys_resize__works(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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_string_quantitys_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantitys_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantitys_resize.h b/level_0/f_string/tests/unit/c/test-string-quantitys_resize.h new file mode 100644 index 000000000..bc764bda3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantitys_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantitys_resize_h +#define _TEST__F_string_quantitys_resize_h + +/** + * Test that the function works. + * + * @see f_string_quantitys_resize() + */ +extern void test__f_string_quantitys_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantitys_resize() + */ +extern void test__f_string_quantitys_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_quantitys_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_adjust.c b/level_0/f_string/tests/unit/c/test-string-quantityss_adjust.c new file mode 100644 index 000000000..cbaa424ed --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-quantityss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_adjust__works(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantityss_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_string_quantityss_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantityss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_adjust.h b/level_0/f_string/tests/unit/c/test-string-quantityss_adjust.h new file mode 100644 index 000000000..7a1f6b83e --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantityss_adjust_h +#define _TEST__F_string_quantityss_adjust_h + +/** + * Test that the function works. + * + * @see f_string_quantityss_adjust() + */ +extern void test__f_string_quantityss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantityss_adjust() + */ +extern void test__f_string_quantityss_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string_quantityss_adjust_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_append.c b/level_0/f_string/tests/unit/c/test-string-quantityss_append.c new file mode 100644 index 000000000..ff8ee2354 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_append.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-quantityss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_append__works(void **state) { + + const int length_sources = 2; + + f_string_quantity_t sources_array[] = { + macro_f_string_quantity_t_initialize(1, 2), + macro_f_string_quantity_t_initialize(3, 4), + }; + + const f_string_quantitys_t source = macro_f_string_quantitys_t_initialize(sources_array, 0, length_sources); + f_string_quantityss_t destination = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantityss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_sources); + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[0].array[i].start, sources_array[i].start); + assert_int_equal(destination.array[0].array[i].total, sources_array[i].total); + } // for + } + + free((void *) destination.array[0].array); + free((void *) destination.array); +} + +void test__f_string_quantityss_append__returns_data_not(void **state) { + + const int length = 5; + f_string_quantitys_t source = f_string_quantityss_t_initialize; + f_string_quantityss_t destination = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantitys_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_quantityss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_quantityss_append__parameter_checking(void **state) { + + f_string_quantitys_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_append.h b/level_0/f_string/tests/unit/c/test-string-quantityss_append.h new file mode 100644 index 000000000..72a7f258f --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantityss_append_h +#define _TEST__F_string_quantityss_append_h + +/** + * Test that the function works. + * + * @see f_string_quantityss_append() + */ +extern void test__f_string_quantityss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_quantityss_append() + */ +extern void test__f_string_quantityss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantityss_append() + */ +extern void test__f_string_quantityss_append__parameter_checking(void **state); + +#endif // _TEST__F_string_quantityss_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_append_all.c b/level_0/f_string/tests/unit/c/test-string-quantityss_append_all.c new file mode 100644 index 000000000..17c0174b2 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_append_all.c @@ -0,0 +1,93 @@ +#include "test-string.h" +#include "test-string-quantityss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_append_all__works(void **state) { + + const int length_sources = 2; + const int length_sources_set = 2; + + f_string_quantity_t sources_array1[] = { + macro_f_string_quantity_t_initialize(1, 2), + macro_f_string_quantity_t_initialize(3, 4), + }; + + f_string_quantity_t sources_array2[] = { + macro_f_string_quantity_t_initialize(5, 6), + macro_f_string_quantity_t_initialize(7, 8), + }; + + f_string_quantitys_t sources_set_array[] = { + macro_f_string_quantitys_t_initialize(sources_array1, 0, length_sources), + macro_f_string_quantitys_t_initialize(sources_array2, 0, length_sources), + }; + + const f_string_quantityss_t source = macro_f_string_quantityss_t_initialize(sources_set_array, 0, length_sources_set); + f_string_quantityss_t destination = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantityss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_sources_set; ++j) { + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[j].array[i].start, sources_set_array[j].array[i].start); + assert_int_equal(destination.array[j].array[i].total, sources_set_array[j].array[i].total); + } // for + } // for + } + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) destination.array); +} + +void test__f_string_quantityss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_quantityss_t source = f_string_quantityss_t_initialize; + f_string_quantityss_t destination = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantityss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_quantityss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_quantityss_append_all__parameter_checking(void **state) { + + const f_string_quantityss_t data = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantityss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_append_all.h b/level_0/f_string/tests/unit/c/test-string-quantityss_append_all.h new file mode 100644 index 000000000..edd12ee21 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantityss_append_all_h +#define _TEST__F_string_quantityss_append_all_h + +/** + * Test that the function works. + * + * @see f_string_quantityss_append_all() + */ +extern void test__f_string_quantityss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_quantityss_append_all() + */ +extern void test__f_string_quantityss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantityss_append_all() + */ +extern void test__f_string_quantityss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_quantityss_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.c new file mode 100644 index 000000000..cf1d197ea --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-quantityss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_decimate_by__works(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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_string_quantityss_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_string_quantityss_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.h new file mode 100644 index 000000000..2ea5057d5 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantityss_decimate_by_h +#define _TEST__F_string_quantityss_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_quantityss_decimate_by() + */ +extern void test__f_string_quantityss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantityss_decimate_by() + */ +extern void test__f_string_quantityss_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_string_quantityss_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.c new file mode 100644 index 000000000..99e87b694 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-quantityss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_decrease_by__works(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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_string_quantityss_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_string_quantityss_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.h new file mode 100644 index 000000000..cbce24f1d --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantityss_decrease_by_h +#define _TEST__F_string_quantityss_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_quantityss_decrease_by() + */ +extern void test__f_string_quantityss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantityss_decrease_by() + */ +extern void test__f_string_quantityss_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_quantityss_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_increase.c b/level_0/f_string/tests/unit/c/test-string-quantityss_increase.c new file mode 100644 index 000000000..bf108adbd --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-quantityss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_increase__works(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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_string_quantityss_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_string_quantityss_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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_string_quantityss_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_string_quantityss_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_increase.h b/level_0/f_string/tests/unit/c/test-string-quantityss_increase.h new file mode 100644 index 000000000..505a80b53 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantityss_increase_h +#define _TEST__F_string_quantityss_increase_h + +/** + * Test that the function works. + * + * @see f_string_quantityss_increase() + */ +extern void test__f_string_quantityss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_quantityss_increase() + */ +extern void test__f_string_quantityss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantityss_increase() + */ +extern void test__f_string_quantityss_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_quantityss_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.c b/level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.c new file mode 100644 index 000000000..7ef6cfcf3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-quantityss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_increase_by__works(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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_string_quantityss_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_string_quantityss_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantitys_t_initialize; + + { + const f_status_t status = f_string_quantityss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.h b/level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.h new file mode 100644 index 000000000..0dc61ade4 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantityss_increase_by_h +#define _TEST__F_string_quantityss_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_quantityss_increase_by() + */ +extern void test__f_string_quantityss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantityss_increase_by() + */ +extern void test__f_string_quantityss_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_quantityss_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_resize.c b/level_0/f_string/tests/unit/c/test-string-quantityss_resize.c new file mode 100644 index 000000000..e4cb92ac8 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-quantityss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_resize__works(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantityss_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_string_quantityss_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_quantityss_t data = f_string_quantityss_t_initialize; + + { + const f_status_t status = f_string_quantityss_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 diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_resize.h b/level_0/f_string/tests/unit/c/test-string-quantityss_resize.h new file mode 100644 index 000000000..202dfd9bc --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_quantityss_resize_h +#define _TEST__F_string_quantityss_resize_h + +/** + * Test that the function works. + * + * @see f_string_quantityss_resize() + */ +extern void test__f_string_quantityss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_quantityss_resize() + */ +extern void test__f_string_quantityss_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_quantityss_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_adjust.c b/level_0/f_string/tests/unit/c/test-string-ranges_adjust.c new file mode 100644 index 000000000..3c8b05df8 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-ranges_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_ranges_adjust__works(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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_string_ranges_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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 diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_adjust.h b/level_0/f_string/tests/unit/c/test-string-ranges_adjust.h new file mode 100644 index 000000000..66ed77f72 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__string_ranges_adjust +#define _TEST__F_string__string_ranges_adjust + +/** + * Test that the function works. + * + * @see f_string_ranges_adjust() + */ +extern void test__f_string_ranges_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_ranges_adjust() + */ +extern void test__f_string_ranges_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string__string_ranges_adjust diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_append.c b/level_0/f_string/tests/unit/c/test-string-ranges_append.c new file mode 100644 index 000000000..b126fb030 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_append.c @@ -0,0 +1,39 @@ +#include "test-string.h" +#include "test-string-ranges_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_ranges_append__works(void **state) { + + const f_array_length_t length = 5; + const f_string_range_t source = macro_f_string_range_t_initialize(1, 2); + f_string_ranges_t destination = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].start, source.start); + assert_int_equal(destination.array[0].stop, source.stop); + } + + free((void *) destination.array); +} + +void test__f_string_ranges_append__parameter_checking(void **state) { + + const f_string_range_t data = f_string_range_t_initialize; + + { + const f_status_t status = f_string_ranges_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_append.h b/level_0/f_string/tests/unit/c/test-string-ranges_append.h new file mode 100644 index 000000000..13217c8f7 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_ranges_append_h +#define _TEST__F_string_ranges_append_h + +/** + * Test that the function works. + * + * @see f_string_ranges_append() + */ +extern void test__f_string_ranges_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_ranges_append() + */ +extern void test__f_string_ranges_append__parameter_checking(void **state); + +#endif // _TEST__F_string_ranges_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_append_all.c b/level_0/f_string/tests/unit/c/test-string-ranges_append_all.c new file mode 100644 index 000000000..733848f31 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_append_all.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-ranges_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_ranges_append_all__works(void **state) { + + const int length_sources = 2; + + f_string_range_t sources_array[] = { + macro_f_string_range_t_initialize(1, 2), + macro_f_string_range_t_initialize(3, 4), + }; + + const f_string_ranges_t source = macro_f_string_ranges_t_initialize(sources_array, 0, length_sources); + f_string_ranges_t destination = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[i].start, source.array[i].start); + assert_int_equal(destination.array[i].stop, source.array[i].stop); + } // for + } + + free((void *) destination.array); +} + +void test__f_string_ranges_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_ranges_t source = f_string_ranges_t_initialize; + f_string_ranges_t destination = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_ranges_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_ranges_append_all__parameter_checking(void **state) { + + const f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_append_all.h b/level_0/f_string/tests/unit/c/test-string-ranges_append_all.h new file mode 100644 index 000000000..7fb731093 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_ranges_append_all_h +#define _TEST__F_string_ranges_append_all_h + +/** + * Test that the function works. + * + * @see f_string_ranges_append_all() + */ +extern void test__f_string_ranges_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_ranges_append_all() + */ +extern void test__f_string_ranges_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_ranges_append_all() + */ +extern void test__f_string_ranges_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_ranges_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.c new file mode 100644 index 000000000..624857b4f --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-ranges_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_ranges_decimate_by__works(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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_string_ranges_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_string_ranges_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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 diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.h new file mode 100644 index 000000000..064bdb43a --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_ranges_decimate_by_h +#define _TEST__F_ranges_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_ranges_decimate_by() + */ +extern void test__f_string_ranges_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_ranges_decimate_by() + */ +extern void test__f_string_ranges_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_ranges_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.c new file mode 100644 index 000000000..7ff01c5fd --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-ranges_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_ranges_decrease_by__works(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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_string_ranges_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_string_ranges_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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 diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.h new file mode 100644 index 000000000..8c4553038 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_ranges_decrease_by_h +#define _TEST__F_string_ranges_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_ranges_decrease_by() + */ +extern void test__f_string_ranges_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_ranges_decrease_by() + */ +extern void test__f_string_ranges_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_ranges_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_increase.c b/level_0/f_string/tests/unit/c/test-string-ranges_increase.c new file mode 100644 index 000000000..220e7c7d0 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-ranges_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_ranges_increase__works(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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_string_ranges_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_string_ranges_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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_string_ranges_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_string_ranges_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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 diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_increase.h b/level_0/f_string/tests/unit/c/test-string-ranges_increase.h new file mode 100644 index 000000000..1746e7ce2 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_ranges_increase_h +#define _TEST__F_string_ranges_increase_h + +/** + * Test that the function works. + * + * @see f_string_ranges_increase() + */ +extern void test__f_string_ranges_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_ranges_increase() + */ +extern void test__f_string_ranges_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_ranges_increase() + */ +extern void test__f_string_ranges_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_ranges_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_increase_by.c b/level_0/f_string/tests/unit/c/test-string-ranges_increase_by.c new file mode 100644 index 000000000..4034fcb73 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-ranges_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_ranges_increase_by__works(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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_string_ranges_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_string_ranges_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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 diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_increase_by.h b/level_0/f_string/tests/unit/c/test-string-ranges_increase_by.h new file mode 100644 index 000000000..8c3a5de99 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_ranges_increase_by_h +#define _TEST__F_string_ranges_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_ranges_increase_by() + */ +extern void test__f_string_ranges_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_ranges_increase_by() + */ +extern void test__f_string_ranges_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_ranges_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_resize.c b/level_0/f_string/tests/unit/c/test-string-ranges_resize.c new file mode 100644 index 000000000..1bc26601c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-ranges_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_ranges_resize__works(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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_string_ranges_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_ranges_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 diff --git a/level_0/f_string/tests/unit/c/test-string-ranges_resize.h b/level_0/f_string/tests/unit/c/test-string-ranges_resize.h new file mode 100644 index 000000000..7b68c7766 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-ranges_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_ranges_resize_h +#define _TEST__F_string_ranges_resize_h + +/** + * Test that the function works. + * + * @see f_string_ranges_resize() + */ +extern void test__f_string_ranges_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_ranges_resize() + */ +extern void test__f_string_ranges_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_ranges_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_adjust.c b/level_0/f_string/tests/unit/c/test-string-rangess_adjust.c new file mode 100644 index 000000000..e1bd3337c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-rangess_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_adjust__works(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_rangess_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_string_rangess_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_rangess_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 diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_adjust.h b/level_0/f_string/tests/unit/c/test-string-rangess_adjust.h new file mode 100644 index 000000000..186b872db --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_rangess_adjust_h +#define _TEST__F_string_rangess_adjust_h + +/** + * Test that the function works. + * + * @see f_string_rangess_adjust() + */ +extern void test__f_string_rangess_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_rangess_adjust() + */ +extern void test__f_string_rangess_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string_rangess_adjust_h diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_append.c b/level_0/f_string/tests/unit/c/test-string-rangess_append.c new file mode 100644 index 000000000..0af745965 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_append.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-rangess_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_append__works(void **state) { + + const int length_sources = 2; + + f_string_range_t sources_array[] = { + macro_f_string_range_t_initialize(1, 2), + macro_f_string_range_t_initialize(3, 4), + }; + + const f_string_ranges_t source = macro_f_string_ranges_t_initialize(sources_array, 0, length_sources); + f_string_rangess_t destination = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_rangess_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_sources); + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[0].array[i].start, sources_array[i].start); + assert_int_equal(destination.array[0].array[i].stop, sources_array[i].stop); + } // for + } + + free((void *) destination.array[0].array); + free((void *) destination.array); +} + +void test__f_string_rangess_append__returns_data_not(void **state) { + + const int length = 5; + f_string_ranges_t source = f_string_rangess_t_initialize; + f_string_rangess_t destination = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_ranges_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_rangess_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_rangess_append__parameter_checking(void **state) { + + f_string_ranges_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_append.h b/level_0/f_string/tests/unit/c/test-string-rangess_append.h new file mode 100644 index 000000000..b6c910f2c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_rangess_append_h +#define _TEST__F_string_rangess_append_h + +/** + * Test that the function works. + * + * @see f_string_rangess_append() + */ +extern void test__f_string_rangess_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_rangess_append() + */ +extern void test__f_string_rangess_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_rangess_append() + */ +extern void test__f_string_rangess_append__parameter_checking(void **state); + +#endif // _TEST__F_string_rangess_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_append_all.c b/level_0/f_string/tests/unit/c/test-string-rangess_append_all.c new file mode 100644 index 000000000..25a4f8e7d --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_append_all.c @@ -0,0 +1,93 @@ +#include "test-string.h" +#include "test-string-rangess_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_append_all__works(void **state) { + + const int length_sources = 2; + const int length_sources_set = 2; + + f_string_range_t sources_array1[] = { + macro_f_string_range_t_initialize(1, 2), + macro_f_string_range_t_initialize(3, 4), + }; + + f_string_range_t sources_array2[] = { + macro_f_string_range_t_initialize(5, 6), + macro_f_string_range_t_initialize(7, 8), + }; + + f_string_ranges_t sources_set_array[] = { + macro_f_string_ranges_t_initialize(sources_array1, 0, length_sources), + macro_f_string_ranges_t_initialize(sources_array2, 0, length_sources), + }; + + const f_string_rangess_t source = macro_f_string_rangess_t_initialize(sources_set_array, 0, length_sources_set); + f_string_rangess_t destination = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_rangess_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_sources_set; ++j) { + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[j].array[i].start, sources_set_array[j].array[i].start); + assert_int_equal(destination.array[j].array[i].stop, sources_set_array[j].array[i].stop); + } // for + } // for + } + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) destination.array); +} + +void test__f_string_rangess_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_rangess_t source = f_string_rangess_t_initialize; + f_string_rangess_t destination = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_rangess_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_rangess_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_rangess_append_all__parameter_checking(void **state) { + + const f_string_rangess_t data = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_rangess_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_append_all.h b/level_0/f_string/tests/unit/c/test-string-rangess_append_all.h new file mode 100644 index 000000000..62f0abc8a --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_rangess_append_all_h +#define _TEST__F_string_rangess_append_all_h + +/** + * Test that the function works. + * + * @see f_string_rangess_append_all() + */ +extern void test__f_string_rangess_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_rangess_append_all() + */ +extern void test__f_string_rangess_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_rangess_append_all() + */ +extern void test__f_string_rangess_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_rangess_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.c new file mode 100644 index 000000000..5b5fd759b --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-rangess_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_decimate_by__works(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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_string_rangess_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_string_rangess_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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 diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.h new file mode 100644 index 000000000..1d8460439 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_rangess_decimate_by_h +#define _TEST__F_string_rangess_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_rangess_decimate_by() + */ +extern void test__f_string_rangess_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_rangess_decimate_by() + */ +extern void test__f_string_rangess_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_string_rangess_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.c new file mode 100644 index 000000000..1562f8792 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-rangess_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_decrease_by__works(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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_string_rangess_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_string_rangess_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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 diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.h new file mode 100644 index 000000000..6eda6265c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_rangess_decrease_by_h +#define _TEST__F_string_rangess_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_rangess_decrease_by() + */ +extern void test__f_string_rangess_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_rangess_decrease_by() + */ +extern void test__f_string_rangess_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_rangess_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_increase.c b/level_0/f_string/tests/unit/c/test-string-rangess_increase.c new file mode 100644 index 000000000..5b7c054ea --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-rangess_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_increase__works(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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_string_rangess_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_string_rangess_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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_string_rangess_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_string_rangess_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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 diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_increase.h b/level_0/f_string/tests/unit/c/test-string-rangess_increase.h new file mode 100644 index 000000000..292798d04 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_rangess_increase_h +#define _TEST__F_string_rangess_increase_h + +/** + * Test that the function works. + * + * @see f_string_rangess_increase() + */ +extern void test__f_string_rangess_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_rangess_increase() + */ +extern void test__f_string_rangess_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_rangess_increase() + */ +extern void test__f_string_rangess_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_rangess_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_increase_by.c b/level_0/f_string/tests/unit/c/test-string-rangess_increase_by.c new file mode 100644 index 000000000..4ca9b5806 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-rangess_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_increase_by__works(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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_string_rangess_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_string_rangess_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_ranges_t_initialize; + + { + const f_status_t status = f_string_rangess_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 diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_increase_by.h b/level_0/f_string/tests/unit/c/test-string-rangess_increase_by.h new file mode 100644 index 000000000..f97a74efe --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_rangess_increase_by_h +#define _TEST__F_string_rangess_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_rangess_increase_by() + */ +extern void test__f_string_rangess_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_rangess_increase_by() + */ +extern void test__f_string_rangess_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_rangess_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_resize.c b/level_0/f_string/tests/unit/c/test-string-rangess_resize.c new file mode 100644 index 000000000..a1997591a --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-rangess_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_resize__works(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_rangess_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_string_rangess_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_rangess_t data = f_string_rangess_t_initialize; + + { + const f_status_t status = f_string_rangess_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 diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_resize.h b/level_0/f_string/tests/unit/c/test-string-rangess_resize.h new file mode 100644 index 000000000..dd3c4e0a8 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_rangess_resize_h +#define _TEST__F_string_rangess_resize_h + +/** + * Test that the function works. + * + * @see f_string_rangess_resize() + */ +extern void test__f_string_rangess_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_rangess_resize() + */ +extern void test__f_string_rangess_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_rangess_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-triples_adjust.c b/level_0/f_string/tests/unit/c/test-string-triples_adjust.c new file mode 100644 index 000000000..dc0a15979 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-triples_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_adjust__works(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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_string_triples_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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 diff --git a/level_0/f_string/tests/unit/c/test-string-triples_adjust.h b/level_0/f_string/tests/unit/c/test-string-triples_adjust.h new file mode 100644 index 000000000..03e6031a1 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__string_triples_adjust +#define _TEST__F_string__string_triples_adjust + +/** + * Test that the function works. + * + * @see f_string_triples_adjust() + */ +extern void test__f_string_triples_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_triples_adjust() + */ +extern void test__f_string_triples_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string__string_triples_adjust diff --git a/level_0/f_string/tests/unit/c/test-string-triples_append.c b/level_0/f_string/tests/unit/c/test-string-triples_append.c new file mode 100644 index 000000000..a593ff619 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_append.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-triples_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_append__works(void **state) { + + const f_string_static_t test_a = macro_f_string_static_t_initialize("a", 0, 1); + const f_string_static_t test_b = macro_f_string_static_t_initialize("b", 0, 1); + const f_string_static_t test_c = macro_f_string_static_t_initialize("c", 0, 1); + + const f_string_triple_t source = macro_f_string_triple_t_initialize(test_a, test_b, test_c); + f_string_triples_t destination = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].a.used, source.a.used); + assert_int_equal(destination.array[0].b.used, source.b.used); + assert_int_equal(destination.array[0].c.used, source.c.used); + + assert_string_equal(destination.array[0].a.string, source.a.string); + assert_string_equal(destination.array[0].b.string, source.b.string); + assert_string_equal(destination.array[0].c.string, source.c.string); + } + + free((void *) destination.array[0].a.string); + free((void *) destination.array[0].b.string); + free((void *) destination.array[0].c.string); + free((void *) destination.array); +} + +void test__f_string_triples_append__parameter_checking(void **state) { + + const f_string_triple_t data = f_string_triple_t_initialize; + + { + const f_status_t status = f_string_triples_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-triples_append.h b/level_0/f_string/tests/unit/c/test-string-triples_append.h new file mode 100644 index 000000000..166be5b59 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_triples_append_h +#define _TEST__F_string_triples_append_h + +/** + * Test that the function works. + * + * @see f_string_triples_append() + */ +extern void test__f_string_triples_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_triples_append() + */ +extern void test__f_string_triples_append__parameter_checking(void **state); + +#endif // _TEST__F_string_triples_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-triples_append_all.c b/level_0/f_string/tests/unit/c/test-string-triples_append_all.c new file mode 100644 index 000000000..f62e0e37e --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_append_all.c @@ -0,0 +1,96 @@ +#include "test-string.h" +#include "test-string-triples_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_append_all__works(void **state) { + + const int length_sources = 2; + + const f_string_static_t test_a = macro_f_string_static_t_initialize("a", 0, 1); + const f_string_static_t test_b = macro_f_string_static_t_initialize("b", 0, 1); + const f_string_static_t test_c = macro_f_string_static_t_initialize("c", 0, 1); + + const f_string_static_t test_d = macro_f_string_static_t_initialize("d", 0, 1); + const f_string_static_t test_e = macro_f_string_static_t_initialize("e", 0, 1); + const f_string_static_t test_f = macro_f_string_static_t_initialize("f", 0, 1); + + f_string_triple_t sources_array[] = { + macro_f_string_triple_t_initialize(test_a, test_b, test_c), + macro_f_string_triple_t_initialize(test_d, test_e, test_f), + }; + + const f_string_triples_t source = macro_f_string_triples_t_initialize(sources_array, 0, length_sources); + f_string_triples_t destination = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[i].a.used, source.array[i].a.used); + assert_int_equal(destination.array[i].b.used, source.array[i].b.used); + assert_int_equal(destination.array[i].c.used, source.array[i].c.used); + + assert_string_equal(destination.array[i].a.string, source.array[i].a.string); + assert_string_equal(destination.array[i].b.string, source.array[i].b.string); + assert_string_equal(destination.array[i].c.string, source.array[i].c.string); + } // for + } + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + free((void *) destination.array[i].a.string); + free((void *) destination.array[i].b.string); + free((void *) destination.array[i].c.string); + } // for + + free((void *) destination.array); +} + +void test__f_string_triples_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_triples_t source = f_string_triples_t_initialize; + f_string_triples_t destination = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_triples_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_triples_append_all__parameter_checking(void **state) { + + const f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-triples_append_all.h b/level_0/f_string/tests/unit/c/test-string-triples_append_all.h new file mode 100644 index 000000000..a8b2317a7 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_triples_append_all_h +#define _TEST__F_string_triples_append_all_h + +/** + * Test that the function works. + * + * @see f_string_triples_append_all() + */ +extern void test__f_string_triples_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_triples_append_all() + */ +extern void test__f_string_triples_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_triples_append_all() + */ +extern void test__f_string_triples_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_triples_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-triples_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-triples_decimate_by.c new file mode 100644 index 000000000..252970fc9 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-triples_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_decimate_by__works(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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_string_triples_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_string_triples_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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 diff --git a/level_0/f_string/tests/unit/c/test-string-triples_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-triples_decimate_by.h new file mode 100644 index 000000000..ac4f00adf --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_triples_decimate_by_h +#define _TEST__F_triples_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_triples_decimate_by() + */ +extern void test__f_string_triples_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_triples_decimate_by() + */ +extern void test__f_string_triples_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_triples_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-triples_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-triples_decrease_by.c new file mode 100644 index 000000000..a40a6fd6f --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-triples_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_decrease_by__works(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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_string_triples_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_string_triples_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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 diff --git a/level_0/f_string/tests/unit/c/test-string-triples_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-triples_decrease_by.h new file mode 100644 index 000000000..5d105a423 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_triples_decrease_by_h +#define _TEST__F_string_triples_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_triples_decrease_by() + */ +extern void test__f_string_triples_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_triples_decrease_by() + */ +extern void test__f_string_triples_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_triples_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-triples_increase.c b/level_0/f_string/tests/unit/c/test-string-triples_increase.c new file mode 100644 index 000000000..850ef10c3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-triples_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_increase__works(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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_string_triples_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_string_triples_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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_string_triples_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_string_triples_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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 diff --git a/level_0/f_string/tests/unit/c/test-string-triples_increase.h b/level_0/f_string/tests/unit/c/test-string-triples_increase.h new file mode 100644 index 000000000..c33997c8e --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_triples_increase_h +#define _TEST__F_string_triples_increase_h + +/** + * Test that the function works. + * + * @see f_string_triples_increase() + */ +extern void test__f_string_triples_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_triples_increase() + */ +extern void test__f_string_triples_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_triples_increase() + */ +extern void test__f_string_triples_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_triples_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-triples_increase_by.c b/level_0/f_string/tests/unit/c/test-string-triples_increase_by.c new file mode 100644 index 000000000..ba44462dd --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-triples_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_increase_by__works(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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_string_triples_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_string_triples_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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 diff --git a/level_0/f_string/tests/unit/c/test-string-triples_increase_by.h b/level_0/f_string/tests/unit/c/test-string-triples_increase_by.h new file mode 100644 index 000000000..473ba1dfa --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_triples_increase_by_h +#define _TEST__F_string_triples_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_triples_increase_by() + */ +extern void test__f_string_triples_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_triples_increase_by() + */ +extern void test__f_string_triples_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_triples_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-triples_resize.c b/level_0/f_string/tests/unit/c/test-string-triples_resize.c new file mode 100644 index 000000000..b249fe175 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-triples_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_resize__works(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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_string_triples_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_triples_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 diff --git a/level_0/f_string/tests/unit/c/test-string-triples_resize.h b/level_0/f_string/tests/unit/c/test-string-triples_resize.h new file mode 100644 index 000000000..d4d59f53e --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_triples_resize_h +#define _TEST__F_string_triples_resize_h + +/** + * Test that the function works. + * + * @see f_string_triples_resize() + */ +extern void test__f_string_triples_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_triples_resize() + */ +extern void test__f_string_triples_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_triples_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_adjust.c b/level_0/f_string/tests/unit/c/test-string-tripless_adjust.c new file mode 100644 index 000000000..ed991621e --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_adjust.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-tripless_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_adjust__works(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_tripless_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_string_tripless_adjust__parameter_checking(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_tripless_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 diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_adjust.h b/level_0/f_string/tests/unit/c/test-string-tripless_adjust.h new file mode 100644 index 000000000..c1df06e2d --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_tripless_adjust_h +#define _TEST__F_string_tripless_adjust_h + +/** + * Test that the function works. + * + * @see f_string_tripless_adjust() + */ +extern void test__f_string_tripless_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_tripless_adjust() + */ +extern void test__f_string_tripless_adjust__parameter_checking(void **state); + +#endif // _TEST__F_string_tripless_adjust_h diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_append.c b/level_0/f_string/tests/unit/c/test-string-tripless_append.c new file mode 100644 index 000000000..4bca45ec4 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_append.c @@ -0,0 +1,96 @@ +#include "test-string.h" +#include "test-string-tripless_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_append__works(void **state) { + + const int length_sources = 2; + + const f_string_static_t test_a = macro_f_string_static_t_initialize("a", 0, 1); + const f_string_static_t test_b = macro_f_string_static_t_initialize("b", 0, 1); + const f_string_static_t test_c = macro_f_string_static_t_initialize("c", 0, 1); + + const f_string_static_t test_d = macro_f_string_static_t_initialize("d", 0, 1); + const f_string_static_t test_e = macro_f_string_static_t_initialize("e", 0, 1); + const f_string_static_t test_f = macro_f_string_static_t_initialize("f", 0, 1); + + f_string_triple_t sources_array[] = { + macro_f_string_triple_t_initialize(test_a, test_b, test_c), + macro_f_string_triple_t_initialize(test_d, test_e, test_f), + }; + + const f_string_triples_t source = macro_f_string_triples_t_initialize(sources_array, 0, length_sources); + f_string_tripless_t destination = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_tripless_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_sources); + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[0].array[i].a.used, sources_array[i].a.used); + assert_int_equal(destination.array[0].array[i].b.used, sources_array[i].b.used); + assert_int_equal(destination.array[0].array[i].c.used, sources_array[i].c.used); + + assert_string_equal(destination.array[0].array[i].a.string, sources_array[i].a.string); + assert_string_equal(destination.array[0].array[i].b.string, sources_array[i].b.string); + assert_string_equal(destination.array[0].array[i].c.string, sources_array[i].c.string); + } // for + } + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + + free((void *) destination.array[0].array[i].a.string); + free((void *) destination.array[0].array[i].b.string); + free((void *) destination.array[0].array[i].c.string); + } // for + + free((void *) destination.array[0].array); + free((void *) destination.array); +} + +void test__f_string_tripless_append__returns_data_not(void **state) { + + const int length = 5; + f_string_triples_t source = f_string_tripless_t_initialize; + f_string_tripless_t destination = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_triples_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_tripless_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_tripless_append__parameter_checking(void **state) { + + f_string_triples_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_append.h b/level_0/f_string/tests/unit/c/test-string-tripless_append.h new file mode 100644 index 000000000..bf0eae5e3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_tripless_append_h +#define _TEST__F_string_tripless_append_h + +/** + * Test that the function works. + * + * @see f_string_tripless_append() + */ +extern void test__f_string_tripless_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_tripless_append() + */ +extern void test__f_string_tripless_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_tripless_append() + */ +extern void test__f_string_tripless_append__parameter_checking(void **state); + +#endif // _TEST__F_string_tripless_append_h diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_append_all.c b/level_0/f_string/tests/unit/c/test-string-tripless_append_all.c new file mode 100644 index 000000000..e657a4c43 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_append_all.c @@ -0,0 +1,122 @@ +#include "test-string.h" +#include "test-string-tripless_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_append_all__works(void **state) { + + const int length_sources = 2; + const int length_sources_set = 2; + + const f_string_static_t test_a = macro_f_string_static_t_initialize("a", 0, 1); + const f_string_static_t test_b = macro_f_string_static_t_initialize("b", 0, 1); + const f_string_static_t test_c = macro_f_string_static_t_initialize("c", 0, 1); + + const f_string_static_t test_d = macro_f_string_static_t_initialize("d", 0, 1); + const f_string_static_t test_e = macro_f_string_static_t_initialize("e", 0, 1); + const f_string_static_t test_f = macro_f_string_static_t_initialize("f", 0, 1); + + const f_string_static_t test_g = macro_f_string_static_t_initialize("g", 0, 1); + const f_string_static_t test_h = macro_f_string_static_t_initialize("h", 0, 1); + const f_string_static_t test_i = macro_f_string_static_t_initialize("i", 0, 1); + + const f_string_static_t test_j = macro_f_string_static_t_initialize("j", 0, 1); + const f_string_static_t test_k = macro_f_string_static_t_initialize("k", 0, 1); + const f_string_static_t test_l = macro_f_string_static_t_initialize("l", 0, 1); + + f_string_triple_t sources_array1[] = { + macro_f_string_triple_t_initialize(test_a, test_b, test_c), + macro_f_string_triple_t_initialize(test_d, test_e, test_f), + }; + + f_string_triple_t sources_array2[] = { + macro_f_string_triple_t_initialize(test_g, test_h, test_i), + macro_f_string_triple_t_initialize(test_j, test_k, test_l), + }; + + f_string_triples_t sources_set_array[] = { + macro_f_string_triples_t_initialize(sources_array1, 0, length_sources), + macro_f_string_triples_t_initialize(sources_array2, 0, length_sources), + }; + + const f_string_tripless_t source = macro_f_string_tripless_t_initialize(sources_set_array, 0, length_sources_set); + f_string_tripless_t destination = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_tripless_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_sources_set; ++j) { + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[j].array[i].a.used, sources_set_array[j].array[i].a.used); + assert_int_equal(destination.array[j].array[i].b.used, sources_set_array[j].array[i].b.used); + assert_int_equal(destination.array[j].array[i].c.used, sources_set_array[j].array[i].c.used); + + assert_string_equal(destination.array[j].array[i].a.string, sources_set_array[j].array[i].a.string); + assert_string_equal(destination.array[j].array[i].b.string, sources_set_array[j].array[i].b.string); + assert_string_equal(destination.array[j].array[i].c.string, sources_set_array[j].array[i].c.string); + } // for + } // for + } + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + + free((void *) destination.array[j].array[i].a.string); + free((void *) destination.array[j].array[i].b.string); + free((void *) destination.array[j].array[i].c.string); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) destination.array); +} + +void test__f_string_tripless_append_all__returns_data_not(void **state) { + + const int length = 5; + f_string_tripless_t source = f_string_tripless_t_initialize; + f_string_tripless_t destination = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_tripless_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_string_tripless_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_string_tripless_append_all__parameter_checking(void **state) { + + const f_string_tripless_t data = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_tripless_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_append_all.h b/level_0/f_string/tests/unit/c/test-string-tripless_append_all.h new file mode 100644 index 000000000..300ab8a54 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_tripless_append_all_h +#define _TEST__F_string_tripless_append_all_h + +/** + * Test that the function works. + * + * @see f_string_tripless_append_all() + */ +extern void test__f_string_tripless_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_tripless_append_all() + */ +extern void test__f_string_tripless_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_tripless_append_all() + */ +extern void test__f_string_tripless_append_all__parameter_checking(void **state); + +#endif // _TEST__F_string_tripless_append_all_h diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.c b/level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.c new file mode 100644 index 000000000..cb7fe8031 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-tripless_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_decimate_by__works(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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_string_tripless_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_string_tripless_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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 diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.h b/level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.h new file mode 100644 index 000000000..bd7164703 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_tripless_decimate_by_h +#define _TEST__F_string_tripless_decimate_by_h + +/** + * Test that the function works. + * + * @see f_string_tripless_decimate_by() + */ +extern void test__f_string_tripless_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_tripless_decimate_by() + */ +extern void test__f_string_tripless_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_string_tripless_decimate_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.c b/level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.c new file mode 100644 index 000000000..0e4724822 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-string.h" +#include "test-string-tripless_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_decrease_by__works(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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_string_tripless_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_string_tripless_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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 diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.h b/level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.h new file mode 100644 index 000000000..7a03b8b6c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_tripless_decrease_by_h +#define _TEST__F_string_tripless_decrease_by_h + +/** + * Test that the function works. + * + * @see f_string_tripless_decrease_by() + */ +extern void test__f_string_tripless_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_tripless_decrease_by() + */ +extern void test__f_string_tripless_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_string_tripless_decrease_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_increase.c b/level_0/f_string/tests/unit/c/test-string-tripless_increase.c new file mode 100644 index 000000000..9d65e02d6 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_increase.c @@ -0,0 +1,76 @@ +#include "test-string.h" +#include "test-string-tripless_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_increase__works(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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_string_tripless_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_string_tripless_increase__returns_data_not(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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_string_tripless_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_string_tripless_increase__parameter_checking(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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 diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_increase.h b/level_0/f_string/tests/unit/c/test-string-tripless_increase.h new file mode 100644 index 000000000..43283e540 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_tripless_increase_h +#define _TEST__F_string_tripless_increase_h + +/** + * Test that the function works. + * + * @see f_string_tripless_increase() + */ +extern void test__f_string_tripless_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_string_tripless_increase() + */ +extern void test__f_string_tripless_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_tripless_increase() + */ +extern void test__f_string_tripless_increase__parameter_checking(void **state); + +#endif // _TEST__F_string_tripless_increase_h diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_increase_by.c b/level_0/f_string/tests/unit/c/test-string-tripless_increase_by.c new file mode 100644 index 000000000..fc8d3e6b6 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_increase_by.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-tripless_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_increase_by__works(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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_string_tripless_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_string_tripless_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_triples_t_initialize; + + { + const f_status_t status = f_string_tripless_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 diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_increase_by.h b/level_0/f_string/tests/unit/c/test-string-tripless_increase_by.h new file mode 100644 index 000000000..1f7983bde --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_tripless_increase_by_h +#define _TEST__F_string_tripless_increase_by_h + +/** + * Test that the function works. + * + * @see f_string_tripless_increase_by() + */ +extern void test__f_string_tripless_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_tripless_increase_by() + */ +extern void test__f_string_tripless_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_string_tripless_increase_by_h diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_resize.c b/level_0/f_string/tests/unit/c/test-string-tripless_resize.c new file mode 100644 index 000000000..142d88649 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_resize.c @@ -0,0 +1,42 @@ +#include "test-string.h" +#include "test-string-tripless_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_resize__works(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_tripless_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_string_tripless_resize__parameter_checking(void **state) { + + const int length = 5; + f_string_tripless_t data = f_string_tripless_t_initialize; + + { + const f_status_t status = f_string_tripless_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 diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_resize.h b/level_0/f_string/tests/unit/c/test-string-tripless_resize.h new file mode 100644 index 000000000..166d681e9 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string_tripless_resize_h +#define _TEST__F_string_tripless_resize_h + +/** + * Test that the function works. + * + * @see f_string_tripless_resize() + */ +extern void test__f_string_tripless_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_string_tripless_resize() + */ +extern void test__f_string_tripless_resize__parameter_checking(void **state); + +#endif // _TEST__F_string_tripless_resize_h diff --git a/level_0/f_string/tests/unit/c/test-string.c b/level_0/f_string/tests/unit/c/test-string.c new file mode 100644 index 000000000..1508cd3da --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string.c @@ -0,0 +1,276 @@ +#include "test-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int setup(void **state) { + + return 0; +} + +int setdown(void **state) { + + errno = 0; + + return 0; +} + +int main(void) { + + const struct CMUnitTest tests[] = { + cmocka_unit_test(test__f_string_dynamics_adjust__works), + cmocka_unit_test(test__f_string_dynamics_append__works), + cmocka_unit_test(test__f_string_dynamics_append_all__works), + cmocka_unit_test(test__f_string_dynamics_append_all__returns_data_not), + cmocka_unit_test(test__f_string_dynamics_decimate_by__works), + cmocka_unit_test(test__f_string_dynamics_decrease_by__works), + cmocka_unit_test(test__f_string_dynamics_increase__works), + cmocka_unit_test(test__f_string_dynamics_increase__returns_data_not), + cmocka_unit_test(test__f_string_dynamics_increase_by__works), + cmocka_unit_test(test__f_string_dynamics_resize__works), + + cmocka_unit_test(test__f_string_dynamicss_adjust__works), + cmocka_unit_test(test__f_string_dynamicss_append__works), + cmocka_unit_test(test__f_string_dynamicss_append__returns_data_not), + cmocka_unit_test(test__f_string_dynamicss_append_all__works), + cmocka_unit_test(test__f_string_dynamicss_append_all__returns_data_not), + cmocka_unit_test(test__f_string_dynamicss_decimate_by__works), + cmocka_unit_test(test__f_string_dynamicss_decrease_by__works), + cmocka_unit_test(test__f_string_dynamicss_increase__works), + cmocka_unit_test(test__f_string_dynamicss_increase__returns_data_not), + cmocka_unit_test(test__f_string_dynamicss_increase_by__works), + cmocka_unit_test(test__f_string_dynamicss_resize__works), + + cmocka_unit_test(test__f_string_maps_adjust__works), + cmocka_unit_test(test__f_string_maps_append__works), + cmocka_unit_test(test__f_string_maps_append_all__works), + cmocka_unit_test(test__f_string_maps_append_all__returns_data_not), + cmocka_unit_test(test__f_string_maps_decimate_by__works), + cmocka_unit_test(test__f_string_maps_decrease_by__works), + cmocka_unit_test(test__f_string_maps_increase__works), + cmocka_unit_test(test__f_string_maps_increase__returns_data_not), + cmocka_unit_test(test__f_string_maps_increase_by__works), + cmocka_unit_test(test__f_string_maps_resize__works), + + cmocka_unit_test(test__f_string_mapss_adjust__works), + cmocka_unit_test(test__f_string_mapss_append__works), + cmocka_unit_test(test__f_string_mapss_append__returns_data_not), + cmocka_unit_test(test__f_string_mapss_append_all__works), + cmocka_unit_test(test__f_string_mapss_append_all__returns_data_not), + cmocka_unit_test(test__f_string_mapss_decimate_by__works), + cmocka_unit_test(test__f_string_mapss_decrease_by__works), + cmocka_unit_test(test__f_string_mapss_increase__works), + cmocka_unit_test(test__f_string_mapss_increase__returns_data_not), + cmocka_unit_test(test__f_string_mapss_increase_by__works), + cmocka_unit_test(test__f_string_mapss_resize__works), + + cmocka_unit_test(test__f_string_map_multis_adjust__works), + cmocka_unit_test(test__f_string_map_multis_append__works), + cmocka_unit_test(test__f_string_map_multis_append_all__works), + cmocka_unit_test(test__f_string_map_multis_append_all__returns_data_not), + cmocka_unit_test(test__f_string_map_multis_decimate_by__works), + cmocka_unit_test(test__f_string_map_multis_decrease_by__works), + cmocka_unit_test(test__f_string_map_multis_increase__works), + cmocka_unit_test(test__f_string_map_multis_increase__returns_data_not), + cmocka_unit_test(test__f_string_map_multis_increase_by__works), + cmocka_unit_test(test__f_string_map_multis_resize__works), + + cmocka_unit_test(test__f_string_map_multiss_adjust__works), + cmocka_unit_test(test__f_string_map_multiss_append__works), + cmocka_unit_test(test__f_string_map_multiss_append__returns_data_not), + cmocka_unit_test(test__f_string_map_multiss_append_all__works), + cmocka_unit_test(test__f_string_map_multiss_append_all__returns_data_not), + cmocka_unit_test(test__f_string_map_multiss_decimate_by__works), + cmocka_unit_test(test__f_string_map_multiss_decrease_by__works), + cmocka_unit_test(test__f_string_map_multiss_increase__works), + cmocka_unit_test(test__f_string_map_multiss_increase__returns_data_not), + cmocka_unit_test(test__f_string_map_multiss_increase_by__works), + cmocka_unit_test(test__f_string_map_multiss_resize__works), + + cmocka_unit_test(test__f_string_quantitys_adjust__works), + cmocka_unit_test(test__f_string_quantitys_append__works), + cmocka_unit_test(test__f_string_quantitys_append_all__works), + cmocka_unit_test(test__f_string_quantitys_append_all__returns_data_not), + cmocka_unit_test(test__f_string_quantitys_decimate_by__works), + cmocka_unit_test(test__f_string_quantitys_decrease_by__works), + cmocka_unit_test(test__f_string_quantitys_increase__works), + cmocka_unit_test(test__f_string_quantitys_increase__returns_data_not), + cmocka_unit_test(test__f_string_quantitys_increase_by__works), + cmocka_unit_test(test__f_string_quantitys_resize__works), + + cmocka_unit_test(test__f_string_quantityss_adjust__works), + cmocka_unit_test(test__f_string_quantityss_append__works), + cmocka_unit_test(test__f_string_quantityss_append__returns_data_not), + cmocka_unit_test(test__f_string_quantityss_append_all__works), + cmocka_unit_test(test__f_string_quantityss_append_all__returns_data_not), + cmocka_unit_test(test__f_string_quantityss_decimate_by__works), + cmocka_unit_test(test__f_string_quantityss_decrease_by__works), + cmocka_unit_test(test__f_string_quantityss_increase__works), + cmocka_unit_test(test__f_string_quantityss_increase__returns_data_not), + cmocka_unit_test(test__f_string_quantityss_increase_by__works), + cmocka_unit_test(test__f_string_quantityss_resize__works), + + cmocka_unit_test(test__f_string_ranges_adjust__works), + cmocka_unit_test(test__f_string_ranges_append__works), + cmocka_unit_test(test__f_string_ranges_append_all__works), + cmocka_unit_test(test__f_string_ranges_append_all__returns_data_not), + cmocka_unit_test(test__f_string_ranges_decimate_by__works), + cmocka_unit_test(test__f_string_ranges_decrease_by__works), + cmocka_unit_test(test__f_string_ranges_increase__works), + cmocka_unit_test(test__f_string_ranges_increase__returns_data_not), + cmocka_unit_test(test__f_string_ranges_increase_by__works), + cmocka_unit_test(test__f_string_ranges_resize__works), + + cmocka_unit_test(test__f_string_rangess_adjust__works), + cmocka_unit_test(test__f_string_rangess_append__works), + cmocka_unit_test(test__f_string_rangess_append__returns_data_not), + cmocka_unit_test(test__f_string_rangess_append_all__works), + cmocka_unit_test(test__f_string_rangess_append_all__returns_data_not), + cmocka_unit_test(test__f_string_rangess_decimate_by__works), + cmocka_unit_test(test__f_string_rangess_decrease_by__works), + cmocka_unit_test(test__f_string_rangess_increase__works), + cmocka_unit_test(test__f_string_rangess_increase__returns_data_not), + cmocka_unit_test(test__f_string_rangess_increase_by__works), + cmocka_unit_test(test__f_string_rangess_resize__works), + + cmocka_unit_test(test__f_string_triples_adjust__works), + cmocka_unit_test(test__f_string_triples_append__works), + cmocka_unit_test(test__f_string_triples_append_all__works), + cmocka_unit_test(test__f_string_triples_append_all__returns_data_not), + cmocka_unit_test(test__f_string_triples_decimate_by__works), + cmocka_unit_test(test__f_string_triples_decrease_by__works), + cmocka_unit_test(test__f_string_triples_increase__works), + cmocka_unit_test(test__f_string_triples_increase__returns_data_not), + cmocka_unit_test(test__f_string_triples_increase_by__works), + cmocka_unit_test(test__f_string_triples_resize__works), + + cmocka_unit_test(test__f_string_tripless_adjust__works), + cmocka_unit_test(test__f_string_tripless_append__works), + cmocka_unit_test(test__f_string_tripless_append__returns_data_not), + cmocka_unit_test(test__f_string_tripless_append_all__works), + cmocka_unit_test(test__f_string_tripless_append_all__returns_data_not), + cmocka_unit_test(test__f_string_tripless_decimate_by__works), + cmocka_unit_test(test__f_string_tripless_decrease_by__works), + cmocka_unit_test(test__f_string_tripless_increase__works), + cmocka_unit_test(test__f_string_tripless_increase__returns_data_not), + cmocka_unit_test(test__f_string_tripless_increase_by__works), + cmocka_unit_test(test__f_string_tripless_resize__works), + + #ifndef _di_level_0_parameter_checking_ + cmocka_unit_test(test__f_string_dynamics_adjust__parameter_checking), + cmocka_unit_test(test__f_string_dynamics_append__parameter_checking), + cmocka_unit_test(test__f_string_dynamics_append_all__parameter_checking), + cmocka_unit_test(test__f_string_dynamics_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_dynamics_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_dynamics_increase__parameter_checking), + cmocka_unit_test(test__f_string_dynamics_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_dynamics_resize__parameter_checking), + + cmocka_unit_test(test__f_string_dynamicss_adjust__parameter_checking), + cmocka_unit_test(test__f_string_dynamicss_append__parameter_checking), + cmocka_unit_test(test__f_string_dynamicss_append_all__parameter_checking), + cmocka_unit_test(test__f_string_dynamicss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_dynamicss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_dynamicss_increase__parameter_checking), + cmocka_unit_test(test__f_string_dynamicss_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_dynamicss_resize__parameter_checking), + + cmocka_unit_test(test__f_string_maps_adjust__parameter_checking), + cmocka_unit_test(test__f_string_maps_append__parameter_checking), + cmocka_unit_test(test__f_string_maps_append_all__parameter_checking), + cmocka_unit_test(test__f_string_maps_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_maps_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_maps_increase__parameter_checking), + cmocka_unit_test(test__f_string_maps_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_maps_resize__parameter_checking), + + cmocka_unit_test(test__f_string_mapss_adjust__parameter_checking), + cmocka_unit_test(test__f_string_mapss_append__parameter_checking), + cmocka_unit_test(test__f_string_mapss_append_all__parameter_checking), + cmocka_unit_test(test__f_string_mapss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_mapss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_mapss_increase__parameter_checking), + cmocka_unit_test(test__f_string_mapss_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_mapss_resize__parameter_checking), + + cmocka_unit_test(test__f_string_map_multis_adjust__parameter_checking), + cmocka_unit_test(test__f_string_map_multis_append__parameter_checking), + cmocka_unit_test(test__f_string_map_multis_append_all__parameter_checking), + cmocka_unit_test(test__f_string_map_multis_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_map_multis_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_map_multis_increase__parameter_checking), + cmocka_unit_test(test__f_string_map_multis_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_map_multis_resize__parameter_checking), + + cmocka_unit_test(test__f_string_map_multiss_adjust__parameter_checking), + cmocka_unit_test(test__f_string_map_multiss_append__parameter_checking), + cmocka_unit_test(test__f_string_map_multiss_append_all__parameter_checking), + cmocka_unit_test(test__f_string_map_multiss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_map_multiss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_map_multiss_increase__parameter_checking), + cmocka_unit_test(test__f_string_map_multiss_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_map_multiss_resize__parameter_checking), + + cmocka_unit_test(test__f_string_quantitys_adjust__parameter_checking), + cmocka_unit_test(test__f_string_quantitys_append__parameter_checking), + cmocka_unit_test(test__f_string_quantitys_append_all__parameter_checking), + cmocka_unit_test(test__f_string_quantitys_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_quantitys_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_quantitys_increase__parameter_checking), + cmocka_unit_test(test__f_string_quantitys_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_quantitys_resize__parameter_checking), + + cmocka_unit_test(test__f_string_quantityss_adjust__parameter_checking), + cmocka_unit_test(test__f_string_quantityss_append__parameter_checking), + cmocka_unit_test(test__f_string_quantityss_append_all__parameter_checking), + cmocka_unit_test(test__f_string_quantityss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_quantityss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_quantityss_increase__parameter_checking), + cmocka_unit_test(test__f_string_quantityss_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_quantityss_resize__parameter_checking), + + cmocka_unit_test(test__f_string_ranges_adjust__parameter_checking), + cmocka_unit_test(test__f_string_ranges_append__parameter_checking), + cmocka_unit_test(test__f_string_ranges_append_all__parameter_checking), + cmocka_unit_test(test__f_string_ranges_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_ranges_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_ranges_increase__parameter_checking), + cmocka_unit_test(test__f_string_ranges_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_ranges_resize__parameter_checking), + + cmocka_unit_test(test__f_string_rangess_adjust__parameter_checking), + cmocka_unit_test(test__f_string_rangess_append__parameter_checking), + cmocka_unit_test(test__f_string_rangess_append_all__parameter_checking), + cmocka_unit_test(test__f_string_rangess_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_rangess_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_rangess_increase__parameter_checking), + cmocka_unit_test(test__f_string_rangess_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_rangess_resize__parameter_checking), + + cmocka_unit_test(test__f_string_triples_adjust__parameter_checking), + cmocka_unit_test(test__f_string_triples_append__parameter_checking), + cmocka_unit_test(test__f_string_triples_append_all__parameter_checking), + cmocka_unit_test(test__f_string_triples_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_triples_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_triples_increase__parameter_checking), + cmocka_unit_test(test__f_string_triples_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_triples_resize__parameter_checking), + + cmocka_unit_test(test__f_string_tripless_adjust__parameter_checking), + cmocka_unit_test(test__f_string_tripless_append__parameter_checking), + cmocka_unit_test(test__f_string_tripless_append_all__parameter_checking), + cmocka_unit_test(test__f_string_tripless_decimate_by__parameter_checking), + cmocka_unit_test(test__f_string_tripless_decrease_by__parameter_checking), + cmocka_unit_test(test__f_string_tripless_increase__parameter_checking), + cmocka_unit_test(test__f_string_tripless_increase_by__parameter_checking), + cmocka_unit_test(test__f_string_tripless_resize__parameter_checking), + #endif // _di_level_0_parameter_checking_ + }; + + return cmocka_run_group_tests(tests, setup, setdown); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string.h b/level_0/f_string/tests/unit/c/test-string.h new file mode 100644 index 000000000..ac58762a8 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string.h @@ -0,0 +1,167 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the string project. + */ +#ifndef _TEST__F_string_h +#define _TEST__F_string_h + +// Libc includes. +#include +#include +#include +#include + +// cmocka includes. +#include + +// FLL-0 includes. +#include + +// Mock includes. +//#include "mock-string.h" + +// Test includes. +#include "test-string-dynamics_adjust.h" +#include "test-string-dynamics_append.h" +#include "test-string-dynamics_append_all.h" +#include "test-string-dynamics_decimate_by.h" +#include "test-string-dynamics_decrease_by.h" +#include "test-string-dynamics_increase.h" +#include "test-string-dynamics_increase_by.h" +#include "test-string-dynamics_resize.h" +#include "test-string-dynamicss_adjust.h" +#include "test-string-dynamicss_append.h" +#include "test-string-dynamicss_append_all.h" +#include "test-string-dynamicss_decimate_by.h" +#include "test-string-dynamicss_decrease_by.h" +#include "test-string-dynamicss_increase.h" +#include "test-string-dynamicss_increase_by.h" +#include "test-string-dynamicss_resize.h" +#include "test-string-maps_adjust.h" +#include "test-string-maps_append.h" +#include "test-string-maps_append_all.h" +#include "test-string-maps_decimate_by.h" +#include "test-string-maps_decrease_by.h" +#include "test-string-maps_increase.h" +#include "test-string-maps_increase_by.h" +#include "test-string-maps_resize.h" +#include "test-string-mapss_adjust.h" +#include "test-string-mapss_append.h" +#include "test-string-mapss_append_all.h" +#include "test-string-mapss_decimate_by.h" +#include "test-string-mapss_decrease_by.h" +#include "test-string-mapss_increase.h" +#include "test-string-mapss_increase_by.h" +#include "test-string-mapss_resize.h" +#include "test-string-map_multis_adjust.h" +#include "test-string-map_multis_append.h" +#include "test-string-map_multis_append_all.h" +#include "test-string-map_multis_decimate_by.h" +#include "test-string-map_multis_decrease_by.h" +#include "test-string-map_multis_increase.h" +#include "test-string-map_multis_increase_by.h" +#include "test-string-map_multis_resize.h" +#include "test-string-map_multiss_adjust.h" +#include "test-string-map_multiss_append.h" +#include "test-string-map_multiss_append_all.h" +#include "test-string-map_multiss_decimate_by.h" +#include "test-string-map_multiss_decrease_by.h" +#include "test-string-map_multiss_increase.h" +#include "test-string-map_multiss_increase_by.h" +#include "test-string-map_multiss_resize.h" +#include "test-string-quantitys_adjust.h" +#include "test-string-quantitys_append.h" +#include "test-string-quantitys_append_all.h" +#include "test-string-quantitys_decimate_by.h" +#include "test-string-quantitys_decrease_by.h" +#include "test-string-quantitys_increase.h" +#include "test-string-quantitys_increase_by.h" +#include "test-string-quantitys_resize.h" +#include "test-string-quantityss_adjust.h" +#include "test-string-quantityss_append.h" +#include "test-string-quantityss_append_all.h" +#include "test-string-quantityss_decimate_by.h" +#include "test-string-quantityss_decrease_by.h" +#include "test-string-quantityss_increase.h" +#include "test-string-quantityss_increase_by.h" +#include "test-string-quantityss_resize.h" +#include "test-string-ranges_adjust.h" +#include "test-string-ranges_append.h" +#include "test-string-ranges_append_all.h" +#include "test-string-ranges_decimate_by.h" +#include "test-string-ranges_decrease_by.h" +#include "test-string-ranges_increase.h" +#include "test-string-ranges_increase_by.h" +#include "test-string-ranges_resize.h" +#include "test-string-rangess_adjust.h" +#include "test-string-rangess_append.h" +#include "test-string-rangess_append_all.h" +#include "test-string-rangess_decimate_by.h" +#include "test-string-rangess_decrease_by.h" +#include "test-string-rangess_increase.h" +#include "test-string-rangess_increase_by.h" +#include "test-string-rangess_resize.h" +#include "test-string-triples_adjust.h" +#include "test-string-triples_append.h" +#include "test-string-triples_append_all.h" +#include "test-string-triples_decimate_by.h" +#include "test-string-triples_decrease_by.h" +#include "test-string-triples_increase.h" +#include "test-string-triples_increase_by.h" +#include "test-string-triples_resize.h" +#include "test-string-tripless_adjust.h" +#include "test-string-tripless_append.h" +#include "test-string-tripless_append_all.h" +#include "test-string-tripless_decimate_by.h" +#include "test-string-tripless_decrease_by.h" +#include "test-string-tripless_increase.h" +#include "test-string-tripless_increase_by.h" +#include "test-string-tripless_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Perform any setup operations. + * + * @param state + * The test state. + * + * @return + * The status of this function, where 0 means success. + */ +extern int setup(void **state); + +/** + * Peform any setdown operations. + * + * @param state + * The test state. + * + * @return + * The status of this function, where 0 means success. + */ +extern int setdown(void **state); + +/** + * Run all tests. + * + * @return + * The final result of the tests. + * + * @see cmocka_run_group_tests() + * @see cmocka_unit_test() + */ +extern int main(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _TEST__F_string_h diff --git a/level_0/f_thread/c/private-thread.c b/level_0/f_thread/c/private-thread.c index 8336058ab..98d163cfe 100644 --- a/level_0/f_thread/c/private-thread.c +++ b/level_0/f_thread/c/private-thread.c @@ -29,16 +29,15 @@ extern "C" { } // for status = f_memory_adjust(attributes->size, length, sizeof(f_thread_attribute_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) @@ -53,16 +52,15 @@ extern "C" { } // for status = f_memory_resize(attributes->size, length, sizeof(f_thread_attribute_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_attributes_decrease_) || !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_) @@ -90,16 +88,15 @@ extern "C" { } // for status = f_memory_adjust(barriers->size, length, sizeof(f_thread_barrier_t), (void **) & barriers->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - barriers->size = length; + barriers->size = length; - if (barriers->used > barriers->size) { - barriers->used = length; - } + if (barriers->used > barriers->size) { + barriers->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) @@ -114,16 +111,15 @@ extern "C" { } // for status = f_memory_resize(barriers->size, length, sizeof(f_thread_barrier_t), (void **) & barriers->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - barriers->size = length; + barriers->size = length; - if (barriers->used > barriers->size) { - barriers->used = length; - } + if (barriers->used > barriers->size) { + barriers->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) @@ -151,16 +147,15 @@ extern "C" { } // for status = f_memory_adjust(attributes->size, length, sizeof(f_thread_barrier_attribute_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) @@ -175,16 +170,15 @@ extern "C" { } // for status = f_memory_resize(attributes->size, length, sizeof(f_thread_barrier_attribute_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_barrier_attributes_decrease_) || !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) @@ -215,16 +209,15 @@ extern "C" { } // for status = f_memory_adjust(attributes->size, length, sizeof(f_thread_condition_attribute_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) @@ -239,16 +232,15 @@ extern "C" { } // for status = f_memory_resize(attributes->size, length, sizeof(f_thread_condition_attribute_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_condition_attributes_decrease_) || !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) @@ -279,16 +271,15 @@ extern "C" { } // for status = f_memory_adjust(conditions->size, length, sizeof(f_thread_condition_t), (void **) & conditions->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - conditions->size = length; + conditions->size = length; - if (conditions->used > conditions->size) { - conditions->used = length; - } + if (conditions->used > conditions->size) { + conditions->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) @@ -303,16 +294,15 @@ extern "C" { } // for status = f_memory_resize(conditions->size, length, sizeof(f_thread_condition_t), (void **) & conditions->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - conditions->size = length; + conditions->size = length; - if (conditions->used > conditions->size) { - conditions->used = length; - } + if (conditions->used > conditions->size) { + conditions->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_conditions_decrease_) || !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) @@ -340,16 +330,15 @@ extern "C" { } // for status = f_memory_adjust(keys->size, length, sizeof(f_thread_key_t), (void **) & keys->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - keys->size = length; + keys->size = length; - if (keys->used > keys->size) { - keys->used = length; - } + if (keys->used > keys->size) { + keys->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) @@ -364,16 +353,15 @@ extern "C" { } // for status = f_memory_resize(keys->size, length, sizeof(f_thread_key_t), (void **) & keys->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - keys->size = length; + keys->size = length; - if (keys->used > keys->size) { - keys->used = length; - } + if (keys->used > keys->size) { + keys->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) @@ -404,16 +392,15 @@ extern "C" { } // for status = f_memory_adjust(locks->size, length, sizeof(f_thread_lock_t), (void **) & locks->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - locks->size = length; + locks->size = length; - if (locks->used > locks->size) { - locks->used = length; - } + if (locks->used > locks->size) { + locks->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) @@ -428,16 +415,15 @@ extern "C" { } // for status = f_memory_resize(locks->size, length, sizeof(f_thread_lock_t), (void **) & locks->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - locks->size = length; + locks->size = length; - if (locks->used > locks->size) { - locks->used = length; - } + if (locks->used > locks->size) { + locks->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) @@ -468,16 +454,15 @@ extern "C" { } // for status = f_memory_adjust(attributes->size, length, sizeof(f_thread_lock_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) @@ -492,16 +477,15 @@ extern "C" { } // for status = f_memory_resize(attributes->size, length, sizeof(f_thread_lock_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) @@ -532,16 +516,15 @@ extern "C" { } // for status = f_memory_adjust(attributes->size, length, sizeof(f_thread_mutex_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) @@ -556,16 +539,15 @@ extern "C" { } // for status = f_memory_resize(attributes->size, length, sizeof(f_thread_mutex_t), (void **) & attributes->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - attributes->size = length; + attributes->size = length; - if (attributes->used > attributes->size) { - attributes->used = length; - } + if (attributes->used > attributes->size) { + attributes->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) @@ -596,16 +578,15 @@ extern "C" { } // for status = f_memory_adjust(mutexs->size, length, sizeof(f_thread_mutex_t), (void **) & mutexs->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - mutexs->size = length; + mutexs->size = length; - if (mutexs->used > mutexs->size) { - mutexs->used = length; - } + if (mutexs->used > mutexs->size) { + mutexs->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) @@ -620,16 +601,15 @@ extern "C" { } // for status = f_memory_resize(mutexs->size, length, sizeof(f_thread_mutex_t), (void **) & mutexs->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - mutexs->size = length; + mutexs->size = length; - if (mutexs->used > mutexs->size) { - mutexs->used = length; - } + if (mutexs->used > mutexs->size) { + mutexs->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) @@ -683,16 +663,15 @@ extern "C" { } // for status = f_memory_resize(semaphores->size, length, sizeof(f_thread_semaphore_t), (void **) & semaphores->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - semaphores->size = length; + semaphores->size = length; - if (semaphores->used > semaphores->size) { - semaphores->used = length; - } + if (semaphores->used > semaphores->size) { + semaphores->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) @@ -707,16 +686,15 @@ extern "C" { } // for status = f_memory_adjust(sets->size, length, sizeof(f_thread_set_t), (void **) & sets->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - sets->size = length; + sets->size = length; - if (sets->used > sets->size) { - sets->used = length; - } + if (sets->used > sets->size) { + sets->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) @@ -731,16 +709,15 @@ extern "C" { } // for status = f_memory_resize(sets->size, length, sizeof(f_thread_set_t), (void **) & sets->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - sets->size = length; + sets->size = length; - if (sets->used > sets->size) { - sets->used = length; - } + if (sets->used > sets->size) { + sets->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_sets_decrease_) || !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) @@ -771,16 +748,15 @@ extern "C" { } // for status = f_memory_adjust(spins->size, length, sizeof(f_thread_spin_t), (void **) & spins->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - spins->size = length; + spins->size = length; - if (spins->used > spins->size) { - spins->used = length; - } + if (spins->used > spins->size) { + spins->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) @@ -796,16 +772,15 @@ extern "C" { } // for status = f_memory_resize(spins->size, length, sizeof(f_thread_spin_t), (void **) & spins->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - spins->size = length; + spins->size = length; - if (spins->used > spins->size) { - spins->used = length; - } + if (spins->used > spins->size) { + spins->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index 4db4cec1b..b3a8d5ab4 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -51,6 +51,8 @@ extern "C" { */ #ifndef _di_f_status_t_ typedef uint16_t f_status_t; + + #define f_status_t_initialize F_none #endif // _di_f_status_t_ /** @@ -937,41 +939,43 @@ extern "C" { * Provide a 128-bit type wrapper, which could be either 64-bit or 128-bit depending on support. * * This is __int128_t when 128-bit is supported and int64_t when not supported. + * + * This provides the types without the normal "f_" leading prefixes to be more in line with the core types like int64_t. */ #ifndef __SIZEOF_INT128__ #ifndef _di_int128_t_ - typedef __int128_t f_int128_t; + typedef __int128_t int128_t; #endif // _di_int128_t_ #ifndef _di_uint128_t_ - typedef __uint128_t f_uint128_t; + typedef __uint128_t uint128_t; #endif // _di_uint128_t_ #else // __SIZEOF_INT128__ #ifndef _di_int128_t_ - typedef int64_t f_int128_t; + typedef int64_t int128_t; #endif // _di_int128_t_ #ifndef _di_uint128_t_ - typedef uint64_t f_uint128_t; + typedef uint64_t uint128_t; #endif // _di_uint128_t_ #endif // __SIZEOF_INT128__ /** - * An array of f_int128_t. + * An array of int128_t. * * The macros are defined in type_array.h or type_array-common.h. * - * array: The array of f_int128_t. + * array: The array of int128_t. * size: Total amount of allocated space. * used: Total number of allocated spaces used. */ #ifndef _di_int128s_t_ typedef struct { - f_int128_t *array; + int128_t *array; f_array_length_t size; f_array_length_t used; @@ -984,11 +988,11 @@ extern "C" { #endif // _di_int128s_t_ /** - * An array of and array of f_int128_t. + * An array of and array of int128_t. * * The macros are defined in type_array.h or type_array-common.h. * - * array: The array of and array of f_int128_t. + * array: The array of and array of int128_t. * size: Total amount of allocated space. * used: Total number of allocated spaces used. */ @@ -1007,17 +1011,17 @@ extern "C" { #endif // _di_int128ss_t_ /** - * An array of f_uint128_t. + * An array of uint128_t. * * The macros are defined in type_array.h or type_array-common.h. * - * array: The array of f_uint128_t. + * array: The array of uint128_t. * size: Total amount of allocated space. * used: Total number of allocated spaces used. */ #ifndef _di_uint128s_t_ typedef struct { - f_uint128_t *array; + uint128_t *array; f_array_length_t size; f_array_length_t used; @@ -1030,11 +1034,11 @@ extern "C" { #endif // _di_uint128s_t_ /** - * An array of and array of f_uint128_t. + * An array of and array of uint128_t. * * The macros are defined in type_array.h or type_array-common.h. * - * array: The array of and array of f_uint128_t. + * array: The array of and array of uint128_t. * size: Total amount of allocated space. * used: Total number of allocated spaces used. */ @@ -1173,8 +1177,10 @@ extern "C" { * used: A representation of how many bytes in name are in used (if 0, then there is no name, thus this can be seen as not a valid identifier). */ #ifndef _di_f_fll_id_t_ + #define f_fll_id_name_length_d 64 + typedef struct { - char name[64]; + char name[f_fll_id_name_length_d]; uint16_t type; uint8_t used; diff --git a/level_0/f_type_array/c/type_array.h b/level_0/f_type_array/c/type_array.h index 401bb7dc6..fdb4769d8 100644 --- a/level_0/f_type_array/c/type_array.h +++ b/level_0/f_type_array/c/type_array.h @@ -29,6 +29,11 @@ #include #include #include +#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/level_0/f_type_array/c/type_array/array_length.c b/level_0/f_type_array/c/type_array/array_length.c index 3479ab463..47929eca6 100644 --- a/level_0/f_type_array/c/type_array/array_length.c +++ b/level_0/f_type_array/c/type_array/array_length.c @@ -17,17 +17,34 @@ extern "C" { #endif // _di_f_array_lengths_adjust_ #ifndef _di_f_array_lengths_append_ - f_status_t f_array_lengths_append(const f_array_lengths_t source, f_array_lengths_t *destination) { + f_status_t f_array_lengths_append(const f_array_length_t source, f_array_lengths_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; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_array_lengths_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } - return private_f_array_lengths_append(source, destination); + destination->array[destination->used++] = source; + + return F_none; } #endif // _di_f_array_lengths_append_ +#ifndef _di_f_array_lengths_append_all_ + f_status_t f_array_lengths_append_all(const f_array_lengths_t source, f_array_lengths_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; + + return private_f_array_lengths_append_all(source, destination); + } +#endif // _di_f_array_lengths_append_all_ + #ifndef _di_f_array_lengths_decimate_by_ f_status_t f_array_lengths_decimate_by(const f_array_length_t amount, f_array_lengths_t *lengths) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +148,31 @@ extern "C" { #endif // _di_f_array_lengthss_adjust_ #ifndef _di_f_array_lengthss_append_ - f_status_t f_array_lengthss_append(const f_array_lengthss_t source, f_array_lengthss_t *destination) { + f_status_t f_array_lengthss_append(const f_array_lengths_t source, f_array_lengthss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_array_lengthss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_array_lengths_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_array_lengthss_append_ + +#ifndef _di_f_array_lengthss_append_all_ + f_status_t f_array_lengthss_append_all(const f_array_lengthss_t source, f_array_lengthss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +187,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_array_lengths_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_array_lengths_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_array_lengthss_append_ +#endif // _di_f_array_lengthss_append_all_ #ifndef _di_f_array_lengthss_decimate_by_ f_status_t f_array_lengthss_decimate_by(const f_array_length_t amount, f_array_lengthss_t *lengthss) { diff --git a/level_0/f_type_array/c/type_array/array_length.h b/level_0/f_type_array/c/type_array/array_length.h index 34c88736b..cbd3360ef 100644 --- a/level_0/f_type_array/c/type_array/array_length.h +++ b/level_0/f_type_array/c/type_array/array_length.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_array_lengths_adjust_ /** - * Append the source lengths onto the destination. + * Append the single source length onto the destination. * * @param source - * The source lengths to append. + * The source length to append. * @param destination * The destination lengths the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_array_lengths_append_ - extern f_status_t f_array_lengths_append(const f_array_lengths_t source, f_array_lengths_t *destination); + extern f_status_t f_array_lengths_append(const f_array_length_t source, f_array_lengths_t *destination); #endif // _di_f_array_lengths_append_ +/** + * Append the source lengths onto the destination. + * + * @param source + * The source lengths to append. + * @param destination + * The destination lengths the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_array_lengths_append_all_ + extern f_status_t f_array_lengths_append_all(const f_array_lengths_t source, f_array_lengths_t *destination); +#endif // _di_f_array_lengths_append_all_ + /** * Resize the string lengths array to a smaller size. * @@ -191,10 +211,10 @@ extern "C" { #endif // _di_f_array_lengthss_adjust_ /** - * Append the source lengthss onto the destination. + * Append the single source lengths onto the destination. * * @param source - * The source lengthss to append. + * The source lengths to append. * @param destination * The destination ranges the source is appended onto. * @@ -207,28 +227,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_array_lengthss_append_ - extern f_status_t f_array_lengthss_append(const f_array_lengthss_t source, f_array_lengthss_t *destination); + extern f_status_t f_array_lengthss_append(const f_array_lengths_t source, f_array_lengthss_t *destination); #endif // _di_f_array_lengthss_append_ /** - * Resize the string lengthss array. + * Append the source lengthss onto the destination. * - * @param length - * The new size to use. - * @param lengthss - * The string lengthss array to resize. + * @param source + * The source lengthss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_array_lengthss_adjust_ - extern f_status_t f_array_lengthss_adjust(const f_array_length_t length, f_array_lengthss_t *lengthss); -#endif // _di_f_array_lengthss_adjust_ +#ifndef _di_f_array_lengthss_append_all_ + extern f_status_t f_array_lengthss_append_all(const f_array_lengthss_t source, f_array_lengthss_t *destination); +#endif // _di_f_array_lengthss_append_all_ /** * Resize the string lengthss array to a smaller size. diff --git a/level_0/f_type_array/c/type_array/cell.c b/level_0/f_type_array/c/type_array/cell.c index d18372d26..90221be28 100644 --- a/level_0/f_type_array/c/type_array/cell.c +++ b/level_0/f_type_array/c/type_array/cell.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_cells_adjust_ #ifndef _di_f_cells_append_ - f_status_t f_cells_append(const f_cells_t source, f_cells_t *destination) { + f_status_t f_cells_append(const f_cell_t source, f_cells_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; - return private_f_cells_append(source, destination); } #endif // _di_f_cells_append_ +#ifndef _di_f_cells_append_all_ + f_status_t f_cells_append_all(const f_cells_t source, f_cells_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; + + return private_f_cells_append_all(source, destination); + } +#endif // _di_f_cells_append_all_ + #ifndef _di_f_cells_decimate_by_ f_status_t f_cells_decimate_by(const f_array_length_t amount, f_cells_t *cells) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_cellss_adjust_ #ifndef _di_f_cellss_append_ - f_status_t f_cellss_append(const f_cellss_t source, f_cellss_t *destination) { + f_status_t f_cellss_append(const f_cells_t source, f_cellss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_cellss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_cells_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_cellss_append_ + +#ifndef _di_f_cellss_append_all_ + f_status_t f_cellss_append_all(const f_cellss_t source, f_cellss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_cells_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_cells_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_cellss_append_ +#endif // _di_f_cellss_append_all_ #ifndef _di_f_cellss_decimate_by_ f_status_t f_cellss_decimate_by(const f_array_length_t amount, f_cellss_t *cellss) { diff --git a/level_0/f_type_array/c/type_array/cell.h b/level_0/f_type_array/c/type_array/cell.h index 034b617aa..ad111f3c8 100644 --- a/level_0/f_type_array/c/type_array/cell.h +++ b/level_0/f_type_array/c/type_array/cell.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_cells_adjust_ /** - * Append the source cells onto the destination. + * Append the single source cell onto the destination. * * @param source - * The source cells to append. + * The source cell to append. * @param destination * The destination cells the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_cells_append_ - extern f_status_t f_cells_append(const f_cells_t source, f_cells_t *destination); + extern f_status_t f_cells_append(const f_cell_t source, f_cells_t *destination); #endif // _di_f_cells_append_ +/** + * Append the source cells onto the destination. + * + * @param source + * The source cells to append. + * @param destination + * The destination cells the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_cells_append_all_ + extern f_status_t f_cells_append_all(const f_cells_t source, f_cells_t *destination); +#endif // _di_f_cells_append_all_ + /** * Resize the string cells array to a smaller size. * @@ -193,10 +213,10 @@ extern "C" { #endif // _di_f_cellss_adjust_ /** - * Append the source cellss onto the destination. + * Append the single source cells onto the destination. * * @param source - * The source cellss to append. + * The source cells to append. * @param destination * The destination ranges the source is appended onto. * @@ -209,28 +229,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_cellss_append_ - extern f_status_t f_cellss_append(const f_cellss_t source, f_cellss_t *destination); + extern f_status_t f_cellss_append(const f_cells_t source, f_cellss_t *destination); #endif // _di_f_cellss_append_ /** - * Resize the string cellss array. + * Append the source cellss onto the destination. * - * @param length - * The new size to use. - * @param cellss - * The string cellss array to resize. + * @param source + * The source cellss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_cellss_adjust_ - extern f_status_t f_cellss_adjust(const f_array_length_t length, f_cellss_t *cellss); -#endif // _di_f_cellss_adjust_ +#ifndef _di_f_cellss_append_all_ + extern f_status_t f_cellss_append_all(const f_cellss_t source, f_cellss_t *destination); +#endif // _di_f_cellss_append_all_ /** * Resize the string cellss array to a smaller size. diff --git a/level_0/f_type_array/c/type_array/fll_id.c b/level_0/f_type_array/c/type_array/fll_id.c index ddd25be29..b64be6503 100644 --- a/level_0/f_type_array/c/type_array/fll_id.c +++ b/level_0/f_type_array/c/type_array/fll_id.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_fll_ids_adjust_ #ifndef _di_f_fll_ids_append_ - f_status_t f_fll_ids_append(const f_fll_ids_t source, f_fll_ids_t *destination) { + f_status_t f_fll_ids_append(const f_fll_id_t source, f_fll_ids_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; - return private_f_fll_ids_append(source, destination); } #endif // _di_f_fll_ids_append_ +#ifndef _di_f_fll_ids_append_all_ + f_status_t f_fll_ids_append_all(const f_fll_ids_t source, f_fll_ids_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; + + return private_f_fll_ids_append_all(source, destination); + } +#endif // _di_f_fll_ids_append_all_ + #ifndef _di_f_fll_ids_decimate_by_ f_status_t f_fll_ids_decimate_by(const f_array_length_t amount, f_fll_ids_t *ids) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_fll_idss_adjust_ #ifndef _di_f_fll_idss_append_ - f_status_t f_fll_idss_append(const f_fll_idss_t source, f_fll_idss_t *destination) { + f_status_t f_fll_idss_append(const f_fll_ids_t source, f_fll_idss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_fll_idss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_fll_ids_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_fll_idss_append_ + +#ifndef _di_f_fll_idss_append_all_ + f_status_t f_fll_idss_append_all(const f_fll_idss_t source, f_fll_idss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_fll_ids_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_fll_ids_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_fll_idss_append_ +#endif // _di_f_fll_idss_append_all_ #ifndef _di_f_fll_idss_decimate_by_ f_status_t f_fll_idss_decimate_by(const f_array_length_t amount, f_fll_idss_t *idss) { diff --git a/level_0/f_type_array/c/type_array/fll_id.h b/level_0/f_type_array/c/type_array/fll_id.h index 6560a6ae1..03b627771 100644 --- a/level_0/f_type_array/c/type_array/fll_id.h +++ b/level_0/f_type_array/c/type_array/fll_id.h @@ -36,12 +36,12 @@ extern "C" { #endif // _di_f_fll_ids_adjust_ /** - * Append the source ids onto the destination. + * Append the single source fll_id onto the destination. * * @param source - * The source ids to append. + * The source fll_id to append. * @param destination - * The destination ids the source is appended onto. + * The destination fll_ids the source is appended onto. * * @return * F_none on success. @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_fll_ids_append_ - extern f_status_t f_fll_ids_append(const f_fll_ids_t source, f_fll_ids_t *destination); + extern f_status_t f_fll_ids_append(const f_fll_id_t source, f_fll_ids_t *destination); #endif // _di_f_fll_ids_append_ +/** + * Append the source fll_ids onto the destination. + * + * @param source + * The source fll_ids to append. + * @param destination + * The destination fll_ids the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_fll_ids_append_all_ + extern f_status_t f_fll_ids_append_all(const f_fll_ids_t source, f_fll_ids_t *destination); +#endif // _di_f_fll_ids_append_all_ + /** * Resize the string ids array to a smaller size. * @@ -193,10 +213,10 @@ extern "C" { #endif // _di_f_fll_idss_adjust_ /** - * Append the source idss onto the destination. + * Append the single source fll_ids onto the destination. * * @param source - * The source idss to append. + * The source fll_ids to append. * @param destination * The destination ranges the source is appended onto. * @@ -209,28 +229,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_fll_idss_append_ - extern f_status_t f_fll_idss_append(const f_fll_idss_t source, f_fll_idss_t *destination); + extern f_status_t f_fll_idss_append(const f_fll_ids_t source, f_fll_idss_t *destination); #endif // _di_f_fll_idss_append_ /** - * Resize the string idss array. + * Append the source fll_idss onto the destination. * - * @param length - * The new size to use. - * @param idss - * The string idss array to resize. + * @param source + * The source fll_idss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_fll_idss_adjust_ - extern f_status_t f_fll_idss_adjust(const f_array_length_t length, f_fll_idss_t *idss); -#endif // _di_f_fll_idss_adjust_ +#ifndef _di_f_fll_idss_append_all_ + extern f_status_t f_fll_idss_append_all(const f_fll_idss_t source, f_fll_idss_t *destination); +#endif // _di_f_fll_idss_append_all_ /** * Resize the string idss array to a smaller size. diff --git a/level_0/f_type_array/c/type_array/int128.c b/level_0/f_type_array/c/type_array/int128.c index 59b1ee182..983caeee7 100644 --- a/level_0/f_type_array/c/type_array/int128.c +++ b/level_0/f_type_array/c/type_array/int128.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_int128s_adjust_ #ifndef _di_f_int128s_append_ - f_status_t f_int128s_append(const f_int128s_t source, f_int128s_t *destination) { + f_status_t f_int128s_append(const int128_t source, f_int128s_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; - return private_f_int128s_append(source, destination); } #endif // _di_f_int128s_append_ +#ifndef _di_f_int128s_append_all_ + f_status_t f_int128s_append_all(const f_int128s_t source, f_int128s_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; + + return private_f_int128s_append_all(source, destination); + } +#endif // _di_f_int128s_append_all_ + #ifndef _di_f_int128s_decimate_by_ f_status_t f_int128s_decimate_by(const f_array_length_t amount, f_int128s_t *int128s) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_int128ss_adjust_ #ifndef _di_f_int128ss_append_ - f_status_t f_int128ss_append(const f_int128ss_t source, f_int128ss_t *destination) { + f_status_t f_int128ss_append(const f_int128s_t source, f_int128ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_int128ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_int128s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_int128ss_append_ + +#ifndef _di_f_int128ss_append_all_ + f_status_t f_int128ss_append_all(const f_int128ss_t source, f_int128ss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_int128s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_int128s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_int128ss_append_ +#endif // _di_f_int128ss_append_all_ #ifndef _di_f_int128ss_decimate_by_ f_status_t f_int128ss_decimate_by(const f_array_length_t amount, f_int128ss_t *int128ss) { @@ -246,246 +285,6 @@ extern "C" { } #endif // _di_f_int128ss_resize_ -#ifndef _di_f_uint128s_adjust_ - f_status_t f_uint128s_adjust(const f_array_length_t length, f_uint128s_t *uint128s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint128s_adjust(length, uint128s); - } -#endif // _di_f_uint128s_adjust_ - -#ifndef _di_f_uint128s_append_ - f_status_t f_uint128s_append(const f_uint128s_t source, f_uint128s_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; - - return private_f_uint128s_append(source, destination); - } -#endif // _di_f_uint128s_append_ - -#ifndef _di_f_uint128s_decimate_by_ - f_status_t f_uint128s_decimate_by(const f_array_length_t amount, f_uint128s_t *uint128s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint128s->size - amount > 0) { - return private_f_uint128s_adjust(uint128s->size - amount, uint128s); - } - - return private_f_uint128s_adjust(0, uint128s); - } -#endif // _di_f_uint128s_decimate_by_ - -#ifndef _di_f_uint128s_decrease_by_ - f_status_t f_uint128s_decrease_by(const f_array_length_t amount, f_uint128s_t *uint128s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint128s->size - amount > 0) { - return private_f_uint128s_resize(uint128s->size - amount, uint128s); - } - - return private_f_uint128s_resize(0, uint128s); - } -#endif // _di_f_uint128s_decrease_by_ - -#ifndef _di_f_uint128s_increase_ - f_status_t f_uint128s_increase(const f_array_length_t step, f_uint128s_t *uint128s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint128s->used + 1 > uint128s->size) { - f_array_length_t size = uint128s->used + step; - - if (size > F_array_length_t_size_d) { - if (uint128s->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint128s_resize(size, uint128s); - } - - return F_data_not; - } -#endif // _di_f_uint128s_increase_ - -#ifndef _di_f_uint128s_increase_by_ - f_status_t f_uint128s_increase_by(const f_array_length_t amount, f_uint128s_t *uint128s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint128s->used + amount > uint128s->size) { - if (uint128s->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint128s_resize(uint128s->used + amount, uint128s); - } - - return F_data_not; - } -#endif // _di_f_uint128s_increase_by_ - -#ifndef _di_f_uint128s_resize_ - f_status_t f_uint128s_resize(const f_array_length_t length, f_uint128s_t *uint128s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint128s_resize(length, uint128s); - } -#endif // _di_f_uint128s_resize_ - -#ifndef _di_f_uint128ss_adjust_ - f_status_t f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint128ss_adjust(length, uint128ss); - } -#endif // _di_f_uint128ss_adjust_ - -#ifndef _di_f_uint128ss_append_ - f_status_t f_uint128ss_append(const f_uint128ss_t source, f_uint128ss_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; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint128ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_uint128s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } // for - - return F_none; - } -#endif // _di_f_uint128ss_append_ - -#ifndef _di_f_uint128ss_decimate_by_ - f_status_t f_uint128ss_decimate_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint128ss->size - amount > 0) { - return private_f_uint128ss_adjust(uint128ss->size - amount, uint128ss); - } - - return private_f_uint128ss_adjust(0, uint128ss); - } -#endif // _di_f_uint128ss_decimate_by_ - -#ifndef _di_f_uint128ss_decrease_by_ - f_status_t f_uint128ss_decrease_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint128ss->size - amount > 0) { - return private_f_uint128ss_resize(uint128ss->size - amount, uint128ss); - } - - return private_f_uint128ss_resize(0, uint128ss); - } -#endif // _di_f_uint128ss_decrease_by_ - -#ifndef _di_f_uint128ss_increase_ - f_status_t f_uint128ss_increase(const f_array_length_t step, f_uint128ss_t *uint128ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint128ss->used + 1 > uint128ss->size) { - f_array_length_t size = uint128ss->used + step; - - if (size > F_array_length_t_size_d) { - if (uint128ss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint128ss_resize(size, uint128ss); - } - - return F_data_not; - } -#endif // _di_f_uint128ss_increase_ - -#ifndef _di_f_uint128ss_increase_by_ - f_status_t f_uint128ss_increase_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint128ss->used + amount > uint128ss->size) { - if (uint128ss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint128ss_resize(uint128ss->used + amount, uint128ss); - } - - return F_data_not; - } -#endif // _di_f_uint128ss_increase_by_ - -#ifndef _di_f_uint128ss_resize_ - f_status_t f_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint128ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint128ss_resize(length, uint128ss); - } -#endif // _di_f_uint128ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int128.h b/level_0/f_type_array/c/type_array/int128.h index 232ad7ae0..df505a165 100644 --- a/level_0/f_type_array/c/type_array/int128.h +++ b/level_0/f_type_array/c/type_array/int128.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_int128s_adjust_ /** - * Append the source int128s onto the destination. + * Append the single source int128 onto the destination. * * @param source - * The source int128s to append. + * The source int128 to append. * @param destination * The destination int128s the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int128s_append_ - extern f_status_t f_int128s_append(const f_int128s_t source, f_int128s_t *destination); + extern f_status_t f_int128s_append(const int128_t source, f_int128s_t *destination); #endif // _di_f_int128s_append_ +/** + * Append the source int128s onto the destination. + * + * @param source + * The source int128s to append. + * @param destination + * The destination int128s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_int128s_append_all_ + extern f_status_t f_int128s_append_all(const f_int128s_t source, f_int128s_t *destination); +#endif // _di_f_int128s_append_all_ + /** * Resize the int128s array to a smaller size. * @@ -193,10 +213,10 @@ extern "C" { #endif // _di_f_int128ss_adjust_ /** - * Append the source int128ss onto the destination. + * Append the single source int128 onto the destination. * * @param source - * The source int128ss to append. + * The source int128s to append. * @param destination * The destination ranges the source is appended onto. * @@ -209,28 +229,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int128ss_append_ - extern f_status_t f_int128ss_append(const f_int128ss_t source, f_int128ss_t *destination); + extern f_status_t f_int128ss_append(const f_int128s_t source, f_int128ss_t *destination); #endif // _di_f_int128ss_append_ /** - * Resize the int128ss array. + * Append the source int128ss onto the destination. * - * @param length - * The new size to use. - * @param int128ss - * The int128ss array to resize. + * @param source + * The source int128ss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_int128ss_adjust_ - extern f_status_t f_int128ss_adjust(const f_array_length_t length, f_int128ss_t *int128ss); -#endif // _di_f_int128ss_adjust_ +#ifndef _di_f_int128ss_append_all_ + extern f_status_t f_int128ss_append_all(const f_int128ss_t source, f_int128ss_t *destination); +#endif // _di_f_int128ss_append_all_ /** * Resize the int128ss array to a smaller size. @@ -350,340 +370,6 @@ extern "C" { extern f_status_t f_int128ss_resize(const f_array_length_t length, f_int128ss_t *int128ss); #endif // _di_f_int128ss_resize_ -/** - * Resize the string uint128s array. - * - * @param length - * The new size to use. - * @param uint128s - * The string uint128s 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(). - */ -#ifndef _di_f_uint128s_adjust_ - extern f_status_t f_uint128s_adjust(const f_array_length_t length, f_uint128s_t *uint128s); -#endif // _di_f_uint128s_adjust_ - -/** - * Append the source uint128s onto the destination. - * - * @param source - * The source uint128s to append. - * @param destination - * The destination uint128s the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint128s_append_ - extern f_status_t f_uint128s_append(const f_uint128s_t source, f_uint128s_t *destination); -#endif // _di_f_uint128s_append_ - -/** - * Resize the string uint128s 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 uint128s - * The string uint128s 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(). - */ -#ifndef _di_f_uint128s_decimate_by_ - extern f_status_t f_uint128s_decimate_by(const f_array_length_t amount, f_uint128s_t *uint128s); -#endif // _di_f_uint128s_decimate_by_ - -/** - * Resize the string uint128s 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 uint128s - * The string uint128s 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(). - */ -#ifndef _di_f_uint128s_decrease_by_ - extern f_status_t f_uint128s_decrease_by(const f_array_length_t amount, f_uint128s_t *uint128s); -#endif // _di_f_uint128s_decrease_by_ - -/** - * Increase the size of the string uint128s array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint128s - * The string uint128s 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(). - */ -#ifndef _di_f_uint128s_increase_ - extern f_status_t f_uint128s_increase(const f_array_length_t step, f_uint128s_t *uint128s); -#endif // _di_f_uint128s_increase_ - -/** - * Resize the string uint128s array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint128s - * The string uint128s 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(). - */ -#ifndef _di_f_uint128s_increase_by_ - extern f_status_t f_uint128s_increase_by(const f_array_length_t amount, f_uint128s_t *uint128s); -#endif // _di_f_uint128s_increase_by_ - -/** - * Resize the string uint128s array. - * - * @param length - * The new size to use. - * @param uint128s - * The string uint128s 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(). - */ -#ifndef _di_f_uint128s_resize_ - extern f_status_t f_uint128s_resize(const f_array_length_t length, f_uint128s_t *uint128s); -#endif // _di_f_uint128s_resize_ - -/** - * Resize the string uint128ss array. - * - * @param length - * The new size to use. - * @param uint128ss - * The string uint128ss 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_memory_destroy(). - */ -#ifndef _di_f_uint128ss_adjust_ - extern f_status_t f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss); -#endif // _di_f_uint128ss_adjust_ - -/** - * Append the source uint128ss onto the destination. - * - * @param source - * The source uint128ss to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint128ss_append_ - extern f_status_t f_uint128ss_append(const f_uint128ss_t source, f_uint128ss_t *destination); -#endif // _di_f_uint128ss_append_ - -/** - * Resize the string uint128ss array. - * - * @param length - * The new size to use. - * @param uint128ss - * The string uint128ss 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_memory_destroy(). - */ -#ifndef _di_f_uint128ss_adjust_ - extern f_status_t f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss); -#endif // _di_f_uint128ss_adjust_ - -/** - * Resize the string uint128ss 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 uint128ss - * The string uint128ss 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_memory_destroy(). - */ -#ifndef _di_f_uint128ss_decimate_by_ - extern f_status_t f_uint128ss_decimate_by(const f_array_length_t amount, f_uint128ss_t *uint128ss); -#endif // _di_f_uint128ss_decimate_by_ - -/** - * Resize the string uint128ss 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 uint128ss - * The string uint128ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint128ss_decrease_by_ - extern f_status_t f_uint128ss_decrease_by(const f_array_length_t amount, f_uint128ss_t *uint128ss); -#endif // _di_f_uint128ss_decrease_by_ - -/** - * Increase the size of the string uint128ss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint128ss - * The string uint128ss 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(). - */ -#ifndef _di_f_uint128ss_increase_ - extern f_status_t f_uint128ss_increase(const f_array_length_t step, f_uint128ss_t *uint128ss); -#endif // _di_f_uint128ss_increase_ - -/** - * Resize the string uint128ss array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint128ss - * The string uint128ss 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(). - */ -#ifndef _di_f_uint128ss_increase_by_ - extern f_status_t f_uint128ss_increase_by(const f_array_length_t amount, f_uint128ss_t *uint128ss); -#endif // _di_f_uint128ss_increase_by_ - -/** - * Resize the string uint128ss array. - * - * @param length - * The new size to use. - * @param uint128ss - * The string uint128ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint128ss_resize_ - extern f_status_t f_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss); -#endif // _di_f_uint128ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int16.c b/level_0/f_type_array/c/type_array/int16.c index 48773a5c9..9221c9318 100644 --- a/level_0/f_type_array/c/type_array/int16.c +++ b/level_0/f_type_array/c/type_array/int16.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_int16s_adjust_ #ifndef _di_f_int16s_append_ - f_status_t f_int16s_append(const f_int16s_t source, f_int16s_t *destination) { + f_status_t f_int16s_append(const int16_t source, f_int16s_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; - return private_f_int16s_append(source, destination); } #endif // _di_f_int16s_append_ +#ifndef _di_f_int16s_append_all_ + f_status_t f_int16s_append_all(const f_int16s_t source, f_int16s_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; + + return private_f_int16s_append_all(source, destination); + } +#endif // _di_f_int16s_append_all_ + #ifndef _di_f_int16s_decimate_by_ f_status_t f_int16s_decimate_by(const f_array_length_t amount, f_int16s_t *int16s) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_int16ss_adjust_ #ifndef _di_f_int16ss_append_ - f_status_t f_int16ss_append(const f_int16ss_t source, f_int16ss_t *destination) { + f_status_t f_int16ss_append(const f_int16s_t source, f_int16ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_int16ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_int16s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_int16ss_append_ + +#ifndef _di_f_int16ss_append_all_ + f_status_t f_int16ss_append_all(const f_int16ss_t source, f_int16ss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_int16s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_int16s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_int16ss_append_ +#endif // _di_f_int16ss_append_all_ #ifndef _di_f_int16ss_decimate_by_ f_status_t f_int16ss_decimate_by(const f_array_length_t amount, f_int16ss_t *int16ss) { @@ -246,246 +285,6 @@ extern "C" { } #endif // _di_f_int16ss_resize_ -#ifndef _di_f_uint16s_adjust_ - f_status_t f_uint16s_adjust(const f_array_length_t length, f_uint16s_t *uint16s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint16s_adjust(length, uint16s); - } -#endif // _di_f_uint16s_adjust_ - -#ifndef _di_f_uint16s_append_ - f_status_t f_uint16s_append(const f_uint16s_t source, f_uint16s_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; - - return private_f_uint16s_append(source, destination); - } -#endif // _di_f_uint16s_append_ - -#ifndef _di_f_uint16s_decimate_by_ - f_status_t f_uint16s_decimate_by(const f_array_length_t amount, f_uint16s_t *uint16s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint16s->size - amount > 0) { - return private_f_uint16s_adjust(uint16s->size - amount, uint16s); - } - - return private_f_uint16s_adjust(0, uint16s); - } -#endif // _di_f_uint16s_decimate_by_ - -#ifndef _di_f_uint16s_decrease_by_ - f_status_t f_uint16s_decrease_by(const f_array_length_t amount, f_uint16s_t *uint16s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint16s->size - amount > 0) { - return private_f_uint16s_resize(uint16s->size - amount, uint16s); - } - - return private_f_uint16s_resize(0, uint16s); - } -#endif // _di_f_uint16s_decrease_by_ - -#ifndef _di_f_uint16s_increase_ - f_status_t f_uint16s_increase(const f_array_length_t step, f_uint16s_t *uint16s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint16s->used + 1 > uint16s->size) { - f_array_length_t size = uint16s->used + step; - - if (size > F_array_length_t_size_d) { - if (uint16s->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint16s_resize(size, uint16s); - } - - return F_data_not; - } -#endif // _di_f_uint16s_increase_ - -#ifndef _di_f_uint16s_increase_by_ - f_status_t f_uint16s_increase_by(const f_array_length_t amount, f_uint16s_t *uint16s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint16s->used + amount > uint16s->size) { - if (uint16s->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint16s_resize(uint16s->used + amount, uint16s); - } - - return F_data_not; - } -#endif // _di_f_uint16s_increase_by_ - -#ifndef _di_f_uint16s_resize_ - f_status_t f_uint16s_resize(const f_array_length_t length, f_uint16s_t *uint16s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint16s_resize(length, uint16s); - } -#endif // _di_f_uint16s_resize_ - -#ifndef _di_f_uint16ss_adjust_ - f_status_t f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint16ss_adjust(length, uint16ss); - } -#endif // _di_f_uint16ss_adjust_ - -#ifndef _di_f_uint16ss_append_ - f_status_t f_uint16ss_append(const f_uint16ss_t source, f_uint16ss_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; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint16ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_uint16s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } // for - - return F_none; - } -#endif // _di_f_uint16ss_append_ - -#ifndef _di_f_uint16ss_decimate_by_ - f_status_t f_uint16ss_decimate_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint16ss->size - amount > 0) { - return private_f_uint16ss_adjust(uint16ss->size - amount, uint16ss); - } - - return private_f_uint16ss_adjust(0, uint16ss); - } -#endif // _di_f_uint16ss_decimate_by_ - -#ifndef _di_f_uint16ss_decrease_by_ - f_status_t f_uint16ss_decrease_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint16ss->size - amount > 0) { - return private_f_uint16ss_resize(uint16ss->size - amount, uint16ss); - } - - return private_f_uint16ss_resize(0, uint16ss); - } -#endif // _di_f_uint16ss_decrease_by_ - -#ifndef _di_f_uint16ss_increase_ - f_status_t f_uint16ss_increase(const f_array_length_t step, f_uint16ss_t *uint16ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint16ss->used + 1 > uint16ss->size) { - f_array_length_t size = uint16ss->used + step; - - if (size > F_array_length_t_size_d) { - if (uint16ss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint16ss_resize(size, uint16ss); - } - - return F_data_not; - } -#endif // _di_f_uint16ss_increase_ - -#ifndef _di_f_uint16ss_increase_by_ - f_status_t f_uint16ss_increase_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint16ss->used + amount > uint16ss->size) { - if (uint16ss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint16ss_resize(uint16ss->used + amount, uint16ss); - } - - return F_data_not; - } -#endif // _di_f_uint16ss_increase_by_ - -#ifndef _di_f_uint16ss_resize_ - f_status_t f_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint16ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint16ss_resize(length, uint16ss); - } -#endif // _di_f_uint16ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int16.h b/level_0/f_type_array/c/type_array/int16.h index 22b28f53f..8fc0c2a52 100644 --- a/level_0/f_type_array/c/type_array/int16.h +++ b/level_0/f_type_array/c/type_array/int16.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_int16s_adjust_ /** - * Append the source int16s onto the destination. + * Append the single source int16 onto the destination. * * @param source - * The source int16s to append. + * The source int16 to append. * @param destination * The destination int16s the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int16s_append_ - extern f_status_t f_int16s_append(const f_int16s_t source, f_int16s_t *destination); + extern f_status_t f_int16s_append(const int16_t source, f_int16s_t *destination); #endif // _di_f_int16s_append_ +/** + * Append the source int16s onto the destination. + * + * @param source + * The source int16s to append. + * @param destination + * The destination int16s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_int16s_append_all_ + extern f_status_t f_int16s_append_all(const f_int16s_t source, f_int16s_t *destination); +#endif // _di_f_int16s_append_all_ + /** * Resize the int16s array to a smaller size. * @@ -193,10 +213,10 @@ extern "C" { #endif // _di_f_int16ss_adjust_ /** - * Append the source int16ss onto the destination. + * Append the single source int16s onto the destination. * * @param source - * The source int16ss to append. + * The source int16s to append. * @param destination * The destination ranges the source is appended onto. * @@ -209,28 +229,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int16ss_append_ - extern f_status_t f_int16ss_append(const f_int16ss_t source, f_int16ss_t *destination); + extern f_status_t f_int16ss_append(const f_int16s_t source, f_int16ss_t *destination); #endif // _di_f_int16ss_append_ /** - * Resize the int16ss array. + * Append the source int16ss onto the destination. * - * @param length - * The new size to use. - * @param int16ss - * The int16ss array to resize. + * @param source + * The source int16ss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_int16ss_adjust_ - extern f_status_t f_int16ss_adjust(const f_array_length_t length, f_int16ss_t *int16ss); -#endif // _di_f_int16ss_adjust_ +#ifndef _di_f_int16ss_append_all_ + extern f_status_t f_int16ss_append_all(const f_int16ss_t source, f_int16ss_t *destination); +#endif // _di_f_int16ss_append_all_ /** * Resize the int16ss array to a smaller size. @@ -352,340 +372,6 @@ extern "C" { extern f_status_t f_int16ss_resize(const f_array_length_t length, f_int16ss_t *int16ss); #endif // _di_f_int16ss_resize_ -/** - * Resize the string uint16s array. - * - * @param length - * The new size to use. - * @param uint16s - * The string uint16s 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(). - */ -#ifndef _di_f_uint16s_adjust_ - extern f_status_t f_uint16s_adjust(const f_array_length_t length, f_uint16s_t *uint16s); -#endif // _di_f_uint16s_adjust_ - -/** - * Append the source uint16s onto the destination. - * - * @param source - * The source uint16s to append. - * @param destination - * The destination uint16s the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint16s_append_ - extern f_status_t f_uint16s_append(const f_uint16s_t source, f_uint16s_t *destination); -#endif // _di_f_uint16s_append_ - -/** - * Resize the string uint16s 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 uint16s - * The string uint16s 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(). - */ -#ifndef _di_f_uint16s_decimate_by_ - extern f_status_t f_uint16s_decimate_by(const f_array_length_t amount, f_uint16s_t *uint16s); -#endif // _di_f_uint16s_decimate_by_ - -/** - * Resize the string uint16s 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 uint16s - * The string uint16s 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(). - */ -#ifndef _di_f_uint16s_decrease_by_ - extern f_status_t f_uint16s_decrease_by(const f_array_length_t amount, f_uint16s_t *uint16s); -#endif // _di_f_uint16s_decrease_by_ - -/** - * Increase the size of the string uint16s array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint16s - * The string uint16s 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(). - */ -#ifndef _di_f_uint16s_increase_ - extern f_status_t f_uint16s_increase(const f_array_length_t step, f_uint16s_t *uint16s); -#endif // _di_f_uint16s_increase_ - -/** - * Resize the string uint16s array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint16s - * The string uint16s 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(). - */ -#ifndef _di_f_uint16s_increase_by_ - extern f_status_t f_uint16s_increase_by(const f_array_length_t amount, f_uint16s_t *uint16s); -#endif // _di_f_uint16s_increase_by_ - -/** - * Resize the string uint16s array. - * - * @param length - * The new size to use. - * @param uint16s - * The string uint16s 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(). - */ -#ifndef _di_f_uint16s_resize_ - extern f_status_t f_uint16s_resize(const f_array_length_t length, f_uint16s_t *uint16s); -#endif // _di_f_uint16s_resize_ - -/** - * Resize the string uint16ss array. - * - * @param length - * The new size to use. - * @param uint16ss - * The string uint16ss 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_memory_destroy(). - */ -#ifndef _di_f_uint16ss_adjust_ - extern f_status_t f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss); -#endif // _di_f_uint16ss_adjust_ - -/** - * Append the source uint16ss onto the destination. - * - * @param source - * The source uint16ss to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint16ss_append_ - extern f_status_t f_uint16ss_append(const f_uint16ss_t source, f_uint16ss_t *destination); -#endif // _di_f_uint16ss_append_ - -/** - * Resize the string uint16ss array. - * - * @param length - * The new size to use. - * @param uint16ss - * The string uint16ss 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_memory_destroy(). - */ -#ifndef _di_f_uint16ss_adjust_ - extern f_status_t f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss); -#endif // _di_f_uint16ss_adjust_ - -/** - * Resize the string uint16ss 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 uint16ss - * The string uint16ss 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_memory_destroy(). - */ -#ifndef _di_f_uint16ss_decimate_by_ - extern f_status_t f_uint16ss_decimate_by(const f_array_length_t amount, f_uint16ss_t *uint16ss); -#endif // _di_f_uint16ss_decimate_by_ - -/** - * Resize the string uint16ss 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 uint16ss - * The string uint16ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint16ss_decrease_by_ - extern f_status_t f_uint16ss_decrease_by(const f_array_length_t amount, f_uint16ss_t *uint16ss); -#endif // _di_f_uint16ss_decrease_by_ - -/** - * Increase the size of the string uint16ss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint16ss - * The string uint16ss 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(). - */ -#ifndef _di_f_uint16ss_increase_ - extern f_status_t f_uint16ss_increase(const f_array_length_t step, f_uint16ss_t *uint16ss); -#endif // _di_f_uint16ss_increase_ - -/** - * Resize the string uint16ss array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint16ss - * The string uint16ss 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(). - */ -#ifndef _di_f_uint16ss_increase_by_ - extern f_status_t f_uint16ss_increase_by(const f_array_length_t amount, f_uint16ss_t *uint16ss); -#endif // _di_f_uint16ss_increase_by_ - -/** - * Resize the string uint16ss array. - * - * @param length - * The new size to use. - * @param uint16ss - * The string uint16ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint16ss_resize_ - extern f_status_t f_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss); -#endif // _di_f_uint16ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int32.c b/level_0/f_type_array/c/type_array/int32.c index 701349eb5..5425634e4 100644 --- a/level_0/f_type_array/c/type_array/int32.c +++ b/level_0/f_type_array/c/type_array/int32.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_int32s_adjust_ #ifndef _di_f_int32s_append_ - f_status_t f_int32s_append(const f_int32s_t source, f_int32s_t *destination) { + f_status_t f_int32s_append(const int32_t source, f_int32s_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; - return private_f_int32s_append(source, destination); } #endif // _di_f_int32s_append_ +#ifndef _di_f_int32s_append_all_ + f_status_t f_int32s_append_all(const f_int32s_t source, f_int32s_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; + + return private_f_int32s_append_all(source, destination); + } +#endif // _di_f_int32s_append_all_ + #ifndef _di_f_int32s_decimate_by_ f_status_t f_int32s_decimate_by(const f_array_length_t amount, f_int32s_t *int32s) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_int32ss_adjust_ #ifndef _di_f_int32ss_append_ - f_status_t f_int32ss_append(const f_int32ss_t source, f_int32ss_t *destination) { + f_status_t f_int32ss_append(const f_int32s_t source, f_int32ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_int32ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_int32s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_int32ss_append_ + +#ifndef _di_f_int32ss_append_all_ + f_status_t f_int32ss_append_all(const f_int32ss_t source, f_int32ss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_int32s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_int32s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_int32ss_append_ +#endif // _di_f_int32ss_append_all_ #ifndef _di_f_int32ss_decimate_by_ f_status_t f_int32ss_decimate_by(const f_array_length_t amount, f_int32ss_t *int32ss) { @@ -246,246 +285,6 @@ extern "C" { } #endif // _di_f_int32ss_resize_ -#ifndef _di_f_uint32s_adjust_ - f_status_t f_uint32s_adjust(const f_array_length_t length, f_uint32s_t *uint32s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint32s_adjust(length, uint32s); - } -#endif // _di_f_uint32s_adjust_ - -#ifndef _di_f_uint32s_append_ - f_status_t f_uint32s_append(const f_uint32s_t source, f_uint32s_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; - - return private_f_uint32s_append(source, destination); - } -#endif // _di_f_uint32s_append_ - -#ifndef _di_f_uint32s_decimate_by_ - f_status_t f_uint32s_decimate_by(const f_array_length_t amount, f_uint32s_t *uint32s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint32s->size - amount > 0) { - return private_f_uint32s_adjust(uint32s->size - amount, uint32s); - } - - return private_f_uint32s_adjust(0, uint32s); - } -#endif // _di_f_uint32s_decimate_by_ - -#ifndef _di_f_uint32s_decrease_by_ - f_status_t f_uint32s_decrease_by(const f_array_length_t amount, f_uint32s_t *uint32s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint32s->size - amount > 0) { - return private_f_uint32s_resize(uint32s->size - amount, uint32s); - } - - return private_f_uint32s_resize(0, uint32s); - } -#endif // _di_f_uint32s_decrease_by_ - -#ifndef _di_f_uint32s_increase_ - f_status_t f_uint32s_increase(const f_array_length_t step, f_uint32s_t *uint32s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint32s->used + 1 > uint32s->size) { - f_array_length_t size = uint32s->used + step; - - if (size > F_array_length_t_size_d) { - if (uint32s->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint32s_resize(size, uint32s); - } - - return F_data_not; - } -#endif // _di_f_uint32s_increase_ - -#ifndef _di_f_uint32s_increase_by_ - f_status_t f_uint32s_increase_by(const f_array_length_t amount, f_uint32s_t *uint32s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint32s->used + amount > uint32s->size) { - if (uint32s->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint32s_resize(uint32s->used + amount, uint32s); - } - - return F_data_not; - } -#endif // _di_f_uint32s_increase_by_ - -#ifndef _di_f_uint32s_resize_ - f_status_t f_uint32s_resize(const f_array_length_t length, f_uint32s_t *uint32s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint32s_resize(length, uint32s); - } -#endif // _di_f_uint32s_resize_ - -#ifndef _di_f_uint32ss_adjust_ - f_status_t f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint32ss_adjust(length, uint32ss); - } -#endif // _di_f_uint32ss_adjust_ - -#ifndef _di_f_uint32ss_append_ - f_status_t f_uint32ss_append(const f_uint32ss_t source, f_uint32ss_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; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint32ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_uint32s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } // for - - return F_none; - } -#endif // _di_f_uint32ss_append_ - -#ifndef _di_f_uint32ss_decimate_by_ - f_status_t f_uint32ss_decimate_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint32ss->size - amount > 0) { - return private_f_uint32ss_adjust(uint32ss->size - amount, uint32ss); - } - - return private_f_uint32ss_adjust(0, uint32ss); - } -#endif // _di_f_uint32ss_decimate_by_ - -#ifndef _di_f_uint32ss_decrease_by_ - f_status_t f_uint32ss_decrease_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint32ss->size - amount > 0) { - return private_f_uint32ss_resize(uint32ss->size - amount, uint32ss); - } - - return private_f_uint32ss_resize(0, uint32ss); - } -#endif // _di_f_uint32ss_decrease_by_ - -#ifndef _di_f_uint32ss_increase_ - f_status_t f_uint32ss_increase(const f_array_length_t step, f_uint32ss_t *uint32ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint32ss->used + 1 > uint32ss->size) { - f_array_length_t size = uint32ss->used + step; - - if (size > F_array_length_t_size_d) { - if (uint32ss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint32ss_resize(size, uint32ss); - } - - return F_data_not; - } -#endif // _di_f_uint32ss_increase_ - -#ifndef _di_f_uint32ss_increase_by_ - f_status_t f_uint32ss_increase_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint32ss->used + amount > uint32ss->size) { - if (uint32ss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint32ss_resize(uint32ss->used + amount, uint32ss); - } - - return F_data_not; - } -#endif // _di_f_uint32ss_increase_by_ - -#ifndef _di_f_uint32ss_resize_ - f_status_t f_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint32ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint32ss_resize(length, uint32ss); - } -#endif // _di_f_uint32ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int32.h b/level_0/f_type_array/c/type_array/int32.h index 7ec1864bd..9d3f4cfe2 100644 --- a/level_0/f_type_array/c/type_array/int32.h +++ b/level_0/f_type_array/c/type_array/int32.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_int32s_adjust_ /** - * Append the source int32s onto the destination. + * Append the single source int32 onto the destination. * * @param source - * The source int32s to append. + * The source int32 to append. * @param destination * The destination int32s the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int32s_append_ - extern f_status_t f_int32s_append(const f_int32s_t source, f_int32s_t *destination); + extern f_status_t f_int32s_append(const int32_t source, f_int32s_t *destination); #endif // _di_f_int32s_append_ +/** + * Append the source int32s onto the destination. + * + * @param source + * The source int32s to append. + * @param destination + * The destination int32s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_int32s_append_all_ + extern f_status_t f_int32s_append_all(const f_int32s_t source, f_int32s_t *destination); +#endif // _di_f_int32s_append_all_ + /** * Resize the int32s array to a smaller size. * @@ -192,10 +212,10 @@ extern "C" { #endif // _di_f_int32ss_adjust_ /** - * Append the source int32ss onto the destination. + * Append the single source int32s onto the destination. * * @param source - * The source int32ss to append. + * The source int32s to append. * @param destination * The destination ranges the source is appended onto. * @@ -208,28 +228,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int32ss_append_ - extern f_status_t f_int32ss_append(const f_int32ss_t source, f_int32ss_t *destination); + extern f_status_t f_int32ss_append(const f_int32s_t source, f_int32ss_t *destination); #endif // _di_f_int32ss_append_ /** - * Resize the int32ss array. + * Append the source int32ss onto the destination. * - * @param length - * The new size to use. - * @param int32ss - * The int32ss array to resize. + * @param source + * The source int32ss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_int32ss_adjust_ - extern f_status_t f_int32ss_adjust(const f_array_length_t length, f_int32ss_t *int32ss); -#endif // _di_f_int32ss_adjust_ +#ifndef _di_f_int32ss_append_all_ + extern f_status_t f_int32ss_append_all(const f_int32ss_t source, f_int32ss_t *destination); +#endif // _di_f_int32ss_append_all_ /** * Resize the int32ss array to a smaller size. @@ -350,340 +370,6 @@ extern "C" { extern f_status_t f_int32ss_resize(const f_array_length_t length, f_int32ss_t *int32ss); #endif // _di_f_int32ss_resize_ -/** - * Resize the string uint32s array. - * - * @param length - * The new size to use. - * @param uint32s - * The string uint32s 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(). - */ -#ifndef _di_f_uint32s_adjust_ - extern f_status_t f_uint32s_adjust(const f_array_length_t length, f_uint32s_t *uint32s); -#endif // _di_f_uint32s_adjust_ - -/** - * Append the source uint32s onto the destination. - * - * @param source - * The source uint32s to append. - * @param destination - * The destination uint32s the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint32s_append_ - extern f_status_t f_uint32s_append(const f_uint32s_t source, f_uint32s_t *destination); -#endif // _di_f_uint32s_append_ - -/** - * Resize the string uint32s 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 uint32s - * The string uint32s 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(). - */ -#ifndef _di_f_uint32s_decimate_by_ - extern f_status_t f_uint32s_decimate_by(const f_array_length_t amount, f_uint32s_t *uint32s); -#endif // _di_f_uint32s_decimate_by_ - -/** - * Resize the string uint32s 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 uint32s - * The string uint32s 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(). - */ -#ifndef _di_f_uint32s_decrease_by_ - extern f_status_t f_uint32s_decrease_by(const f_array_length_t amount, f_uint32s_t *uint32s); -#endif // _di_f_uint32s_decrease_by_ - -/** - * Increase the size of the string uint32s array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint32s - * The string uint32s 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(). - */ -#ifndef _di_f_uint32s_increase_ - extern f_status_t f_uint32s_increase(const f_array_length_t step, f_uint32s_t *uint32s); -#endif // _di_f_uint32s_increase_ - -/** - * Resize the string uint32s array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint32s - * The string uint32s 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(). - */ -#ifndef _di_f_uint32s_increase_by_ - extern f_status_t f_uint32s_increase_by(const f_array_length_t amount, f_uint32s_t *uint32s); -#endif // _di_f_uint32s_increase_by_ - -/** - * Resize the string uint32s array. - * - * @param length - * The new size to use. - * @param uint32s - * The string uint32s 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(). - */ -#ifndef _di_f_uint32s_resize_ - extern f_status_t f_uint32s_resize(const f_array_length_t length, f_uint32s_t *uint32s); -#endif // _di_f_uint32s_resize_ - -/** - * Resize the string uint32ss array. - * - * @param length - * The new size to use. - * @param uint32ss - * The string uint32ss 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_memory_destroy(). - */ -#ifndef _di_f_uint32ss_adjust_ - extern f_status_t f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss); -#endif // _di_f_uint32ss_adjust_ - -/** - * Append the source uint32ss onto the destination. - * - * @param source - * The source uint32ss to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint32ss_append_ - extern f_status_t f_uint32ss_append(const f_uint32ss_t source, f_uint32ss_t *destination); -#endif // _di_f_uint32ss_append_ - -/** - * Resize the string uint32ss array. - * - * @param length - * The new size to use. - * @param uint32ss - * The string uint32ss 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_memory_destroy(). - */ -#ifndef _di_f_uint32ss_adjust_ - extern f_status_t f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss); -#endif // _di_f_uint32ss_adjust_ - -/** - * Resize the string uint32ss 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 uint32ss - * The string uint32ss 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_memory_destroy(). - */ -#ifndef _di_f_uint32ss_decimate_by_ - extern f_status_t f_uint32ss_decimate_by(const f_array_length_t amount, f_uint32ss_t *uint32ss); -#endif // _di_f_uint32ss_decimate_by_ - -/** - * Resize the string uint32ss 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 uint32ss - * The string uint32ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint32ss_decrease_by_ - extern f_status_t f_uint32ss_decrease_by(const f_array_length_t amount, f_uint32ss_t *uint32ss); -#endif // _di_f_uint32ss_decrease_by_ - -/** - * Increase the size of the string uint32ss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint32ss - * The string uint32ss 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(). - */ -#ifndef _di_f_uint32ss_increase_ - extern f_status_t f_uint32ss_increase(const f_array_length_t step, f_uint32ss_t *uint32ss); -#endif // _di_f_uint32ss_increase_ - -/** - * Resize the string uint32ss array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint32ss - * The string uint32ss 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(). - */ -#ifndef _di_f_uint32ss_increase_by_ - extern f_status_t f_uint32ss_increase_by(const f_array_length_t amount, f_uint32ss_t *uint32ss); -#endif // _di_f_uint32ss_increase_by_ - -/** - * Resize the string uint32ss array. - * - * @param length - * The new size to use. - * @param uint32ss - * The string uint32ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint32ss_resize_ - extern f_status_t f_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss); -#endif // _di_f_uint32ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int64.c b/level_0/f_type_array/c/type_array/int64.c index 687ad2218..128f61f28 100644 --- a/level_0/f_type_array/c/type_array/int64.c +++ b/level_0/f_type_array/c/type_array/int64.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_int64s_adjust_ #ifndef _di_f_int64s_append_ - f_status_t f_int64s_append(const f_int64s_t source, f_int64s_t *destination) { + f_status_t f_int64s_append(const int64_t source, f_int64s_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; - return private_f_int64s_append(source, destination); } #endif // _di_f_int64s_append_ +#ifndef _di_f_int64s_append_all_ + f_status_t f_int64s_append_all(const f_int64s_t source, f_int64s_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; + + return private_f_int64s_append_all(source, destination); + } +#endif // _di_f_int64s_append_all_ + #ifndef _di_f_int64s_decimate_by_ f_status_t f_int64s_decimate_by(const f_array_length_t amount, f_int64s_t *int64s) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_int64ss_adjust_ #ifndef _di_f_int64ss_append_ - f_status_t f_int64ss_append(const f_int64ss_t source, f_int64ss_t *destination) { + f_status_t f_int64ss_append(const f_int64s_t source, f_int64ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_int64ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_int64s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_int64ss_append_ + +#ifndef _di_f_int64ss_append_all_ + f_status_t f_int64ss_append_all(const f_int64ss_t source, f_int64ss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_int64s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_int64s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_int64ss_append_ +#endif // _di_f_int64ss_append_all_ #ifndef _di_f_int64ss_decimate_by_ f_status_t f_int64ss_decimate_by(const f_array_length_t amount, f_int64ss_t *int64ss) { @@ -246,246 +285,6 @@ extern "C" { } #endif // _di_f_int64ss_resize_ -#ifndef _di_f_uint64s_adjust_ - f_status_t f_uint64s_adjust(const f_array_length_t length, f_uint64s_t *uint64s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint64s_adjust(length, uint64s); - } -#endif // _di_f_uint64s_adjust_ - -#ifndef _di_f_uint64s_append_ - f_status_t f_uint64s_append(const f_uint64s_t source, f_uint64s_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; - - return private_f_uint64s_append(source, destination); - } -#endif // _di_f_uint64s_append_ - -#ifndef _di_f_uint64s_decimate_by_ - f_status_t f_uint64s_decimate_by(const f_array_length_t amount, f_uint64s_t *uint64s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint64s->size - amount > 0) { - return private_f_uint64s_adjust(uint64s->size - amount, uint64s); - } - - return private_f_uint64s_adjust(0, uint64s); - } -#endif // _di_f_uint64s_decimate_by_ - -#ifndef _di_f_uint64s_decrease_by_ - f_status_t f_uint64s_decrease_by(const f_array_length_t amount, f_uint64s_t *uint64s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint64s->size - amount > 0) { - return private_f_uint64s_resize(uint64s->size - amount, uint64s); - } - - return private_f_uint64s_resize(0, uint64s); - } -#endif // _di_f_uint64s_decrease_by_ - -#ifndef _di_f_uint64s_increase_ - f_status_t f_uint64s_increase(const f_array_length_t step, f_uint64s_t *uint64s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint64s->used + 1 > uint64s->size) { - f_array_length_t size = uint64s->used + step; - - if (size > F_array_length_t_size_d) { - if (uint64s->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint64s_resize(size, uint64s); - } - - return F_data_not; - } -#endif // _di_f_uint64s_increase_ - -#ifndef _di_f_uint64s_increase_by_ - f_status_t f_uint64s_increase_by(const f_array_length_t amount, f_uint64s_t *uint64s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint64s->used + amount > uint64s->size) { - if (uint64s->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint64s_resize(uint64s->used + amount, uint64s); - } - - return F_data_not; - } -#endif // _di_f_uint64s_increase_by_ - -#ifndef _di_f_uint64s_resize_ - f_status_t f_uint64s_resize(const f_array_length_t length, f_uint64s_t *uint64s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint64s_resize(length, uint64s); - } -#endif // _di_f_uint64s_resize_ - -#ifndef _di_f_uint64ss_adjust_ - f_status_t f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint64ss_adjust(length, uint64ss); - } -#endif // _di_f_uint64ss_adjust_ - -#ifndef _di_f_uint64ss_append_ - f_status_t f_uint64ss_append(const f_uint64ss_t source, f_uint64ss_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; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint64ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_uint64s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } // for - - return F_none; - } -#endif // _di_f_uint64ss_append_ - -#ifndef _di_f_uint64ss_decimate_by_ - f_status_t f_uint64ss_decimate_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint64ss->size - amount > 0) { - return private_f_uint64ss_adjust(uint64ss->size - amount, uint64ss); - } - - return private_f_uint64ss_adjust(0, uint64ss); - } -#endif // _di_f_uint64ss_decimate_by_ - -#ifndef _di_f_uint64ss_decrease_by_ - f_status_t f_uint64ss_decrease_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint64ss->size - amount > 0) { - return private_f_uint64ss_resize(uint64ss->size - amount, uint64ss); - } - - return private_f_uint64ss_resize(0, uint64ss); - } -#endif // _di_f_uint64ss_decrease_by_ - -#ifndef _di_f_uint64ss_increase_ - f_status_t f_uint64ss_increase(const f_array_length_t step, f_uint64ss_t *uint64ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint64ss->used + 1 > uint64ss->size) { - f_array_length_t size = uint64ss->used + step; - - if (size > F_array_length_t_size_d) { - if (uint64ss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint64ss_resize(size, uint64ss); - } - - return F_data_not; - } -#endif // _di_f_uint64ss_increase_ - -#ifndef _di_f_uint64ss_increase_by_ - f_status_t f_uint64ss_increase_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint64ss->used + amount > uint64ss->size) { - if (uint64ss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint64ss_resize(uint64ss->used + amount, uint64ss); - } - - return F_data_not; - } -#endif // _di_f_uint64ss_increase_by_ - -#ifndef _di_f_uint64ss_resize_ - f_status_t f_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint64ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint64ss_resize(length, uint64ss); - } -#endif // _di_f_uint64ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int64.h b/level_0/f_type_array/c/type_array/int64.h index 21df2426f..8ec4a6ce9 100644 --- a/level_0/f_type_array/c/type_array/int64.h +++ b/level_0/f_type_array/c/type_array/int64.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_int64s_adjust_ /** - * Append the source int64s onto the destination. + * Append the single source int64 onto the destination. * * @param source - * The source int64s to append. + * The source int64 to append. * @param destination * The destination int64s the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int64s_append_ - extern f_status_t f_int64s_append(const f_int64s_t source, f_int64s_t *destination); + extern f_status_t f_int64s_append(const int64_t source, f_int64s_t *destination); #endif // _di_f_int64s_append_ +/** + * Append the source int64s onto the destination. + * + * @param source + * The source int64s to append. + * @param destination + * The destination int64s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_int64s_append_all_ + extern f_status_t f_int64s_append_all(const f_int64s_t source, f_int64s_t *destination); +#endif // _di_f_int64s_append_all_ + /** * Resize the int64s array to a smaller size. * @@ -193,10 +213,10 @@ extern "C" { #endif // _di_f_int64ss_adjust_ /** - * Append the source int64ss onto the destination. + * Append the single source int64s onto the destination. * * @param source - * The source int64ss to append. + * The source int64s to append. * @param destination * The destination ranges the source is appended onto. * @@ -209,28 +229,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int64ss_append_ - extern f_status_t f_int64ss_append(const f_int64ss_t source, f_int64ss_t *destination); + extern f_status_t f_int64ss_append(const f_int64s_t source, f_int64ss_t *destination); #endif // _di_f_int64ss_append_ /** - * Resize the int64ss array. + * Append the source int64ss onto the destination. * - * @param length - * The new size to use. - * @param int64ss - * The int64ss array to resize. + * @param source + * The source int64ss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_int64ss_adjust_ - extern f_status_t f_int64ss_adjust(const f_array_length_t length, f_int64ss_t *int64ss); -#endif // _di_f_int64ss_adjust_ +#ifndef _di_f_int64ss_append_all_ + extern f_status_t f_int64ss_append_all(const f_int64ss_t source, f_int64ss_t *destination); +#endif // _di_f_int64ss_append_all_ /** * Resize the int64ss array to a smaller size. @@ -352,342 +372,6 @@ extern "C" { extern f_status_t f_int64ss_resize(const f_array_length_t length, f_int64ss_t *int64ss); #endif // _di_f_int64ss_resize_ -/** - * Resize the string uint64s array. - * - * @param length - * The new size to use. - * @param uint64s - * The string uint64s 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(). - */ -#ifndef _di_f_uint64s_adjust_ - extern f_status_t f_uint64s_adjust(const f_array_length_t length, f_uint64s_t *uint64s); -#endif // _di_f_uint64s_adjust_ - -/** - * Append the source uint64s onto the destination. - * - * @param source - * The source uint64s to append. - * @param destination - * The destination uint64s the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint64s_append_ - extern f_status_t f_uint64s_append(const f_uint64s_t source, f_uint64s_t *destination); -#endif // _di_f_uint64s_append_ - -/** - * Resize the string uint64s 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 uint64s - * The string uint64s 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(). - */ -#ifndef _di_f_uint64s_decimate_by_ - extern f_status_t f_uint64s_decimate_by(const f_array_length_t amount, f_uint64s_t *uint64s); -#endif // _di_f_uint64s_decimate_by_ - -/** - * Resize the string uint64s 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 uint64s - * The string uint64s 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(). - */ -#ifndef _di_f_uint64s_decrease_by_ - extern f_status_t f_uint64s_decrease_by(const f_array_length_t amount, f_uint64s_t *uint64s); -#endif // _di_f_uint64s_decrease_by_ - -/** - * Increase the size of the string uint64s array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint64s - * The string uint64s 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(). - */ -#ifndef _di_f_uint64s_increase_ - extern f_status_t f_uint64s_increase(const f_array_length_t step, f_uint64s_t *uint64s); -#endif // _di_f_uint64s_increase_ - -/** - * Resize the string uint64s array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint64s - * The string uint64s 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(). - */ -#ifndef _di_f_uint64s_increase_by_ - extern f_status_t f_uint64s_increase_by(const f_array_length_t amount, f_uint64s_t *uint64s); -#endif // _di_f_uint64s_increase_by_ - -/** - * Resize the string uint64s array. - * - * @param length - * The new size to use. - * @param uint64s - * The string uint64s 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(). - */ -#ifndef _di_f_uint64s_resize_ - extern f_status_t f_uint64s_resize(const f_array_length_t length, f_uint64s_t *uint64s); -#endif // _di_f_uint64s_resize_ - -/** - * Resize the string uint64ss array. - * - * @param length - * The new size to use. - * @param uint64ss - * The string uint64ss 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_memory_destroy(). - */ -#ifndef _di_f_uint64ss_adjust_ - extern f_status_t f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss); -#endif // _di_f_uint64ss_adjust_ - -/** - * Append the source uint64ss onto the destination. - * - * @param source - * The source uint64ss to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint64ss_append_ - extern f_status_t f_uint64ss_append(const f_uint64ss_t source, f_uint64ss_t *destination); -#endif // _di_f_uint64ss_append_ - -/** - * Resize the string uint64ss array. - * - * @param length - * The new size to use. - * @param uint64ss - * The string uint64ss 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_memory_destroy(). - */ -#ifndef _di_f_uint64ss_adjust_ - extern f_status_t f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss); -#endif // _di_f_uint64ss_adjust_ - -/** - * Resize the string uint64ss 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 uint64ss - * The string uint64ss 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_memory_destroy(). - */ -#ifndef _di_f_uint64ss_decimate_by_ - extern f_status_t f_uint64ss_decimate_by(const f_array_length_t amount, f_uint64ss_t *uint64ss); -#endif // _di_f_uint64ss_decimate_by_ - -/** - * Resize the string uint64ss 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 uint64ss - * The string uint64ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint64ss_decrease_by_ - extern f_status_t f_uint64ss_decrease_by(const f_array_length_t amount, f_uint64ss_t *uint64ss); -#endif // _di_f_uint64ss_decrease_by_ - -/** - * Increase the size of the string uint64ss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint64ss - * The string uint64ss 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(). - */ -#ifndef _di_f_uint64ss_increase_ - extern f_status_t f_uint64ss_increase(const f_array_length_t step, f_uint64ss_t *uint64ss); -#endif // _di_f_uint64ss_increase_ - -/** - * Resize the string uint64ss array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint64ss - * The string uint64ss 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(). - */ -#ifndef _di_f_uint64ss_increase_by_ - extern f_status_t f_uint64ss_increase_by(const f_array_length_t amount, f_uint64ss_t *uint64ss); -#endif // _di_f_uint64ss_increase_by_ - -/** - * Resize the string uint64ss array. - * - * @param length - * The new size to use. - * @param uint64ss - * The string uint64ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint64ss_resize_ - extern f_status_t f_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss); -#endif // _di_f_uint64ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int8.c b/level_0/f_type_array/c/type_array/int8.c index c23258fb7..055d25271 100644 --- a/level_0/f_type_array/c/type_array/int8.c +++ b/level_0/f_type_array/c/type_array/int8.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_int8s_adjust_ #ifndef _di_f_int8s_append_ - f_status_t f_int8s_append(const f_int8s_t source, f_int8s_t *destination) { + f_status_t f_int8s_append(const int8_t source, f_int8s_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; - return private_f_int8s_append(source, destination); } #endif // _di_f_int8s_append_ +#ifndef _di_f_int8s_append_all_ + f_status_t f_int8s_append_all(const f_int8s_t source, f_int8s_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; + + return private_f_int8s_append_all(source, destination); + } +#endif // _di_f_int8s_append_all_ + #ifndef _di_f_int8s_decimate_by_ f_status_t f_int8s_decimate_by(const f_array_length_t amount, f_int8s_t *int8s) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_int8ss_adjust_ #ifndef _di_f_int8ss_append_ - f_status_t f_int8ss_append(const f_int8ss_t source, f_int8ss_t *destination) { + f_status_t f_int8ss_append(const f_int8s_t source, f_int8ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_int8ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_int8s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_int8ss_append_ + +#ifndef _di_f_int8ss_append_all_ + f_status_t f_int8ss_append_all(const f_int8ss_t source, f_int8ss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_int8s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_int8s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_int8ss_append_ +#endif // _di_f_int8ss_append_all_ #ifndef _di_f_int8ss_decimate_by_ f_status_t f_int8ss_decimate_by(const f_array_length_t amount, f_int8ss_t *int8ss) { @@ -246,246 +285,6 @@ extern "C" { } #endif // _di_f_int8ss_resize_ -#ifndef _di_f_uint8s_adjust_ - f_status_t f_uint8s_adjust(const f_array_length_t length, f_uint8s_t *uint8s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint8s_adjust(length, uint8s); - } -#endif // _di_f_uint8s_adjust_ - -#ifndef _di_f_uint8s_append_ - f_status_t f_uint8s_append(const f_uint8s_t source, f_uint8s_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; - - return private_f_uint8s_append(source, destination); - } -#endif // _di_f_uint8s_append_ - -#ifndef _di_f_uint8s_decimate_by_ - f_status_t f_uint8s_decimate_by(const f_array_length_t amount, f_uint8s_t *uint8s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint8s->size - amount > 0) { - return private_f_uint8s_adjust(uint8s->size - amount, uint8s); - } - - return private_f_uint8s_adjust(0, uint8s); - } -#endif // _di_f_uint8s_decimate_by_ - -#ifndef _di_f_uint8s_decrease_by_ - f_status_t f_uint8s_decrease_by(const f_array_length_t amount, f_uint8s_t *uint8s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint8s->size - amount > 0) { - return private_f_uint8s_resize(uint8s->size - amount, uint8s); - } - - return private_f_uint8s_resize(0, uint8s); - } -#endif // _di_f_uint8s_decrease_by_ - -#ifndef _di_f_uint8s_increase_ - f_status_t f_uint8s_increase(const f_array_length_t step, f_uint8s_t *uint8s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint8s->used + 1 > uint8s->size) { - f_array_length_t size = uint8s->used + step; - - if (size > F_array_length_t_size_d) { - if (uint8s->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint8s_resize(size, uint8s); - } - - return F_data_not; - } -#endif // _di_f_uint8s_increase_ - -#ifndef _di_f_uint8s_increase_by_ - f_status_t f_uint8s_increase_by(const f_array_length_t amount, f_uint8s_t *uint8s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint8s->used + amount > uint8s->size) { - if (uint8s->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint8s_resize(uint8s->used + amount, uint8s); - } - - return F_data_not; - } -#endif // _di_f_uint8s_increase_by_ - -#ifndef _di_f_uint8s_resize_ - f_status_t f_uint8s_resize(const f_array_length_t length, f_uint8s_t *uint8s) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8s) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint8s_resize(length, uint8s); - } -#endif // _di_f_uint8s_resize_ - -#ifndef _di_f_uint8ss_adjust_ - f_status_t f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint8ss_adjust(length, uint8ss); - } -#endif // _di_f_uint8ss_adjust_ - -#ifndef _di_f_uint8ss_append_ - f_status_t f_uint8ss_append(const f_uint8ss_t source, f_uint8ss_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; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint8ss_resize(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_uint8s_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } // for - - return F_none; - } -#endif // _di_f_uint8ss_append_ - -#ifndef _di_f_uint8ss_decimate_by_ - f_status_t f_uint8ss_decimate_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint8ss->size - amount > 0) { - return private_f_uint8ss_adjust(uint8ss->size - amount, uint8ss); - } - - return private_f_uint8ss_adjust(0, uint8ss); - } -#endif // _di_f_uint8ss_decimate_by_ - -#ifndef _di_f_uint8ss_decrease_by_ - f_status_t f_uint8ss_decrease_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint8ss->size - amount > 0) { - return private_f_uint8ss_resize(uint8ss->size - amount, uint8ss); - } - - return private_f_uint8ss_resize(0, uint8ss); - } -#endif // _di_f_uint8ss_decrease_by_ - -#ifndef _di_f_uint8ss_increase_ - f_status_t f_uint8ss_increase(const f_array_length_t step, f_uint8ss_t *uint8ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && uint8ss->used + 1 > uint8ss->size) { - f_array_length_t size = uint8ss->used + step; - - if (size > F_array_length_t_size_d) { - if (uint8ss->used + 1 > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_array_length_t_size_d; - } - - return private_f_uint8ss_resize(size, uint8ss); - } - - return F_data_not; - } -#endif // _di_f_uint8ss_increase_ - -#ifndef _di_f_uint8ss_increase_by_ - f_status_t f_uint8ss_increase_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) { - return F_data_not; - } - - if (uint8ss->used + amount > uint8ss->size) { - if (uint8ss->used + amount > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - return private_f_uint8ss_resize(uint8ss->used + amount, uint8ss); - } - - return F_data_not; - } -#endif // _di_f_uint8ss_increase_by_ - -#ifndef _di_f_uint8ss_resize_ - f_status_t f_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss) { - #ifndef _di_level_0_parameter_checking_ - if (!uint8ss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_uint8ss_resize(length, uint8ss); - } -#endif // _di_f_uint8ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/int8.h b/level_0/f_type_array/c/type_array/int8.h index c88e49e71..65f2bd0a5 100644 --- a/level_0/f_type_array/c/type_array/int8.h +++ b/level_0/f_type_array/c/type_array/int8.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_int8s_adjust_ /** - * Append the source int8s onto the destination. + * Append the single source int8 onto the destination. * * @param source - * The source int8s to append. + * The source int8 to append. * @param destination * The destination int8s the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int8s_append_ - extern f_status_t f_int8s_append(const f_int8s_t source, f_int8s_t *destination); + extern f_status_t f_int8s_append(const int8_t source, f_int8s_t *destination); #endif // _di_f_int8s_append_ +/** + * Append the source int8s onto the destination. + * + * @param source + * The source int8s to append. + * @param destination + * The destination int8s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_int8s_append_all_ + extern f_status_t f_int8s_append_all(const f_int8s_t source, f_int8s_t *destination); +#endif // _di_f_int8s_append_all_ + /** * Resize the int8s array to a smaller size. * @@ -193,10 +213,10 @@ extern "C" { #endif // _di_f_int8ss_adjust_ /** - * Append the source int8ss onto the destination. + * Append the single source int8s onto the destination. * * @param source - * The source int8ss to append. + * The source int8s to append. * @param destination * The destination ranges the source is appended onto. * @@ -209,28 +229,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_int8ss_append_ - extern f_status_t f_int8ss_append(const f_int8ss_t source, f_int8ss_t *destination); + extern f_status_t f_int8ss_append(const f_int8s_t source, f_int8ss_t *destination); #endif // _di_f_int8ss_append_ /** - * Resize the int8ss array. + * Append the source int8ss onto the destination. * - * @param length - * The new size to use. - * @param int8ss - * The int8ss array to resize. + * @param source + * The source int8ss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_int8ss_adjust_ - extern f_status_t f_int8ss_adjust(const f_array_length_t length, f_int8ss_t *int8ss); -#endif // _di_f_int8ss_adjust_ +#ifndef _di_f_int8ss_append_all_ + extern f_status_t f_int8ss_append_all(const f_int8ss_t source, f_int8ss_t *destination); +#endif // _di_f_int8ss_append_all_ /** * Resize the int8ss array to a smaller size. @@ -352,342 +372,6 @@ extern "C" { extern f_status_t f_int8ss_resize(const f_array_length_t length, f_int8ss_t *int8ss); #endif // _di_f_int8ss_resize_ -/** - * Resize the string uint8s array. - * - * @param length - * The new size to use. - * @param uint8s - * The string uint8s 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(). - */ -#ifndef _di_f_uint8s_adjust_ - extern f_status_t f_uint8s_adjust(const f_array_length_t length, f_uint8s_t *uint8s); -#endif // _di_f_uint8s_adjust_ - -/** - * Append the source uint8s onto the destination. - * - * @param source - * The source uint8s to append. - * @param destination - * The destination uint8s the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint8s_append_ - extern f_status_t f_uint8s_append(const f_uint8s_t source, f_uint8s_t *destination); -#endif // _di_f_uint8s_append_ - -/** - * Resize the string uint8s 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 uint8s - * The string uint8s 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(). - */ -#ifndef _di_f_uint8s_decimate_by_ - extern f_status_t f_uint8s_decimate_by(const f_array_length_t amount, f_uint8s_t *uint8s); -#endif // _di_f_uint8s_decimate_by_ - -/** - * Resize the string uint8s 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 uint8s - * The string uint8s 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(). - */ -#ifndef _di_f_uint8s_decrease_by_ - extern f_status_t f_uint8s_decrease_by(const f_array_length_t amount, f_uint8s_t *uint8s); -#endif // _di_f_uint8s_decrease_by_ - -/** - * Increase the size of the string uint8s array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint8s - * The string uint8s 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(). - */ -#ifndef _di_f_uint8s_increase_ - extern f_status_t f_uint8s_increase(const f_array_length_t step, f_uint8s_t *uint8s); -#endif // _di_f_uint8s_increase_ - -/** - * Resize the string uint8s array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint8s - * The string uint8s 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(). - */ -#ifndef _di_f_uint8s_increase_by_ - extern f_status_t f_uint8s_increase_by(const f_array_length_t amount, f_uint8s_t *uint8s); -#endif // _di_f_uint8s_increase_by_ - -/** - * Resize the string uint8s array. - * - * @param length - * The new size to use. - * @param uint8s - * The string uint8s 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(). - */ -#ifndef _di_f_uint8s_resize_ - extern f_status_t f_uint8s_resize(const f_array_length_t length, f_uint8s_t *uint8s); -#endif // _di_f_uint8s_resize_ - -/** - * Resize the string uint8ss array. - * - * @param length - * The new size to use. - * @param uint8ss - * The string uint8ss 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_memory_destroy(). - */ -#ifndef _di_f_uint8ss_adjust_ - extern f_status_t f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss); -#endif // _di_f_uint8ss_adjust_ - -/** - * Append the source uint8ss onto the destination. - * - * @param source - * The source uint8ss to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint8ss_append_ - extern f_status_t f_uint8ss_append(const f_uint8ss_t source, f_uint8ss_t *destination); -#endif // _di_f_uint8ss_append_ - -/** - * Resize the string uint8ss array. - * - * @param length - * The new size to use. - * @param uint8ss - * The string uint8ss 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_memory_destroy(). - */ -#ifndef _di_f_uint8ss_adjust_ - extern f_status_t f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss); -#endif // _di_f_uint8ss_adjust_ - -/** - * Resize the string uint8ss 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 uint8ss - * The string uint8ss 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_memory_destroy(). - */ -#ifndef _di_f_uint8ss_decimate_by_ - extern f_status_t f_uint8ss_decimate_by(const f_array_length_t amount, f_uint8ss_t *uint8ss); -#endif // _di_f_uint8ss_decimate_by_ - -/** - * Resize the string uint8ss 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 uint8ss - * The string uint8ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint8ss_decrease_by_ - extern f_status_t f_uint8ss_decrease_by(const f_array_length_t amount, f_uint8ss_t *uint8ss); -#endif // _di_f_uint8ss_decrease_by_ - -/** - * Increase the size of the string uint8ss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint8ss - * The string uint8ss 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(). - */ -#ifndef _di_f_uint8ss_increase_ - extern f_status_t f_uint8ss_increase(const f_array_length_t step, f_uint8ss_t *uint8ss); -#endif // _di_f_uint8ss_increase_ - -/** - * Resize the string uint8ss array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint8ss - * The string uint8ss 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(). - */ -#ifndef _di_f_uint8ss_increase_by_ - extern f_status_t f_uint8ss_increase_by(const f_array_length_t amount, f_uint8ss_t *uint8ss); -#endif // _di_f_uint8ss_increase_by_ - -/** - * Resize the string uint8ss array. - * - * @param length - * The new size to use. - * @param uint8ss - * The string uint8ss 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_delete(). - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_uint8ss_resize_ - extern f_status_t f_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss); -#endif // _di_f_uint8ss_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/private-array_length.c b/level_0/f_type_array/c/type_array/private-array_length.c index f83dc8ead..a5569eaf6 100644 --- a/level_0/f_type_array/c/type_array/private-array_length.c +++ b/level_0/f_type_array/c/type_array/private-array_length.c @@ -9,51 +9,61 @@ extern "C" { f_status_t private_f_array_lengths_adjust(const f_array_length_t length, f_array_lengths_t *array_lengths) { const f_status_t status = f_memory_adjust(array_lengths->size, length, sizeof(f_array_length_t), (void **) & array_lengths->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - array_lengths->size = length; + array_lengths->size = length; - if (array_lengths->used > array_lengths->size) { - array_lengths->used = length; - } + if (array_lengths->used > array_lengths->size) { + array_lengths->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_array_lengths_adjust_) || !defined(_di_f_array_lengths_decimate_by_) #if !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengthss_append_) - extern f_status_t private_f_array_lengths_append(const f_array_lengths_t source, f_array_lengths_t *destination) { + extern f_status_t private_f_array_lengths_append(const f_array_length_t source, f_array_lengths_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_array_lengths_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengthss_append_) + +#if !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengths_append_all_) || !defined(_di_f_array_lengthss_append_all_) + extern f_status_t private_f_array_lengths_append_all(const f_array_lengths_t source, f_array_lengths_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_array_lengths_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_array_lengths_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; } // for return F_none; } -#endif // !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengthss_append_) +#endif // !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengths_append_all_) || !defined(_di_f_array_lengthss_append_all_) #if !defined(_di_f_array_lengths_resize_) || !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengths_decimate_by_) || !defined(_di_f_array_lengthss_append_) f_status_t private_f_array_lengths_resize(const f_array_length_t length, f_array_lengths_t *lengths) { const f_status_t status = f_memory_resize(lengths->size, length, sizeof(f_array_length_t), (void **) & lengths->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - lengths->size = length; + lengths->size = length; - if (lengths->used > lengths->size) { - lengths->used = length; - } + if (lengths->used > lengths->size) { + lengths->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_array_lengths_resize_) || !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengths_decimate_by_) || !defined(_di_f_array_lengthss_append_) @@ -72,16 +82,15 @@ extern "C" { } // for status = f_memory_adjust(lengthss->size, length, sizeof(f_array_lengths_t), (void **) & lengthss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - lengthss->size = length; + lengthss->size = length; - if (lengthss->used > lengthss->size) { - lengthss->used = length; - } + if (lengthss->used > lengthss->size) { + lengthss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_array_lengthss_adjust_) || !defined(_di_f_array_lengthss_decimate_by_) @@ -100,16 +109,15 @@ extern "C" { } // for status = f_memory_resize(lengthss->size, length, sizeof(f_array_lengths_t), (void **) & lengthss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - lengthss->size = length; + lengthss->size = length; - if (lengthss->used > lengthss->size) { - lengthss->used = length; - } + if (lengthss->used > lengthss->size) { + lengthss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_array_lengthss_decrease_by_) || !defined(_di_f_array_lengthss_increase_) || !defined(_di_f_array_lengthss_increase_by_) || !defined(_di_f_array_lengthss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-array_length.h b/level_0/f_type_array/c/type_array/private-array_length.h index d65214e1a..3fdf52877 100644 --- a/level_0/f_type_array/c/type_array/private-array_length.h +++ b/level_0/f_type_array/c/type_array/private-array_length.h @@ -44,7 +44,7 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source array_lengths to append. + * The source array_length to append. * @param destination * The destination lengths the source is appended onto. * @@ -53,13 +53,38 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). * + * @see f_memory_resize() * @see f_array_lengths_append() * @see f_array_lengthss_append() */ #if !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengthss_append_) - extern f_status_t private_f_array_lengths_append(const f_array_lengths_t source, f_array_lengths_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_array_lengths_append(const f_array_length_t source, f_array_lengths_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengthss_append_) +/** + * Private implementation for appending the array_length array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source array_lengths 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_array_lengths_append_all() + * @see f_array_lengthss_append() + * @see f_array_lengthss_append_all() + */ +#if !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengths_append_all_) || !defined(_di_f_array_lengthss_append_all_) + extern f_status_t private_f_array_lengths_append_all(const f_array_lengths_t source, f_array_lengths_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_array_lengths_append_) || !defined(_di_f_array_lengths_append_all_) || !defined(_di_f_array_lengthss_append_all_) + /** * Private implementation for resizing the array_lengths array. * diff --git a/level_0/f_type_array/c/type_array/private-cell.c b/level_0/f_type_array/c/type_array/private-cell.c index 61237d9b7..77582303e 100644 --- a/level_0/f_type_array/c/type_array/private-cell.c +++ b/level_0/f_type_array/c/type_array/private-cell.c @@ -9,51 +9,64 @@ extern "C" { f_status_t private_f_cells_adjust(const f_array_length_t length, f_cells_t *cells) { const f_status_t status = f_memory_adjust(cells->size, length, sizeof(f_cell_t), (void **) & cells->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - cells->size = length; + cells->size = length; - if (cells->used > cells->size) { - cells->used = length; - } + if (cells->used > cells->size) { + cells->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_cells_adjust_) || !defined(_di_f_cells_decimate_by_) #if !defined(_di_f_cells_append_) || !defined(_di_f_cellss_append_) - extern f_status_t private_f_cells_append(const f_cells_t source, f_cells_t *destination) { + extern f_status_t private_f_cells_append(const f_cell_t source, f_cells_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_cells_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].row = source.row; + destination->array[destination->used++].column = source.column; + + return F_none; + } +#endif // !defined(_di_f_cells_append_) || !defined(_di_f_cellss_append_) + +#if !defined(_di_f_cells_append_) || !defined(_di_f_cells_append_all_) || !defined(_di_f_cellss_append_all_) + extern f_status_t private_f_cells_append_all(const f_cells_t source, f_cells_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_cells_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_cells_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + + destination->array[destination->used].row = source.array[i].row; + destination->array[destination->used++].column = source.array[i].column; } // for return F_none; } -#endif // !defined(_di_f_cells_append_) || !defined(_di_f_cellss_append_) +#endif // !defined(_di_f_cells_append_) || !defined(_di_f_cells_append_all_) || !defined(_di_f_cellss_append_all_) #if !defined(_di_f_cells_resize_) || !defined(_di_f_cells_append_) || !defined(_di_f_cells_decimate_by_) || !defined(_di_f_cellss_append_) f_status_t private_f_cells_resize(const f_array_length_t length, f_cells_t *cells) { const f_status_t status = f_memory_resize(cells->size, length, sizeof(f_cell_t), (void **) & cells->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - cells->size = length; + cells->size = length; - if (cells->used > cells->size) { - cells->used = length; - } + if (cells->used > cells->size) { + cells->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_cells_resize_) || !defined(_di_f_cells_append_) || !defined(_di_f_cells_decimate_by_) || !defined(_di_f_cellss_append_) @@ -72,16 +85,15 @@ extern "C" { } // for status = f_memory_adjust(cellss->size, length, sizeof(f_cells_t), (void **) & cellss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - cellss->size = length; + cellss->size = length; - if (cellss->used > cellss->size) { - cellss->used = length; - } + if (cellss->used > cellss->size) { + cellss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_cellss_adjust_) || !defined(_di_f_cellss_decimate_by_) @@ -100,16 +112,15 @@ extern "C" { } // for status = f_memory_resize(cellss->size, length, sizeof(f_cells_t), (void **) & cellss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - cellss->size = length; + cellss->size = length; - if (cellss->used > cellss->size) { - cellss->used = length; - } + if (cellss->used > cellss->size) { + cellss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_cellss_decrease_by_) || !defined(_di_f_cellss_increase_) || !defined(_di_f_cellss_increase_by_) || !defined(_di_f_cellss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-cell.h b/level_0/f_type_array/c/type_array/private-cell.h index e665dcbb6..32b5a074f 100644 --- a/level_0/f_type_array/c/type_array/private-cell.h +++ b/level_0/f_type_array/c/type_array/private-cell.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source cells to append. + * The source cell to append. * @param destination - * The destination cells the source is appended onto. + * 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_cells_append() * @see f_cellss_append() */ #if !defined(_di_f_cells_append_) || !defined(_di_f_cellss_append_) - extern f_status_t private_f_cells_append(const f_cells_t source, f_cells_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_cells_append(const f_cell_t source, f_cells_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_cells_append_) || !defined(_di_f_cellss_append_) +/** + * Private implementation for appending the cell array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source cells 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_cells_append_all() + * @see f_cellss_append() + * @see f_cellss_append_all() + */ +#if !defined(_di_f_cells_append_) || !defined(_di_f_cells_append_all_) || !defined(_di_f_cellss_append_all_) + extern f_status_t private_f_cells_append_all(const f_cells_t source, f_cells_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_cells_append_) || !defined(_di_f_cells_append_all_) || !defined(_di_f_cellss_append_all_) + /** * Private implementation for resizing the cells array. * diff --git a/level_0/f_type_array/c/type_array/private-fll_id.c b/level_0/f_type_array/c/type_array/private-fll_id.c index 42deb316b..ddf172a19 100644 --- a/level_0/f_type_array/c/type_array/private-fll_id.c +++ b/level_0/f_type_array/c/type_array/private-fll_id.c @@ -9,51 +9,68 @@ extern "C" { f_status_t private_f_fll_ids_adjust(const f_array_length_t length, f_fll_ids_t *ids) { const f_status_t status = f_memory_adjust(ids->size, length, sizeof(f_fll_id_t), (void **) & ids->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - ids->size = length; + ids->size = length; - if (ids->used > ids->size) { - ids->used = length; - } + if (ids->used > ids->size) { + ids->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_fll_ids_adjust_) || !defined(_di_f_fll_ids_decimate_by_) #if !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_idss_append_) - extern f_status_t private_f_fll_ids_append(const f_fll_ids_t source, f_fll_ids_t *destination) { + extern f_status_t private_f_fll_ids_append(const f_fll_id_t source, f_fll_ids_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_fll_ids_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + memcpy(destination->array[destination->used].name, source.name, sizeof(char) * f_fll_id_name_length_d); + + destination->array[destination->used].type = source.type; + destination->array[destination->used++].used = source.used; + + return F_none; + } +#endif // !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_idss_append_) + +#if !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_append_all_) || !defined(_di_f_fll_idss_append_all_) + extern f_status_t private_f_fll_ids_append_all(const f_fll_ids_t source, f_fll_ids_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_fll_ids_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_fll_ids_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + + memcpy(destination->array[destination->used].name, source.array[i].name, sizeof(char) * f_fll_id_name_length_d); + + destination->array[destination->used].type = source.array[i].type; + destination->array[destination->used++].used = source.array[i].used; } // for return F_none; } -#endif // !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_idss_append_) +#endif // !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_append_all_) || !defined(_di_f_fll_idss_append_all_) #if !defined(_di_f_fll_ids_resize_) || !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_decimate_by_) || !defined(_di_f_fll_idss_append_) f_status_t private_f_fll_ids_resize(const f_array_length_t length, f_fll_ids_t *ids) { const f_status_t status = f_memory_resize(ids->size, length, sizeof(f_fll_id_t), (void **) & ids->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - ids->size = length; + ids->size = length; - if (ids->used > ids->size) { - ids->used = length; - } + if (ids->used > ids->size) { + ids->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_fll_ids_resize_) || !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_decimate_by_) || !defined(_di_f_fll_idss_append_) @@ -72,16 +89,15 @@ extern "C" { } // for status = f_memory_adjust(idss->size, length, sizeof(f_fll_ids_t), (void **) & idss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - idss->size = length; + idss->size = length; - if (idss->used > idss->size) { - idss->used = length; - } + if (idss->used > idss->size) { + idss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_fll_idss_adjust_) || !defined(_di_f_fll_idss_decimate_by_) @@ -100,16 +116,15 @@ extern "C" { } // for status = f_memory_resize(idss->size, length, sizeof(f_fll_ids_t), (void **) & idss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - idss->size = length; + idss->size = length; - if (idss->used > idss->size) { - idss->used = length; - } + if (idss->used > idss->size) { + idss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_fll_idss_decrease_by_) || !defined(_di_f_fll_idss_increase_) || !defined(_di_f_fll_idss_increase_by_) || !defined(_di_f_fll_idss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-fll_id.h b/level_0/f_type_array/c/type_array/private-fll_id.h index c6db12e3e..b7d14d356 100644 --- a/level_0/f_type_array/c/type_array/private-fll_id.h +++ b/level_0/f_type_array/c/type_array/private-fll_id.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source fll_ids to append. + * The source fll_id to append. * @param destination - * The destination fll_ids the source is appended onto. + * 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_fll_ids_append() * @see f_fll_idss_append() */ #if !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_idss_append_) - extern f_status_t private_f_fll_ids_append(const f_fll_ids_t source, f_fll_ids_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_fll_ids_append(const f_fll_id_t source, f_fll_ids_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_idss_append_) +/** + * Private implementation for appending the fll_id array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source fll_ids 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_fll_ids_append_all() + * @see f_fll_idss_append() + * @see f_fll_idss_append_all() + */ +#if !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_append_all_) || !defined(_di_f_fll_idss_append_all_) + extern f_status_t private_f_fll_ids_append_all(const f_fll_ids_t source, f_fll_ids_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_fll_ids_append_) || !defined(_di_f_fll_ids_append_all_) || !defined(_di_f_fll_idss_append_all_) + /** * Private implementation for resizing the fll_ids array. * diff --git a/level_0/f_type_array/c/type_array/private-int128.c b/level_0/f_type_array/c/type_array/private-int128.c index 0ce66e8a4..d241cd4a5 100644 --- a/level_0/f_type_array/c/type_array/private-int128.c +++ b/level_0/f_type_array/c/type_array/private-int128.c @@ -8,52 +8,62 @@ extern "C" { #if !defined(_di_f_int128s_adjust_) || !defined(_di_f_int128s_decimate_by_) f_status_t private_f_int128s_adjust(const f_array_length_t length, f_int128s_t *int128s) { - const f_status_t status = f_memory_adjust(int128s->size, length, sizeof(f_int128_t), (void **) & int128s->array); + const f_status_t status = f_memory_adjust(int128s->size, length, sizeof(f_int128s_t), (void **) & int128s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int128s->size = length; + int128s->size = length; - if (int128s->used > int128s->size) { - int128s->used = length; - } + if (int128s->used > int128s->size) { + int128s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int128s_adjust_) || !defined(_di_f_int128s_decimate_by_) #if !defined(_di_f_int128s_append_) || !defined(_di_f_int128ss_append_) - extern f_status_t private_f_int128s_append(const f_int128s_t source, f_int128s_t *destination) { + extern f_status_t private_f_int128s_append(const int128_t source, f_int128s_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_int128s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_int128s_append_) || !defined(_di_f_int128ss_append_) + +#if !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_append_all_) || !defined(_di_f_int128ss_append_all_) + extern f_status_t private_f_int128s_append_all(const f_int128s_t source, f_int128s_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_int128s_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_int128s_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; } // for return F_none; } -#endif // !defined(_di_f_int128s_append_) || !defined(_di_f_int128ss_append_) +#endif // !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_append_all_) || !defined(_di_f_int128ss_append_all_) #if !defined(_di_f_int128s_resize_) || !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_decimate_by_) || !defined(_di_f_int128ss_append_) f_status_t private_f_int128s_resize(const f_array_length_t length, f_int128s_t *int128s) { - const f_status_t status = f_memory_resize(int128s->size, length, sizeof(f_int128_t), (void **) & int128s->array); + const f_status_t status = f_memory_resize(int128s->size, length, sizeof(f_int128s_t), (void **) & int128s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int128s->size = length; + int128s->size = length; - if (int128s->used > int128s->size) { - int128s->used = length; - } + if (int128s->used > int128s->size) { + int128s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int128s_resize_) || !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_decimate_by_) || !defined(_di_f_int128ss_append_) @@ -72,16 +82,15 @@ extern "C" { } // for status = f_memory_adjust(int128ss->size, length, sizeof(f_int128s_t), (void **) & int128ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int128ss->size = length; + int128ss->size = length; - if (int128ss->used > int128ss->size) { - int128ss->used = length; - } + if (int128ss->used > int128ss->size) { + int128ss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int128ss_adjust_) || !defined(_di_f_int128ss_decimate_by_) @@ -100,126 +109,17 @@ extern "C" { } // for status = f_memory_resize(int128ss->size, length, sizeof(f_int128s_t), (void **) & int128ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int128ss->size = length; - - if (int128ss->used > int128ss->size) { - int128ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_int128ss_decrease_by_) || !defined(_di_f_int128ss_increase_) || !defined(_di_f_int128ss_increase_by_) || !defined(_di_f_int128ss_resize_) - -#if !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) - f_status_t private_f_uint128s_adjust(const f_array_length_t length, f_uint128s_t *uint128s) { - - const f_status_t status = f_memory_adjust(uint128s->size, length, sizeof(f_uint128_t), (void **) & uint128s->array); + int128ss->size = length; - if (F_status_is_error_not(status)) { - uint128s->size = length; - - if (uint128s->used > uint128s->size) { - uint128s->used = length; - } + if (int128ss->used > int128ss->size) { + int128ss->used = length; } - return status; - } -#endif // !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) - -#if !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) - extern f_status_t private_f_uint128s_append(const f_uint128s_t source, f_uint128s_t *destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint128s_adjust(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; - } // for - return F_none; } -#endif // !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) - -#if !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decimate_by_) || !defined(_di_f_uint128ss_append_) - f_status_t private_f_uint128s_resize(const f_array_length_t length, f_uint128s_t *uint128s) { - - const f_status_t status = f_memory_resize(uint128s->size, length, sizeof(f_uint128_t), (void **) & uint128s->array); - - if (F_status_is_error_not(status)) { - uint128s->size = length; - - if (uint128s->used > uint128s->size) { - uint128s->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decimate_by_) || !defined(_di_f_uint128ss_append_) - -#if !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) - f_status_t private_f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint128ss->size; ++i) { - - status = f_memory_destroy(uint128ss->array[i].size, sizeof(f_uint128s_t), (void **) & uint128ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint128ss->array[i].size = 0; - uint128ss->array[i].used = 0; - } // for - - status = f_memory_adjust(uint128ss->size, length, sizeof(f_uint128s_t), (void **) & uint128ss->array); - - if (F_status_is_error_not(status)) { - uint128ss->size = length; - - if (uint128ss->used > uint128ss->size) { - uint128ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) - -#if !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) - f_status_t private_f_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint128ss->size; ++i) { - - status = f_memory_delete(uint128ss->array[i].size, sizeof(f_uint128s_t), (void **) & uint128ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint128ss->array[i].size = 0; - uint128ss->array[i].used = 0; - } // for - - status = f_memory_resize(uint128ss->size, length, sizeof(f_uint128s_t), (void **) & uint128ss->array); - - if (F_status_is_error_not(status)) { - uint128ss->size = length; - - if (uint128ss->used > uint128ss->size) { - uint128ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) +#endif // !defined(_di_f_int128ss_decrease_by_) || !defined(_di_f_int128ss_increase_) || !defined(_di_f_int128ss_increase_by_) || !defined(_di_f_int128ss_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_type_array/c/type_array/private-int128.h b/level_0/f_type_array/c/type_array/private-int128.h index 919b47c8a..f410fea34 100644 --- a/level_0/f_type_array/c/type_array/private-int128.h +++ b/level_0/f_type_array/c/type_array/private-int128.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source int128s to append. + * The source int128 to append. * @param destination - * The destination int128s the source is appended onto. + * 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_int128s_append() * @see f_int128ss_append() */ #if !defined(_di_f_int128s_append_) || !defined(_di_f_int128ss_append_) - extern f_status_t private_f_int128s_append(const f_int128s_t source, f_int128s_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_int128s_append(const int128_t source, f_int128s_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int128s_append_) || !defined(_di_f_int128ss_append_) +/** + * Private implementation for appending the int128 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source int128s 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_int128s_append_all() + * @see f_int128ss_append() + * @see f_int128ss_append_all() + */ +#if !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_append_all_) || !defined(_di_f_int128ss_append_all_) + extern f_status_t private_f_int128s_append_all(const f_int128s_t source, f_int128s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_int128s_append_) || !defined(_di_f_int128s_append_all_) || !defined(_di_f_int128ss_append_all_) + /** * Private implementation for resizing the int128s array. * @@ -143,134 +168,6 @@ extern "C" { extern f_status_t private_f_int128ss_resize(const f_array_length_t length, f_int128ss_t *int128ss) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int128ss_decrease_by_) || !defined(_di_f_int128ss_increase_) || !defined(_di_f_int128ss_increase_by_) || !defined(_di_f_int128ss_resize_) -/** - * Private implementation for resizing the uint128s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint128s - * The uint128s 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(). - * - * @see f_uint128s_adjust() - * @see f_uint128s_decimate_by() - */ -#if !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) - extern f_status_t private_f_uint128s_adjust(const f_array_length_t length, f_uint128s_t *uint128s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) - -/** - * Private implementation for appending the uint128 array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source uint128s to append. - * @param destination - * The destination uint128s the source is appended onto. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint128s_append() - * @see f_uint128ss_append() - */ -#if !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) - extern f_status_t private_f_uint128s_append(const f_uint128s_t source, f_uint128s_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) - -/** - * Private implementation for resizing the uint128s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint128s - * The uint128s 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(). - * - * @see f_uint128s_resize() - * @see f_uint128s_append() - * @see f_uint128s_decimate_by() - * @see f_uint128ss_append() - */ -#if !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decimate_by_) || !defined(_di_f_uint128ss_append_) - extern f_status_t private_f_uint128s_resize(const f_array_length_t length, f_uint128s_t *uint128s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decimate_by_) || !defined(_di_f_uint128ss_append_) - -/** - * Private implementation for resizing the uint128ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint128ss - * The uint128ss 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_uint128ss_adjust() - * @see f_uint128ss_decimate_by() - */ -#if !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) - extern f_status_t private_f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) - -/** - * Private implementation for resizing the uint128ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param uint128ss - * The uint128ss 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_uint128ss_decrease_by() - * @see f_uint128ss_increase() - * @see f_uint128ss_increase_by() - * @see f_uint128ss_resize() - */ -#if !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) - extern f_status_t private_f_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/private-int16.c b/level_0/f_type_array/c/type_array/private-int16.c index 76a0f22db..2cd16d8a5 100644 --- a/level_0/f_type_array/c/type_array/private-int16.c +++ b/level_0/f_type_array/c/type_array/private-int16.c @@ -9,51 +9,61 @@ extern "C" { f_status_t private_f_int16s_adjust(const f_array_length_t length, f_int16s_t *int16s) { const f_status_t status = f_memory_adjust(int16s->size, length, sizeof(int16_t), (void **) & int16s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int16s->size = length; + int16s->size = length; - if (int16s->used > int16s->size) { - int16s->used = length; - } + if (int16s->used > int16s->size) { + int16s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int16s_adjust_) || !defined(_di_f_int16s_decimate_by_) #if !defined(_di_f_int16s_append_) || !defined(_di_f_int16ss_append_) - extern f_status_t private_f_int16s_append(const f_int16s_t source, f_int16s_t *destination) { + extern f_status_t private_f_int16s_append(const int16_t source, f_int16s_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_int16s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_int16s_append_) || !defined(_di_f_int16ss_append_) + +#if !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_append_all_) || !defined(_di_f_int16ss_append_all_) + extern f_status_t private_f_int16s_append_all(const f_int16s_t source, f_int16s_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_int16s_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_int16s_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; } // for return F_none; } -#endif // !defined(_di_f_int16s_append_) || !defined(_di_f_int16ss_append_) +#endif // !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_append_all_) || !defined(_di_f_int16ss_append_all_) #if !defined(_di_f_int16s_resize_) || !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_decimate_by_) || !defined(_di_f_int16ss_append_) f_status_t private_f_int16s_resize(const f_array_length_t length, f_int16s_t *int16s) { const f_status_t status = f_memory_resize(int16s->size, length, sizeof(int16_t), (void **) & int16s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int16s->size = length; + int16s->size = length; - if (int16s->used > int16s->size) { - int16s->used = length; - } + if (int16s->used > int16s->size) { + int16s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int16s_resize_) || !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_decimate_by_) || !defined(_di_f_int16ss_append_) @@ -72,16 +82,15 @@ extern "C" { } // for status = f_memory_adjust(int16ss->size, length, sizeof(f_int16s_t), (void **) & int16ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int16ss->size = length; + int16ss->size = length; - if (int16ss->used > int16ss->size) { - int16ss->used = length; - } + if (int16ss->used > int16ss->size) { + int16ss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int16ss_adjust_) || !defined(_di_f_int16ss_decimate_by_) @@ -100,126 +109,17 @@ extern "C" { } // for status = f_memory_resize(int16ss->size, length, sizeof(f_int16s_t), (void **) & int16ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int16ss->size = length; - - if (int16ss->used > int16ss->size) { - int16ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_int16ss_decrease_by_) || !defined(_di_f_int16ss_increase_) || !defined(_di_f_int16ss_increase_by_) || !defined(_di_f_int16ss_resize_) - -#if !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) - f_status_t private_f_uint16s_adjust(const f_array_length_t length, f_uint16s_t *uint16s) { - - const f_status_t status = f_memory_adjust(uint16s->size, length, sizeof(uint16_t), (void **) & uint16s->array); + int16ss->size = length; - if (F_status_is_error_not(status)) { - uint16s->size = length; - - if (uint16s->used > uint16s->size) { - uint16s->used = length; - } + if (int16ss->used > int16ss->size) { + int16ss->used = length; } - return status; - } -#endif // !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) - -#if !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) - extern f_status_t private_f_uint16s_append(const f_uint16s_t source, f_uint16s_t *destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint16s_adjust(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; - } // for - return F_none; } -#endif // !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) - -#if !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decimate_by_) || !defined(_di_f_uint16ss_append_) - f_status_t private_f_uint16s_resize(const f_array_length_t length, f_uint16s_t *uint16s) { - - const f_status_t status = f_memory_resize(uint16s->size, length, sizeof(uint16_t), (void **) & uint16s->array); - - if (F_status_is_error_not(status)) { - uint16s->size = length; - - if (uint16s->used > uint16s->size) { - uint16s->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decimate_by_) || !defined(_di_f_uint16ss_append_) - -#if !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) - f_status_t private_f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint16ss->size; ++i) { - - status = f_memory_destroy(uint16ss->array[i].size, sizeof(f_uint16s_t), (void **) & uint16ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint16ss->array[i].size = 0; - uint16ss->array[i].used = 0; - } // for - - status = f_memory_adjust(uint16ss->size, length, sizeof(f_uint16s_t), (void **) & uint16ss->array); - - if (F_status_is_error_not(status)) { - uint16ss->size = length; - - if (uint16ss->used > uint16ss->size) { - uint16ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) - -#if !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) - f_status_t private_f_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint16ss->size; ++i) { - - status = f_memory_delete(uint16ss->array[i].size, sizeof(f_uint16s_t), (void **) & uint16ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint16ss->array[i].size = 0; - uint16ss->array[i].used = 0; - } // for - - status = f_memory_resize(uint16ss->size, length, sizeof(f_uint16s_t), (void **) & uint16ss->array); - - if (F_status_is_error_not(status)) { - uint16ss->size = length; - - if (uint16ss->used > uint16ss->size) { - uint16ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) +#endif // !defined(_di_f_int16ss_decrease_by_) || !defined(_di_f_int16ss_increase_) || !defined(_di_f_int16ss_increase_by_) || !defined(_di_f_int16ss_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_type_array/c/type_array/private-int16.h b/level_0/f_type_array/c/type_array/private-int16.h index ade08c4e0..f5b972db7 100644 --- a/level_0/f_type_array/c/type_array/private-int16.h +++ b/level_0/f_type_array/c/type_array/private-int16.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source int16s to append. + * The source int16 to append. * @param destination - * The destination int16s the source is appended onto. + * 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_int16s_append() * @see f_int16ss_append() */ #if !defined(_di_f_int16s_append_) || !defined(_di_f_int16ss_append_) - extern f_status_t private_f_int16s_append(const f_int16s_t source, f_int16s_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_int16s_append(const int16_t source, f_int16s_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int16s_append_) || !defined(_di_f_int16ss_append_) +/** + * Private implementation for appending the int16 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source int16s 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_int16s_append_all() + * @see f_int16ss_append() + * @see f_int16ss_append_all() + */ +#if !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_append_all_) || !defined(_di_f_int16ss_append_all_) + extern f_status_t private_f_int16s_append_all(const f_int16s_t source, f_int16s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_int16s_append_) || !defined(_di_f_int16s_append_all_) || !defined(_di_f_int16ss_append_all_) + /** * Private implementation for resizing the int16s array. * @@ -143,134 +168,6 @@ extern "C" { extern f_status_t private_f_int16ss_resize(const f_array_length_t length, f_int16ss_t *int16ss) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int16ss_decrease_by_) || !defined(_di_f_int16ss_increase_) || !defined(_di_f_int16ss_increase_by_) || !defined(_di_f_int16ss_resize_) -/** - * Private implementation for resizing the uint16s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint16s - * The uint16s 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(). - * - * @see f_uint16s_adjust() - * @see f_uint16s_decimate_by() - */ -#if !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) - extern f_status_t private_f_uint16s_adjust(const f_array_length_t length, f_uint16s_t *uint16s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) - -/** - * Private implementation for appending the uint16 array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source uint16s to append. - * @param destination - * The destination uint16s the source is appended onto. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint16s_append() - * @see f_uint16ss_append() - */ -#if !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) - extern f_status_t private_f_uint16s_append(const f_uint16s_t source, f_uint16s_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) - -/** - * Private implementation for resizing the uint16s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint16s - * The uint16s 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(). - * - * @see f_uint16s_resize() - * @see f_uint16s_append() - * @see f_uint16s_decimate_by() - * @see f_uint16ss_append() - */ -#if !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decimate_by_) || !defined(_di_f_uint16ss_append_) - extern f_status_t private_f_uint16s_resize(const f_array_length_t length, f_uint16s_t *uint16s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decimate_by_) || !defined(_di_f_uint16ss_append_) - -/** - * Private implementation for resizing the uint16ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint16ss - * The uint16ss 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_uint16ss_adjust() - * @see f_uint16ss_decimate_by() - */ -#if !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) - extern f_status_t private_f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) - -/** - * Private implementation for resizing the uint16ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param uint16ss - * The uint16ss 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_uint16ss_decrease_by() - * @see f_uint16ss_increase() - * @see f_uint16ss_increase_by() - * @see f_uint16ss_resize() - */ -#if !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) - extern f_status_t private_f_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/private-int32.c b/level_0/f_type_array/c/type_array/private-int32.c index 10f910d4e..5ced25065 100644 --- a/level_0/f_type_array/c/type_array/private-int32.c +++ b/level_0/f_type_array/c/type_array/private-int32.c @@ -9,51 +9,61 @@ extern "C" { f_status_t private_f_int32s_adjust(const f_array_length_t length, f_int32s_t *int32s) { const f_status_t status = f_memory_adjust(int32s->size, length, sizeof(int32_t), (void **) & int32s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int32s->size = length; + int32s->size = length; - if (int32s->used > int32s->size) { - int32s->used = length; - } + if (int32s->used > int32s->size) { + int32s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int32s_adjust_) || !defined(_di_f_int32s_decimate_by_) #if !defined(_di_f_int32s_append_) || !defined(_di_f_int32ss_append_) - extern f_status_t private_f_int32s_append(const f_int32s_t source, f_int32s_t *destination) { + extern f_status_t private_f_int32s_append(const int32_t source, f_int32s_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_int32s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_int32s_append_) || !defined(_di_f_int32ss_append_) + +#if !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_append_all_) || !defined(_di_f_int32ss_append_all_) + extern f_status_t private_f_int32s_append_all(const f_int32s_t source, f_int32s_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_int32s_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_int32s_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; } // for return F_none; } -#endif // !defined(_di_f_int32s_append_) || !defined(_di_f_int32ss_append_) +#endif // !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_append_all_) || !defined(_di_f_int32ss_append_all_) #if !defined(_di_f_int32s_resize_) || !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_decimate_by_) || !defined(_di_f_int32ss_append_) f_status_t private_f_int32s_resize(const f_array_length_t length, f_int32s_t *int32s) { const f_status_t status = f_memory_resize(int32s->size, length, sizeof(int32_t), (void **) & int32s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int32s->size = length; + int32s->size = length; - if (int32s->used > int32s->size) { - int32s->used = length; - } + if (int32s->used > int32s->size) { + int32s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int32s_resize_) || !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_decimate_by_) || !defined(_di_f_int32ss_append_) @@ -72,16 +82,15 @@ extern "C" { } // for status = f_memory_adjust(int32ss->size, length, sizeof(f_int32s_t), (void **) & int32ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int32ss->size = length; + int32ss->size = length; - if (int32ss->used > int32ss->size) { - int32ss->used = length; - } + if (int32ss->used > int32ss->size) { + int32ss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int32ss_adjust_) || !defined(_di_f_int32ss_decimate_by_) @@ -100,126 +109,17 @@ extern "C" { } // for status = f_memory_resize(int32ss->size, length, sizeof(f_int32s_t), (void **) & int32ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int32ss->size = length; - - if (int32ss->used > int32ss->size) { - int32ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_int32ss_decrease_by_) || !defined(_di_f_int32ss_increase_) || !defined(_di_f_int32ss_increase_by_) || !defined(_di_f_int32ss_resize_) - -#if !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) - f_status_t private_f_uint32s_adjust(const f_array_length_t length, f_uint32s_t *uint32s) { - - const f_status_t status = f_memory_adjust(uint32s->size, length, sizeof(uint32_t), (void **) & uint32s->array); + int32ss->size = length; - if (F_status_is_error_not(status)) { - uint32s->size = length; - - if (uint32s->used > uint32s->size) { - uint32s->used = length; - } + if (int32ss->used > int32ss->size) { + int32ss->used = length; } - return status; - } -#endif // !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) - -#if !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) - extern f_status_t private_f_uint32s_append(const f_uint32s_t source, f_uint32s_t *destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint32s_adjust(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; - } // for - return F_none; } -#endif // !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) - -#if !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decimate_by_) || !defined(_di_f_uint32ss_append_) - f_status_t private_f_uint32s_resize(const f_array_length_t length, f_uint32s_t *uint32s) { - - const f_status_t status = f_memory_resize(uint32s->size, length, sizeof(uint32_t), (void **) & uint32s->array); - - if (F_status_is_error_not(status)) { - uint32s->size = length; - - if (uint32s->used > uint32s->size) { - uint32s->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decimate_by_) || !defined(_di_f_uint32ss_append_) - -#if !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) - f_status_t private_f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint32ss->size; ++i) { - - status = f_memory_destroy(uint32ss->array[i].size, sizeof(f_uint32s_t), (void **) & uint32ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint32ss->array[i].size = 0; - uint32ss->array[i].used = 0; - } // for - - status = f_memory_adjust(uint32ss->size, length, sizeof(f_uint32s_t), (void **) & uint32ss->array); - - if (F_status_is_error_not(status)) { - uint32ss->size = length; - - if (uint32ss->used > uint32ss->size) { - uint32ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) - -#if !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) - f_status_t private_f_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint32ss->size; ++i) { - - status = f_memory_delete(uint32ss->array[i].size, sizeof(f_uint32s_t), (void **) & uint32ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint32ss->array[i].size = 0; - uint32ss->array[i].used = 0; - } // for - - status = f_memory_resize(uint32ss->size, length, sizeof(f_uint32s_t), (void **) & uint32ss->array); - - if (F_status_is_error_not(status)) { - uint32ss->size = length; - - if (uint32ss->used > uint32ss->size) { - uint32ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) +#endif // !defined(_di_f_int32ss_decrease_by_) || !defined(_di_f_int32ss_increase_) || !defined(_di_f_int32ss_increase_by_) || !defined(_di_f_int32ss_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_type_array/c/type_array/private-int32.h b/level_0/f_type_array/c/type_array/private-int32.h index 920021fdc..1898bb8b8 100644 --- a/level_0/f_type_array/c/type_array/private-int32.h +++ b/level_0/f_type_array/c/type_array/private-int32.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source int32s to append. + * The source int32 to append. * @param destination - * The destination int32s the source is appended onto. + * 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_int32s_append() * @see f_int32ss_append() */ #if !defined(_di_f_int32s_append_) || !defined(_di_f_int32ss_append_) - extern f_status_t private_f_int32s_append(const f_int32s_t source, f_int32s_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_int32s_append(const int32_t source, f_int32s_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int32s_append_) || !defined(_di_f_int32ss_append_) +/** + * Private implementation for appending the int32 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source int32s 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_int32s_append_all() + * @see f_int32ss_append() + * @see f_int32ss_append_all() + */ +#if !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_append_all_) || !defined(_di_f_int32ss_append_all_) + extern f_status_t private_f_int32s_append_all(const f_int32s_t source, f_int32s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_int32s_append_) || !defined(_di_f_int32s_append_all_) || !defined(_di_f_int32ss_append_all_) + /** * Private implementation for resizing the int32s array. * @@ -143,134 +168,6 @@ extern "C" { extern f_status_t private_f_int32ss_resize(const f_array_length_t length, f_int32ss_t *int32ss) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int32ss_decrease_by_) || !defined(_di_f_int32ss_increase_) || !defined(_di_f_int32ss_increase_by_) || !defined(_di_f_int32ss_resize_) -/** - * Private implementation for resizing the uint32s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint32s - * The uint32s 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(). - * - * @see f_uint32s_adjust() - * @see f_uint32s_decimate_by() - */ -#if !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) - extern f_status_t private_f_uint32s_adjust(const f_array_length_t length, f_uint32s_t *uint32s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) - -/** - * Private implementation for appending the uint32 array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source uint32s to append. - * @param destination - * The destination uint32s the source is appended onto. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint32s_append() - * @see f_uint32ss_append() - */ -#if !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) - extern f_status_t private_f_uint32s_append(const f_uint32s_t source, f_uint32s_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) - -/** - * Private implementation for resizing the uint32s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint32s - * The uint32s 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(). - * - * @see f_uint32s_resize() - * @see f_uint32s_append() - * @see f_uint32s_decimate_by() - * @see f_uint32ss_append() - */ -#if !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decimate_by_) || !defined(_di_f_uint32ss_append_) - extern f_status_t private_f_uint32s_resize(const f_array_length_t length, f_uint32s_t *uint32s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decimate_by_) || !defined(_di_f_uint32ss_append_) - -/** - * Private implementation for resizing the uint32ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint32ss - * The uint32ss 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_uint32ss_adjust() - * @see f_uint32ss_decimate_by() - */ -#if !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) - extern f_status_t private_f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) - -/** - * Private implementation for resizing the uint32ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param uint32ss - * The uint32ss 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_uint32ss_decrease_by() - * @see f_uint32ss_increase() - * @see f_uint32ss_increase_by() - * @see f_uint32ss_resize() - */ -#if !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) - extern f_status_t private_f_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/private-int64.c b/level_0/f_type_array/c/type_array/private-int64.c index e3c12d8fe..1063d7f88 100644 --- a/level_0/f_type_array/c/type_array/private-int64.c +++ b/level_0/f_type_array/c/type_array/private-int64.c @@ -9,51 +9,61 @@ extern "C" { f_status_t private_f_int64s_adjust(const f_array_length_t length, f_int64s_t *int64s) { const f_status_t status = f_memory_adjust(int64s->size, length, sizeof(int64_t), (void **) & int64s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int64s->size = length; + int64s->size = length; - if (int64s->used > int64s->size) { - int64s->used = length; - } + if (int64s->used > int64s->size) { + int64s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int64s_adjust_) || !defined(_di_f_int64s_decimate_by_) #if !defined(_di_f_int64s_append_) || !defined(_di_f_int64ss_append_) - extern f_status_t private_f_int64s_append(const f_int64s_t source, f_int64s_t *destination) { + extern f_status_t private_f_int64s_append(const int64_t source, f_int64s_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_int64s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_int64s_append_) || !defined(_di_f_int64ss_append_) + +#if !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_append_all_) || !defined(_di_f_int64ss_append_all_) + extern f_status_t private_f_int64s_append_all(const f_int64s_t source, f_int64s_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_int64s_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_int64s_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; } // for return F_none; } -#endif // !defined(_di_f_int64s_append_) || !defined(_di_f_int64ss_append_) +#endif // !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_append_all_) || !defined(_di_f_int64ss_append_all_) #if !defined(_di_f_int64s_resize_) || !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_decimate_by_) || !defined(_di_f_int64ss_append_) f_status_t private_f_int64s_resize(const f_array_length_t length, f_int64s_t *int64s) { const f_status_t status = f_memory_resize(int64s->size, length, sizeof(int64_t), (void **) & int64s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int64s->size = length; + int64s->size = length; - if (int64s->used > int64s->size) { - int64s->used = length; - } + if (int64s->used > int64s->size) { + int64s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int64s_resize_) || !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_decimate_by_) || !defined(_di_f_int64ss_append_) @@ -72,16 +82,15 @@ extern "C" { } // for status = f_memory_adjust(int64ss->size, length, sizeof(f_int64s_t), (void **) & int64ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int64ss->size = length; + int64ss->size = length; - if (int64ss->used > int64ss->size) { - int64ss->used = length; - } + if (int64ss->used > int64ss->size) { + int64ss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int64ss_adjust_) || !defined(_di_f_int64ss_decimate_by_) @@ -100,126 +109,17 @@ extern "C" { } // for status = f_memory_resize(int64ss->size, length, sizeof(f_int64s_t), (void **) & int64ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int64ss->size = length; - - if (int64ss->used > int64ss->size) { - int64ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_int64ss_decrease_by_) || !defined(_di_f_int64ss_increase_) || !defined(_di_f_int64ss_increase_by_) || !defined(_di_f_int64ss_resize_) - -#if !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) - f_status_t private_f_uint64s_adjust(const f_array_length_t length, f_uint64s_t *uint64s) { - - const f_status_t status = f_memory_adjust(uint64s->size, length, sizeof(uint64_t), (void **) & uint64s->array); + int64ss->size = length; - if (F_status_is_error_not(status)) { - uint64s->size = length; - - if (uint64s->used > uint64s->size) { - uint64s->used = length; - } + if (int64ss->used > int64ss->size) { + int64ss->used = length; } - return status; - } -#endif // !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) - -#if !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) - extern f_status_t private_f_uint64s_append(const f_uint64s_t source, f_uint64s_t *destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint64s_adjust(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; - } // for - return F_none; } -#endif // !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) - -#if !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decimate_by_) || !defined(_di_f_uint64ss_append_) - f_status_t private_f_uint64s_resize(const f_array_length_t length, f_uint64s_t *uint64s) { - - const f_status_t status = f_memory_resize(uint64s->size, length, sizeof(uint64_t), (void **) & uint64s->array); - - if (F_status_is_error_not(status)) { - uint64s->size = length; - - if (uint64s->used > uint64s->size) { - uint64s->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decimate_by_) || !defined(_di_f_uint64ss_append_) - -#if !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) - f_status_t private_f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint64ss->size; ++i) { - - status = f_memory_destroy(uint64ss->array[i].size, sizeof(f_uint64s_t), (void **) & uint64ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint64ss->array[i].size = 0; - uint64ss->array[i].used = 0; - } // for - - status = f_memory_adjust(uint64ss->size, length, sizeof(f_uint64s_t), (void **) & uint64ss->array); - - if (F_status_is_error_not(status)) { - uint64ss->size = length; - - if (uint64ss->used > uint64ss->size) { - uint64ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) - -#if !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) - f_status_t private_f_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint64ss->size; ++i) { - - status = f_memory_delete(uint64ss->array[i].size, sizeof(f_uint64s_t), (void **) & uint64ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint64ss->array[i].size = 0; - uint64ss->array[i].used = 0; - } // for - - status = f_memory_resize(uint64ss->size, length, sizeof(f_uint64s_t), (void **) & uint64ss->array); - - if (F_status_is_error_not(status)) { - uint64ss->size = length; - - if (uint64ss->used > uint64ss->size) { - uint64ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) +#endif // !defined(_di_f_int64ss_decrease_by_) || !defined(_di_f_int64ss_increase_) || !defined(_di_f_int64ss_increase_by_) || !defined(_di_f_int64ss_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_type_array/c/type_array/private-int64.h b/level_0/f_type_array/c/type_array/private-int64.h index 741065d54..7bdde5e99 100644 --- a/level_0/f_type_array/c/type_array/private-int64.h +++ b/level_0/f_type_array/c/type_array/private-int64.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source int64s to append. + * The source int64 to append. * @param destination - * The destination int64s the source is appended onto. + * 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_int64s_append() * @see f_int64ss_append() */ #if !defined(_di_f_int64s_append_) || !defined(_di_f_int64ss_append_) - extern f_status_t private_f_int64s_append(const f_int64s_t source, f_int64s_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_int64s_append(const int64_t source, f_int64s_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int64s_append_) || !defined(_di_f_int64ss_append_) +/** + * Private implementation for appending the int64 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source int64s 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_int64s_append_all() + * @see f_int64ss_append() + * @see f_int64ss_append_all() + */ +#if !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_append_all_) || !defined(_di_f_int64ss_append_all_) + extern f_status_t private_f_int64s_append_all(const f_int64s_t source, f_int64s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_int64s_append_) || !defined(_di_f_int64s_append_all_) || !defined(_di_f_int64ss_append_all_) + /** * Private implementation for resizing the int64s array. * @@ -143,134 +168,6 @@ extern "C" { extern f_status_t private_f_int64ss_resize(const f_array_length_t length, f_int64ss_t *int64ss) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int64ss_decrease_by_) || !defined(_di_f_int64ss_increase_) || !defined(_di_f_int64ss_increase_by_) || !defined(_di_f_int64ss_resize_) -/** - * Private implementation for resizing the uint64s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint64s - * The uint64s 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(). - * - * @see f_uint64s_adjust() - * @see f_uint64s_decimate_by() - */ -#if !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) - extern f_status_t private_f_uint64s_adjust(const f_array_length_t length, f_uint64s_t *uint64s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) - -/** - * Private implementation for appending the uint64 array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source uint64s to append. - * @param destination - * The destination uint64s the source is appended onto. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint64s_append() - * @see f_uint64ss_append() - */ -#if !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) - extern f_status_t private_f_uint64s_append(const f_uint64s_t source, f_uint64s_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) - -/** - * Private implementation for resizing the uint64s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint64s - * The uint64s 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(). - * - * @see f_uint64s_resize() - * @see f_uint64s_append() - * @see f_uint64s_decimate_by() - * @see f_uint64ss_append() - */ -#if !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decimate_by_) || !defined(_di_f_uint64ss_append_) - extern f_status_t private_f_uint64s_resize(const f_array_length_t length, f_uint64s_t *uint64s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decimate_by_) || !defined(_di_f_uint64ss_append_) - -/** - * Private implementation for resizing the uint64ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint64ss - * The uint64ss 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_uint64ss_adjust() - * @see f_uint64ss_decimate_by() - */ -#if !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) - extern f_status_t private_f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) - -/** - * Private implementation for resizing the uint64ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param uint64ss - * The uint64ss 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_uint64ss_decrease_by() - * @see f_uint64ss_increase() - * @see f_uint64ss_increase_by() - * @see f_uint64ss_resize() - */ -#if !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) - extern f_status_t private_f_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/private-int8.c b/level_0/f_type_array/c/type_array/private-int8.c index 7b5cb2d8f..32e98351d 100644 --- a/level_0/f_type_array/c/type_array/private-int8.c +++ b/level_0/f_type_array/c/type_array/private-int8.c @@ -9,51 +9,61 @@ extern "C" { f_status_t private_f_int8s_adjust(const f_array_length_t length, f_int8s_t *int8s) { const f_status_t status = f_memory_adjust(int8s->size, length, sizeof(int8_t), (void **) & int8s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int8s->size = length; + int8s->size = length; - if (int8s->used > int8s->size) { - int8s->used = length; - } + if (int8s->used > int8s->size) { + int8s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int8s_adjust_) || !defined(_di_f_int8s_decimate_by_) #if !defined(_di_f_int8s_append_) || !defined(_di_f_int8ss_append_) - extern f_status_t private_f_int8s_append(const f_int8s_t source, f_int8s_t *destination) { + extern f_status_t private_f_int8s_append(const int8_t source, f_int8s_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_int8s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8ss_append_) + +#if !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8ss_append_all_) + extern f_status_t private_f_int8s_append_all(const f_int8s_t source, f_int8s_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_int8s_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_int8s_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; } // for return F_none; } -#endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8ss_append_) +#endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8ss_append_all_) #if !defined(_di_f_int8s_resize_) || !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_decimate_by_) || !defined(_di_f_int8ss_append_) f_status_t private_f_int8s_resize(const f_array_length_t length, f_int8s_t *int8s) { const f_status_t status = f_memory_resize(int8s->size, length, sizeof(int8_t), (void **) & int8s->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int8s->size = length; + int8s->size = length; - if (int8s->used > int8s->size) { - int8s->used = length; - } + if (int8s->used > int8s->size) { + int8s->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int8s_resize_) || !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_decimate_by_) || !defined(_di_f_int8ss_append_) @@ -72,16 +82,15 @@ extern "C" { } // for status = f_memory_adjust(int8ss->size, length, sizeof(f_int8s_t), (void **) & int8ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int8ss->size = length; + int8ss->size = length; - if (int8ss->used > int8ss->size) { - int8ss->used = length; - } + if (int8ss->used > int8ss->size) { + int8ss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_int8ss_adjust_) || !defined(_di_f_int8ss_decimate_by_) @@ -100,126 +109,17 @@ extern "C" { } // for status = f_memory_resize(int8ss->size, length, sizeof(f_int8s_t), (void **) & int8ss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - int8ss->size = length; - - if (int8ss->used > int8ss->size) { - int8ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_int8ss_decrease_by_) || !defined(_di_f_int8ss_increase_) || !defined(_di_f_int8ss_increase_by_) || !defined(_di_f_int8ss_resize_) - -#if !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) - f_status_t private_f_uint8s_adjust(const f_array_length_t length, f_uint8s_t *uint8s) { - - const f_status_t status = f_memory_adjust(uint8s->size, length, sizeof(uint8_t), (void **) & uint8s->array); + int8ss->size = length; - if (F_status_is_error_not(status)) { - uint8s->size = length; - - if (uint8s->used > uint8s->size) { - uint8s->used = length; - } + if (int8ss->used > int8ss->size) { + int8ss->used = length; } - return status; - } -#endif // !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) - -#if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) - extern f_status_t private_f_uint8s_append(const f_uint8s_t source, f_uint8s_t *destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_uint8s_adjust(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; - } // for - return F_none; } -#endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) - -#if !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_decimate_by_) || !defined(_di_f_uint8ss_append_) - f_status_t private_f_uint8s_resize(const f_array_length_t length, f_uint8s_t *uint8s) { - - const f_status_t status = f_memory_resize(uint8s->size, length, sizeof(uint8_t), (void **) & uint8s->array); - - if (F_status_is_error_not(status)) { - uint8s->size = length; - - if (uint8s->used > uint8s->size) { - uint8s->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_decimate_by_) || !defined(_di_f_uint8ss_append_) - -#if !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) - f_status_t private_f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint8ss->size; ++i) { - - status = f_memory_destroy(uint8ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint8ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint8ss->array[i].size = 0; - uint8ss->array[i].used = 0; - } // for - - status = f_memory_adjust(uint8ss->size, length, sizeof(f_uint8s_t), (void **) & uint8ss->array); - - if (F_status_is_error_not(status)) { - uint8ss->size = length; - - if (uint8ss->used > uint8ss->size) { - uint8ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) - -#if !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) - f_status_t private_f_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss) { - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < uint8ss->size; ++i) { - - status = f_memory_delete(uint8ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint8ss->array[i].array); - if (F_status_is_error(status)) return status; - - uint8ss->array[i].size = 0; - uint8ss->array[i].used = 0; - } // for - - status = f_memory_resize(uint8ss->size, length, sizeof(f_uint8s_t), (void **) & uint8ss->array); - - if (F_status_is_error_not(status)) { - uint8ss->size = length; - - if (uint8ss->used > uint8ss->size) { - uint8ss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) +#endif // !defined(_di_f_int8ss_decrease_by_) || !defined(_di_f_int8ss_increase_) || !defined(_di_f_int8ss_increase_by_) || !defined(_di_f_int8ss_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_type_array/c/type_array/private-int8.h b/level_0/f_type_array/c/type_array/private-int8.h index 101e111d0..4a31370ac 100644 --- a/level_0/f_type_array/c/type_array/private-int8.h +++ b/level_0/f_type_array/c/type_array/private-int8.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source int8s to append. + * The source int8 to append. * @param destination - * The destination int8s the source is appended onto. + * 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_int8s_append() * @see f_int8ss_append() */ #if !defined(_di_f_int8s_append_) || !defined(_di_f_int8ss_append_) - extern f_status_t private_f_int8s_append(const f_int8s_t source, f_int8s_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_int8s_append(const int8_t source, f_int8s_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8ss_append_) +/** + * Private implementation for appending the int8 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source int8s 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_int8s_append_all() + * @see f_int8ss_append() + * @see f_int8ss_append_all() + */ +#if !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8ss_append_all_) + extern f_status_t private_f_int8s_append_all(const f_int8s_t source, f_int8s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_int8s_append_) || !defined(_di_f_int8s_append_all_) || !defined(_di_f_int8ss_append_all_) + /** * Private implementation for resizing the int8s array. * @@ -143,134 +168,6 @@ extern "C" { extern f_status_t private_f_int8ss_resize(const f_array_length_t length, f_int8ss_t *int8ss) F_attribute_visibility_internal_d; #endif // !defined(_di_f_int8ss_decrease_by_) || !defined(_di_f_int8ss_increase_) || !defined(_di_f_int8ss_increase_by_) || !defined(_di_f_int8ss_resize_) -/** - * Private implementation for resizing the uint8s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint8s - * The uint8s 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(). - * - * @see f_uint8s_adjust() - * @see f_uint8s_decimate_by() - */ -#if !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) - extern f_status_t private_f_uint8s_adjust(const f_array_length_t length, f_uint8s_t *uint8s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) - -/** - * Private implementation for appending the uint8 array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source uint8s to append. - * @param destination - * The destination uint8s the source is appended onto. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_uint8s_append() - * @see f_uint8ss_append() - */ -#if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) - extern f_status_t private_f_uint8s_append(const f_uint8s_t source, f_uint8s_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) - -/** - * Private implementation for resizing the uint8s array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint8s - * The uint8s 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(). - * - * @see f_uint8s_resize() - * @see f_uint8s_append() - * @see f_uint8s_decimate_by() - * @see f_uint8ss_append() - */ -#if !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_decimate_by_) || !defined(_di_f_uint8ss_append_) - extern f_status_t private_f_uint8s_resize(const f_array_length_t length, f_uint8s_t *uint8s) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_decimate_by_) || !defined(_di_f_uint8ss_append_) - -/** - * Private implementation for resizing the uint8ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param uint8ss - * The uint8ss 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_uint8ss_adjust() - * @see f_uint8ss_decimate_by() - */ -#if !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) - extern f_status_t private_f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) - -/** - * Private implementation for resizing the uint8ss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param uint8ss - * The uint8ss 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_uint8ss_decrease_by() - * @see f_uint8ss_increase() - * @see f_uint8ss_increase_by() - * @see f_uint8ss_resize() - */ -#if !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) - extern f_status_t private_f_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/c/type_array/private-state.c b/level_0/f_type_array/c/type_array/private-state.c index 4990b518d..0ac6f9213 100644 --- a/level_0/f_type_array/c/type_array/private-state.c +++ b/level_0/f_type_array/c/type_array/private-state.c @@ -9,51 +9,78 @@ extern "C" { f_status_t private_f_states_adjust(const f_array_length_t length, f_states_t *states) { const f_status_t status = f_memory_adjust(states->size, length, sizeof(f_state_t), (void **) & states->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - states->size = length; + states->size = length; - if (states->used > states->size) { - states->used = length; - } + if (states->used > states->size) { + states->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_states_adjust_) || !defined(_di_f_states_decimate_by_) #if !defined(_di_f_states_append_) || !defined(_di_f_statess_append_) - extern f_status_t private_f_states_append(const f_states_t source, f_states_t *destination) { + extern f_status_t private_f_states_append(const f_state_t source, f_states_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_states_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].step_large = source.step_large; + destination->array[destination->used].step_small = source.step_small; + + destination->array[destination->used].handle = source.handle; + destination->array[destination->used].interrupt = source.interrupt; + + destination->array[destination->used].callbacks = source.callbacks; + destination->array[destination->used].custom = source.custom; + destination->array[destination->used++].data = source.data; + + return F_none; + } +#endif // !defined(_di_f_states_append_) || !defined(_di_f_statess_append_) + +#if !defined(_di_f_states_append_) || !defined(_di_f_states_append_all_) || !defined(_di_f_statess_append_all_) + extern f_status_t private_f_states_append_all(const f_states_t source, f_states_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_states_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_states_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + + destination->array[destination->used].step_large = source.array[i].step_large; + destination->array[destination->used].step_small = source.array[i].step_small; + + destination->array[destination->used].handle = source.array[i].handle; + destination->array[destination->used].interrupt = source.array[i].interrupt; + + destination->array[destination->used].callbacks = source.array[i].callbacks; + destination->array[destination->used].custom = source.array[i].custom; + destination->array[destination->used++].data = source.array[i].data; } // for return F_none; } -#endif // !defined(_di_f_states_append_) || !defined(_di_f_statess_append_) +#endif // !defined(_di_f_states_append_) || !defined(_di_f_states_append_all_) || !defined(_di_f_statess_append_all_) #if !defined(_di_f_states_resize_) || !defined(_di_f_states_append_) || !defined(_di_f_states_decimate_by_) || !defined(_di_f_statess_append_) f_status_t private_f_states_resize(const f_array_length_t length, f_states_t *states) { const f_status_t status = f_memory_resize(states->size, length, sizeof(f_state_t), (void **) & states->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - states->size = length; + states->size = length; - if (states->used > states->size) { - states->used = length; - } + if (states->used > states->size) { + states->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_states_resize_) || !defined(_di_f_states_append_) || !defined(_di_f_states_decimate_by_) || !defined(_di_f_statess_append_) @@ -72,16 +99,15 @@ extern "C" { } // for status = f_memory_adjust(statess->size, length, sizeof(f_states_t), (void **) & statess->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - statess->size = length; + statess->size = length; - if (statess->used > statess->size) { - statess->used = length; - } + if (statess->used > statess->size) { + statess->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_statess_adjust_) || !defined(_di_f_statess_decimate_by_) @@ -100,16 +126,15 @@ extern "C" { } // for status = f_memory_resize(statess->size, length, sizeof(f_states_t), (void **) & statess->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - statess->size = length; + statess->size = length; - if (statess->used > statess->size) { - statess->used = length; - } + if (statess->used > statess->size) { + statess->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_statess_decrease_by_) || !defined(_di_f_statess_increase_) || !defined(_di_f_statess_increase_by_) || !defined(_di_f_statess_resize_) diff --git a/level_0/f_type_array/c/type_array/private-state.h b/level_0/f_type_array/c/type_array/private-state.h index d66168837..b999c3b3d 100644 --- a/level_0/f_type_array/c/type_array/private-state.h +++ b/level_0/f_type_array/c/type_array/private-state.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source states to append. + * The source state to append. * @param destination - * The destination states the source is appended onto. + * 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_states_append() * @see f_statess_append() */ #if !defined(_di_f_states_append_) || !defined(_di_f_statess_append_) - extern f_status_t private_f_states_append(const f_states_t source, f_states_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_states_append(const f_state_t source, f_states_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_states_append_) || !defined(_di_f_statess_append_) +/** + * Private implementation for appending the state array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source states 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_states_append_all() + * @see f_statess_append() + * @see f_statess_append_all() + */ +#if !defined(_di_f_states_append_) || !defined(_di_f_states_append_all_) || !defined(_di_f_statess_append_all_) + extern f_status_t private_f_states_append_all(const f_states_t source, f_states_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_states_append_) || !defined(_di_f_states_append_all_) || !defined(_di_f_statess_append_all_) + /** * Private implementation for resizing the states array. * diff --git a/level_0/f_type_array/c/type_array/private-status.c b/level_0/f_type_array/c/type_array/private-status.c index 024372b18..8e68dd565 100644 --- a/level_0/f_type_array/c/type_array/private-status.c +++ b/level_0/f_type_array/c/type_array/private-status.c @@ -9,51 +9,61 @@ extern "C" { f_status_t private_f_statuss_adjust(const f_array_length_t length, f_statuss_t *statuss) { const f_status_t status = f_memory_adjust(statuss->size, length, sizeof(f_status_t), (void **) & statuss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - statuss->size = length; + statuss->size = length; - if (statuss->used > statuss->size) { - statuss->used = length; - } + if (statuss->used > statuss->size) { + statuss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_statuss_adjust_) || !defined(_di_f_statuss_decimate_by_) #if !defined(_di_f_statuss_append_) || !defined(_di_f_statusss_append_) - extern f_status_t private_f_statuss_append(const f_statuss_t source, f_statuss_t *destination) { + extern f_status_t private_f_statuss_append(const f_status_t source, f_statuss_t *destination) { - f_status_t status = F_none; + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_statuss_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_statuss_append_) || !defined(_di_f_statusss_append_) + +#if !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_append_all_) || !defined(_di_f_statusss_append_all_) + extern f_status_t private_f_statuss_append_all(const f_statuss_t source, f_statuss_t *destination) { if (destination->used + source.used > destination->size) { - status = private_f_statuss_adjust(destination->used + source.used, destination); + const f_status_t status = private_f_statuss_adjust(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used] = source.array[i]; + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; } // for return F_none; } -#endif // !defined(_di_f_statuss_append_) || !defined(_di_f_statusss_append_) +#endif // !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_append_all_) || !defined(_di_f_statusss_append_all_) #if !defined(_di_f_statuss_resize_) || !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_decimate_by_) || !defined(_di_f_statusss_append_) f_status_t private_f_statuss_resize(const f_array_length_t length, f_statuss_t *statuss) { const f_status_t status = f_memory_resize(statuss->size, length, sizeof(f_status_t), (void **) & statuss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - statuss->size = length; + statuss->size = length; - if (statuss->used > statuss->size) { - statuss->used = length; - } + if (statuss->used > statuss->size) { + statuss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_statuss_resize_) || !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_decimate_by_) || !defined(_di_f_statusss_append_) @@ -72,16 +82,15 @@ extern "C" { } // for status = f_memory_adjust(statusss->size, length, sizeof(f_statuss_t), (void **) & statusss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - statusss->size = length; + statusss->size = length; - if (statusss->used > statusss->size) { - statusss->used = length; - } + if (statusss->used > statusss->size) { + statusss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_statusss_adjust_) || !defined(_di_f_statusss_decimate_by_) @@ -100,16 +109,15 @@ extern "C" { } // for status = f_memory_resize(statusss->size, length, sizeof(f_statuss_t), (void **) & statusss->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - statusss->size = length; + statusss->size = length; - if (statusss->used > statusss->size) { - statusss->used = length; - } + if (statusss->used > statusss->size) { + statusss->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_statusss_decrease_by_) || !defined(_di_f_statusss_increase_) || !defined(_di_f_statusss_increase_by_) || !defined(_di_f_statusss_resize_) diff --git a/level_0/f_type_array/c/type_array/private-status.h b/level_0/f_type_array/c/type_array/private-status.h index 5e328f2de..4bce1fb92 100644 --- a/level_0/f_type_array/c/type_array/private-status.h +++ b/level_0/f_type_array/c/type_array/private-status.h @@ -44,22 +44,47 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source statuss to append. + * The source status to append. * @param destination - * The destination statuss the source is appended onto. + * 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_statuss_append() * @see f_statusss_append() */ #if !defined(_di_f_statuss_append_) || !defined(_di_f_statusss_append_) - extern f_status_t private_f_statuss_append(const f_statuss_t source, f_statuss_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_statuss_append(const f_status_t source, f_statuss_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_statuss_append_) || !defined(_di_f_statusss_append_) +/** + * Private implementation for appending the status array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source statuss 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_statuss_append_all() + * @see f_statusss_append() + * @see f_statusss_append_all() + */ +#if !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_append_all_) || !defined(_di_f_statusss_append_all_) + extern f_status_t private_f_statuss_append_all(const f_statuss_t source, f_statuss_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_statuss_append_) || !defined(_di_f_statuss_append_all_) || !defined(_di_f_statusss_append_all_) + /** * Private implementation for resizing the statuss array. * diff --git a/level_0/f_type_array/c/type_array/private-uint128.c b/level_0/f_type_array/c/type_array/private-uint128.c new file mode 100644 index 000000000..7a14d278e --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint128.c @@ -0,0 +1,126 @@ +#include "../type_array.h" +#include "private-uint128.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) + f_status_t private_f_uint128s_adjust(const f_array_length_t length, f_uint128s_t *uint128s) { + + const f_status_t status = f_memory_adjust(uint128s->size, length, sizeof(f_uint128s_t), (void **) & uint128s->array); + if (F_status_is_error(status)) return status; + + uint128s->size = length; + + if (uint128s->used > uint128s->size) { + uint128s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) + +#if !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) + extern f_status_t private_f_uint128s_append(const uint128_t source, f_uint128s_t *destination) { + + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_uint128s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) + +#if !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_append_all_) || !defined(_di_f_uint128ss_append_all_) + extern f_status_t private_f_uint128s_append_all(const f_uint128s_t source, f_uint128s_t *destination) { + + if (destination->used + source.used > destination->size) { + const f_status_t status = private_f_uint128s_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; + } // for + + return F_none; + } +#endif // !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_append_all_) || !defined(_di_f_uint128ss_append_all_) + +#if !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decimate_by_) || !defined(_di_f_uint128ss_append_) + f_status_t private_f_uint128s_resize(const f_array_length_t length, f_uint128s_t *uint128s) { + + const f_status_t status = f_memory_resize(uint128s->size, length, sizeof(f_uint128s_t), (void **) & uint128s->array); + if (F_status_is_error(status)) return status; + + uint128s->size = length; + + if (uint128s->used > uint128s->size) { + uint128s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decimate_by_) || !defined(_di_f_uint128ss_append_) + +#if !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) + f_status_t private_f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint128ss->size; ++i) { + + status = f_memory_destroy(uint128ss->array[i].size, sizeof(f_uint128s_t), (void **) & uint128ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint128ss->array[i].size = 0; + uint128ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint128ss->size, length, sizeof(f_uint128s_t), (void **) & uint128ss->array); + if (F_status_is_error(status)) return status; + + uint128ss->size = length; + + if (uint128ss->used > uint128ss->size) { + uint128ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) + +#if !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) + f_status_t private_f_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint128ss->size; ++i) { + + status = f_memory_delete(uint128ss->array[i].size, sizeof(f_uint128s_t), (void **) & uint128ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint128ss->array[i].size = 0; + uint128ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint128ss->size, length, sizeof(f_uint128s_t), (void **) & uint128ss->array); + if (F_status_is_error(status)) return status; + + uint128ss->size = length; + + if (uint128ss->used > uint128ss->size) { + uint128ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/private-uint128.h b/level_0/f_type_array/c/type_array/private-uint128.h new file mode 100644 index 000000000..b0678eb71 --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint128.h @@ -0,0 +1,175 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_type_array_uint128_h +#define _PRIVATE_F_type_array_uint128_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing the uint128s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint128s + * The uint128s 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(). + * + * @see f_uint128s_adjust() + * @see f_uint128s_decimate_by() + */ +#if !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) + extern f_status_t private_f_uint128s_adjust(const f_array_length_t length, f_uint128s_t *uint128s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint128s_adjust_) || !defined(_di_f_uint128s_decimate_by_) + +/** + * Private implementation for appending the uint128 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint128 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_uint128s_append() + * @see f_uint128ss_append() + */ +#if !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) + extern f_status_t private_f_uint128s_append(const uint128_t source, f_uint128s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128ss_append_) + +/** + * Private implementation for appending the uint128 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint128s 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_uint128s_append_all() + * @see f_uint128ss_append() + * @see f_uint128ss_append_all() + */ +#if !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_append_all_) || !defined(_di_f_uint128ss_append_all_) + extern f_status_t private_f_uint128s_append_all(const f_uint128s_t source, f_uint128s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_append_all_) || !defined(_di_f_uint128ss_append_all_) + +/** + * Private implementation for resizing the uint128s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint128s + * The uint128s 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(). + * + * @see f_uint128s_resize() + * @see f_uint128s_append() + * @see f_uint128s_decimate_by() + * @see f_uint128ss_append() + */ +#if !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decimate_by_) || !defined(_di_f_uint128ss_append_) + extern f_status_t private_f_uint128s_resize(const f_array_length_t length, f_uint128s_t *uint128s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint128s_resize_) || !defined(_di_f_uint128s_append_) || !defined(_di_f_uint128s_decimate_by_) || !defined(_di_f_uint128ss_append_) + +/** + * Private implementation for resizing the uint128ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint128ss + * The uint128ss 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_uint128ss_adjust() + * @see f_uint128ss_decimate_by() + */ +#if !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) + extern f_status_t private_f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint128ss_adjust_) || !defined(_di_f_uint128ss_decimate_by_) + +/** + * Private implementation for resizing the uint128ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to resize to. + * @param uint128ss + * The uint128ss 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_uint128ss_decrease_by() + * @see f_uint128ss_increase() + * @see f_uint128ss_increase_by() + * @see f_uint128ss_resize() + */ +#if !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) + extern f_status_t private_f_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint128ss_decrease_by_) || !defined(_di_f_uint128ss_increase_) || !defined(_di_f_uint128ss_increase_by_) || !defined(_di_f_uint128ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_type_array_uint128_h diff --git a/level_0/f_type_array/c/type_array/private-uint16.c b/level_0/f_type_array/c/type_array/private-uint16.c new file mode 100644 index 000000000..bb49cf1c2 --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint16.c @@ -0,0 +1,126 @@ +#include "../type_array.h" +#include "private-uint16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) + f_status_t private_f_uint16s_adjust(const f_array_length_t length, f_uint16s_t *uint16s) { + + const f_status_t status = f_memory_adjust(uint16s->size, length, sizeof(uint16_t), (void **) & uint16s->array); + if (F_status_is_error(status)) return status; + + uint16s->size = length; + + if (uint16s->used > uint16s->size) { + uint16s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) + +#if !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) + extern f_status_t private_f_uint16s_append(const uint16_t source, f_uint16s_t *destination) { + + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_uint16s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) + +#if !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_append_all_) || !defined(_di_f_uint16ss_append_all_) + extern f_status_t private_f_uint16s_append_all(const f_uint16s_t source, f_uint16s_t *destination) { + + if (destination->used + source.used > destination->size) { + const f_status_t status = private_f_uint16s_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; + } // for + + return F_none; + } +#endif // !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_append_all_) || !defined(_di_f_uint16ss_append_all_) + +#if !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decimate_by_) || !defined(_di_f_uint16ss_append_) + f_status_t private_f_uint16s_resize(const f_array_length_t length, f_uint16s_t *uint16s) { + + const f_status_t status = f_memory_resize(uint16s->size, length, sizeof(uint16_t), (void **) & uint16s->array); + if (F_status_is_error(status)) return status; + + uint16s->size = length; + + if (uint16s->used > uint16s->size) { + uint16s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decimate_by_) || !defined(_di_f_uint16ss_append_) + +#if !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) + f_status_t private_f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint16ss->size; ++i) { + + status = f_memory_destroy(uint16ss->array[i].size, sizeof(f_uint16s_t), (void **) & uint16ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint16ss->array[i].size = 0; + uint16ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint16ss->size, length, sizeof(f_uint16s_t), (void **) & uint16ss->array); + if (F_status_is_error(status)) return status; + + uint16ss->size = length; + + if (uint16ss->used > uint16ss->size) { + uint16ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) + +#if !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) + f_status_t private_f_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint16ss->size; ++i) { + + status = f_memory_delete(uint16ss->array[i].size, sizeof(f_uint16s_t), (void **) & uint16ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint16ss->array[i].size = 0; + uint16ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint16ss->size, length, sizeof(f_uint16s_t), (void **) & uint16ss->array); + if (F_status_is_error(status)) return status; + + uint16ss->size = length; + + if (uint16ss->used > uint16ss->size) { + uint16ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/private-uint16.h b/level_0/f_type_array/c/type_array/private-uint16.h new file mode 100644 index 000000000..d52a3b717 --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint16.h @@ -0,0 +1,175 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_type_array_uint16_h +#define _PRIVATE_F_type_array_uint16_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing the uint16s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint16s + * The uint16s 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(). + * + * @see f_uint16s_adjust() + * @see f_uint16s_decimate_by() + */ +#if !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) + extern f_status_t private_f_uint16s_adjust(const f_array_length_t length, f_uint16s_t *uint16s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint16s_adjust_) || !defined(_di_f_uint16s_decimate_by_) + +/** + * Private implementation for appending the uint16 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint16 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_uint16s_append() + * @see f_uint16ss_append() + */ +#if !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) + extern f_status_t private_f_uint16s_append(const uint16_t source, f_uint16s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16ss_append_) + +/** + * Private implementation for appending the uint16 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint16s 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_uint16s_append_all() + * @see f_uint16ss_append() + * @see f_uint16ss_append_all() + */ +#if !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_append_all_) || !defined(_di_f_uint16ss_append_all_) + extern f_status_t private_f_uint16s_append_all(const f_uint16s_t source, f_uint16s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_append_all_) || !defined(_di_f_uint16ss_append_all_) + +/** + * Private implementation for resizing the uint16s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint16s + * The uint16s 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(). + * + * @see f_uint16s_resize() + * @see f_uint16s_append() + * @see f_uint16s_decimate_by() + * @see f_uint16ss_append() + */ +#if !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decimate_by_) || !defined(_di_f_uint16ss_append_) + extern f_status_t private_f_uint16s_resize(const f_array_length_t length, f_uint16s_t *uint16s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint16s_resize_) || !defined(_di_f_uint16s_append_) || !defined(_di_f_uint16s_decimate_by_) || !defined(_di_f_uint16ss_append_) + +/** + * Private implementation for resizing the uint16ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint16ss + * The uint16ss 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_uint16ss_adjust() + * @see f_uint16ss_decimate_by() + */ +#if !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) + extern f_status_t private_f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint16ss_adjust_) || !defined(_di_f_uint16ss_decimate_by_) + +/** + * Private implementation for resizing the uint16ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to resize to. + * @param uint16ss + * The uint16ss 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_uint16ss_decrease_by() + * @see f_uint16ss_increase() + * @see f_uint16ss_increase_by() + * @see f_uint16ss_resize() + */ +#if !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) + extern f_status_t private_f_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint16ss_decrease_by_) || !defined(_di_f_uint16ss_increase_) || !defined(_di_f_uint16ss_increase_by_) || !defined(_di_f_uint16ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_type_array_uint16_h diff --git a/level_0/f_type_array/c/type_array/private-uint32.c b/level_0/f_type_array/c/type_array/private-uint32.c new file mode 100644 index 000000000..5f9105ae7 --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint32.c @@ -0,0 +1,126 @@ +#include "../type_array.h" +#include "private-uint32.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) + f_status_t private_f_uint32s_adjust(const f_array_length_t length, f_uint32s_t *uint32s) { + + const f_status_t status = f_memory_adjust(uint32s->size, length, sizeof(uint32_t), (void **) & uint32s->array); + if (F_status_is_error(status)) return status; + + uint32s->size = length; + + if (uint32s->used > uint32s->size) { + uint32s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) + +#if !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) + extern f_status_t private_f_uint32s_append(const uint32_t source, f_uint32s_t *destination) { + + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_uint32s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) + +#if !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_append_all_) || !defined(_di_f_uint32ss_append_all_) + extern f_status_t private_f_uint32s_append_all(const f_uint32s_t source, f_uint32s_t *destination) { + + if (destination->used + source.used > destination->size) { + const f_status_t status = private_f_uint32s_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; + } // for + + return F_none; + } +#endif // !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_append_all_) || !defined(_di_f_uint32ss_append_all_) + +#if !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decimate_by_) || !defined(_di_f_uint32ss_append_) + f_status_t private_f_uint32s_resize(const f_array_length_t length, f_uint32s_t *uint32s) { + + const f_status_t status = f_memory_resize(uint32s->size, length, sizeof(uint32_t), (void **) & uint32s->array); + if (F_status_is_error(status)) return status; + + uint32s->size = length; + + if (uint32s->used > uint32s->size) { + uint32s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decimate_by_) || !defined(_di_f_uint32ss_append_) + +#if !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) + f_status_t private_f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint32ss->size; ++i) { + + status = f_memory_destroy(uint32ss->array[i].size, sizeof(f_uint32s_t), (void **) & uint32ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint32ss->array[i].size = 0; + uint32ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint32ss->size, length, sizeof(f_uint32s_t), (void **) & uint32ss->array); + if (F_status_is_error(status)) return status; + + uint32ss->size = length; + + if (uint32ss->used > uint32ss->size) { + uint32ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) + +#if !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) + f_status_t private_f_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint32ss->size; ++i) { + + status = f_memory_delete(uint32ss->array[i].size, sizeof(f_uint32s_t), (void **) & uint32ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint32ss->array[i].size = 0; + uint32ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint32ss->size, length, sizeof(f_uint32s_t), (void **) & uint32ss->array); + if (F_status_is_error(status)) return status; + + uint32ss->size = length; + + if (uint32ss->used > uint32ss->size) { + uint32ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/private-uint32.h b/level_0/f_type_array/c/type_array/private-uint32.h new file mode 100644 index 000000000..fd97ca4cc --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint32.h @@ -0,0 +1,175 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_type_array_uint32_h +#define _PRIVATE_F_type_array_uint32_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing the uint32s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint32s + * The uint32s 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(). + * + * @see f_uint32s_adjust() + * @see f_uint32s_decimate_by() + */ +#if !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) + extern f_status_t private_f_uint32s_adjust(const f_array_length_t length, f_uint32s_t *uint32s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint32s_adjust_) || !defined(_di_f_uint32s_decimate_by_) + +/** + * Private implementation for appending the uint32 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint32 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_uint32s_append() + * @see f_uint32ss_append() + */ +#if !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) + extern f_status_t private_f_uint32s_append(const uint32_t source, f_uint32s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32ss_append_) + +/** + * Private implementation for appending the uint32 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint32s 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_uint32s_append_all() + * @see f_uint32ss_append() + * @see f_uint32ss_append_all() + */ +#if !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_append_all_) || !defined(_di_f_uint32ss_append_all_) + extern f_status_t private_f_uint32s_append_all(const f_uint32s_t source, f_uint32s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_append_all_) || !defined(_di_f_uint32ss_append_all_) + +/** + * Private implementation for resizing the uint32s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint32s + * The uint32s 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(). + * + * @see f_uint32s_resize() + * @see f_uint32s_append() + * @see f_uint32s_decimate_by() + * @see f_uint32ss_append() + */ +#if !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decimate_by_) || !defined(_di_f_uint32ss_append_) + extern f_status_t private_f_uint32s_resize(const f_array_length_t length, f_uint32s_t *uint32s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint32s_resize_) || !defined(_di_f_uint32s_append_) || !defined(_di_f_uint32s_decimate_by_) || !defined(_di_f_uint32ss_append_) + +/** + * Private implementation for resizing the uint32ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint32ss + * The uint32ss 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_uint32ss_adjust() + * @see f_uint32ss_decimate_by() + */ +#if !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) + extern f_status_t private_f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint32ss_adjust_) || !defined(_di_f_uint32ss_decimate_by_) + +/** + * Private implementation for resizing the uint32ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to resize to. + * @param uint32ss + * The uint32ss 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_uint32ss_decrease_by() + * @see f_uint32ss_increase() + * @see f_uint32ss_increase_by() + * @see f_uint32ss_resize() + */ +#if !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) + extern f_status_t private_f_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint32ss_decrease_by_) || !defined(_di_f_uint32ss_increase_) || !defined(_di_f_uint32ss_increase_by_) || !defined(_di_f_uint32ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_type_array_uint32_h diff --git a/level_0/f_type_array/c/type_array/private-uint64.c b/level_0/f_type_array/c/type_array/private-uint64.c new file mode 100644 index 000000000..b2d99b391 --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint64.c @@ -0,0 +1,126 @@ +#include "../type_array.h" +#include "private-uint64.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) + f_status_t private_f_uint64s_adjust(const f_array_length_t length, f_uint64s_t *uint64s) { + + const f_status_t status = f_memory_adjust(uint64s->size, length, sizeof(uint64_t), (void **) & uint64s->array); + if (F_status_is_error(status)) return status; + + uint64s->size = length; + + if (uint64s->used > uint64s->size) { + uint64s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) + +#if !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) + extern f_status_t private_f_uint64s_append(const uint64_t source, f_uint64s_t *destination) { + + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_uint64s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) + +#if !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_append_all_) || !defined(_di_f_uint64ss_append_all_) + extern f_status_t private_f_uint64s_append_all(const f_uint64s_t source, f_uint64s_t *destination) { + + if (destination->used + source.used > destination->size) { + const f_status_t status = private_f_uint64s_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; + } // for + + return F_none; + } +#endif // !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_append_all_) || !defined(_di_f_uint64ss_append_all_) + +#if !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decimate_by_) || !defined(_di_f_uint64ss_append_) + f_status_t private_f_uint64s_resize(const f_array_length_t length, f_uint64s_t *uint64s) { + + const f_status_t status = f_memory_resize(uint64s->size, length, sizeof(uint64_t), (void **) & uint64s->array); + if (F_status_is_error(status)) return status; + + uint64s->size = length; + + if (uint64s->used > uint64s->size) { + uint64s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decimate_by_) || !defined(_di_f_uint64ss_append_) + +#if !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) + f_status_t private_f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint64ss->size; ++i) { + + status = f_memory_destroy(uint64ss->array[i].size, sizeof(f_uint64s_t), (void **) & uint64ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint64ss->array[i].size = 0; + uint64ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint64ss->size, length, sizeof(f_uint64s_t), (void **) & uint64ss->array); + if (F_status_is_error(status)) return status; + + uint64ss->size = length; + + if (uint64ss->used > uint64ss->size) { + uint64ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) + +#if !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) + f_status_t private_f_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint64ss->size; ++i) { + + status = f_memory_delete(uint64ss->array[i].size, sizeof(f_uint64s_t), (void **) & uint64ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint64ss->array[i].size = 0; + uint64ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint64ss->size, length, sizeof(f_uint64s_t), (void **) & uint64ss->array); + if (F_status_is_error(status)) return status; + + uint64ss->size = length; + + if (uint64ss->used > uint64ss->size) { + uint64ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/private-uint64.h b/level_0/f_type_array/c/type_array/private-uint64.h new file mode 100644 index 000000000..912f94041 --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint64.h @@ -0,0 +1,175 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_type_array_uint64_h +#define _PRIVATE_F_type_array_uint64_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing the uint64s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint64s + * The uint64s 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(). + * + * @see f_uint64s_adjust() + * @see f_uint64s_decimate_by() + */ +#if !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) + extern f_status_t private_f_uint64s_adjust(const f_array_length_t length, f_uint64s_t *uint64s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint64s_adjust_) || !defined(_di_f_uint64s_decimate_by_) + +/** + * Private implementation for appending the uint64 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint64 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_uint64s_append() + * @see f_uint64ss_append() + */ +#if !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) + extern f_status_t private_f_uint64s_append(const uint64_t source, f_uint64s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64ss_append_) + +/** + * Private implementation for appending the uint64 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint64s 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_uint64s_append_all() + * @see f_uint64ss_append() + * @see f_uint64ss_append_all() + */ +#if !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_append_all_) || !defined(_di_f_uint64ss_append_all_) + extern f_status_t private_f_uint64s_append_all(const f_uint64s_t source, f_uint64s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_append_all_) || !defined(_di_f_uint64ss_append_all_) + +/** + * Private implementation for resizing the uint64s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint64s + * The uint64s 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(). + * + * @see f_uint64s_resize() + * @see f_uint64s_append() + * @see f_uint64s_decimate_by() + * @see f_uint64ss_append() + */ +#if !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decimate_by_) || !defined(_di_f_uint64ss_append_) + extern f_status_t private_f_uint64s_resize(const f_array_length_t length, f_uint64s_t *uint64s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint64s_resize_) || !defined(_di_f_uint64s_append_) || !defined(_di_f_uint64s_decimate_by_) || !defined(_di_f_uint64ss_append_) + +/** + * Private implementation for resizing the uint64ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint64ss + * The uint64ss 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_uint64ss_adjust() + * @see f_uint64ss_decimate_by() + */ +#if !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) + extern f_status_t private_f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint64ss_adjust_) || !defined(_di_f_uint64ss_decimate_by_) + +/** + * Private implementation for resizing the uint64ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to resize to. + * @param uint64ss + * The uint64ss 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_uint64ss_decrease_by() + * @see f_uint64ss_increase() + * @see f_uint64ss_increase_by() + * @see f_uint64ss_resize() + */ +#if !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) + extern f_status_t private_f_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint64ss_decrease_by_) || !defined(_di_f_uint64ss_increase_) || !defined(_di_f_uint64ss_increase_by_) || !defined(_di_f_uint64ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_type_array_uint64_h diff --git a/level_0/f_type_array/c/type_array/private-uint8.c b/level_0/f_type_array/c/type_array/private-uint8.c new file mode 100644 index 000000000..3956357f8 --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint8.c @@ -0,0 +1,126 @@ +#include "../type_array.h" +#include "private-uint8.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) + f_status_t private_f_uint8s_adjust(const f_array_length_t length, f_uint8s_t *uint8s) { + + const f_status_t status = f_memory_adjust(uint8s->size, length, sizeof(uint8_t), (void **) & uint8s->array); + if (F_status_is_error(status)) return status; + + uint8s->size = length; + + if (uint8s->used > uint8s->size) { + uint8s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) + +#if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) + extern f_status_t private_f_uint8s_append(const uint8_t source, f_uint8s_t *destination) { + + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_uint8s_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used++] = source; + + return F_none; + } +#endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) + +#if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8ss_append_all_) + extern f_status_t private_f_uint8s_append_all(const f_uint8s_t source, f_uint8s_t *destination) { + + if (destination->used + source.used > destination->size) { + const f_status_t status = private_f_uint8s_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + destination->array[destination->used++] = source.array[i]; + } // for + + return F_none; + } +#endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8ss_append_all_) + +#if !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_decimate_by_) || !defined(_di_f_uint8ss_append_) + f_status_t private_f_uint8s_resize(const f_array_length_t length, f_uint8s_t *uint8s) { + + const f_status_t status = f_memory_resize(uint8s->size, length, sizeof(uint8_t), (void **) & uint8s->array); + if (F_status_is_error(status)) return status; + + uint8s->size = length; + + if (uint8s->used > uint8s->size) { + uint8s->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_decimate_by_) || !defined(_di_f_uint8ss_append_) + +#if !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) + f_status_t private_f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint8ss->size; ++i) { + + status = f_memory_destroy(uint8ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint8ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint8ss->array[i].size = 0; + uint8ss->array[i].used = 0; + } // for + + status = f_memory_adjust(uint8ss->size, length, sizeof(f_uint8s_t), (void **) & uint8ss->array); + if (F_status_is_error(status)) return status; + + uint8ss->size = length; + + if (uint8ss->used > uint8ss->size) { + uint8ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) + +#if !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) + f_status_t private_f_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss) { + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < uint8ss->size; ++i) { + + status = f_memory_delete(uint8ss->array[i].size, sizeof(f_uint8s_t), (void **) & uint8ss->array[i].array); + if (F_status_is_error(status)) return status; + + uint8ss->array[i].size = 0; + uint8ss->array[i].used = 0; + } // for + + status = f_memory_resize(uint8ss->size, length, sizeof(f_uint8s_t), (void **) & uint8ss->array); + if (F_status_is_error(status)) return status; + + uint8ss->size = length; + + if (uint8ss->used > uint8ss->size) { + uint8ss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/private-uint8.h b/level_0/f_type_array/c/type_array/private-uint8.h new file mode 100644 index 000000000..8f7704e1c --- /dev/null +++ b/level_0/f_type_array/c/type_array/private-uint8.h @@ -0,0 +1,175 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_type_array_uint8_h +#define _PRIVATE_F_type_array_uint8_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing the uint8s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint8s + * The uint8s 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(). + * + * @see f_uint8s_adjust() + * @see f_uint8s_decimate_by() + */ +#if !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) + extern f_status_t private_f_uint8s_adjust(const f_array_length_t length, f_uint8s_t *uint8s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint8s_adjust_) || !defined(_di_f_uint8s_decimate_by_) + +/** + * Private implementation for appending the uint8 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint8 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_uint8s_append() + * @see f_uint8ss_append() + */ +#if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) + extern f_status_t private_f_uint8s_append(const uint8_t source, f_uint8s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8ss_append_) + +/** + * Private implementation for appending the uint8 array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source uint8s 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_uint8s_append_all() + * @see f_uint8ss_append() + * @see f_uint8ss_append_all() + */ +#if !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8ss_append_all_) + extern f_status_t private_f_uint8s_append_all(const f_uint8s_t source, f_uint8s_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_append_all_) || !defined(_di_f_uint8ss_append_all_) + +/** + * Private implementation for resizing the uint8s array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint8s + * The uint8s 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(). + * + * @see f_uint8s_resize() + * @see f_uint8s_append() + * @see f_uint8s_decimate_by() + * @see f_uint8ss_append() + */ +#if !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_decimate_by_) || !defined(_di_f_uint8ss_append_) + extern f_status_t private_f_uint8s_resize(const f_array_length_t length, f_uint8s_t *uint8s) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint8s_resize_) || !defined(_di_f_uint8s_append_) || !defined(_di_f_uint8s_decimate_by_) || !defined(_di_f_uint8ss_append_) + +/** + * Private implementation for resizing the uint8ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to adjust to. + * @param uint8ss + * The uint8ss 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_uint8ss_adjust() + * @see f_uint8ss_decimate_by() + */ +#if !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) + extern f_status_t private_f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint8ss_adjust_) || !defined(_di_f_uint8ss_decimate_by_) + +/** + * Private implementation for resizing the uint8ss array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The length to resize to. + * @param uint8ss + * The uint8ss 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_uint8ss_decrease_by() + * @see f_uint8ss_increase() + * @see f_uint8ss_increase_by() + * @see f_uint8ss_resize() + */ +#if !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) + extern f_status_t private_f_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_uint8ss_decrease_by_) || !defined(_di_f_uint8ss_increase_) || !defined(_di_f_uint8ss_increase_by_) || !defined(_di_f_uint8ss_resize_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_type_array_uint8_h diff --git a/level_0/f_type_array/c/type_array/state.c b/level_0/f_type_array/c/type_array/state.c index d416b9b0e..d9efd2823 100644 --- a/level_0/f_type_array/c/type_array/state.c +++ b/level_0/f_type_array/c/type_array/state.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_states_adjust_ #ifndef _di_f_states_append_ - f_status_t f_states_append(const f_states_t source, f_states_t *destination) { + f_status_t f_states_append(const f_state_t source, f_states_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; - return private_f_states_append(source, destination); } #endif // _di_f_states_append_ +#ifndef _di_f_states_append_all_ + f_status_t f_states_append_all(const f_states_t source, f_states_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; + + return private_f_states_append_all(source, destination); + } +#endif // _di_f_states_append_all_ + #ifndef _di_f_states_decimate_by_ f_status_t f_states_decimate_by(const f_array_length_t amount, f_states_t *states) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_statess_adjust_ #ifndef _di_f_statess_append_ - f_status_t f_statess_append(const f_statess_t source, f_statess_t *destination) { + f_status_t f_statess_append(const f_states_t source, f_statess_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_statess_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_states_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_statess_append_ + +#ifndef _di_f_statess_append_all_ + f_status_t f_statess_append_all(const f_statess_t source, f_statess_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_states_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_states_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_statess_append_ +#endif // _di_f_statess_append_all_ #ifndef _di_f_statess_decimate_by_ f_status_t f_statess_decimate_by(const f_array_length_t amount, f_statess_t *statess) { diff --git a/level_0/f_type_array/c/type_array/state.h b/level_0/f_type_array/c/type_array/state.h index cf63b29f8..8a58724da 100644 --- a/level_0/f_type_array/c/type_array/state.h +++ b/level_0/f_type_array/c/type_array/state.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_states_adjust_ /** - * Append the source states onto the destination. + * Append the single source state onto the destination. * * @param source - * The source states to append. + * The source state to append. * @param destination * The destination states the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_states_append_ - extern f_status_t f_states_append(const f_states_t source, f_states_t *destination); + extern f_status_t f_states_append(const f_state_t source, f_states_t *destination); #endif // _di_f_states_append_ +/** + * Append the source states onto the destination. + * + * @param source + * The source states to append. + * @param destination + * The destination states the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_states_append_all_ + extern f_status_t f_states_append_all(const f_states_t source, f_states_t *destination); +#endif // _di_f_states_append_all_ + /** * Resize the string states array to a smaller size. * @@ -193,10 +213,10 @@ extern "C" { #endif // _di_f_statess_adjust_ /** - * Append the source statess onto the destination. + * Append the single source states onto the destination. * * @param source - * The source statess to append. + * The source states to append. * @param destination * The destination ranges the source is appended onto. * @@ -209,28 +229,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_statess_append_ - extern f_status_t f_statess_append(const f_statess_t source, f_statess_t *destination); + extern f_status_t f_statess_append(const f_states_t source, f_statess_t *destination); #endif // _di_f_statess_append_ /** - * Resize the string statess array. + * Append the source statess onto the destination. * - * @param length - * The new size to use. - * @param statess - * The string statess array to resize. + * @param source + * The source statess to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_statess_adjust_ - extern f_status_t f_statess_adjust(const f_array_length_t length, f_statess_t *statess); -#endif // _di_f_statess_adjust_ +#ifndef _di_f_statess_append_all_ + extern f_status_t f_statess_append_all(const f_statess_t source, f_statess_t *destination); +#endif // _di_f_statess_append_all_ /** * Resize the string statess array to a smaller size. diff --git a/level_0/f_type_array/c/type_array/status.c b/level_0/f_type_array/c/type_array/status.c index 2eb4a3706..b602cbdf1 100644 --- a/level_0/f_type_array/c/type_array/status.c +++ b/level_0/f_type_array/c/type_array/status.c @@ -17,17 +17,27 @@ extern "C" { #endif // _di_f_statuss_adjust_ #ifndef _di_f_statuss_append_ - f_status_t f_statuss_append(const f_statuss_t source, f_statuss_t *destination) { + f_status_t f_statuss_append(const f_status_t source, f_statuss_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; - return private_f_statuss_append(source, destination); } #endif // _di_f_statuss_append_ +#ifndef _di_f_statuss_append_all_ + f_status_t f_statuss_append_all(const f_statuss_t source, f_statuss_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; + + return private_f_statuss_append_all(source, destination); + } +#endif // _di_f_statuss_append_all_ + #ifndef _di_f_statuss_decimate_by_ f_status_t f_statuss_decimate_by(const f_array_length_t amount, f_statuss_t *statuss) { #ifndef _di_level_0_parameter_checking_ @@ -131,7 +141,31 @@ extern "C" { #endif // _di_f_statusss_adjust_ #ifndef _di_f_statusss_append_ - f_status_t f_statusss_append(const f_statusss_t source, f_statusss_t *destination) { + f_status_t f_statusss_append(const f_statuss_t source, f_statusss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_statusss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_statuss_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_statusss_append_ + +#ifndef _di_f_statusss_append_all_ + f_status_t f_statusss_append_all(const f_statusss_t source, f_statusss_t *destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -146,13 +180,18 @@ extern "C" { } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - status = private_f_statuss_append(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_statuss_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } } // for return F_none; } -#endif // _di_f_statusss_append_ +#endif // _di_f_statusss_append_all_ #ifndef _di_f_statusss_decimate_by_ f_status_t f_statusss_decimate_by(const f_array_length_t amount, f_statusss_t *statusss) { diff --git a/level_0/f_type_array/c/type_array/status.h b/level_0/f_type_array/c/type_array/status.h index 196cabb2b..6d6214886 100644 --- a/level_0/f_type_array/c/type_array/status.h +++ b/level_0/f_type_array/c/type_array/status.h @@ -36,10 +36,10 @@ extern "C" { #endif // _di_f_statuss_adjust_ /** - * Append the source statuss onto the destination. + * Append the single source status onto the destination. * * @param source - * The source statuss to append. + * The source status to append. * @param destination * The destination statuss the source is appended onto. * @@ -52,9 +52,29 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_statuss_append_ - extern f_status_t f_statuss_append(const f_statuss_t source, f_statuss_t *destination); + extern f_status_t f_statuss_append(const f_status_t source, f_statuss_t *destination); #endif // _di_f_statuss_append_ +/** + * Append the source statuss onto the destination. + * + * @param source + * The source statuss to append. + * @param destination + * The destination statuss the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_statuss_append_all_ + extern f_status_t f_statuss_append_all(const f_statuss_t source, f_statuss_t *destination); +#endif // _di_f_statuss_append_all_ + /** * Resize the string statuss array to a smaller size. * @@ -193,10 +213,10 @@ extern "C" { #endif // _di_f_statusss_adjust_ /** - * Append the source statusss onto the destination. + * Append the single source statuss onto the destination. * * @param source - * The source statusss to append. + * The source statuss to append. * @param destination * The destination ranges the source is appended onto. * @@ -209,28 +229,28 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_statusss_append_ - extern f_status_t f_statusss_append(const f_statusss_t source, f_statusss_t *destination); + extern f_status_t f_statusss_append(const f_statuss_t source, f_statusss_t *destination); #endif // _di_f_statusss_append_ /** - * Resize the string statusss array. + * Append the source statusss onto the destination. * - * @param length - * The new size to use. - * @param statusss - * The string statusss array to resize. + * @param source + * The source statusss to append. + * @param destination + * The destination ranges the source is appended onto. * * @return * F_none on success. + * F_data_not on success, but there is nothing to append (size == 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_memory_destroy(). + * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_statusss_adjust_ - extern f_status_t f_statusss_adjust(const f_array_length_t length, f_statusss_t *statusss); -#endif // _di_f_statusss_adjust_ +#ifndef _di_f_statusss_append_all_ + extern f_status_t f_statusss_append_all(const f_statusss_t source, f_statusss_t *destination); +#endif // _di_f_statusss_append_all_ /** * Resize the string statusss array to a smaller size. diff --git a/level_0/f_type_array/c/type_array/uint128.c b/level_0/f_type_array/c/type_array/uint128.c new file mode 100644 index 000000000..9afaf3c9b --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint128.c @@ -0,0 +1,290 @@ +#include "../type_array.h" +#include "uint128.h" +#include "private-uint128.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_uint128s_adjust_ + f_status_t f_uint128s_adjust(const f_array_length_t length, f_uint128s_t *uint128s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint128s_adjust(length, uint128s); + } +#endif // _di_f_uint128s_adjust_ + +#ifndef _di_f_uint128s_append_ + f_status_t f_uint128s_append(const uint128_t source, f_uint128s_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint128s_append(source, destination); + } +#endif // _di_f_uint128s_append_ + +#ifndef _di_f_uint128s_append_all_ + f_status_t f_uint128s_append_all(const f_uint128s_t source, f_uint128s_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; + + return private_f_uint128s_append_all(source, destination); + } +#endif // _di_f_uint128s_append_all_ + +#ifndef _di_f_uint128s_decimate_by_ + f_status_t f_uint128s_decimate_by(const f_array_length_t amount, f_uint128s_t *uint128s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint128s->size - amount > 0) { + return private_f_uint128s_adjust(uint128s->size - amount, uint128s); + } + + return private_f_uint128s_adjust(0, uint128s); + } +#endif // _di_f_uint128s_decimate_by_ + +#ifndef _di_f_uint128s_decrease_by_ + f_status_t f_uint128s_decrease_by(const f_array_length_t amount, f_uint128s_t *uint128s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint128s->size - amount > 0) { + return private_f_uint128s_resize(uint128s->size - amount, uint128s); + } + + return private_f_uint128s_resize(0, uint128s); + } +#endif // _di_f_uint128s_decrease_by_ + +#ifndef _di_f_uint128s_increase_ + f_status_t f_uint128s_increase(const f_array_length_t step, f_uint128s_t *uint128s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint128s->used + 1 > uint128s->size) { + f_array_length_t size = uint128s->used + step; + + if (size > F_array_length_t_size_d) { + if (uint128s->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint128s_resize(size, uint128s); + } + + return F_data_not; + } +#endif // _di_f_uint128s_increase_ + +#ifndef _di_f_uint128s_increase_by_ + f_status_t f_uint128s_increase_by(const f_array_length_t amount, f_uint128s_t *uint128s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint128s->used + amount > uint128s->size) { + if (uint128s->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint128s_resize(uint128s->used + amount, uint128s); + } + + return F_data_not; + } +#endif // _di_f_uint128s_increase_by_ + +#ifndef _di_f_uint128s_resize_ + f_status_t f_uint128s_resize(const f_array_length_t length, f_uint128s_t *uint128s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint128s_resize(length, uint128s); + } +#endif // _di_f_uint128s_resize_ + +#ifndef _di_f_uint128ss_adjust_ + f_status_t f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint128ss_adjust(length, uint128ss); + } +#endif // _di_f_uint128ss_adjust_ + +#ifndef _di_f_uint128ss_append_ + f_status_t f_uint128ss_append(const f_uint128s_t source, f_uint128ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_uint128ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_uint128s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_uint128ss_append_ + +#ifndef _di_f_uint128ss_append_all_ + f_status_t f_uint128ss_append_all(const f_uint128ss_t source, f_uint128ss_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_uint128ss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_uint128s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_uint128ss_append_all_ + +#ifndef _di_f_uint128ss_decimate_by_ + f_status_t f_uint128ss_decimate_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint128ss->size - amount > 0) { + return private_f_uint128ss_adjust(uint128ss->size - amount, uint128ss); + } + + return private_f_uint128ss_adjust(0, uint128ss); + } +#endif // _di_f_uint128ss_decimate_by_ + +#ifndef _di_f_uint128ss_decrease_by_ + f_status_t f_uint128ss_decrease_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint128ss->size - amount > 0) { + return private_f_uint128ss_resize(uint128ss->size - amount, uint128ss); + } + + return private_f_uint128ss_resize(0, uint128ss); + } +#endif // _di_f_uint128ss_decrease_by_ + +#ifndef _di_f_uint128ss_increase_ + f_status_t f_uint128ss_increase(const f_array_length_t step, f_uint128ss_t *uint128ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint128ss->used + 1 > uint128ss->size) { + f_array_length_t size = uint128ss->used + step; + + if (size > F_array_length_t_size_d) { + if (uint128ss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint128ss_resize(size, uint128ss); + } + + return F_data_not; + } +#endif // _di_f_uint128ss_increase_ + +#ifndef _di_f_uint128ss_increase_by_ + f_status_t f_uint128ss_increase_by(const f_array_length_t amount, f_uint128ss_t *uint128ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint128ss->used + amount > uint128ss->size) { + if (uint128ss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint128ss_resize(uint128ss->used + amount, uint128ss); + } + + return F_data_not; + } +#endif // _di_f_uint128ss_increase_by_ + +#ifndef _di_f_uint128ss_resize_ + f_status_t f_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint128ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint128ss_resize(length, uint128ss); + } +#endif // _di_f_uint128ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/uint128.h b/level_0/f_type_array/c/type_array/uint128.h new file mode 100644 index 000000000..4634384f9 --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint128.h @@ -0,0 +1,377 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines data to be used for/by type (array) related functionality. + * + * This is auto-included by type_array.h and should not need to be explicitly included. + */ +#ifndef _F_type_array_uint128_h +#define _F_type_array_uint128_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Resize the string uint128s array. + * + * @param length + * The new size to use. + * @param uint128s + * The string uint128s 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(). + */ +#ifndef _di_f_uint128s_adjust_ + extern f_status_t f_uint128s_adjust(const f_array_length_t length, f_uint128s_t *uint128s); +#endif // _di_f_uint128s_adjust_ + +/** + * Append the single source uint128 onto the destination. + * + * @param source + * The source uint128 to append. + * @param destination + * The destination uint128s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint128s_append_ + extern f_status_t f_uint128s_append(const uint128_t source, f_uint128s_t *destination); +#endif // _di_f_uint128s_append_ + +/** + * Append the source uint128s onto the destination. + * + * @param source + * The source uint128s to append. + * @param destination + * The destination uint128s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint128s_append_all_ + extern f_status_t f_uint128s_append_all(const f_uint128s_t source, f_uint128s_t *destination); +#endif // _di_f_uint128s_append_all_ + +/** + * Resize the string uint128s 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 uint128s + * The string uint128s 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(). + */ +#ifndef _di_f_uint128s_decimate_by_ + extern f_status_t f_uint128s_decimate_by(const f_array_length_t amount, f_uint128s_t *uint128s); +#endif // _di_f_uint128s_decimate_by_ + +/** + * Resize the string uint128s 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 uint128s + * The string uint128s 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(). + */ +#ifndef _di_f_uint128s_decrease_by_ + extern f_status_t f_uint128s_decrease_by(const f_array_length_t amount, f_uint128s_t *uint128s); +#endif // _di_f_uint128s_decrease_by_ + +/** + * Increase the size of the string uint128s array, but only if necesary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint128s + * The string uint128s 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(). + */ +#ifndef _di_f_uint128s_increase_ + extern f_status_t f_uint128s_increase(const f_array_length_t step, f_uint128s_t *uint128s); +#endif // _di_f_uint128s_increase_ + +/** + * Resize the string uint128s array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint128s + * The string uint128s 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(). + */ +#ifndef _di_f_uint128s_increase_by_ + extern f_status_t f_uint128s_increase_by(const f_array_length_t amount, f_uint128s_t *uint128s); +#endif // _di_f_uint128s_increase_by_ + +/** + * Resize the string uint128s array. + * + * @param length + * The new size to use. + * @param uint128s + * The string uint128s 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(). + */ +#ifndef _di_f_uint128s_resize_ + extern f_status_t f_uint128s_resize(const f_array_length_t length, f_uint128s_t *uint128s); +#endif // _di_f_uint128s_resize_ + +/** + * Resize the string uint128ss array. + * + * @param length + * The new size to use. + * @param uint128ss + * The string uint128ss 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_memory_destroy(). + */ +#ifndef _di_f_uint128ss_adjust_ + extern f_status_t f_uint128ss_adjust(const f_array_length_t length, f_uint128ss_t *uint128ss); +#endif // _di_f_uint128ss_adjust_ + +/** + * Append the single source uint128s onto the destination. + * + * @param source + * The source uint128s to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint128ss_append_ + extern f_status_t f_uint128ss_append(const f_uint128s_t source, f_uint128ss_t *destination); +#endif // _di_f_uint128ss_append_ + +/** + * Append the source uint128ss onto the destination. + * + * @param source + * The source uint128ss to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint128ss_append_all_ + extern f_status_t f_uint128ss_append_all(const f_uint128ss_t source, f_uint128ss_t *destination); +#endif // _di_f_uint128ss_append_all_ + +/** + * Resize the string uint128ss 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 uint128ss + * The string uint128ss 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_memory_destroy(). + */ +#ifndef _di_f_uint128ss_decimate_by_ + extern f_status_t f_uint128ss_decimate_by(const f_array_length_t amount, f_uint128ss_t *uint128ss); +#endif // _di_f_uint128ss_decimate_by_ + +/** + * Resize the string uint128ss 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 uint128ss + * The string uint128ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint128ss_decrease_by_ + extern f_status_t f_uint128ss_decrease_by(const f_array_length_t amount, f_uint128ss_t *uint128ss); +#endif // _di_f_uint128ss_decrease_by_ + +/** + * Increase the size of the string uint128ss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint128ss + * The string uint128ss 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(). + */ +#ifndef _di_f_uint128ss_increase_ + extern f_status_t f_uint128ss_increase(const f_array_length_t step, f_uint128ss_t *uint128ss); +#endif // _di_f_uint128ss_increase_ + +/** + * Resize the string uint128ss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint128ss + * The string uint128ss 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(). + */ +#ifndef _di_f_uint128ss_increase_by_ + extern f_status_t f_uint128ss_increase_by(const f_array_length_t amount, f_uint128ss_t *uint128ss); +#endif // _di_f_uint128ss_increase_by_ + +/** + * Resize the string uint128ss array. + * + * @param length + * The new size to use. + * @param uint128ss + * The string uint128ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint128ss_resize_ + extern f_status_t f_uint128ss_resize(const f_array_length_t length, f_uint128ss_t *uint128ss); +#endif // _di_f_uint128ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_array_uint128_h diff --git a/level_0/f_type_array/c/type_array/uint16.c b/level_0/f_type_array/c/type_array/uint16.c new file mode 100644 index 000000000..c56edf425 --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint16.c @@ -0,0 +1,290 @@ +#include "../type_array.h" +#include "uint16.h" +#include "private-uint16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_uint16s_adjust_ + f_status_t f_uint16s_adjust(const f_array_length_t length, f_uint16s_t *uint16s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint16s_adjust(length, uint16s); + } +#endif // _di_f_uint16s_adjust_ + +#ifndef _di_f_uint16s_append_ + f_status_t f_uint16s_append(const uint16_t source, f_uint16s_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint16s_append(source, destination); + } +#endif // _di_f_uint16s_append_ + +#ifndef _di_f_uint16s_append_all_ + f_status_t f_uint16s_append_all(const f_uint16s_t source, f_uint16s_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; + + return private_f_uint16s_append_all(source, destination); + } +#endif // _di_f_uint16s_append_all_ + +#ifndef _di_f_uint16s_decimate_by_ + f_status_t f_uint16s_decimate_by(const f_array_length_t amount, f_uint16s_t *uint16s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint16s->size - amount > 0) { + return private_f_uint16s_adjust(uint16s->size - amount, uint16s); + } + + return private_f_uint16s_adjust(0, uint16s); + } +#endif // _di_f_uint16s_decimate_by_ + +#ifndef _di_f_uint16s_decrease_by_ + f_status_t f_uint16s_decrease_by(const f_array_length_t amount, f_uint16s_t *uint16s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint16s->size - amount > 0) { + return private_f_uint16s_resize(uint16s->size - amount, uint16s); + } + + return private_f_uint16s_resize(0, uint16s); + } +#endif // _di_f_uint16s_decrease_by_ + +#ifndef _di_f_uint16s_increase_ + f_status_t f_uint16s_increase(const f_array_length_t step, f_uint16s_t *uint16s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint16s->used + 1 > uint16s->size) { + f_array_length_t size = uint16s->used + step; + + if (size > F_array_length_t_size_d) { + if (uint16s->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint16s_resize(size, uint16s); + } + + return F_data_not; + } +#endif // _di_f_uint16s_increase_ + +#ifndef _di_f_uint16s_increase_by_ + f_status_t f_uint16s_increase_by(const f_array_length_t amount, f_uint16s_t *uint16s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint16s->used + amount > uint16s->size) { + if (uint16s->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint16s_resize(uint16s->used + amount, uint16s); + } + + return F_data_not; + } +#endif // _di_f_uint16s_increase_by_ + +#ifndef _di_f_uint16s_resize_ + f_status_t f_uint16s_resize(const f_array_length_t length, f_uint16s_t *uint16s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint16s_resize(length, uint16s); + } +#endif // _di_f_uint16s_resize_ + +#ifndef _di_f_uint16ss_adjust_ + f_status_t f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint16ss_adjust(length, uint16ss); + } +#endif // _di_f_uint16ss_adjust_ + +#ifndef _di_f_uint16ss_append_ + f_status_t f_uint16ss_append(const f_uint16s_t source, f_uint16ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_uint16ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_uint16s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_uint16ss_append_ + +#ifndef _di_f_uint16ss_append_all_ + f_status_t f_uint16ss_append_all(const f_uint16ss_t source, f_uint16ss_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_uint16ss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_uint16s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_uint16ss_append_all_ + +#ifndef _di_f_uint16ss_decimate_by_ + f_status_t f_uint16ss_decimate_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint16ss->size - amount > 0) { + return private_f_uint16ss_adjust(uint16ss->size - amount, uint16ss); + } + + return private_f_uint16ss_adjust(0, uint16ss); + } +#endif // _di_f_uint16ss_decimate_by_ + +#ifndef _di_f_uint16ss_decrease_by_ + f_status_t f_uint16ss_decrease_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint16ss->size - amount > 0) { + return private_f_uint16ss_resize(uint16ss->size - amount, uint16ss); + } + + return private_f_uint16ss_resize(0, uint16ss); + } +#endif // _di_f_uint16ss_decrease_by_ + +#ifndef _di_f_uint16ss_increase_ + f_status_t f_uint16ss_increase(const f_array_length_t step, f_uint16ss_t *uint16ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint16ss->used + 1 > uint16ss->size) { + f_array_length_t size = uint16ss->used + step; + + if (size > F_array_length_t_size_d) { + if (uint16ss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint16ss_resize(size, uint16ss); + } + + return F_data_not; + } +#endif // _di_f_uint16ss_increase_ + +#ifndef _di_f_uint16ss_increase_by_ + f_status_t f_uint16ss_increase_by(const f_array_length_t amount, f_uint16ss_t *uint16ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint16ss->used + amount > uint16ss->size) { + if (uint16ss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint16ss_resize(uint16ss->used + amount, uint16ss); + } + + return F_data_not; + } +#endif // _di_f_uint16ss_increase_by_ + +#ifndef _di_f_uint16ss_resize_ + f_status_t f_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint16ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint16ss_resize(length, uint16ss); + } +#endif // _di_f_uint16ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/uint16.h b/level_0/f_type_array/c/type_array/uint16.h new file mode 100644 index 000000000..31aa62ffe --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint16.h @@ -0,0 +1,377 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines data to be used for/by type (array) related functionality. + * + * This is auto-included by type_array.h and should not need to be explicitly included. + */ +#ifndef _F_type_array_uint16_h +#define _F_type_array_uint16_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Resize the string uint16s array. + * + * @param length + * The new size to use. + * @param uint16s + * The string uint16s 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(). + */ +#ifndef _di_f_uint16s_adjust_ + extern f_status_t f_uint16s_adjust(const f_array_length_t length, f_uint16s_t *uint16s); +#endif // _di_f_uint16s_adjust_ + +/** + * Append the single source uint16 onto the destination. + * + * @param source + * The source uint16 to append. + * @param destination + * The destination uint16s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint16s_append_ + extern f_status_t f_uint16s_append(const uint16_t source, f_uint16s_t *destination); +#endif // _di_f_uint16s_append_ + +/** + * Append the source uint16s onto the destination. + * + * @param source + * The source uint16s to append. + * @param destination + * The destination uint16s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint16s_append_all_ + extern f_status_t f_uint16s_append_all(const f_uint16s_t source, f_uint16s_t *destination); +#endif // _di_f_uint16s_append_all_ + +/** + * Resize the string uint16s 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 uint16s + * The string uint16s 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(). + */ +#ifndef _di_f_uint16s_decimate_by_ + extern f_status_t f_uint16s_decimate_by(const f_array_length_t amount, f_uint16s_t *uint16s); +#endif // _di_f_uint16s_decimate_by_ + +/** + * Resize the string uint16s 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 uint16s + * The string uint16s 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(). + */ +#ifndef _di_f_uint16s_decrease_by_ + extern f_status_t f_uint16s_decrease_by(const f_array_length_t amount, f_uint16s_t *uint16s); +#endif // _di_f_uint16s_decrease_by_ + +/** + * Increase the size of the string uint16s array, but only if necesary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint16s + * The string uint16s 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(). + */ +#ifndef _di_f_uint16s_increase_ + extern f_status_t f_uint16s_increase(const f_array_length_t step, f_uint16s_t *uint16s); +#endif // _di_f_uint16s_increase_ + +/** + * Resize the string uint16s array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint16s + * The string uint16s 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(). + */ +#ifndef _di_f_uint16s_increase_by_ + extern f_status_t f_uint16s_increase_by(const f_array_length_t amount, f_uint16s_t *uint16s); +#endif // _di_f_uint16s_increase_by_ + +/** + * Resize the string uint16s array. + * + * @param length + * The new size to use. + * @param uint16s + * The string uint16s 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(). + */ +#ifndef _di_f_uint16s_resize_ + extern f_status_t f_uint16s_resize(const f_array_length_t length, f_uint16s_t *uint16s); +#endif // _di_f_uint16s_resize_ + +/** + * Resize the string uint16ss array. + * + * @param length + * The new size to use. + * @param uint16ss + * The string uint16ss 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_memory_destroy(). + */ +#ifndef _di_f_uint16ss_adjust_ + extern f_status_t f_uint16ss_adjust(const f_array_length_t length, f_uint16ss_t *uint16ss); +#endif // _di_f_uint16ss_adjust_ + +/** + * Append the single source uint16s onto the destination. + * + * @param source + * The source uint16s to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint16ss_append_ + extern f_status_t f_uint16ss_append(const f_uint16s_t source, f_uint16ss_t *destination); +#endif // _di_f_uint16ss_append_ + +/** + * Append the source uint16ss onto the destination. + * + * @param source + * The source uint16ss to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint16ss_append_all_ + extern f_status_t f_uint16ss_append_all(const f_uint16ss_t source, f_uint16ss_t *destination); +#endif // _di_f_uint16ss_append_all_ + +/** + * Resize the string uint16ss 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 uint16ss + * The string uint16ss 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_memory_destroy(). + */ +#ifndef _di_f_uint16ss_decimate_by_ + extern f_status_t f_uint16ss_decimate_by(const f_array_length_t amount, f_uint16ss_t *uint16ss); +#endif // _di_f_uint16ss_decimate_by_ + +/** + * Resize the string uint16ss 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 uint16ss + * The string uint16ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint16ss_decrease_by_ + extern f_status_t f_uint16ss_decrease_by(const f_array_length_t amount, f_uint16ss_t *uint16ss); +#endif // _di_f_uint16ss_decrease_by_ + +/** + * Increase the size of the string uint16ss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint16ss + * The string uint16ss 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(). + */ +#ifndef _di_f_uint16ss_increase_ + extern f_status_t f_uint16ss_increase(const f_array_length_t step, f_uint16ss_t *uint16ss); +#endif // _di_f_uint16ss_increase_ + +/** + * Resize the string uint16ss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint16ss + * The string uint16ss 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(). + */ +#ifndef _di_f_uint16ss_increase_by_ + extern f_status_t f_uint16ss_increase_by(const f_array_length_t amount, f_uint16ss_t *uint16ss); +#endif // _di_f_uint16ss_increase_by_ + +/** + * Resize the string uint16ss array. + * + * @param length + * The new size to use. + * @param uint16ss + * The string uint16ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint16ss_resize_ + extern f_status_t f_uint16ss_resize(const f_array_length_t length, f_uint16ss_t *uint16ss); +#endif // _di_f_uint16ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_array_uint16_h diff --git a/level_0/f_type_array/c/type_array/uint32.c b/level_0/f_type_array/c/type_array/uint32.c new file mode 100644 index 000000000..4c4e5bf00 --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint32.c @@ -0,0 +1,290 @@ +#include "../type_array.h" +#include "uint32.h" +#include "private-uint32.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_uint32s_adjust_ + f_status_t f_uint32s_adjust(const f_array_length_t length, f_uint32s_t *uint32s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint32s_adjust(length, uint32s); + } +#endif // _di_f_uint32s_adjust_ + +#ifndef _di_f_uint32s_append_ + f_status_t f_uint32s_append(const uint32_t source, f_uint32s_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint32s_append(source, destination); + } +#endif // _di_f_uint32s_append_ + +#ifndef _di_f_uint32s_append_all_ + f_status_t f_uint32s_append_all(const f_uint32s_t source, f_uint32s_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; + + return private_f_uint32s_append_all(source, destination); + } +#endif // _di_f_uint32s_append_all_ + +#ifndef _di_f_uint32s_decimate_by_ + f_status_t f_uint32s_decimate_by(const f_array_length_t amount, f_uint32s_t *uint32s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint32s->size - amount > 0) { + return private_f_uint32s_adjust(uint32s->size - amount, uint32s); + } + + return private_f_uint32s_adjust(0, uint32s); + } +#endif // _di_f_uint32s_decimate_by_ + +#ifndef _di_f_uint32s_decrease_by_ + f_status_t f_uint32s_decrease_by(const f_array_length_t amount, f_uint32s_t *uint32s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint32s->size - amount > 0) { + return private_f_uint32s_resize(uint32s->size - amount, uint32s); + } + + return private_f_uint32s_resize(0, uint32s); + } +#endif // _di_f_uint32s_decrease_by_ + +#ifndef _di_f_uint32s_increase_ + f_status_t f_uint32s_increase(const f_array_length_t step, f_uint32s_t *uint32s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint32s->used + 1 > uint32s->size) { + f_array_length_t size = uint32s->used + step; + + if (size > F_array_length_t_size_d) { + if (uint32s->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint32s_resize(size, uint32s); + } + + return F_data_not; + } +#endif // _di_f_uint32s_increase_ + +#ifndef _di_f_uint32s_increase_by_ + f_status_t f_uint32s_increase_by(const f_array_length_t amount, f_uint32s_t *uint32s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint32s->used + amount > uint32s->size) { + if (uint32s->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint32s_resize(uint32s->used + amount, uint32s); + } + + return F_data_not; + } +#endif // _di_f_uint32s_increase_by_ + +#ifndef _di_f_uint32s_resize_ + f_status_t f_uint32s_resize(const f_array_length_t length, f_uint32s_t *uint32s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint32s_resize(length, uint32s); + } +#endif // _di_f_uint32s_resize_ + +#ifndef _di_f_uint32ss_adjust_ + f_status_t f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint32ss_adjust(length, uint32ss); + } +#endif // _di_f_uint32ss_adjust_ + +#ifndef _di_f_uint32ss_append_ + f_status_t f_uint32ss_append(const f_uint32s_t source, f_uint32ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_uint32ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_uint32s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_uint32ss_append_ + +#ifndef _di_f_uint32ss_append_all_ + f_status_t f_uint32ss_append_all(const f_uint32ss_t source, f_uint32ss_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_uint32ss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_uint32s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_uint32ss_append_all_ + +#ifndef _di_f_uint32ss_decimate_by_ + f_status_t f_uint32ss_decimate_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint32ss->size - amount > 0) { + return private_f_uint32ss_adjust(uint32ss->size - amount, uint32ss); + } + + return private_f_uint32ss_adjust(0, uint32ss); + } +#endif // _di_f_uint32ss_decimate_by_ + +#ifndef _di_f_uint32ss_decrease_by_ + f_status_t f_uint32ss_decrease_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint32ss->size - amount > 0) { + return private_f_uint32ss_resize(uint32ss->size - amount, uint32ss); + } + + return private_f_uint32ss_resize(0, uint32ss); + } +#endif // _di_f_uint32ss_decrease_by_ + +#ifndef _di_f_uint32ss_increase_ + f_status_t f_uint32ss_increase(const f_array_length_t step, f_uint32ss_t *uint32ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint32ss->used + 1 > uint32ss->size) { + f_array_length_t size = uint32ss->used + step; + + if (size > F_array_length_t_size_d) { + if (uint32ss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint32ss_resize(size, uint32ss); + } + + return F_data_not; + } +#endif // _di_f_uint32ss_increase_ + +#ifndef _di_f_uint32ss_increase_by_ + f_status_t f_uint32ss_increase_by(const f_array_length_t amount, f_uint32ss_t *uint32ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint32ss->used + amount > uint32ss->size) { + if (uint32ss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint32ss_resize(uint32ss->used + amount, uint32ss); + } + + return F_data_not; + } +#endif // _di_f_uint32ss_increase_by_ + +#ifndef _di_f_uint32ss_resize_ + f_status_t f_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint32ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint32ss_resize(length, uint32ss); + } +#endif // _di_f_uint32ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/uint32.h b/level_0/f_type_array/c/type_array/uint32.h new file mode 100644 index 000000000..a06177898 --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint32.h @@ -0,0 +1,377 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines data to be used for/by type (array) related functionality. + * + * This is auto-included by type_array.h and should not need to be explicitly included. + */ +#ifndef _F_type_array_uint32_h +#define _F_type_array_uint32_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Resize the string uint32s array. + * + * @param length + * The new size to use. + * @param uint32s + * The string uint32s 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(). + */ +#ifndef _di_f_uint32s_adjust_ + extern f_status_t f_uint32s_adjust(const f_array_length_t length, f_uint32s_t *uint32s); +#endif // _di_f_uint32s_adjust_ + +/** + * Append the single source uint32 onto the destination. + * + * @param source + * The source uint32 to append. + * @param destination + * The destination uint32s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint32s_append_ + extern f_status_t f_uint32s_append(const uint32_t source, f_uint32s_t *destination); +#endif // _di_f_uint32s_append_ + +/** + * Append the source uint32s onto the destination. + * + * @param source + * The source uint32s to append. + * @param destination + * The destination uint32s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint32s_append_all_ + extern f_status_t f_uint32s_append_all(const f_uint32s_t source, f_uint32s_t *destination); +#endif // _di_f_uint32s_append_all_ + +/** + * Resize the string uint32s 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 uint32s + * The string uint32s 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(). + */ +#ifndef _di_f_uint32s_decimate_by_ + extern f_status_t f_uint32s_decimate_by(const f_array_length_t amount, f_uint32s_t *uint32s); +#endif // _di_f_uint32s_decimate_by_ + +/** + * Resize the string uint32s 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 uint32s + * The string uint32s 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(). + */ +#ifndef _di_f_uint32s_decrease_by_ + extern f_status_t f_uint32s_decrease_by(const f_array_length_t amount, f_uint32s_t *uint32s); +#endif // _di_f_uint32s_decrease_by_ + +/** + * Increase the size of the string uint32s array, but only if necesary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint32s + * The string uint32s 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(). + */ +#ifndef _di_f_uint32s_increase_ + extern f_status_t f_uint32s_increase(const f_array_length_t step, f_uint32s_t *uint32s); +#endif // _di_f_uint32s_increase_ + +/** + * Resize the string uint32s array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint32s + * The string uint32s 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(). + */ +#ifndef _di_f_uint32s_increase_by_ + extern f_status_t f_uint32s_increase_by(const f_array_length_t amount, f_uint32s_t *uint32s); +#endif // _di_f_uint32s_increase_by_ + +/** + * Resize the string uint32s array. + * + * @param length + * The new size to use. + * @param uint32s + * The string uint32s 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(). + */ +#ifndef _di_f_uint32s_resize_ + extern f_status_t f_uint32s_resize(const f_array_length_t length, f_uint32s_t *uint32s); +#endif // _di_f_uint32s_resize_ + +/** + * Resize the string uint32ss array. + * + * @param length + * The new size to use. + * @param uint32ss + * The string uint32ss 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_memory_destroy(). + */ +#ifndef _di_f_uint32ss_adjust_ + extern f_status_t f_uint32ss_adjust(const f_array_length_t length, f_uint32ss_t *uint32ss); +#endif // _di_f_uint32ss_adjust_ + +/** + * Append the single source uint32s onto the destination. + * + * @param source + * The source uint32s to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint32ss_append_ + extern f_status_t f_uint32ss_append(const f_uint32s_t source, f_uint32ss_t *destination); +#endif // _di_f_uint32ss_append_ + +/** + * Append the source uint32ss onto the destination. + * + * @param source + * The source uint32ss to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint32ss_append_all_ + extern f_status_t f_uint32ss_append_all(const f_uint32ss_t source, f_uint32ss_t *destination); +#endif // _di_f_uint32ss_append_all_ + +/** + * Resize the string uint32ss 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 uint32ss + * The string uint32ss 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_memory_destroy(). + */ +#ifndef _di_f_uint32ss_decimate_by_ + extern f_status_t f_uint32ss_decimate_by(const f_array_length_t amount, f_uint32ss_t *uint32ss); +#endif // _di_f_uint32ss_decimate_by_ + +/** + * Resize the string uint32ss 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 uint32ss + * The string uint32ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint32ss_decrease_by_ + extern f_status_t f_uint32ss_decrease_by(const f_array_length_t amount, f_uint32ss_t *uint32ss); +#endif // _di_f_uint32ss_decrease_by_ + +/** + * Increase the size of the string uint32ss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint32ss + * The string uint32ss 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(). + */ +#ifndef _di_f_uint32ss_increase_ + extern f_status_t f_uint32ss_increase(const f_array_length_t step, f_uint32ss_t *uint32ss); +#endif // _di_f_uint32ss_increase_ + +/** + * Resize the string uint32ss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint32ss + * The string uint32ss 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(). + */ +#ifndef _di_f_uint32ss_increase_by_ + extern f_status_t f_uint32ss_increase_by(const f_array_length_t amount, f_uint32ss_t *uint32ss); +#endif // _di_f_uint32ss_increase_by_ + +/** + * Resize the string uint32ss array. + * + * @param length + * The new size to use. + * @param uint32ss + * The string uint32ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint32ss_resize_ + extern f_status_t f_uint32ss_resize(const f_array_length_t length, f_uint32ss_t *uint32ss); +#endif // _di_f_uint32ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_array_uint32_h diff --git a/level_0/f_type_array/c/type_array/uint64.c b/level_0/f_type_array/c/type_array/uint64.c new file mode 100644 index 000000000..ec8a048bc --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint64.c @@ -0,0 +1,290 @@ +#include "../type_array.h" +#include "uint64.h" +#include "private-uint64.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_uint64s_adjust_ + f_status_t f_uint64s_adjust(const f_array_length_t length, f_uint64s_t *uint64s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint64s_adjust(length, uint64s); + } +#endif // _di_f_uint64s_adjust_ + +#ifndef _di_f_uint64s_append_ + f_status_t f_uint64s_append(const uint64_t source, f_uint64s_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint64s_append(source, destination); + } +#endif // _di_f_uint64s_append_ + +#ifndef _di_f_uint64s_append_all_ + f_status_t f_uint64s_append_all(const f_uint64s_t source, f_uint64s_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; + + return private_f_uint64s_append_all(source, destination); + } +#endif // _di_f_uint64s_append_all_ + +#ifndef _di_f_uint64s_decimate_by_ + f_status_t f_uint64s_decimate_by(const f_array_length_t amount, f_uint64s_t *uint64s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint64s->size - amount > 0) { + return private_f_uint64s_adjust(uint64s->size - amount, uint64s); + } + + return private_f_uint64s_adjust(0, uint64s); + } +#endif // _di_f_uint64s_decimate_by_ + +#ifndef _di_f_uint64s_decrease_by_ + f_status_t f_uint64s_decrease_by(const f_array_length_t amount, f_uint64s_t *uint64s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint64s->size - amount > 0) { + return private_f_uint64s_resize(uint64s->size - amount, uint64s); + } + + return private_f_uint64s_resize(0, uint64s); + } +#endif // _di_f_uint64s_decrease_by_ + +#ifndef _di_f_uint64s_increase_ + f_status_t f_uint64s_increase(const f_array_length_t step, f_uint64s_t *uint64s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint64s->used + 1 > uint64s->size) { + f_array_length_t size = uint64s->used + step; + + if (size > F_array_length_t_size_d) { + if (uint64s->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint64s_resize(size, uint64s); + } + + return F_data_not; + } +#endif // _di_f_uint64s_increase_ + +#ifndef _di_f_uint64s_increase_by_ + f_status_t f_uint64s_increase_by(const f_array_length_t amount, f_uint64s_t *uint64s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint64s->used + amount > uint64s->size) { + if (uint64s->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint64s_resize(uint64s->used + amount, uint64s); + } + + return F_data_not; + } +#endif // _di_f_uint64s_increase_by_ + +#ifndef _di_f_uint64s_resize_ + f_status_t f_uint64s_resize(const f_array_length_t length, f_uint64s_t *uint64s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint64s_resize(length, uint64s); + } +#endif // _di_f_uint64s_resize_ + +#ifndef _di_f_uint64ss_adjust_ + f_status_t f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint64ss_adjust(length, uint64ss); + } +#endif // _di_f_uint64ss_adjust_ + +#ifndef _di_f_uint64ss_append_ + f_status_t f_uint64ss_append(const f_uint64s_t source, f_uint64ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_uint64ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_uint64s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_uint64ss_append_ + +#ifndef _di_f_uint64ss_append_all_ + f_status_t f_uint64ss_append_all(const f_uint64ss_t source, f_uint64ss_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_uint64ss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_uint64s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_uint64ss_append_all_ + +#ifndef _di_f_uint64ss_decimate_by_ + f_status_t f_uint64ss_decimate_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint64ss->size - amount > 0) { + return private_f_uint64ss_adjust(uint64ss->size - amount, uint64ss); + } + + return private_f_uint64ss_adjust(0, uint64ss); + } +#endif // _di_f_uint64ss_decimate_by_ + +#ifndef _di_f_uint64ss_decrease_by_ + f_status_t f_uint64ss_decrease_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint64ss->size - amount > 0) { + return private_f_uint64ss_resize(uint64ss->size - amount, uint64ss); + } + + return private_f_uint64ss_resize(0, uint64ss); + } +#endif // _di_f_uint64ss_decrease_by_ + +#ifndef _di_f_uint64ss_increase_ + f_status_t f_uint64ss_increase(const f_array_length_t step, f_uint64ss_t *uint64ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint64ss->used + 1 > uint64ss->size) { + f_array_length_t size = uint64ss->used + step; + + if (size > F_array_length_t_size_d) { + if (uint64ss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint64ss_resize(size, uint64ss); + } + + return F_data_not; + } +#endif // _di_f_uint64ss_increase_ + +#ifndef _di_f_uint64ss_increase_by_ + f_status_t f_uint64ss_increase_by(const f_array_length_t amount, f_uint64ss_t *uint64ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint64ss->used + amount > uint64ss->size) { + if (uint64ss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint64ss_resize(uint64ss->used + amount, uint64ss); + } + + return F_data_not; + } +#endif // _di_f_uint64ss_increase_by_ + +#ifndef _di_f_uint64ss_resize_ + f_status_t f_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint64ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint64ss_resize(length, uint64ss); + } +#endif // _di_f_uint64ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/uint64.h b/level_0/f_type_array/c/type_array/uint64.h new file mode 100644 index 000000000..0398898f6 --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint64.h @@ -0,0 +1,379 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines data to be used for/by type (array) related functionality. + * + * This is auto-included by type_array.h and should not need to be explicitly included. + */ +#ifndef _F_type_array_uint64_h +#define _F_type_array_uint64_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Resize the string uint64s array. + * + * @param length + * The new size to use. + * @param uint64s + * The string uint64s 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(). + */ +#ifndef _di_f_uint64s_adjust_ + extern f_status_t f_uint64s_adjust(const f_array_length_t length, f_uint64s_t *uint64s); +#endif // _di_f_uint64s_adjust_ + +/** + * Append the single source uint64 onto the destination. + * + * @param source + * The source uint64 to append. + * @param destination + * The destination uint64s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint64s_append_ + extern f_status_t f_uint64s_append(const uint64_t source, f_uint64s_t *destination); +#endif // _di_f_uint64s_append_ + +/** + * Append the source uint64s onto the destination. + * + * @param source + * The source uint64s to append. + * @param destination + * The destination uint64s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint64s_append_all_ + extern f_status_t f_uint64s_append_all(const f_uint64s_t source, f_uint64s_t *destination); +#endif // _di_f_uint64s_append_all_ + +/** + * Resize the string uint64s 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 uint64s + * The string uint64s 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(). + */ +#ifndef _di_f_uint64s_decimate_by_ + extern f_status_t f_uint64s_decimate_by(const f_array_length_t amount, f_uint64s_t *uint64s); +#endif // _di_f_uint64s_decimate_by_ + +/** + * Resize the string uint64s 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 uint64s + * The string uint64s 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(). + */ +#ifndef _di_f_uint64s_decrease_by_ + extern f_status_t f_uint64s_decrease_by(const f_array_length_t amount, f_uint64s_t *uint64s); +#endif // _di_f_uint64s_decrease_by_ + +/** + * Increase the size of the string uint64s array, but only if necesary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint64s + * The string uint64s 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(). + */ +#ifndef _di_f_uint64s_increase_ + extern f_status_t f_uint64s_increase(const f_array_length_t step, f_uint64s_t *uint64s); +#endif // _di_f_uint64s_increase_ + +/** + * Resize the string uint64s array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint64s + * The string uint64s 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(). + */ +#ifndef _di_f_uint64s_increase_by_ + extern f_status_t f_uint64s_increase_by(const f_array_length_t amount, f_uint64s_t *uint64s); +#endif // _di_f_uint64s_increase_by_ + +/** + * Resize the string uint64s array. + * + * @param length + * The new size to use. + * @param uint64s + * The string uint64s 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(). + */ +#ifndef _di_f_uint64s_resize_ + extern f_status_t f_uint64s_resize(const f_array_length_t length, f_uint64s_t *uint64s); +#endif // _di_f_uint64s_resize_ + +/** + * Resize the string uint64ss array. + * + * @param length + * The new size to use. + * @param uint64ss + * The string uint64ss 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_memory_destroy(). + */ +#ifndef _di_f_uint64ss_adjust_ + extern f_status_t f_uint64ss_adjust(const f_array_length_t length, f_uint64ss_t *uint64ss); +#endif // _di_f_uint64ss_adjust_ + +/** + * Append the single source uint64s onto the destination. + * + * @param source + * The source uint64s to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint64ss_append_ + extern f_status_t f_uint64ss_append(const f_uint64s_t source, f_uint64ss_t *destination); +#endif // _di_f_uint64ss_append_ + +/** + * Append the source uint64ss onto the destination. + * + * @param source + * The source uint64ss to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint64ss_append_all_ + extern f_status_t f_uint64ss_append_all(const f_uint64ss_t source, f_uint64ss_t *destination); +#endif // _di_f_uint64ss_append_all_ + +/** + * Resize the string uint64ss 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 uint64ss + * The string uint64ss 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_memory_destroy(). + */ +#ifndef _di_f_uint64ss_decimate_by_ + extern f_status_t f_uint64ss_decimate_by(const f_array_length_t amount, f_uint64ss_t *uint64ss); +#endif // _di_f_uint64ss_decimate_by_ + +/** + * Resize the string uint64ss 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 uint64ss + * The string uint64ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint64ss_decrease_by_ + extern f_status_t f_uint64ss_decrease_by(const f_array_length_t amount, f_uint64ss_t *uint64ss); +#endif // _di_f_uint64ss_decrease_by_ + +/** + * Increase the size of the string uint64ss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint64ss + * The string uint64ss 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(). + */ +#ifndef _di_f_uint64ss_increase_ + extern f_status_t f_uint64ss_increase(const f_array_length_t step, f_uint64ss_t *uint64ss); +#endif // _di_f_uint64ss_increase_ + +/** + * Resize the string uint64ss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint64ss + * The string uint64ss 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(). + */ +#ifndef _di_f_uint64ss_increase_by_ + extern f_status_t f_uint64ss_increase_by(const f_array_length_t amount, f_uint64ss_t *uint64ss); +#endif // _di_f_uint64ss_increase_by_ + +/** + * Resize the string uint64ss array. + * + * @param length + * The new size to use. + * @param uint64ss + * The string uint64ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint64ss_resize_ + extern f_status_t f_uint64ss_resize(const f_array_length_t length, f_uint64ss_t *uint64ss); +#endif // _di_f_uint64ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_array_uint64_h diff --git a/level_0/f_type_array/c/type_array/uint8.c b/level_0/f_type_array/c/type_array/uint8.c new file mode 100644 index 000000000..eaa88d884 --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint8.c @@ -0,0 +1,290 @@ +#include "../type_array.h" +#include "uint8.h" +#include "private-uint8.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_uint8s_adjust_ + f_status_t f_uint8s_adjust(const f_array_length_t length, f_uint8s_t *uint8s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint8s_adjust(length, uint8s); + } +#endif // _di_f_uint8s_adjust_ + +#ifndef _di_f_uint8s_append_ + f_status_t f_uint8s_append(const uint8_t source, f_uint8s_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint8s_append(source, destination); + } +#endif // _di_f_uint8s_append_ + +#ifndef _di_f_uint8s_append_all_ + f_status_t f_uint8s_append_all(const f_uint8s_t source, f_uint8s_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; + + return private_f_uint8s_append_all(source, destination); + } +#endif // _di_f_uint8s_append_all_ + +#ifndef _di_f_uint8s_decimate_by_ + f_status_t f_uint8s_decimate_by(const f_array_length_t amount, f_uint8s_t *uint8s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint8s->size - amount > 0) { + return private_f_uint8s_adjust(uint8s->size - amount, uint8s); + } + + return private_f_uint8s_adjust(0, uint8s); + } +#endif // _di_f_uint8s_decimate_by_ + +#ifndef _di_f_uint8s_decrease_by_ + f_status_t f_uint8s_decrease_by(const f_array_length_t amount, f_uint8s_t *uint8s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint8s->size - amount > 0) { + return private_f_uint8s_resize(uint8s->size - amount, uint8s); + } + + return private_f_uint8s_resize(0, uint8s); + } +#endif // _di_f_uint8s_decrease_by_ + +#ifndef _di_f_uint8s_increase_ + f_status_t f_uint8s_increase(const f_array_length_t step, f_uint8s_t *uint8s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint8s->used + 1 > uint8s->size) { + f_array_length_t size = uint8s->used + step; + + if (size > F_array_length_t_size_d) { + if (uint8s->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint8s_resize(size, uint8s); + } + + return F_data_not; + } +#endif // _di_f_uint8s_increase_ + +#ifndef _di_f_uint8s_increase_by_ + f_status_t f_uint8s_increase_by(const f_array_length_t amount, f_uint8s_t *uint8s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint8s->used + amount > uint8s->size) { + if (uint8s->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint8s_resize(uint8s->used + amount, uint8s); + } + + return F_data_not; + } +#endif // _di_f_uint8s_increase_by_ + +#ifndef _di_f_uint8s_resize_ + f_status_t f_uint8s_resize(const f_array_length_t length, f_uint8s_t *uint8s) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8s) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint8s_resize(length, uint8s); + } +#endif // _di_f_uint8s_resize_ + +#ifndef _di_f_uint8ss_adjust_ + f_status_t f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint8ss_adjust(length, uint8ss); + } +#endif // _di_f_uint8ss_adjust_ + +#ifndef _di_f_uint8ss_append_ + f_status_t f_uint8ss_append(const f_uint8s_t source, f_uint8ss_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; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_uint8ss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + status = private_f_uint8s_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + + ++destination->used; + + return F_none; + } +#endif // _di_f_uint8ss_append_ + +#ifndef _di_f_uint8ss_append_all_ + f_status_t f_uint8ss_append_all(const f_uint8ss_t source, f_uint8ss_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_uint8ss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_uint8s_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_uint8ss_append_all_ + +#ifndef _di_f_uint8ss_decimate_by_ + f_status_t f_uint8ss_decimate_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint8ss->size - amount > 0) { + return private_f_uint8ss_adjust(uint8ss->size - amount, uint8ss); + } + + return private_f_uint8ss_adjust(0, uint8ss); + } +#endif // _di_f_uint8ss_decimate_by_ + +#ifndef _di_f_uint8ss_decrease_by_ + f_status_t f_uint8ss_decrease_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint8ss->size - amount > 0) { + return private_f_uint8ss_resize(uint8ss->size - amount, uint8ss); + } + + return private_f_uint8ss_resize(0, uint8ss); + } +#endif // _di_f_uint8ss_decrease_by_ + +#ifndef _di_f_uint8ss_increase_ + f_status_t f_uint8ss_increase(const f_array_length_t step, f_uint8ss_t *uint8ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && uint8ss->used + 1 > uint8ss->size) { + f_array_length_t size = uint8ss->used + step; + + if (size > F_array_length_t_size_d) { + if (uint8ss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_uint8ss_resize(size, uint8ss); + } + + return F_data_not; + } +#endif // _di_f_uint8ss_increase_ + +#ifndef _di_f_uint8ss_increase_by_ + f_status_t f_uint8ss_increase_by(const f_array_length_t amount, f_uint8ss_t *uint8ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) { + return F_data_not; + } + + if (uint8ss->used + amount > uint8ss->size) { + if (uint8ss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_uint8ss_resize(uint8ss->used + amount, uint8ss); + } + + return F_data_not; + } +#endif // _di_f_uint8ss_increase_by_ + +#ifndef _di_f_uint8ss_resize_ + f_status_t f_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss) { + #ifndef _di_level_0_parameter_checking_ + if (!uint8ss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_uint8ss_resize(length, uint8ss); + } +#endif // _di_f_uint8ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/uint8.h b/level_0/f_type_array/c/type_array/uint8.h new file mode 100644 index 000000000..d9f7cf648 --- /dev/null +++ b/level_0/f_type_array/c/type_array/uint8.h @@ -0,0 +1,379 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines data to be used for/by type (array) related functionality. + * + * This is auto-included by type_array.h and should not need to be explicitly included. + */ +#ifndef _F_type_array_uint8_h +#define _F_type_array_uint8_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Resize the string uint8s array. + * + * @param length + * The new size to use. + * @param uint8s + * The string uint8s 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(). + */ +#ifndef _di_f_uint8s_adjust_ + extern f_status_t f_uint8s_adjust(const f_array_length_t length, f_uint8s_t *uint8s); +#endif // _di_f_uint8s_adjust_ + +/** + * Append the single source uint8 onto the destination. + * + * @param source + * The source uint8 to append. + * @param destination + * The destination uint8s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint8s_append_ + extern f_status_t f_uint8s_append(const uint8_t source, f_uint8s_t *destination); +#endif // _di_f_uint8s_append_ + +/** + * Append the source uint8s onto the destination. + * + * @param source + * The source uint8s to append. + * @param destination + * The destination uint8s the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint8s_append_all_ + extern f_status_t f_uint8s_append_all(const f_uint8s_t source, f_uint8s_t *destination); +#endif // _di_f_uint8s_append_all_ + +/** + * Resize the string uint8s 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 uint8s + * The string uint8s 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(). + */ +#ifndef _di_f_uint8s_decimate_by_ + extern f_status_t f_uint8s_decimate_by(const f_array_length_t amount, f_uint8s_t *uint8s); +#endif // _di_f_uint8s_decimate_by_ + +/** + * Resize the string uint8s 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 uint8s + * The string uint8s 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(). + */ +#ifndef _di_f_uint8s_decrease_by_ + extern f_status_t f_uint8s_decrease_by(const f_array_length_t amount, f_uint8s_t *uint8s); +#endif // _di_f_uint8s_decrease_by_ + +/** + * Increase the size of the string uint8s array, but only if necesary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint8s + * The string uint8s 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(). + */ +#ifndef _di_f_uint8s_increase_ + extern f_status_t f_uint8s_increase(const f_array_length_t step, f_uint8s_t *uint8s); +#endif // _di_f_uint8s_increase_ + +/** + * Resize the string uint8s array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint8s + * The string uint8s 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(). + */ +#ifndef _di_f_uint8s_increase_by_ + extern f_status_t f_uint8s_increase_by(const f_array_length_t amount, f_uint8s_t *uint8s); +#endif // _di_f_uint8s_increase_by_ + +/** + * Resize the string uint8s array. + * + * @param length + * The new size to use. + * @param uint8s + * The string uint8s 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(). + */ +#ifndef _di_f_uint8s_resize_ + extern f_status_t f_uint8s_resize(const f_array_length_t length, f_uint8s_t *uint8s); +#endif // _di_f_uint8s_resize_ + +/** + * Resize the string uint8ss array. + * + * @param length + * The new size to use. + * @param uint8ss + * The string uint8ss 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_memory_destroy(). + */ +#ifndef _di_f_uint8ss_adjust_ + extern f_status_t f_uint8ss_adjust(const f_array_length_t length, f_uint8ss_t *uint8ss); +#endif // _di_f_uint8ss_adjust_ + +/** + * Append the single source uint8s onto the destination. + * + * @param source + * The source uint8s to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint8ss_append_ + extern f_status_t f_uint8ss_append(const f_uint8s_t source, f_uint8ss_t *destination); +#endif // _di_f_uint8ss_append_ + +/** + * Append the source uint8ss onto the destination. + * + * @param source + * The source uint8ss to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint8ss_append_all_ + extern f_status_t f_uint8ss_append_all(const f_uint8ss_t source, f_uint8ss_t *destination); +#endif // _di_f_uint8ss_append_all_ + +/** + * Resize the string uint8ss 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 uint8ss + * The string uint8ss 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_memory_destroy(). + */ +#ifndef _di_f_uint8ss_decimate_by_ + extern f_status_t f_uint8ss_decimate_by(const f_array_length_t amount, f_uint8ss_t *uint8ss); +#endif // _di_f_uint8ss_decimate_by_ + +/** + * Resize the string uint8ss 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 uint8ss + * The string uint8ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint8ss_decrease_by_ + extern f_status_t f_uint8ss_decrease_by(const f_array_length_t amount, f_uint8ss_t *uint8ss); +#endif // _di_f_uint8ss_decrease_by_ + +/** + * Increase the size of the string uint8ss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint8ss + * The string uint8ss 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(). + */ +#ifndef _di_f_uint8ss_increase_ + extern f_status_t f_uint8ss_increase(const f_array_length_t step, f_uint8ss_t *uint8ss); +#endif // _di_f_uint8ss_increase_ + +/** + * Resize the string uint8ss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_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 uint8ss + * The string uint8ss 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(). + */ +#ifndef _di_f_uint8ss_increase_by_ + extern f_status_t f_uint8ss_increase_by(const f_array_length_t amount, f_uint8ss_t *uint8ss); +#endif // _di_f_uint8ss_increase_by_ + +/** + * Resize the string uint8ss array. + * + * @param length + * The new size to use. + * @param uint8ss + * The string uint8ss 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_delete(). + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_uint8ss_resize_ + extern f_status_t f_uint8ss_resize(const f_array_length_t length, f_uint8ss_t *uint8ss); +#endif // _di_f_uint8ss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_array_uint8_h diff --git a/level_0/f_type_array/data/build/settings b/level_0/f_type_array/data/build/settings index 8db520741..ac828fd7d 100644 --- a/level_0/f_type_array/data/build/settings +++ b/level_0/f_type_array/data/build/settings @@ -31,8 +31,8 @@ build_objects_library_static build_objects_program build_objects_program_shared build_objects_program_static -build_sources_library type_array/array_length.c type_array/cell.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/state.c type_array/status.c -build_sources_library type_array/private-array_length.c type_array/private-cell.c type_array/private-fll_id.c type_array/private-int8.c type_array/private-int16.c type_array/private-int32.c type_array/private-int64.c type_array/private-int128.c type_array/private-state.c type_array/private-status.c +build_sources_library type_array/array_length.c type_array/cell.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c +build_sources_library type_array/private-array_length.c type_array/private-cell.c type_array/private-fll_id.c type_array/private-int8.c type_array/private-int16.c type_array/private-int32.c type_array/private-int64.c type_array/private-int128.c type_array/private-state.c type_array/private-status.c type_array/private-uint8.c type_array/private-uint16.c type_array/private-uint32.c type_array/private-uint64.c type_array/private-uint128.c build_sources_library_shared build_sources_library_static build_sources_object @@ -41,7 +41,7 @@ build_sources_object_static build_sources_program build_sources_program_shared build_sources_program_static -build_sources_headers type_array.h type_array/common.h type_array/array_length.h type_array/cell.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/state.h type_array/status.h +build_sources_headers type_array.h type_array/common.h type_array/array_length.h type_array/cell.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h build_sources_headers_shared build_sources_headers_static build_sources_script diff --git a/level_0/f_type_array/data/build/settings-tests b/level_0/f_type_array/data/build/settings-tests index 4fcb2bd06..8873b420f 100644 --- a/level_0/f_type_array/data/build/settings-tests +++ b/level_0/f_type_array/data/build/settings-tests @@ -19,36 +19,36 @@ build_libraries-individual -lf_memory -lf_type_array build_libraries-level -lfll_0 build_libraries-monolithic -lfll -build_sources_program test-type_array-array_lengths_adjust.c test-type_array-array_lengths_append.c test-type_array-array_lengths_decimate_by.c test-type_array-array_lengths_decrease_by.c test-type_array-array_lengths_increase.c test-type_array-array_lengths_increase_by.c test-type_array-array_lengths_resize.c -build_sources_program test-type_array-array_lengthss_adjust.c test-type_array-array_lengthss_append.c test-type_array-array_lengthss_decimate_by.c test-type_array-array_lengthss_decrease_by.c test-type_array-array_lengthss_increase.c test-type_array-array_lengthss_increase_by.c test-type_array-array_lengthss_resize.c -build_sources_program test-type_array-fll_ids_adjust.c test-type_array-fll_ids_append.c test-type_array-fll_ids_decimate_by.c test-type_array-fll_ids_decrease_by.c test-type_array-fll_ids_increase.c test-type_array-fll_ids_increase_by.c test-type_array-fll_ids_resize.c -build_sources_program test-type_array-fll_idss_adjust.c test-type_array-fll_idss_append.c test-type_array-fll_idss_decimate_by.c test-type_array-fll_idss_decrease_by.c test-type_array-fll_idss_increase.c test-type_array-fll_idss_increase_by.c test-type_array-fll_idss_resize.c -build_sources_program test-type_array-cells_adjust.c test-type_array-cells_append.c test-type_array-cells_decimate_by.c test-type_array-cells_decrease_by.c test-type_array-cells_increase.c test-type_array-cells_increase_by.c test-type_array-cells_resize.c -build_sources_program test-type_array-cellss_adjust.c test-type_array-cellss_append.c test-type_array-cellss_decimate_by.c test-type_array-cellss_decrease_by.c test-type_array-cellss_increase.c test-type_array-cellss_increase_by.c test-type_array-cellss_resize.c -build_sources_program test-type_array-int8s_adjust.c test-type_array-int8s_append.c test-type_array-int8s_decimate_by.c test-type_array-int8s_decrease_by.c test-type_array-int8s_increase.c test-type_array-int8s_increase_by.c test-type_array-int8s_resize.c -build_sources_program test-type_array-int8ss_adjust.c test-type_array-int8ss_append.c test-type_array-int8ss_decimate_by.c test-type_array-int8ss_decrease_by.c test-type_array-int8ss_increase.c test-type_array-int8ss_increase_by.c test-type_array-int8ss_resize.c -build_sources_program test-type_array-int16s_adjust.c test-type_array-int16s_append.c test-type_array-int16s_decimate_by.c test-type_array-int16s_decrease_by.c test-type_array-int16s_increase.c test-type_array-int16s_increase_by.c test-type_array-int16s_resize.c -build_sources_program test-type_array-int16ss_adjust.c test-type_array-int16ss_append.c test-type_array-int16ss_decimate_by.c test-type_array-int16ss_decrease_by.c test-type_array-int16ss_increase.c test-type_array-int16ss_increase_by.c test-type_array-int16ss_resize.c -build_sources_program test-type_array-int32s_adjust.c test-type_array-int32s_append.c test-type_array-int32s_decimate_by.c test-type_array-int32s_decrease_by.c test-type_array-int32s_increase.c test-type_array-int32s_increase_by.c test-type_array-int32s_resize.c -build_sources_program test-type_array-int32ss_adjust.c test-type_array-int32ss_append.c test-type_array-int32ss_decimate_by.c test-type_array-int32ss_decrease_by.c test-type_array-int32ss_increase.c test-type_array-int32ss_increase_by.c test-type_array-int32ss_resize.c -build_sources_program test-type_array-int64s_adjust.c test-type_array-int64s_append.c test-type_array-int64s_decimate_by.c test-type_array-int64s_decrease_by.c test-type_array-int64s_increase.c test-type_array-int64s_increase_by.c test-type_array-int64s_resize.c -build_sources_program test-type_array-int64ss_adjust.c test-type_array-int64ss_append.c test-type_array-int64ss_decimate_by.c test-type_array-int64ss_decrease_by.c test-type_array-int64ss_increase.c test-type_array-int64ss_increase_by.c test-type_array-int64ss_resize.c -build_sources_program test-type_array-int128s_adjust.c test-type_array-int128s_append.c test-type_array-int128s_decimate_by.c test-type_array-int128s_decrease_by.c test-type_array-int128s_increase.c test-type_array-int128s_increase_by.c test-type_array-int128s_resize.c -build_sources_program test-type_array-int128ss_adjust.c test-type_array-int128ss_append.c test-type_array-int128ss_decimate_by.c test-type_array-int128ss_decrease_by.c test-type_array-int128ss_increase.c test-type_array-int128ss_increase_by.c test-type_array-int128ss_resize.c -build_sources_program test-type_array-states_adjust.c test-type_array-states_append.c test-type_array-states_decimate_by.c test-type_array-states_decrease_by.c test-type_array-states_increase.c test-type_array-states_increase_by.c test-type_array-states_resize.c -build_sources_program test-type_array-statess_adjust.c test-type_array-statess_append.c test-type_array-statess_decimate_by.c test-type_array-statess_decrease_by.c test-type_array-statess_increase.c test-type_array-statess_increase_by.c test-type_array-statess_resize.c -build_sources_program test-type_array-statuss_adjust.c test-type_array-statuss_append.c test-type_array-statuss_decimate_by.c test-type_array-statuss_decrease_by.c test-type_array-statuss_increase.c test-type_array-statuss_increase_by.c test-type_array-statuss_resize.c -build_sources_program test-type_array-statusss_adjust.c test-type_array-statusss_append.c test-type_array-statusss_decimate_by.c test-type_array-statusss_decrease_by.c test-type_array-statusss_increase.c test-type_array-statusss_increase_by.c test-type_array-statusss_resize.c -build_sources_program test-type_array-uint8s_adjust.c test-type_array-uint8s_append.c test-type_array-uint8s_decimate_by.c test-type_array-uint8s_decrease_by.c test-type_array-uint8s_increase.c test-type_array-uint8s_increase_by.c test-type_array-uint8s_resize.c -build_sources_program test-type_array-uint8ss_adjust.c test-type_array-uint8ss_append.c test-type_array-uint8ss_decimate_by.c test-type_array-uint8ss_decrease_by.c test-type_array-uint8ss_increase.c test-type_array-uint8ss_increase_by.c test-type_array-uint8ss_resize.c -build_sources_program test-type_array-uint16s_adjust.c test-type_array-uint16s_append.c test-type_array-uint16s_decimate_by.c test-type_array-uint16s_decrease_by.c test-type_array-uint16s_increase.c test-type_array-uint16s_increase_by.c test-type_array-uint16s_resize.c -build_sources_program test-type_array-uint16ss_adjust.c test-type_array-uint16ss_append.c test-type_array-uint16ss_decimate_by.c test-type_array-uint16ss_decrease_by.c test-type_array-uint16ss_increase.c test-type_array-uint16ss_increase_by.c test-type_array-uint16ss_resize.c -build_sources_program test-type_array-uint32s_adjust.c test-type_array-uint32s_append.c test-type_array-uint32s_decimate_by.c test-type_array-uint32s_decrease_by.c test-type_array-uint32s_increase.c test-type_array-uint32s_increase_by.c test-type_array-uint32s_resize.c -build_sources_program test-type_array-uint32ss_adjust.c test-type_array-uint32ss_append.c test-type_array-uint32ss_decimate_by.c test-type_array-uint32ss_decrease_by.c test-type_array-uint32ss_increase.c test-type_array-uint32ss_increase_by.c test-type_array-uint32ss_resize.c -build_sources_program test-type_array-uint64s_adjust.c test-type_array-uint64s_append.c test-type_array-uint64s_decimate_by.c test-type_array-uint64s_decrease_by.c test-type_array-uint64s_increase.c test-type_array-uint64s_increase_by.c test-type_array-uint64s_resize.c -build_sources_program test-type_array-uint64ss_adjust.c test-type_array-uint64ss_append.c test-type_array-uint64ss_decimate_by.c test-type_array-uint64ss_decrease_by.c test-type_array-uint64ss_increase.c test-type_array-uint64ss_increase_by.c test-type_array-uint64ss_resize.c -build_sources_program test-type_array-uint128s_adjust.c test-type_array-uint128s_append.c test-type_array-uint128s_decimate_by.c test-type_array-uint128s_decrease_by.c test-type_array-uint128s_increase.c test-type_array-uint128s_increase_by.c test-type_array-uint128s_resize.c -build_sources_program test-type_array-uint128ss_adjust.c test-type_array-uint128ss_append.c test-type_array-uint128ss_decimate_by.c test-type_array-uint128ss_decrease_by.c test-type_array-uint128ss_increase.c test-type_array-uint128ss_increase_by.c test-type_array-uint128ss_resize.c +build_sources_program test-type_array-array_lengths_adjust.c test-type_array-array_lengths_append.c test-type_array-array_lengths_append_all.c test-type_array-array_lengths_decimate_by.c test-type_array-array_lengths_decrease_by.c test-type_array-array_lengths_increase.c test-type_array-array_lengths_increase_by.c test-type_array-array_lengths_resize.c +build_sources_program test-type_array-array_lengthss_adjust.c test-type_array-array_lengthss_append.c test-type_array-array_lengthss_append_all.c test-type_array-array_lengthss_decimate_by.c test-type_array-array_lengthss_decrease_by.c test-type_array-array_lengthss_increase.c test-type_array-array_lengthss_increase_by.c test-type_array-array_lengthss_resize.c +build_sources_program test-type_array-fll_ids_adjust.c test-type_array-fll_ids_append.c test-type_array-fll_ids_append_all.c test-type_array-fll_ids_decimate_by.c test-type_array-fll_ids_decrease_by.c test-type_array-fll_ids_increase.c test-type_array-fll_ids_increase_by.c test-type_array-fll_ids_resize.c +build_sources_program test-type_array-fll_idss_adjust.c test-type_array-fll_idss_append.c test-type_array-fll_idss_append_all.c test-type_array-fll_idss_decimate_by.c test-type_array-fll_idss_decrease_by.c test-type_array-fll_idss_increase.c test-type_array-fll_idss_increase_by.c test-type_array-fll_idss_resize.c +build_sources_program test-type_array-cells_adjust.c test-type_array-cells_append.c test-type_array-cells_append_all.c test-type_array-cells_decimate_by.c test-type_array-cells_decrease_by.c test-type_array-cells_increase.c test-type_array-cells_increase_by.c test-type_array-cells_resize.c +build_sources_program test-type_array-cellss_adjust.c test-type_array-cellss_append.c test-type_array-cellss_append_all.c test-type_array-cellss_decimate_by.c test-type_array-cellss_decrease_by.c test-type_array-cellss_increase.c test-type_array-cellss_increase_by.c test-type_array-cellss_resize.c +build_sources_program test-type_array-int8s_adjust.c test-type_array-int8s_append.c test-type_array-int8s_append_all.c test-type_array-int8s_decimate_by.c test-type_array-int8s_decrease_by.c test-type_array-int8s_increase.c test-type_array-int8s_increase_by.c test-type_array-int8s_resize.c +build_sources_program test-type_array-int8ss_adjust.c test-type_array-int8ss_append.c test-type_array-int8ss_append_all.c test-type_array-int8ss_decimate_by.c test-type_array-int8ss_decrease_by.c test-type_array-int8ss_increase.c test-type_array-int8ss_increase_by.c test-type_array-int8ss_resize.c +build_sources_program test-type_array-int16s_adjust.c test-type_array-int16s_append.c test-type_array-int16s_append_all.c test-type_array-int16s_decimate_by.c test-type_array-int16s_decrease_by.c test-type_array-int16s_increase.c test-type_array-int16s_increase_by.c test-type_array-int16s_resize.c +build_sources_program test-type_array-int16ss_adjust.c test-type_array-int16ss_append.c test-type_array-int16ss_append_all.c test-type_array-int16ss_decimate_by.c test-type_array-int16ss_decrease_by.c test-type_array-int16ss_increase.c test-type_array-int16ss_increase_by.c test-type_array-int16ss_resize.c +build_sources_program test-type_array-int32s_adjust.c test-type_array-int32s_append.c test-type_array-int32s_append_all.c test-type_array-int32s_decimate_by.c test-type_array-int32s_decrease_by.c test-type_array-int32s_increase.c test-type_array-int32s_increase_by.c test-type_array-int32s_resize.c +build_sources_program test-type_array-int32ss_adjust.c test-type_array-int32ss_append.c test-type_array-int32ss_append_all.c test-type_array-int32ss_decimate_by.c test-type_array-int32ss_decrease_by.c test-type_array-int32ss_increase.c test-type_array-int32ss_increase_by.c test-type_array-int32ss_resize.c +build_sources_program test-type_array-int64s_adjust.c test-type_array-int64s_append.c test-type_array-int64s_append_all.c test-type_array-int64s_decimate_by.c test-type_array-int64s_decrease_by.c test-type_array-int64s_increase.c test-type_array-int64s_increase_by.c test-type_array-int64s_resize.c +build_sources_program test-type_array-int64ss_adjust.c test-type_array-int64ss_append.c test-type_array-int64ss_append_all.c test-type_array-int64ss_decimate_by.c test-type_array-int64ss_decrease_by.c test-type_array-int64ss_increase.c test-type_array-int64ss_increase_by.c test-type_array-int64ss_resize.c +build_sources_program test-type_array-int128s_adjust.c test-type_array-int128s_append.c test-type_array-int128s_append_all.c test-type_array-int128s_decimate_by.c test-type_array-int128s_decrease_by.c test-type_array-int128s_increase.c test-type_array-int128s_increase_by.c test-type_array-int128s_resize.c +build_sources_program test-type_array-int128ss_adjust.c test-type_array-int128ss_append.c test-type_array-int128ss_append_all.c test-type_array-int128ss_decimate_by.c test-type_array-int128ss_decrease_by.c test-type_array-int128ss_increase.c test-type_array-int128ss_increase_by.c test-type_array-int128ss_resize.c +build_sources_program test-type_array-states_adjust.c test-type_array-states_append.c test-type_array-states_append_all.c test-type_array-states_decimate_by.c test-type_array-states_decrease_by.c test-type_array-states_increase.c test-type_array-states_increase_by.c test-type_array-states_resize.c +build_sources_program test-type_array-statess_adjust.c test-type_array-statess_append.c test-type_array-statess_append_all.c test-type_array-statess_decimate_by.c test-type_array-statess_decrease_by.c test-type_array-statess_increase.c test-type_array-statess_increase_by.c test-type_array-statess_resize.c +build_sources_program test-type_array-statuss_adjust.c test-type_array-statuss_append.c test-type_array-statuss_append_all.c test-type_array-statuss_decimate_by.c test-type_array-statuss_decrease_by.c test-type_array-statuss_increase.c test-type_array-statuss_increase_by.c test-type_array-statuss_resize.c +build_sources_program test-type_array-statusss_adjust.c test-type_array-statusss_append.c test-type_array-statusss_append_all.c test-type_array-statusss_decimate_by.c test-type_array-statusss_decrease_by.c test-type_array-statusss_increase.c test-type_array-statusss_increase_by.c test-type_array-statusss_resize.c +build_sources_program test-type_array-uint8s_adjust.c test-type_array-uint8s_append.c test-type_array-uint8s_append_all.c test-type_array-uint8s_decimate_by.c test-type_array-uint8s_decrease_by.c test-type_array-uint8s_increase.c test-type_array-uint8s_increase_by.c test-type_array-uint8s_resize.c +build_sources_program test-type_array-uint8ss_adjust.c test-type_array-uint8ss_append.c test-type_array-uint8ss_append_all.c test-type_array-uint8ss_decimate_by.c test-type_array-uint8ss_decrease_by.c test-type_array-uint8ss_increase.c test-type_array-uint8ss_increase_by.c test-type_array-uint8ss_resize.c +build_sources_program test-type_array-uint16s_adjust.c test-type_array-uint16s_append.c test-type_array-uint16s_append_all.c test-type_array-uint16s_decimate_by.c test-type_array-uint16s_decrease_by.c test-type_array-uint16s_increase.c test-type_array-uint16s_increase_by.c test-type_array-uint16s_resize.c +build_sources_program test-type_array-uint16ss_adjust.c test-type_array-uint16ss_append.c test-type_array-uint16ss_append_all.c test-type_array-uint16ss_decimate_by.c test-type_array-uint16ss_decrease_by.c test-type_array-uint16ss_increase.c test-type_array-uint16ss_increase_by.c test-type_array-uint16ss_resize.c +build_sources_program test-type_array-uint32s_adjust.c test-type_array-uint32s_append.c test-type_array-uint32s_append_all.c test-type_array-uint32s_decimate_by.c test-type_array-uint32s_decrease_by.c test-type_array-uint32s_increase.c test-type_array-uint32s_increase_by.c test-type_array-uint32s_resize.c +build_sources_program test-type_array-uint32ss_adjust.c test-type_array-uint32ss_append.c test-type_array-uint32ss_append_all.c test-type_array-uint32ss_decimate_by.c test-type_array-uint32ss_decrease_by.c test-type_array-uint32ss_increase.c test-type_array-uint32ss_increase_by.c test-type_array-uint32ss_resize.c +build_sources_program test-type_array-uint64s_adjust.c test-type_array-uint64s_append.c test-type_array-uint64s_append_all.c test-type_array-uint64s_decimate_by.c test-type_array-uint64s_decrease_by.c test-type_array-uint64s_increase.c test-type_array-uint64s_increase_by.c test-type_array-uint64s_resize.c +build_sources_program test-type_array-uint64ss_adjust.c test-type_array-uint64ss_append.c test-type_array-uint64ss_append_all.c test-type_array-uint64ss_decimate_by.c test-type_array-uint64ss_decrease_by.c test-type_array-uint64ss_increase.c test-type_array-uint64ss_increase_by.c test-type_array-uint64ss_resize.c +build_sources_program test-type_array-uint128s_adjust.c test-type_array-uint128s_append.c test-type_array-uint128s_append_all.c test-type_array-uint128s_decimate_by.c test-type_array-uint128s_decrease_by.c test-type_array-uint128s_increase.c test-type_array-uint128s_increase_by.c test-type_array-uint128s_resize.c +build_sources_program test-type_array-uint128ss_adjust.c test-type_array-uint128ss_append.c test-type_array-uint128ss_append_all.c test-type_array-uint128ss_decimate_by.c test-type_array-uint128ss_decrease_by.c test-type_array-uint128ss_increase.c test-type_array-uint128ss_increase_by.c test-type_array-uint128ss_resize.c build_sources_program test-type_array.c build_script no diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_adjust.c index 90c9a84a6..d58020d47 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_array_lengths_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_array_lengths_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengths_adjust__parameter_checking(void **state) { const int length = 5; f_array_lengths_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_adjust.h index 431fa8265..f59c7d317 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengths_adjust__works(void **state); * * @see f_type_array_array_lengths_adjust() */ -extern void test__f_type_array_array_lengths_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengths_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengths_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append.c index db56b6694..8e63f9473 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_array_lengths_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_array_lengths_t source = f_array_lengths_t_initialize; + const f_array_length_t source = 3; f_array_lengths_t destination = f_array_lengths_t_initialize; - { - const f_status_t status = f_array_lengths_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_array_lengths_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_array_lengths_append__returns_data_not(void **state) { +void test__f_type_array_array_lengths_append__parameter_checking(void **state) { - const int length = 5; - f_array_lengths_t source = f_array_lengths_t_initialize; - f_array_lengths_t destination = f_array_lengths_t_initialize; - - { - const f_status_t status = f_array_lengths_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_array_lengths_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_array_lengths_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_array_lengths_t data = f_array_lengths_t_initialize; + const f_array_length_t data = f_array_length_t_initialize; { const f_status_t status = f_array_lengths_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append.h index 366669eca..de1290cee 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_array_lengths_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_array_lengths_append() - */ -extern void test__f_type_array_array_lengths_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_array_lengths_append() */ -extern void test__f_type_array_array_lengths_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengths_append__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengths_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append_all.c new file mode 100644 index 000000000..144a80d84 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengths_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengths_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_array_lengths_t source = f_array_lengths_t_initialize; + f_array_lengths_t destination = f_array_lengths_t_initialize; + + { + const f_status_t status = f_array_lengths_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_array_lengths_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_array_lengths_append_all__returns_data_not(void **state) { + + const int length = 5; + f_array_lengths_t source = f_array_lengths_t_initialize; + f_array_lengths_t destination = f_array_lengths_t_initialize; + + { + const f_status_t status = f_array_lengths_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_array_lengths_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_array_lengths_append_all__parameter_checking(void **state) { + + const f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_array_lengths_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append_all.h new file mode 100644 index 000000000..0cf641ba7 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengths_append_all +#define _TEST__F_type_array__array_lengths_append_all + +/** + * Test that the function works. + * + * @see f_type_array_array_lengths_append_all() + */ +extern void test__f_type_array_array_lengths_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_array_lengths_append_all() + */ +extern void test__f_type_array_array_lengths_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengths_append_all() + */ +extern void test__f_type_array_array_lengths_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__array_lengths_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decimate_by.c index f24803234..5150b8f90 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_array_lengths_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_array_lengths_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengths_decimate_by__parameter_checking(void **state) { const int length = 5; f_array_lengths_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decimate_by.h index ae9599783..84d569fc2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengths_decimate_by__works(void **state); * * @see f_type_array_array_lengths_decimate_by() */ -extern void test__f_type_array_array_lengths_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengths_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengths_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decrease_by.c index c6c9ba80f..92f43662b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_array_lengths_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_array_lengths_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengths_decrease_by__parameter_checking(void **state) { const int length = 5; f_array_lengths_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decrease_by.h index 3197742b9..131b6d9cc 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengths_decrease_by__works(void **state); * * @see f_type_array_array_lengths_decrease_by() */ -extern void test__f_type_array_array_lengths_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengths_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengths_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase.c index 8aacad3ac..5b88f6026 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_array_lengths_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_array_lengths_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_array_lengths_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengths_increase__parameter_checking(void **state) { const int length = 5; f_array_lengths_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase.h index 9e5d4c1d2..bf89633b2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_array_lengths_increase__returns_data_not(void **s * * @see f_type_array_array_lengths_increase() */ -extern void test__f_type_array_array_lengths_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengths_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengths_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase_by.c index 98f468052..bb83dce59 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_array_lengths_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_array_lengths_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengths_increase_by__parameter_checking(void **state) { const int length = 5; f_array_lengths_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase_by.h index 99cfc3047..820cfa38b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengths_increase_by__works(void **state); * * @see f_type_array_array_lengths_increase_by() */ -extern void test__f_type_array_array_lengths_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengths_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengths_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_resize.c index 5ac149856..1c655c4ce 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_array_lengths_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_array_lengths_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengths_resize__parameter_checking(void **state) { const int length = 5; f_array_lengths_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_resize.h index 297f223dd..648b40fa5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengths_resize__works(void **state); * * @see f_type_array_array_lengths_resize() */ -extern void test__f_type_array_array_lengths_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengths_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengths_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_adjust.c index 1de770f9e..a691c7eb5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_array_lengthss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_array_lengthss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengthss_adjust__parameter_checking(void **state) { const int length = 5; f_array_lengthss_t data = f_array_lengthss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_adjust.h index c75c5aeda..49ac75a8c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengthss_adjust__works(void **state); * * @see f_type_array_array_lengthss_adjust() */ -extern void test__f_type_array_array_lengthss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengthss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengthss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append.c index 161c26317..53d7abdbd 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append.c @@ -9,52 +9,34 @@ void test__f_type_array_array_lengthss_append__works(void **state) { const int length = 5; const int length_inner = 2; - f_array_lengthss_t source = f_array_lengths_t_initialize; - f_array_lengthss_t destination = f_array_lengths_t_initialize; + f_array_lengths_t source = f_array_lengths_t_initialize; + f_array_lengthss_t destination = f_array_lengthss_t_initialize; { - const f_status_t status = f_array_lengthss_resize(length, &source); + const f_status_t status = f_array_lengths_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_array_lengths_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_array_lengthss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +48,11 @@ void test__f_type_array_array_lengthss_append__works(void **state) { void test__f_type_array_array_lengthss_append__returns_data_not(void **state) { const int length = 5; - f_array_lengthss_t source = f_array_lengths_t_initialize; - f_array_lengthss_t destination = f_array_lengths_t_initialize; + f_array_lengths_t source = f_array_lengths_t_initialize; + f_array_lengthss_t destination = f_array_lengthss_t_initialize; { - const f_status_t status = f_array_lengthss_resize(length, &source); + const f_status_t status = f_array_lengths_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +65,21 @@ void test__f_type_array_array_lengthss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_array_lengthss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengthss_append__parameter_checking(void **state) { - const int length = 5; - f_array_lengthss_t data = f_array_lengths_t_initialize; + const f_array_lengths_t data = f_array_lengths_t_initialize; { const f_status_t status = f_array_lengthss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append.h index 451b2e080..26855d6fa 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_array_lengthss_append__returns_data_not(void **st * * @see f_type_array_array_lengthss_append() */ -extern void test__f_type_array_array_lengthss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengthss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengthss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append_all.c new file mode 100644 index 000000000..213257b64 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengthss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengthss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_array_lengthss_t source = f_array_lengthss_t_initialize; + f_array_lengthss_t destination = f_array_lengthss_t_initialize; + + { + const f_status_t status = f_array_lengthss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_array_lengths_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_array_lengthss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_array_lengthss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_array_lengthss_t source = f_array_lengthss_t_initialize; + f_array_lengthss_t destination = f_array_lengthss_t_initialize; + + { + const f_status_t status = f_array_lengthss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_array_lengthss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_array_lengthss_append_all__parameter_checking(void **state) { + + const f_array_lengthss_t data = f_array_lengthss_t_initialize; + + { + const f_status_t status = f_array_lengthss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append_all.h new file mode 100644 index 000000000..497d99c17 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengthss_append_all +#define _TEST__F_type_array__array_lengthss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_array_lengthss_append_all() + */ +extern void test__f_type_array_array_lengthss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_array_lengthss_append_all() + */ +extern void test__f_type_array_array_lengthss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengthss_append_all() + */ +extern void test__f_type_array_array_lengthss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__array_lengthss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decimate_by.c index e01550af4..911307f31 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_array_lengthss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_array_lengthss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengthss_decimate_by__parameter_checking(void **state) { const int length = 5; f_array_lengthss_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decimate_by.h index f1ca46562..b4248034a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengthss_decimate_by__works(void **state); * * @see f_type_array_array_lengthss_decimate_by() */ -extern void test__f_type_array_array_lengthss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengthss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengthss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decrease_by.c index 2c83fba69..0a092ad39 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_array_lengthss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_array_lengthss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengthss_decrease_by__parameter_checking(void **state) { const int length = 5; f_array_lengthss_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decrease_by.h index 02b5980a7..75c840d29 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengthss_decrease_by__works(void **state); * * @see f_type_array_array_lengthss_decrease_by() */ -extern void test__f_type_array_array_lengthss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengthss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengthss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase.c index 089e8e721..d5ada76cd 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_array_lengthss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_array_lengthss_increase__returns_data_not(void **state) free((void *) data.array); } -void test__f_type_array_array_lengthss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengthss_increase__parameter_checking(void **state) { const int length = 5; f_array_lengthss_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase.h index 88a71cb12..678879300 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_array_lengthss_increase__returns_data_not(void ** * * @see f_type_array_array_lengthss_increase() */ -extern void test__f_type_array_array_lengthss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengthss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengthss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase_by.c index 8fa183502..5bbbbf17d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_array_lengthss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_array_lengthss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengthss_increase_by__parameter_checking(void **state) { const int length = 5; f_array_lengthss_t data = f_array_lengths_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase_by.h index 05eb52650..789f8e12b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengthss_increase_by__works(void **state); * * @see f_type_array_array_lengthss_increase_by() */ -extern void test__f_type_array_array_lengthss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengthss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengthss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_resize.c index 2435445bc..a2d030f7b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_array_lengthss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_array_lengthss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_array_lengthss_resize__parameter_checking(void **state) { const int length = 5; f_array_lengthss_t data = f_array_lengthss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_resize.h index a8fd772ec..0011f3276 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_array_lengthss_resize__works(void **state); * * @see f_type_array_array_lengthss_resize() */ -extern void test__f_type_array_array_lengthss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_array_lengthss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__array_lengthss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-cells_adjust.c index a221c69ad..4dbf3a401 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_cells_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_cells_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cells_adjust__parameter_checking(void **state) { const int length = 5; f_cells_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-cells_adjust.h index 49443d389..53d4c6344 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cells_adjust__works(void **state); * * @see f_type_array_cells_adjust() */ -extern void test__f_type_array_cells_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cells_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__cells_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-cells_append.c index 605d3a0cd..195145612 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_append.c @@ -7,82 +7,30 @@ extern "C" { void test__f_type_array_cells_append__works(void **state) { - const int length = 5; - f_cells_t source = f_cells_t_initialize; + const f_cell_t source = { .row = 1, .column = 2 }; f_cells_t destination = f_cells_t_initialize; - const f_cell_t cell_0 = { .row = 1, .column = 2 }; - const f_cell_t cell_1 = { .row = 3, .column = 4 }; - - { - const f_status_t status = f_cells_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - memcpy(&source.array[source.used++], (void *) &cell_0, sizeof(f_cell_t)); - memcpy(&source.array[source.used++], (void *) &cell_1, sizeof(f_cell_t)); - { const f_status_t status = f_cells_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - assert_int_equal(destination.array[0].row, cell_0.row); - assert_int_equal(destination.array[0].column, cell_0.column); - - assert_int_equal(destination.array[1].row, cell_1.row); - assert_int_equal(destination.array[1].column, cell_1.column); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].row, source.row); + assert_int_equal(destination.array[0].column, source.column); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_cells_append__returns_data_not(void **state) { +void test__f_type_array_cells_append__parameter_checking(void **state) { - const int length = 5; - f_cells_t source = f_cells_t_initialize; - f_cells_t destination = f_cells_t_initialize; - - { - const f_status_t status = f_cells_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_cells_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_cells_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_cells_t data = f_cells_t_initialize; + const f_cell_t data = f_cell_t_initialize; { const f_status_t status = f_cells_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-cells_append.h index e5145842e..ba16169cb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_cells_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_cells_append() - */ -extern void test__f_type_array_cells_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_cells_append() */ -extern void test__f_type_array_cells_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cells_append__parameter_checking(void **state); #endif // _TEST__F_type_array__cells_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-cells_append_all.c new file mode 100644 index 000000000..071c2b10e --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_append_all.c @@ -0,0 +1,85 @@ +#include "test-type_array.h" +#include "test-type_array-cells_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cells_append_all__works(void **state) { + + const int length = 5; + f_cells_t source = f_cells_t_initialize; + f_cells_t destination = f_cells_t_initialize; + + const f_cell_t cell_0 = { .row = 1, .column = 2 }; + const f_cell_t cell_1 = { .row = 3, .column = 4 }; + + { + const f_status_t status = f_cells_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + memcpy(&source.array[source.used++], (void *) &cell_0, sizeof(f_cell_t)); + memcpy(&source.array[source.used++], (void *) &cell_1, sizeof(f_cell_t)); + + { + const f_status_t status = f_cells_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + assert_int_equal(destination.array[0].row, cell_0.row); + assert_int_equal(destination.array[0].column, cell_0.column); + + assert_int_equal(destination.array[1].row, cell_1.row); + assert_int_equal(destination.array[1].column, cell_1.column); + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_cells_append_all__returns_data_not(void **state) { + + const int length = 5; + f_cells_t source = f_cells_t_initialize; + f_cells_t destination = f_cells_t_initialize; + + { + const f_status_t status = f_cells_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_cells_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_cells_append_all__parameter_checking(void **state) { + + const f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_cells_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-cells_append_all.h new file mode 100644 index 000000000..31cd25913 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cells_append_all +#define _TEST__F_type_array__cells_append_all + +/** + * Test that the function works. + * + * @see f_type_array_cells_append_all() + */ +extern void test__f_type_array_cells_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_cells_append_all() + */ +extern void test__f_type_array_cells_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cells_append_all() + */ +extern void test__f_type_array_cells_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__cells_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-cells_decimate_by.c index d415836d3..a9bf7b06d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_cells_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_cells_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cells_decimate_by__parameter_checking(void **state) { const int length = 5; f_cells_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-cells_decimate_by.h index 0d3fcbc33..b689fff2a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cells_decimate_by__works(void **state); * * @see f_type_array_cells_decimate_by() */ -extern void test__f_type_array_cells_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cells_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__cells_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-cells_decrease_by.c index 93dee61b9..bd44d1b30 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_cells_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_cells_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cells_decrease_by__parameter_checking(void **state) { const int length = 5; f_cells_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-cells_decrease_by.h index abb091ea6..09d89d339 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cells_decrease_by__works(void **state); * * @see f_type_array_cells_decrease_by() */ -extern void test__f_type_array_cells_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cells_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__cells_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase.c index 926ad2ca1..7842295d6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_cells_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_cells_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_cells_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cells_increase__parameter_checking(void **state) { const int length = 5; f_cells_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase.h index cf7d40891..81964f4e3 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_cells_increase__returns_data_not(void **state); * * @see f_type_array_cells_increase() */ -extern void test__f_type_array_cells_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cells_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__cells_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase_by.c index 3a53c5394..ed71d469d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_cells_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_cells_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cells_increase_by__parameter_checking(void **state) { const int length = 5; f_cells_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase_by.h index b55f0817a..f3daa7817 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cells_increase_by__works(void **state); * * @see f_type_array_cells_increase_by() */ -extern void test__f_type_array_cells_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cells_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__cells_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-cells_resize.c index af1fec9f7..35e6699c1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_cells_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_cells_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cells_resize__parameter_checking(void **state) { const int length = 5; f_cells_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cells_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-cells_resize.h index f263e6b06..b89bdf8a7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cells_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cells_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cells_resize__works(void **state); * * @see f_type_array_cells_resize() */ -extern void test__f_type_array_cells_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cells_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__cells_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_adjust.c index aadc7cd9e..b44fcf28e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_cellss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_cellss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cellss_adjust__parameter_checking(void **state) { const int length = 5; f_cellss_t data = f_cellss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_adjust.h index 1111bdc0c..b4d07e758 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cellss_adjust__works(void **state); * * @see f_type_array_cellss_adjust() */ -extern void test__f_type_array_cellss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cellss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__cellss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append.c index 4f6d3453f..9cbefbd7e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append.c @@ -8,57 +8,38 @@ extern "C" { void test__f_type_array_cellss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_cellss_t source = f_cells_t_initialize; - f_cellss_t destination = f_cells_t_initialize; + f_cells_t source = f_cells_t_initialize; + f_cellss_t destination = f_cellss_t_initialize; - const f_cell_t cell_0 = { .row = 1, .column = 2 }; - const f_cell_t cell_1 = { .row = 3, .column = 4 }; + const f_cell_t cell = { .row = 1, .column = 2 }; { - const f_status_t status = f_cellss_resize(length, &source); + const f_status_t status = f_cells_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_cells_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &cell_0, sizeof(f_cell_t)); - memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &cell_1, sizeof(f_cell_t)); - } // for - } + while (source.used < length) { + memcpy(&source.array[source.used++], (void *) &cell, sizeof(f_cell_t)); + } // while { const f_status_t status = f_cellss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - assert_int_equal(destination.array[i].array[0].row, cell_0.row); - assert_int_equal(destination.array[i].array[0].column, cell_0.column); - - assert_int_equal(destination.array[i].array[1].row, cell_1.row); - assert_int_equal(destination.array[i].array[1].column, cell_1.column); + assert_int_equal(destination.array[0].array[i].row, cell.row); + assert_int_equal(destination.array[0].array[i].column, cell.column); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -70,11 +51,11 @@ void test__f_type_array_cellss_append__works(void **state) { void test__f_type_array_cellss_append__returns_data_not(void **state) { const int length = 5; - f_cellss_t source = f_cells_t_initialize; - f_cellss_t destination = f_cells_t_initialize; + f_cells_t source = f_cellss_t_initialize; + f_cellss_t destination = f_cellss_t_initialize; { - const f_status_t status = f_cellss_resize(length, &source); + const f_status_t status = f_cells_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -87,26 +68,21 @@ void test__f_type_array_cellss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_cellss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cellss_append__parameter_checking(void **state) { - const int length = 5; - f_cellss_t data = f_cells_t_initialize; + f_cells_t data = f_cells_t_initialize; { const f_status_t status = f_cellss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append.h index 74f4c784f..cc487251d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_cellss_append__returns_data_not(void **state); * * @see f_type_array_cellss_append() */ -extern void test__f_type_array_cellss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cellss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__cellss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append_all.c new file mode 100644 index 000000000..b7a193259 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append_all.c @@ -0,0 +1,109 @@ +#include "test-type_array.h" +#include "test-type_array-cellss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cellss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_cellss_t source = f_cellss_t_initialize; + f_cellss_t destination = f_cellss_t_initialize; + + const f_cell_t cell_0 = { .row = 1, .column = 2 }; + const f_cell_t cell_1 = { .row = 3, .column = 4 }; + + { + const f_status_t status = f_cellss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_cells_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &cell_0, sizeof(f_cell_t)); + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &cell_1, sizeof(f_cell_t)); + } // for + } + + { + const f_status_t status = f_cellss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + assert_int_equal(destination.array[i].array[0].row, cell_0.row); + assert_int_equal(destination.array[i].array[0].column, cell_0.column); + + assert_int_equal(destination.array[i].array[1].row, cell_1.row); + assert_int_equal(destination.array[i].array[1].column, cell_1.column); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_cellss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_cellss_t source = f_cellss_t_initialize; + f_cellss_t destination = f_cellss_t_initialize; + + { + const f_status_t status = f_cellss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_cellss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_cellss_append_all__parameter_checking(void **state) { + + const f_cellss_t data = f_cellss_t_initialize; + + { + const f_status_t status = f_cellss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append_all.h new file mode 100644 index 000000000..2721cddef --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cellss_append_all +#define _TEST__F_type_array__cellss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_cellss_append_all() + */ +extern void test__f_type_array_cellss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_cellss_append_all() + */ +extern void test__f_type_array_cellss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cellss_append_all() + */ +extern void test__f_type_array_cellss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__cellss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decimate_by.c index 4c0dcad56..abc400c21 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_cellss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_cellss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cellss_decimate_by__parameter_checking(void **state) { const int length = 5; f_cellss_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decimate_by.h index 93509eed2..3f4382528 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cellss_decimate_by__works(void **state); * * @see f_type_array_cellss_decimate_by() */ -extern void test__f_type_array_cellss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cellss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__cellss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decrease_by.c index a8e8e1bf3..8fe429d4a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_cellss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_cellss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cellss_decrease_by__parameter_checking(void **state) { const int length = 5; f_cellss_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decrease_by.h index b3cdd0a95..9b5e4b07a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cellss_decrease_by__works(void **state); * * @see f_type_array_cellss_decrease_by() */ -extern void test__f_type_array_cellss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cellss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__cellss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase.c index c34df58a8..577bd627b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_cellss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_cellss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_cellss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cellss_increase__parameter_checking(void **state) { const int length = 5; f_cellss_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase.h index e5ce06b94..74ca065c7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_cellss_increase__returns_data_not(void **state); * * @see f_type_array_cellss_increase() */ -extern void test__f_type_array_cellss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cellss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__cellss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase_by.c index b0828fffc..07e7c3707 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_cellss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_cellss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cellss_increase_by__parameter_checking(void **state) { const int length = 5; f_cellss_t data = f_cells_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase_by.h index 16267cf4b..9152f1dca 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cellss_increase_by__works(void **state); * * @see f_type_array_cellss_increase_by() */ -extern void test__f_type_array_cellss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cellss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__cellss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_resize.c index fed4516ef..79fb87520 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_cellss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_cellss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_cellss_resize__parameter_checking(void **state) { const int length = 5; f_cellss_t data = f_cellss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_resize.h index 03c7df1ba..a0977f0c3 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-cellss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-cellss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_cellss_resize__works(void **state); * * @see f_type_array_cellss_resize() */ -extern void test__f_type_array_cellss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_cellss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__cellss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_adjust.c index c382c7d31..658031ed1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_fll_ids_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_fll_ids_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_ids_adjust__parameter_checking(void **state) { const int length = 5; f_fll_ids_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_adjust.h index d63264d3a..486be6fef 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_ids_adjust__works(void **state); * * @see f_type_array_fll_ids_adjust() */ -extern void test__f_type_array_fll_ids_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_ids_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_ids_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append.c index c23032453..e208d80b1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append.c @@ -8,83 +8,31 @@ extern "C" { void test__f_type_array_fll_ids_append__works(void **state) { const int length = 5; - f_fll_ids_t source = f_fll_ids_t_initialize; + const f_fll_id_t source = { .name = "test", .type = 1, .used = 4 }; f_fll_ids_t destination = f_fll_ids_t_initialize; - const f_fll_id_t fll_id_0 = { .name = "test", .type = 1, .used = 4 }; - const f_fll_id_t fll_id_1 = { .name = "other", .type = 2, .used = 5 }; - - { - const f_status_t status = f_fll_ids_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - memcpy(&source.array[source.used++], (void *) &fll_id_0, sizeof(f_fll_id_t)); - memcpy(&source.array[source.used++], (void *) &fll_id_1, sizeof(f_fll_id_t)); - { const f_status_t status = f_fll_ids_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - assert_string_equal(destination.array[0].name, fll_id_0.name); - assert_int_equal(destination.array[0].type, fll_id_0.type); - assert_int_equal(destination.array[0].used, fll_id_0.used); - - assert_string_equal(destination.array[1].name, fll_id_1.name); - assert_int_equal(destination.array[1].type, fll_id_1.type); - assert_int_equal(destination.array[1].used, fll_id_1.used); + assert_int_equal(destination.used, 1); + assert_string_equal(destination.array[0].name, source.name); + assert_int_equal(destination.array[0].type, source.type); + assert_int_equal(destination.array[0].used, source.used); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_fll_ids_append__returns_data_not(void **state) { +void test__f_type_array_fll_ids_append__parameter_checking(void **state) { - const int length = 5; - f_fll_ids_t source = f_fll_ids_t_initialize; - f_fll_ids_t destination = f_fll_ids_t_initialize; - - { - const f_status_t status = f_fll_ids_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_fll_ids_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_fll_ids_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_fll_ids_t data = f_fll_ids_t_initialize; + const f_fll_id_t data = f_fll_id_t_initialize; { const f_status_t status = f_fll_ids_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append.h index 3b051fd8f..a665436d9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_fll_ids_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_fll_ids_append() - */ -extern void test__f_type_array_fll_ids_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_fll_ids_append() */ -extern void test__f_type_array_fll_ids_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_ids_append__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_ids_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append_all.c new file mode 100644 index 000000000..1b12eb0ef --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append_all.c @@ -0,0 +1,87 @@ +#include "test-type_array.h" +#include "test-type_array-fll_ids_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_ids_append_all__works(void **state) { + + const int length = 5; + f_fll_ids_t source = f_fll_ids_t_initialize; + f_fll_ids_t destination = f_fll_ids_t_initialize; + + const f_fll_id_t fll_id_0 = { .name = "test", .type = 1, .used = 4 }; + const f_fll_id_t fll_id_1 = { .name = "other", .type = 2, .used = 5 }; + + { + const f_status_t status = f_fll_ids_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + memcpy(&source.array[source.used++], (void *) &fll_id_0, sizeof(f_fll_id_t)); + memcpy(&source.array[source.used++], (void *) &fll_id_1, sizeof(f_fll_id_t)); + + { + const f_status_t status = f_fll_ids_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + assert_string_equal(destination.array[0].name, fll_id_0.name); + assert_int_equal(destination.array[0].type, fll_id_0.type); + assert_int_equal(destination.array[0].used, fll_id_0.used); + + assert_string_equal(destination.array[1].name, fll_id_1.name); + assert_int_equal(destination.array[1].type, fll_id_1.type); + assert_int_equal(destination.array[1].used, fll_id_1.used); + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_fll_ids_append_all__returns_data_not(void **state) { + + const int length = 5; + f_fll_ids_t source = f_fll_ids_t_initialize; + f_fll_ids_t destination = f_fll_ids_t_initialize; + + { + const f_status_t status = f_fll_ids_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_fll_ids_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_fll_ids_append_all__parameter_checking(void **state) { + + const f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_fll_ids_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append_all.h new file mode 100644 index 000000000..4093df151 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_ids_append_all +#define _TEST__F_type_array__fll_ids_append_all + +/** + * Test that the function works. + * + * @see f_type_array_fll_ids_append_all() + */ +extern void test__f_type_array_fll_ids_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_fll_ids_append_all() + */ +extern void test__f_type_array_fll_ids_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_ids_append_all() + */ +extern void test__f_type_array_fll_ids_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__fll_ids_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decimate_by.c index ca014f360..fa796a462 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_fll_ids_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_fll_ids_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_ids_decimate_by__parameter_checking(void **state) { const int length = 5; f_fll_ids_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decimate_by.h index 36a0149cd..cd4471d2e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_ids_decimate_by__works(void **state); * * @see f_type_array_fll_ids_decimate_by() */ -extern void test__f_type_array_fll_ids_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_ids_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_ids_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decrease_by.c index a2ef8a5cf..a60e13936 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_fll_ids_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_fll_ids_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_ids_decrease_by__parameter_checking(void **state) { const int length = 5; f_fll_ids_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decrease_by.h index 8d47fe01b..9506bcad4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_ids_decrease_by__works(void **state); * * @see f_type_array_fll_ids_decrease_by() */ -extern void test__f_type_array_fll_ids_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_ids_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_ids_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase.c index 6ce6d106e..a359f318d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_fll_ids_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_fll_ids_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_fll_ids_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_ids_increase__parameter_checking(void **state) { const int length = 5; f_fll_ids_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase.h index 313b6d6f4..f5e8d8760 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_fll_ids_increase__returns_data_not(void **state); * * @see f_type_array_fll_ids_increase() */ -extern void test__f_type_array_fll_ids_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_ids_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_ids_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase_by.c index 96a11ac86..e3b60b6be 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_fll_ids_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_fll_ids_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_ids_increase_by__parameter_checking(void **state) { const int length = 5; f_fll_ids_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase_by.h index 5a9866771..159d816f6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_ids_increase_by__works(void **state); * * @see f_type_array_fll_ids_increase_by() */ -extern void test__f_type_array_fll_ids_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_ids_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_ids_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_resize.c index 2e759943a..a5b56ed1f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_fll_ids_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_fll_ids_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_ids_resize__parameter_checking(void **state) { const int length = 5; f_fll_ids_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_resize.h index 7f034bbea..7ae4f8408 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_ids_resize__works(void **state); * * @see f_type_array_fll_ids_resize() */ -extern void test__f_type_array_fll_ids_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_ids_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_ids_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_adjust.c index 188e147a7..979b56da9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_fll_idss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_fll_idss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_idss_adjust__parameter_checking(void **state) { const int length = 5; f_fll_idss_t data = f_fll_idss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_adjust.h index 98f5d3797..6dfdf9536 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_idss_adjust__works(void **state); * * @see f_type_array_fll_idss_adjust() */ -extern void test__f_type_array_fll_idss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_idss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_idss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append.c index bb7dd2873..a08c60404 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append.c @@ -8,59 +8,39 @@ extern "C" { void test__f_type_array_fll_idss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_fll_idss_t source = f_fll_ids_t_initialize; - f_fll_idss_t destination = f_fll_ids_t_initialize; + f_fll_ids_t source = f_fll_ids_t_initialize; + f_fll_idss_t destination = f_fll_idss_t_initialize; - const f_fll_id_t fll_id_0 = { .name = "test", .type = 1, .used = 4 }; - const f_fll_id_t fll_id_1 = { .name = "other", .type = 2, .used = 5 }; + const f_fll_id_t fll_id = { .name = "test", .type = 1, .used = 4 }; { - const f_status_t status = f_fll_idss_resize(length, &source); + const f_status_t status = f_fll_ids_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_fll_ids_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &fll_id_0, sizeof(f_fll_id_t)); - memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &fll_id_1, sizeof(f_fll_id_t)); - } // for - } + while (source.used < length) { + memcpy(&source.array[source.used++], (void *) &fll_id, sizeof(f_fll_id_t)); + } // while { const f_status_t status = f_fll_idss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - assert_string_equal(destination.array[i].array[0].name, fll_id_0.name); - assert_int_equal(destination.array[i].array[0].type, fll_id_0.type); - assert_int_equal(destination.array[i].array[0].used, fll_id_0.used); - - assert_string_equal(destination.array[i].array[1].name, fll_id_1.name); - assert_int_equal(destination.array[i].array[1].type, fll_id_1.type); - assert_int_equal(destination.array[i].array[1].used, fll_id_1.used); + assert_string_equal(destination.array[0].array[i].name, fll_id.name); + assert_int_equal(destination.array[0].array[i].type, fll_id.type); + assert_int_equal(destination.array[0].array[i].used, fll_id.used); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -72,11 +52,11 @@ void test__f_type_array_fll_idss_append__works(void **state) { void test__f_type_array_fll_idss_append__returns_data_not(void **state) { const int length = 5; - f_fll_idss_t source = f_fll_ids_t_initialize; - f_fll_idss_t destination = f_fll_ids_t_initialize; + f_fll_ids_t source = f_fll_idss_t_initialize; + f_fll_idss_t destination = f_fll_idss_t_initialize; { - const f_status_t status = f_fll_idss_resize(length, &source); + const f_status_t status = f_fll_ids_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -89,26 +69,21 @@ void test__f_type_array_fll_idss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_fll_idss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_idss_append__parameter_checking(void **state) { - const int length = 5; - f_fll_idss_t data = f_fll_ids_t_initialize; + f_fll_ids_t data = f_fll_ids_t_initialize; { const f_status_t status = f_fll_idss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append.h index 43a851e5e..9cbc569fb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_fll_idss_append__returns_data_not(void **state); * * @see f_type_array_fll_idss_append() */ -extern void test__f_type_array_fll_idss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_idss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_idss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append_all.c new file mode 100644 index 000000000..774d9c716 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append_all.c @@ -0,0 +1,111 @@ +#include "test-type_array.h" +#include "test-type_array-fll_idss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_idss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_fll_idss_t source = f_fll_idss_t_initialize; + f_fll_idss_t destination = f_fll_idss_t_initialize; + + const f_fll_id_t fll_id_0 = { .name = "test", .type = 1, .used = 4 }; + const f_fll_id_t fll_id_1 = { .name = "other", .type = 2, .used = 5 }; + + { + const f_status_t status = f_fll_idss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_fll_ids_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &fll_id_0, sizeof(f_fll_id_t)); + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &fll_id_1, sizeof(f_fll_id_t)); + } // for + } + + { + const f_status_t status = f_fll_idss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + assert_string_equal(destination.array[i].array[0].name, fll_id_0.name); + assert_int_equal(destination.array[i].array[0].type, fll_id_0.type); + assert_int_equal(destination.array[i].array[0].used, fll_id_0.used); + + assert_string_equal(destination.array[i].array[1].name, fll_id_1.name); + assert_int_equal(destination.array[i].array[1].type, fll_id_1.type); + assert_int_equal(destination.array[i].array[1].used, fll_id_1.used); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_fll_idss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_fll_idss_t source = f_fll_idss_t_initialize; + f_fll_idss_t destination = f_fll_idss_t_initialize; + + { + const f_status_t status = f_fll_idss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_fll_idss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_fll_idss_append_all__parameter_checking(void **state) { + + const f_fll_idss_t data = f_fll_idss_t_initialize; + + { + const f_status_t status = f_fll_idss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append_all.h new file mode 100644 index 000000000..baa023d90 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_idss_append_all +#define _TEST__F_type_array__fll_idss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_fll_idss_append_all() + */ +extern void test__f_type_array_fll_idss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_fll_idss_append_all() + */ +extern void test__f_type_array_fll_idss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_idss_append_all() + */ +extern void test__f_type_array_fll_idss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__fll_idss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decimate_by.c index 52ea7121e..168f7d428 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_fll_idss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_fll_idss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_idss_decimate_by__parameter_checking(void **state) { const int length = 5; f_fll_idss_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decimate_by.h index 30f011e08..c4edbe325 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_idss_decimate_by__works(void **state); * * @see f_type_array_fll_idss_decimate_by() */ -extern void test__f_type_array_fll_idss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_idss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_idss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decrease_by.c index 852572660..3f7f82667 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_fll_idss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_fll_idss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_idss_decrease_by__parameter_checking(void **state) { const int length = 5; f_fll_idss_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decrease_by.h index 21fa83130..35a43c333 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_idss_decrease_by__works(void **state); * * @see f_type_array_fll_idss_decrease_by() */ -extern void test__f_type_array_fll_idss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_idss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_idss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase.c index 9915a6fdd..d7e5a57a8 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_fll_idss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_fll_idss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_fll_idss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_idss_increase__parameter_checking(void **state) { const int length = 5; f_fll_idss_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase.h index 5a9773a63..358ba3e86 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_fll_idss_increase__returns_data_not(void **state) * * @see f_type_array_fll_idss_increase() */ -extern void test__f_type_array_fll_idss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_idss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_idss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase_by.c index 764ae839d..05ba92e35 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_fll_idss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_fll_idss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_idss_increase_by__parameter_checking(void **state) { const int length = 5; f_fll_idss_t data = f_fll_ids_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase_by.h index 0636d44ce..cf8687e95 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_idss_increase_by__works(void **state); * * @see f_type_array_fll_idss_increase_by() */ -extern void test__f_type_array_fll_idss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_idss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_idss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_resize.c index 451a722f8..e0891ee1d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_fll_idss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_fll_idss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_fll_idss_resize__parameter_checking(void **state) { const int length = 5; f_fll_idss_t data = f_fll_idss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_resize.h index 9d8db2789..42840151f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_fll_idss_resize__works(void **state); * * @see f_type_array_fll_idss_resize() */ -extern void test__f_type_array_fll_idss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_fll_idss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__fll_idss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_adjust.c index 0c92b26be..3463b16b5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int128s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int128s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128s_adjust__parameter_checking(void **state) { const int length = 5; f_int128s_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_adjust.h index 58bb505d8..467b52224 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128s_adjust__works(void **state); * * @see f_type_array_int128s_adjust() */ -extern void test__f_type_array_int128s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int128s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append.c index 56f80578d..b90596457 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_int128s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_int128s_t source = f_int128s_t_initialize; + const int128_t source = 3; f_int128s_t destination = f_int128s_t_initialize; - { - const f_status_t status = f_int128s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_int128s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_int128s_append__returns_data_not(void **state) { +void test__f_type_array_int128s_append__parameter_checking(void **state) { - const int length = 5; - f_int128s_t source = f_int128s_t_initialize; - f_int128s_t destination = f_int128s_t_initialize; - - { - const f_status_t status = f_int128s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_int128s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_int128s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_int128s_t data = f_int128s_t_initialize; + const uint128_t data = 0; { const f_status_t status = f_int128s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append.h index 95f3f1d77..0ad1cba9e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_int128s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_int128s_append() - */ -extern void test__f_type_array_int128s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_int128s_append() */ -extern void test__f_type_array_int128s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int128s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append_all.c new file mode 100644 index 000000000..281f2077a --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-int128s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int128s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_int128s_t source = f_int128s_t_initialize; + f_int128s_t destination = f_int128s_t_initialize; + + { + const f_status_t status = f_int128s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_int128s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int128s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int128s_t source = f_int128s_t_initialize; + f_int128s_t destination = f_int128s_t_initialize; + + { + const f_status_t status = f_int128s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int128s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int128s_append_all__parameter_checking(void **state) { + + const f_int128s_t data = f_int128s_t_initialize; + + { + const f_status_t status = f_int128s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append_all.h new file mode 100644 index 000000000..a63f610cc --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int128s_append_all +#define _TEST__F_type_array__int128s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int128s_append_all() + */ +extern void test__f_type_array_int128s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int128s_append_all() + */ +extern void test__f_type_array_int128s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int128s_append_all() + */ +extern void test__f_type_array_int128s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int128s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decimate_by.c index b2cc9e547..f9276b00c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int128s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int128s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128s_decimate_by__parameter_checking(void **state) { const int length = 5; f_int128s_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decimate_by.h index b8d393a45..27c95e5b2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128s_decimate_by__works(void **state); * * @see f_type_array_int128s_decimate_by() */ -extern void test__f_type_array_int128s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int128s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decrease_by.c index 09b67604a..af81902b4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int128s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int128s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128s_decrease_by__parameter_checking(void **state) { const int length = 5; f_int128s_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decrease_by.h index 82a61084d..614d3b554 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128s_decrease_by__works(void **state); * * @see f_type_array_int128s_decrease_by() */ -extern void test__f_type_array_int128s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int128s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase.c index 30b8d758f..35aa7add7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int128s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int128s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int128s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128s_increase__parameter_checking(void **state) { const int length = 5; f_int128s_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase.h index 2ef2e4dbb..daf6bdba0 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int128s_increase__returns_data_not(void **state); * * @see f_type_array_int128s_increase() */ -extern void test__f_type_array_int128s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int128s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase_by.c index 48ff216e1..37583da8a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int128s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int128s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128s_increase_by__parameter_checking(void **state) { const int length = 5; f_int128s_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase_by.h index e5b74b8ef..b1c35bf91 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128s_increase_by__works(void **state); * * @see f_type_array_int128s_increase_by() */ -extern void test__f_type_array_int128s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int128s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_resize.c index 399d9b365..19b6c1367 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int128s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int128s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128s_resize__parameter_checking(void **state) { const int length = 5; f_int128s_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_resize.h index 4b1752d15..4d4c60dcd 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128s_resize__works(void **state); * * @see f_type_array_int128s_resize() */ -extern void test__f_type_array_int128s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int128s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_adjust.c index dc07786b5..7bdd2832c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int128ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int128ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128ss_adjust__parameter_checking(void **state) { const int length = 5; f_int128ss_t data = f_int128ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_adjust.h index 9adcfba8d..21c0fa848 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128ss_adjust__works(void **state); * * @see f_type_array_int128ss_adjust() */ -extern void test__f_type_array_int128ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int128ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append.c index e38f4ebc8..c67b66d78 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_int128ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_int128ss_t source = f_int128s_t_initialize; - f_int128ss_t destination = f_int128s_t_initialize; + f_int128s_t source = f_int128s_t_initialize; + f_int128ss_t destination = f_int128ss_t_initialize; { - const f_status_t status = f_int128ss_resize(length, &source); + const f_status_t status = f_int128s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_int128s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_int128ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_int128ss_append__works(void **state) { void test__f_type_array_int128ss_append__returns_data_not(void **state) { const int length = 5; - f_int128ss_t source = f_int128s_t_initialize; - f_int128ss_t destination = f_int128s_t_initialize; + f_int128s_t source = f_int128s_t_initialize; + f_int128ss_t destination = f_int128ss_t_initialize; { - const f_status_t status = f_int128ss_resize(length, &source); + const f_status_t status = f_int128s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_int128ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_int128ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128ss_append__parameter_checking(void **state) { - const int length = 5; - f_int128ss_t data = f_int128s_t_initialize; + f_int128s_t data = f_int128s_t_initialize; { const f_status_t status = f_int128ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append.h index ee9774100..e27c02588 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int128ss_append__returns_data_not(void **state); * * @see f_type_array_int128ss_append() */ -extern void test__f_type_array_int128ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int128ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append_all.c new file mode 100644 index 000000000..26f33bc96 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-int128ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int128ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_int128ss_t source = f_int128ss_t_initialize; + f_int128ss_t destination = f_int128ss_t_initialize; + + { + const f_status_t status = f_int128ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_int128s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_int128ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int128ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int128ss_t source = f_int128ss_t_initialize; + f_int128ss_t destination = f_int128ss_t_initialize; + + { + const f_status_t status = f_int128ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int128ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int128ss_append_all__parameter_checking(void **state) { + + const f_int128ss_t data = f_int128ss_t_initialize; + + { + const f_status_t status = f_int128ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append_all.h new file mode 100644 index 000000000..8c0339f22 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int128ss_append_all +#define _TEST__F_type_array__int128ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int128ss_append_all() + */ +extern void test__f_type_array_int128ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int128ss_append_all() + */ +extern void test__f_type_array_int128ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int128ss_append_all() + */ +extern void test__f_type_array_int128ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int128ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decimate_by.c index 6e082c80d..1a6c370a2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int128ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int128ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_int128ss_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decimate_by.h index 75aa4f2ad..b4a36479c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128ss_decimate_by__works(void **state); * * @see f_type_array_int128ss_decimate_by() */ -extern void test__f_type_array_int128ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int128ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decrease_by.c index d622f362e..a8ac1f498 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int128ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int128ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_int128ss_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decrease_by.h index 9afeb069b..f7f4da9c2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128ss_decrease_by__works(void **state); * * @see f_type_array_int128ss_decrease_by() */ -extern void test__f_type_array_int128ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int128ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase.c index c234ff513..d0cfcc1cc 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int128ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int128ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int128ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128ss_increase__parameter_checking(void **state) { const int length = 5; f_int128ss_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase.h index 97c4c286c..575159933 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int128ss_increase__returns_data_not(void **state) * * @see f_type_array_int128ss_increase() */ -extern void test__f_type_array_int128ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int128ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase_by.c index 43e6d7b26..8588735ac 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int128ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int128ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128ss_increase_by__parameter_checking(void **state) { const int length = 5; f_int128ss_t data = f_int128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase_by.h index 9844d5537..dbb6090a9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128ss_increase_by__works(void **state); * * @see f_type_array_int128ss_increase_by() */ -extern void test__f_type_array_int128ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int128ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_resize.c index 149159b99..72eaa3fe1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int128ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int128ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int128ss_resize__parameter_checking(void **state) { const int length = 5; f_int128ss_t data = f_int128ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_resize.h index 37601156e..821daa23a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int128ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int128ss_resize__works(void **state); * * @see f_type_array_int128ss_resize() */ -extern void test__f_type_array_int128ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int128ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int128ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_adjust.c index 529453aa6..3f0931e89 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int16s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int16s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16s_adjust__parameter_checking(void **state) { const int length = 5; f_int16s_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_adjust.h index 6fa621409..9376cd3f9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16s_adjust__works(void **state); * * @see f_type_array_int16s_adjust() */ -extern void test__f_type_array_int16s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int16s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append.c index d4133b959..163f197b9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_int16s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_int16s_t source = f_int16s_t_initialize; + const uint16_t source = 3; f_int16s_t destination = f_int16s_t_initialize; - { - const f_status_t status = f_int16s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_int16s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_int16s_append__returns_data_not(void **state) { +void test__f_type_array_int16s_append__parameter_checking(void **state) { - const int length = 5; - f_int16s_t source = f_int16s_t_initialize; - f_int16s_t destination = f_int16s_t_initialize; - - { - const f_status_t status = f_int16s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_int16s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_int16s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_int16s_t data = f_int16s_t_initialize; + const uint16_t data = 0; { const f_status_t status = f_int16s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append.h index 98a2ddcd9..173530c15 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_int16s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_int16s_append() - */ -extern void test__f_type_array_int16s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_int16s_append() */ -extern void test__f_type_array_int16s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int16s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append_all.c new file mode 100644 index 000000000..19506b0fb --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-int16s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int16s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_int16s_t source = f_int16s_t_initialize; + f_int16s_t destination = f_int16s_t_initialize; + + { + const f_status_t status = f_int16s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_int16s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int16s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int16s_t source = f_int16s_t_initialize; + f_int16s_t destination = f_int16s_t_initialize; + + { + const f_status_t status = f_int16s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int16s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int16s_append_all__parameter_checking(void **state) { + + const f_int16s_t data = f_int16s_t_initialize; + + { + const f_status_t status = f_int16s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append_all.h new file mode 100644 index 000000000..2a4637cfb --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int16s_append_all +#define _TEST__F_type_array__int16s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int16s_append_all() + */ +extern void test__f_type_array_int16s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int16s_append_all() + */ +extern void test__f_type_array_int16s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int16s_append_all() + */ +extern void test__f_type_array_int16s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int16s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decimate_by.c index cb4452c71..9fff75ddf 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int16s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int16s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16s_decimate_by__parameter_checking(void **state) { const int length = 5; f_int16s_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decimate_by.h index 80a521863..f77b1aed2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16s_decimate_by__works(void **state); * * @see f_type_array_int16s_decimate_by() */ -extern void test__f_type_array_int16s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int16s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decrease_by.c index e6cd758af..3d30dc178 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int16s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int16s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16s_decrease_by__parameter_checking(void **state) { const int length = 5; f_int16s_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decrease_by.h index 56bacd433..b7a215d8e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16s_decrease_by__works(void **state); * * @see f_type_array_int16s_decrease_by() */ -extern void test__f_type_array_int16s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int16s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase.c index 26eaf9099..0d7fe4b64 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int16s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int16s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int16s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16s_increase__parameter_checking(void **state) { const int length = 5; f_int16s_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase.h index e1c208ebb..8a9c1cba5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int16s_increase__returns_data_not(void **state); * * @see f_type_array_int16s_increase() */ -extern void test__f_type_array_int16s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int16s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase_by.c index dbad4856a..2f717aeb0 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int16s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int16s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16s_increase_by__parameter_checking(void **state) { const int length = 5; f_int16s_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase_by.h index 719c9205c..37e7b4d75 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16s_increase_by__works(void **state); * * @see f_type_array_int16s_increase_by() */ -extern void test__f_type_array_int16s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int16s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_resize.c index 450e07d81..c632a9ea4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int16s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int16s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16s_resize__parameter_checking(void **state) { const int length = 5; f_int16s_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_resize.h index e1627b712..5f2933e53 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16s_resize__works(void **state); * * @see f_type_array_int16s_resize() */ -extern void test__f_type_array_int16s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int16s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_adjust.c index 5bb4fc8b5..3055b1738 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int16ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int16ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16ss_adjust__parameter_checking(void **state) { const int length = 5; f_int16ss_t data = f_int16ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_adjust.h index efb8582d7..c2412551f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16ss_adjust__works(void **state); * * @see f_type_array_int16ss_adjust() */ -extern void test__f_type_array_int16ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int16ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append.c index f1e23dc98..36ee09d00 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_int16ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_int16ss_t source = f_int16s_t_initialize; - f_int16ss_t destination = f_int16s_t_initialize; + f_int16s_t source = f_int16s_t_initialize; + f_int16ss_t destination = f_int16ss_t_initialize; { - const f_status_t status = f_int16ss_resize(length, &source); + const f_status_t status = f_int16s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_int16s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_int16ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_int16ss_append__works(void **state) { void test__f_type_array_int16ss_append__returns_data_not(void **state) { const int length = 5; - f_int16ss_t source = f_int16s_t_initialize; - f_int16ss_t destination = f_int16s_t_initialize; + f_int16s_t source = f_int16s_t_initialize; + f_int16ss_t destination = f_int16ss_t_initialize; { - const f_status_t status = f_int16ss_resize(length, &source); + const f_status_t status = f_int16s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_int16ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_int16ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16ss_append__parameter_checking(void **state) { - const int length = 5; - f_int16ss_t data = f_int16s_t_initialize; + f_int16s_t data = f_int16s_t_initialize; { const f_status_t status = f_int16ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append.h index c40ed3b00..7bab07fa0 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int16ss_append__returns_data_not(void **state); * * @see f_type_array_int16ss_append() */ -extern void test__f_type_array_int16ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int16ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append_all.c new file mode 100644 index 000000000..08d312316 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-int16ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int16ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_int16ss_t source = f_int16ss_t_initialize; + f_int16ss_t destination = f_int16ss_t_initialize; + + { + const f_status_t status = f_int16ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_int16s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_int16ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int16ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int16ss_t source = f_int16ss_t_initialize; + f_int16ss_t destination = f_int16ss_t_initialize; + + { + const f_status_t status = f_int16ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int16ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int16ss_append_all__parameter_checking(void **state) { + + const f_int16ss_t data = f_int16ss_t_initialize; + + { + const f_status_t status = f_int16ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append_all.h new file mode 100644 index 000000000..8d9fe34ee --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int16ss_append_all +#define _TEST__F_type_array__int16ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int16ss_append_all() + */ +extern void test__f_type_array_int16ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int16ss_append_all() + */ +extern void test__f_type_array_int16ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int16ss_append_all() + */ +extern void test__f_type_array_int16ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int16ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decimate_by.c index ac36f8d99..fd7040ebc 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int16ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int16ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_int16ss_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decimate_by.h index 1384c682f..2bd7c2f9d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16ss_decimate_by__works(void **state); * * @see f_type_array_int16ss_decimate_by() */ -extern void test__f_type_array_int16ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int16ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decrease_by.c index 67ba87cd0..ed3a4548e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int16ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int16ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_int16ss_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decrease_by.h index a8813c98d..f5d687a1e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16ss_decrease_by__works(void **state); * * @see f_type_array_int16ss_decrease_by() */ -extern void test__f_type_array_int16ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int16ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase.c index db4347046..f1d8273d4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int16ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int16ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int16ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16ss_increase__parameter_checking(void **state) { const int length = 5; f_int16ss_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase.h index 032a4bb05..c0b275d4e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int16ss_increase__returns_data_not(void **state); * * @see f_type_array_int16ss_increase() */ -extern void test__f_type_array_int16ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int16ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase_by.c index ffccc6eb8..cbb4a2901 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int16ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int16ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16ss_increase_by__parameter_checking(void **state) { const int length = 5; f_int16ss_t data = f_int16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase_by.h index 0d02ffb80..78956ec6b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16ss_increase_by__works(void **state); * * @see f_type_array_int16ss_increase_by() */ -extern void test__f_type_array_int16ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int16ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_resize.c index 078b770ec..7a4e8925d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int16ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int16ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int16ss_resize__parameter_checking(void **state) { const int length = 5; f_int16ss_t data = f_int16ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_resize.h index b57993d71..6f962b705 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int16ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int16ss_resize__works(void **state); * * @see f_type_array_int16ss_resize() */ -extern void test__f_type_array_int16ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int16ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int16ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_adjust.c index 3cc76bf8c..8aafe65ed 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int32s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int32s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32s_adjust__parameter_checking(void **state) { const int length = 5; f_int32s_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_adjust.h index cf4f06dcc..913daa8cc 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32s_adjust__works(void **state); * * @see f_type_array_int32s_adjust() */ -extern void test__f_type_array_int32s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int32s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append.c index 596cddc56..c384176b7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_int32s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_int32s_t source = f_int32s_t_initialize; + const int32_t source = 3; f_int32s_t destination = f_int32s_t_initialize; - { - const f_status_t status = f_int32s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_int32s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_int32s_append__returns_data_not(void **state) { +void test__f_type_array_int32s_append__parameter_checking(void **state) { - const int length = 5; - f_int32s_t source = f_int32s_t_initialize; - f_int32s_t destination = f_int32s_t_initialize; - - { - const f_status_t status = f_int32s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_int32s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_int32s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_int32s_t data = f_int32s_t_initialize; + const uint32_t data = 0; { const f_status_t status = f_int32s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append.h index 61330219d..4c22e28c4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_int32s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_int32s_append() - */ -extern void test__f_type_array_int32s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_int32s_append() */ -extern void test__f_type_array_int32s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int32s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append_all.c new file mode 100644 index 000000000..dc8bfbce7 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-int32s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int32s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_int32s_t source = f_int32s_t_initialize; + f_int32s_t destination = f_int32s_t_initialize; + + { + const f_status_t status = f_int32s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_int32s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int32s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int32s_t source = f_int32s_t_initialize; + f_int32s_t destination = f_int32s_t_initialize; + + { + const f_status_t status = f_int32s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int32s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int32s_append_all__parameter_checking(void **state) { + + const f_int32s_t data = f_int32s_t_initialize; + + { + const f_status_t status = f_int32s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append_all.h new file mode 100644 index 000000000..ed79d51ba --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int32s_append_all +#define _TEST__F_type_array__int32s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int32s_append_all() + */ +extern void test__f_type_array_int32s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int32s_append_all() + */ +extern void test__f_type_array_int32s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int32s_append_all() + */ +extern void test__f_type_array_int32s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int32s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decimate_by.c index cd2d362fa..d6b5032d8 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int32s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int32s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32s_decimate_by__parameter_checking(void **state) { const int length = 5; f_int32s_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decimate_by.h index 6fbb447dd..ee9a6af92 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32s_decimate_by__works(void **state); * * @see f_type_array_int32s_decimate_by() */ -extern void test__f_type_array_int32s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int32s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decrease_by.c index e0d167a33..71279a42b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int32s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int32s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32s_decrease_by__parameter_checking(void **state) { const int length = 5; f_int32s_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decrease_by.h index fad9c5e2e..ed428af50 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32s_decrease_by__works(void **state); * * @see f_type_array_int32s_decrease_by() */ -extern void test__f_type_array_int32s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int32s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase.c index a2d11f63d..a6d40221d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int32s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int32s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int32s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32s_increase__parameter_checking(void **state) { const int length = 5; f_int32s_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase.h index d7536cda1..7fe8cf58a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int32s_increase__returns_data_not(void **state); * * @see f_type_array_int32s_increase() */ -extern void test__f_type_array_int32s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int32s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase_by.c index 4e4a8af47..c89ce82d7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int32s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int32s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32s_increase_by__parameter_checking(void **state) { const int length = 5; f_int32s_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase_by.h index 95ed773a4..8be454eb7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32s_increase_by__works(void **state); * * @see f_type_array_int32s_increase_by() */ -extern void test__f_type_array_int32s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int32s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_resize.c index db4251dd7..fdc0204a8 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int32s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int32s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32s_resize__parameter_checking(void **state) { const int length = 5; f_int32s_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_resize.h index 64fb507e4..82f054e11 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32s_resize__works(void **state); * * @see f_type_array_int32s_resize() */ -extern void test__f_type_array_int32s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int32s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_adjust.c index c25b621aa..a973a0361 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int32ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int32ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32ss_adjust__parameter_checking(void **state) { const int length = 5; f_int32ss_t data = f_int32ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_adjust.h index 8d9200cd9..a105b7bcb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32ss_adjust__works(void **state); * * @see f_type_array_int32ss_adjust() */ -extern void test__f_type_array_int32ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int32ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append.c index 038ad3a49..b4d67f967 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_int32ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_int32ss_t source = f_int32s_t_initialize; - f_int32ss_t destination = f_int32s_t_initialize; + f_int32s_t source = f_int32s_t_initialize; + f_int32ss_t destination = f_int32ss_t_initialize; { - const f_status_t status = f_int32ss_resize(length, &source); + const f_status_t status = f_int32s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_int32s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_int32ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_int32ss_append__works(void **state) { void test__f_type_array_int32ss_append__returns_data_not(void **state) { const int length = 5; - f_int32ss_t source = f_int32s_t_initialize; - f_int32ss_t destination = f_int32s_t_initialize; + f_int32s_t source = f_int32s_t_initialize; + f_int32ss_t destination = f_int32ss_t_initialize; { - const f_status_t status = f_int32ss_resize(length, &source); + const f_status_t status = f_int32s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_int32ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_int32ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32ss_append__parameter_checking(void **state) { - const int length = 5; - f_int32ss_t data = f_int32s_t_initialize; + f_int32s_t data = f_int32s_t_initialize; { const f_status_t status = f_int32ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append.h index 7caf1fea5..5d56e68ab 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int32ss_append__returns_data_not(void **state); * * @see f_type_array_int32ss_append() */ -extern void test__f_type_array_int32ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int32ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append_all.c new file mode 100644 index 000000000..c002afaaa --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-int32ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int32ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_int32ss_t source = f_int32ss_t_initialize; + f_int32ss_t destination = f_int32ss_t_initialize; + + { + const f_status_t status = f_int32ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_int32s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_int32ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int32ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int32ss_t source = f_int32ss_t_initialize; + f_int32ss_t destination = f_int32ss_t_initialize; + + { + const f_status_t status = f_int32ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int32ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int32ss_append_all__parameter_checking(void **state) { + + const f_int32ss_t data = f_int32ss_t_initialize; + + { + const f_status_t status = f_int32ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append_all.h new file mode 100644 index 000000000..8aaeae7ac --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int32ss_append_all +#define _TEST__F_type_array__int32ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int32ss_append_all() + */ +extern void test__f_type_array_int32ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int32ss_append_all() + */ +extern void test__f_type_array_int32ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int32ss_append_all() + */ +extern void test__f_type_array_int32ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int32ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decimate_by.c index 7e3f68639..0fdb7e553 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int32ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int32ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_int32ss_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decimate_by.h index 722bb5981..2fc576de9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32ss_decimate_by__works(void **state); * * @see f_type_array_int32ss_decimate_by() */ -extern void test__f_type_array_int32ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int32ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decrease_by.c index 688c10a83..99a08265d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int32ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int32ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_int32ss_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decrease_by.h index 1fc42cda0..9fa824773 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32ss_decrease_by__works(void **state); * * @see f_type_array_int32ss_decrease_by() */ -extern void test__f_type_array_int32ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int32ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase.c index 35bfac7b7..a3160a470 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int32ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int32ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int32ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32ss_increase__parameter_checking(void **state) { const int length = 5; f_int32ss_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase.h index 8fdccb367..ae844df2d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int32ss_increase__returns_data_not(void **state); * * @see f_type_array_int32ss_increase() */ -extern void test__f_type_array_int32ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int32ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase_by.c index 30e121bf5..47f49fddb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int32ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int32ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32ss_increase_by__parameter_checking(void **state) { const int length = 5; f_int32ss_t data = f_int32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase_by.h index 09b2d956d..e2ec6e57e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32ss_increase_by__works(void **state); * * @see f_type_array_int32ss_increase_by() */ -extern void test__f_type_array_int32ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int32ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_resize.c index 8805d36da..c53d81e54 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int32ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int32ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int32ss_resize__parameter_checking(void **state) { const int length = 5; f_int32ss_t data = f_int32ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_resize.h index aee14e10a..32e26a829 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int32ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int32ss_resize__works(void **state); * * @see f_type_array_int32ss_resize() */ -extern void test__f_type_array_int32ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int32ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int32ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_adjust.c index fb63404d8..252565b07 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int64s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int64s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64s_adjust__parameter_checking(void **state) { const int length = 5; f_int64s_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_adjust.h index 090b24d44..fca10f459 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64s_adjust__works(void **state); * * @see f_type_array_int64s_adjust() */ -extern void test__f_type_array_int64s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int64s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append.c index 4bb91c66e..2515eeb30 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_int64s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_int64s_t source = f_int64s_t_initialize; + const int64_t source = 3; f_int64s_t destination = f_int64s_t_initialize; - { - const f_status_t status = f_int64s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_int64s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_int64s_append__returns_data_not(void **state) { +void test__f_type_array_int64s_append__parameter_checking(void **state) { - const int length = 5; - f_int64s_t source = f_int64s_t_initialize; - f_int64s_t destination = f_int64s_t_initialize; - - { - const f_status_t status = f_int64s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_int64s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_int64s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_int64s_t data = f_int64s_t_initialize; + const uint64_t data = 0; { const f_status_t status = f_int64s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append.h index 8bec71ba6..050b258d0 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_int64s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_int64s_append() - */ -extern void test__f_type_array_int64s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_int64s_append() */ -extern void test__f_type_array_int64s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int64s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append_all.c new file mode 100644 index 000000000..dae1f313e --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-int64s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int64s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_int64s_t source = f_int64s_t_initialize; + f_int64s_t destination = f_int64s_t_initialize; + + { + const f_status_t status = f_int64s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_int64s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int64s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int64s_t source = f_int64s_t_initialize; + f_int64s_t destination = f_int64s_t_initialize; + + { + const f_status_t status = f_int64s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int64s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int64s_append_all__parameter_checking(void **state) { + + const f_int64s_t data = f_int64s_t_initialize; + + { + const f_status_t status = f_int64s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append_all.h new file mode 100644 index 000000000..ae20d0cd1 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int64s_append_all +#define _TEST__F_type_array__int64s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int64s_append_all() + */ +extern void test__f_type_array_int64s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int64s_append_all() + */ +extern void test__f_type_array_int64s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int64s_append_all() + */ +extern void test__f_type_array_int64s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int64s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decimate_by.c index c3ae4c9fd..18cb0f7aa 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int64s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int64s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64s_decimate_by__parameter_checking(void **state) { const int length = 5; f_int64s_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decimate_by.h index 31123c675..3cd695b6b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64s_decimate_by__works(void **state); * * @see f_type_array_int64s_decimate_by() */ -extern void test__f_type_array_int64s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int64s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decrease_by.c index 426014f0d..93d4de8a6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int64s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int64s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64s_decrease_by__parameter_checking(void **state) { const int length = 5; f_int64s_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decrease_by.h index e79a31779..9f7fcdc0f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64s_decrease_by__works(void **state); * * @see f_type_array_int64s_decrease_by() */ -extern void test__f_type_array_int64s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int64s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase.c index 90b472bba..2aaf4f5d1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int64s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int64s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int64s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64s_increase__parameter_checking(void **state) { const int length = 5; f_int64s_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase.h index 7538f33ab..ec62ee031 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int64s_increase__returns_data_not(void **state); * * @see f_type_array_int64s_increase() */ -extern void test__f_type_array_int64s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int64s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase_by.c index 4e04bfc55..774930054 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int64s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int64s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64s_increase_by__parameter_checking(void **state) { const int length = 5; f_int64s_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase_by.h index 38dbd1a35..f8bd91a3e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64s_increase_by__works(void **state); * * @see f_type_array_int64s_increase_by() */ -extern void test__f_type_array_int64s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int64s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_resize.c index da472e93d..f2cf58d1b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int64s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int64s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64s_resize__parameter_checking(void **state) { const int length = 5; f_int64s_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_resize.h index a70d30fd4..7de48761d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64s_resize__works(void **state); * * @see f_type_array_int64s_resize() */ -extern void test__f_type_array_int64s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int64s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_adjust.c index 0804f0a89..5bb533e85 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int64ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int64ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64ss_adjust__parameter_checking(void **state) { const int length = 5; f_int64ss_t data = f_int64ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_adjust.h index 8c25372c0..af3236440 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64ss_adjust__works(void **state); * * @see f_type_array_int64ss_adjust() */ -extern void test__f_type_array_int64ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int64ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append.c index 826772ba9..f0bba2e0e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_int64ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_int64ss_t source = f_int64s_t_initialize; - f_int64ss_t destination = f_int64s_t_initialize; + f_int64s_t source = f_int64s_t_initialize; + f_int64ss_t destination = f_int64ss_t_initialize; { - const f_status_t status = f_int64ss_resize(length, &source); + const f_status_t status = f_int64s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_int64s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_int64ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_int64ss_append__works(void **state) { void test__f_type_array_int64ss_append__returns_data_not(void **state) { const int length = 5; - f_int64ss_t source = f_int64s_t_initialize; - f_int64ss_t destination = f_int64s_t_initialize; + f_int64s_t source = f_int64s_t_initialize; + f_int64ss_t destination = f_int64ss_t_initialize; { - const f_status_t status = f_int64ss_resize(length, &source); + const f_status_t status = f_int64s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_int64ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_int64ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64ss_append__parameter_checking(void **state) { - const int length = 5; - f_int64ss_t data = f_int64s_t_initialize; + f_int64s_t data = f_int64s_t_initialize; { const f_status_t status = f_int64ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append.h index ea50420c1..69065b9b5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int64ss_append__returns_data_not(void **state); * * @see f_type_array_int64ss_append() */ -extern void test__f_type_array_int64ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int64ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append_all.c new file mode 100644 index 000000000..bd4b6672d --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-int64ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int64ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_int64ss_t source = f_int64ss_t_initialize; + f_int64ss_t destination = f_int64ss_t_initialize; + + { + const f_status_t status = f_int64ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_int64s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_int64ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int64ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int64ss_t source = f_int64ss_t_initialize; + f_int64ss_t destination = f_int64ss_t_initialize; + + { + const f_status_t status = f_int64ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int64ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int64ss_append_all__parameter_checking(void **state) { + + const f_int64ss_t data = f_int64ss_t_initialize; + + { + const f_status_t status = f_int64ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append_all.h new file mode 100644 index 000000000..6052ec529 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int64ss_append_all +#define _TEST__F_type_array__int64ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int64ss_append_all() + */ +extern void test__f_type_array_int64ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int64ss_append_all() + */ +extern void test__f_type_array_int64ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int64ss_append_all() + */ +extern void test__f_type_array_int64ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int64ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decimate_by.c index 9e08407f3..03567e8e9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int64ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int64ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_int64ss_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decimate_by.h index 9636e802e..a813fff39 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64ss_decimate_by__works(void **state); * * @see f_type_array_int64ss_decimate_by() */ -extern void test__f_type_array_int64ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int64ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decrease_by.c index f49a6e5b3..f2909c013 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int64ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int64ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_int64ss_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decrease_by.h index ef1adf1f0..966ce27ca 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64ss_decrease_by__works(void **state); * * @see f_type_array_int64ss_decrease_by() */ -extern void test__f_type_array_int64ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int64ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase.c index 45159b1b7..b0e705438 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int64ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int64ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int64ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64ss_increase__parameter_checking(void **state) { const int length = 5; f_int64ss_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase.h index ac70919a2..2549016eb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int64ss_increase__returns_data_not(void **state); * * @see f_type_array_int64ss_increase() */ -extern void test__f_type_array_int64ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int64ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase_by.c index f3e11f056..206def852 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int64ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int64ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64ss_increase_by__parameter_checking(void **state) { const int length = 5; f_int64ss_t data = f_int64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase_by.h index 3857a061f..689f6586f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64ss_increase_by__works(void **state); * * @see f_type_array_int64ss_increase_by() */ -extern void test__f_type_array_int64ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int64ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_resize.c index b2a5f3567..cceffafa8 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int64ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int64ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int64ss_resize__parameter_checking(void **state) { const int length = 5; f_int64ss_t data = f_int64ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_resize.h index e1cee1d48..4d8570239 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int64ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int64ss_resize__works(void **state); * * @see f_type_array_int64ss_resize() */ -extern void test__f_type_array_int64ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int64ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int64ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_adjust.c index 46c197322..f857eb0e0 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int8s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int8s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8s_adjust__parameter_checking(void **state) { const int length = 5; f_int8s_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_adjust.h index 800cd3330..6fea315bb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8s_adjust__works(void **state); * * @see f_type_array_int8s_adjust() */ -extern void test__f_type_array_int8s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int8s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append.c index 5d4ecb156..8412a3e20 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_int8s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_int8s_t source = f_int8s_t_initialize; + const int8_t source = 3; f_int8s_t destination = f_int8s_t_initialize; - { - const f_status_t status = f_int8s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_int8s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_int8s_append__returns_data_not(void **state) { +void test__f_type_array_int8s_append__parameter_checking(void **state) { - const int length = 5; - f_int8s_t source = f_int8s_t_initialize; - f_int8s_t destination = f_int8s_t_initialize; - - { - const f_status_t status = f_int8s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_int8s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_int8s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_int8s_t data = f_int8s_t_initialize; + const uint8_t data = 0; { const f_status_t status = f_int8s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append.h index 3bda741f5..221938dd1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_int8s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_int8s_append() - */ -extern void test__f_type_array_int8s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_int8s_append() */ -extern void test__f_type_array_int8s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int8s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append_all.c new file mode 100644 index 000000000..79279e3aa --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-int8s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int8s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_int8s_t source = f_int8s_t_initialize; + f_int8s_t destination = f_int8s_t_initialize; + + { + const f_status_t status = f_int8s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_int8s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int8s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int8s_t source = f_int8s_t_initialize; + f_int8s_t destination = f_int8s_t_initialize; + + { + const f_status_t status = f_int8s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int8s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int8s_append_all__parameter_checking(void **state) { + + const f_int8s_t data = f_int8s_t_initialize; + + { + const f_status_t status = f_int8s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append_all.h new file mode 100644 index 000000000..28e46c8c6 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int8s_append_all +#define _TEST__F_type_array__int8s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int8s_append_all() + */ +extern void test__f_type_array_int8s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int8s_append_all() + */ +extern void test__f_type_array_int8s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int8s_append_all() + */ +extern void test__f_type_array_int8s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int8s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decimate_by.c index 744cb0da6..388ed4957 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int8s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int8s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8s_decimate_by__parameter_checking(void **state) { const int length = 5; f_int8s_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decimate_by.h index 873be7f8a..269b5d777 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8s_decimate_by__works(void **state); * * @see f_type_array_int8s_decimate_by() */ -extern void test__f_type_array_int8s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int8s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decrease_by.c index 118d7e801..e5cfb1e2e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int8s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int8s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8s_decrease_by__parameter_checking(void **state) { const int length = 5; f_int8s_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decrease_by.h index de0ee3415..61b3b8401 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8s_decrease_by__works(void **state); * * @see f_type_array_int8s_decrease_by() */ -extern void test__f_type_array_int8s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int8s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase.c index 2d6de2a61..37d9220ab 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int8s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int8s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int8s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8s_increase__parameter_checking(void **state) { const int length = 5; f_int8s_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase.h index cf688badc..99012eada 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int8s_increase__returns_data_not(void **state); * * @see f_type_array_int8s_increase() */ -extern void test__f_type_array_int8s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int8s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase_by.c index 5fae4cdc4..d847d5220 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int8s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int8s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8s_increase_by__parameter_checking(void **state) { const int length = 5; f_int8s_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase_by.h index a0d242e6a..0b903acc0 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8s_increase_by__works(void **state); * * @see f_type_array_int8s_increase_by() */ -extern void test__f_type_array_int8s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int8s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_resize.c index b18288611..c367b7369 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int8s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int8s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8s_resize__parameter_checking(void **state) { const int length = 5; f_int8s_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_resize.h index df99311ea..bf0e9ce72 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8s_resize__works(void **state); * * @see f_type_array_int8s_resize() */ -extern void test__f_type_array_int8s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int8s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_adjust.c index 2c185fe8b..d230abd2d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_int8ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_int8ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8ss_adjust__parameter_checking(void **state) { const int length = 5; f_int8ss_t data = f_int8ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_adjust.h index ba46d8bf1..6e982b8c5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8ss_adjust__works(void **state); * * @see f_type_array_int8ss_adjust() */ -extern void test__f_type_array_int8ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__int8ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append.c index e6ed2aab5..5372566f1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_int8ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_int8ss_t source = f_int8s_t_initialize; - f_int8ss_t destination = f_int8s_t_initialize; + f_int8s_t source = f_int8s_t_initialize; + f_int8ss_t destination = f_int8ss_t_initialize; { - const f_status_t status = f_int8ss_resize(length, &source); + const f_status_t status = f_int8s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_int8s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_int8ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_int8ss_append__works(void **state) { void test__f_type_array_int8ss_append__returns_data_not(void **state) { const int length = 5; - f_int8ss_t source = f_int8s_t_initialize; - f_int8ss_t destination = f_int8s_t_initialize; + f_int8s_t source = f_int8s_t_initialize; + f_int8ss_t destination = f_int8ss_t_initialize; { - const f_status_t status = f_int8ss_resize(length, &source); + const f_status_t status = f_int8s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_int8ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_int8ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8ss_append__parameter_checking(void **state) { - const int length = 5; - f_int8ss_t data = f_int8s_t_initialize; + f_int8s_t data = f_int8s_t_initialize; { const f_status_t status = f_int8ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append.h index 238c7de1b..57a27abf9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int8ss_append__returns_data_not(void **state); * * @see f_type_array_int8ss_append() */ -extern void test__f_type_array_int8ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__int8ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append_all.c new file mode 100644 index 000000000..6aeb35f3a --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-int8ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_int8ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_int8ss_t source = f_int8ss_t_initialize; + f_int8ss_t destination = f_int8ss_t_initialize; + + { + const f_status_t status = f_int8ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_int8s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_int8ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_int8ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_int8ss_t source = f_int8ss_t_initialize; + f_int8ss_t destination = f_int8ss_t_initialize; + + { + const f_status_t status = f_int8ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_int8ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_int8ss_append_all__parameter_checking(void **state) { + + const f_int8ss_t data = f_int8ss_t_initialize; + + { + const f_status_t status = f_int8ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append_all.h new file mode 100644 index 000000000..2ce922d3f --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__int8ss_append_all +#define _TEST__F_type_array__int8ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_int8ss_append_all() + */ +extern void test__f_type_array_int8ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_int8ss_append_all() + */ +extern void test__f_type_array_int8ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_int8ss_append_all() + */ +extern void test__f_type_array_int8ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__int8ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decimate_by.c index 6523a9df1..373da6343 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int8ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int8ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_int8ss_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decimate_by.h index 19afd6c34..aba84119c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8ss_decimate_by__works(void **state); * * @see f_type_array_int8ss_decimate_by() */ -extern void test__f_type_array_int8ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int8ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decrease_by.c index ae62dd78c..67e3342cb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_int8ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_int8ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_int8ss_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decrease_by.h index 3944b7d06..2925c2465 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8ss_decrease_by__works(void **state); * * @see f_type_array_int8ss_decrease_by() */ -extern void test__f_type_array_int8ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int8ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase.c index 009e260aa..39445e040 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_int8ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_int8ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_int8ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8ss_increase__parameter_checking(void **state) { const int length = 5; f_int8ss_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase.h index 5b08baba1..1d18bb67b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_int8ss_increase__returns_data_not(void **state); * * @see f_type_array_int8ss_increase() */ -extern void test__f_type_array_int8ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__int8ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase_by.c index bb20da4a3..dc4f64ee6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_int8ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_int8ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8ss_increase_by__parameter_checking(void **state) { const int length = 5; f_int8ss_t data = f_int8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase_by.h index 5668e6fb7..1c8071937 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8ss_increase_by__works(void **state); * * @see f_type_array_int8ss_increase_by() */ -extern void test__f_type_array_int8ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__int8ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_resize.c index 72018800a..49b9f42a9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_int8ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_int8ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_int8ss_resize__parameter_checking(void **state) { const int length = 5; f_int8ss_t data = f_int8ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_resize.h index b3eaf4704..42dda375b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-int8ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_int8ss_resize__works(void **state); * * @see f_type_array_int8ss_resize() */ -extern void test__f_type_array_int8ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_int8ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__int8ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_adjust.c index 7bbd14c8f..4337c9935 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_states_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_states_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_states_adjust__parameter_checking(void **state) { const int length = 5; f_states_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-states_adjust.h index ef92edc79..dbc993a87 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_states_adjust__works(void **state); * * @see f_type_array_states_adjust() */ -extern void test__f_type_array_states_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_states_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__states_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_append.c index 7c6e95b21..849dae4e7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_append.c @@ -7,92 +7,39 @@ extern "C" { void test__f_type_array_states_append__works(void **state) { - const int length = 5; - f_states_t source = f_states_t_initialize; - f_states_t destination = f_states_t_initialize; - - const f_state_t state_0 = { .step_large = 10, .step_small = 1, .handle = 0, .interrupt = 0, .callbacks = 0, .custom = 0, .data = 0 }; - const f_state_t state_1 = { .step_large = 20, .step_small = 2, .handle = 0, .interrupt = 0, .callbacks = 0, .custom = 0, .data = 0 }; - - { - const f_status_t status = f_states_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } + int fake_1 = 1; + int fake_2 = 2; + int fake_3 = 3; - memcpy(&source.array[source.used++], (void *) &state_0, sizeof(f_state_t)); - memcpy(&source.array[source.used++], (void *) &state_1, sizeof(f_state_t)); + const f_state_t source = macro_f_state_t_initialize(12, 6, 0, 0, (void *) &fake_1, (void *) &fake_2, (void *) &fake_3); + f_states_t destination = f_states_t_initialize; { const f_status_t status = f_states_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - assert_int_equal(destination.array[0].step_large, state_0.step_large); - assert_int_equal(destination.array[0].step_small, state_0.step_small); - assert_null(destination.array[0].handle); - assert_null(destination.array[0].interrupt); - assert_null(destination.array[0].callbacks); - assert_null(destination.array[0].custom); - assert_null(destination.array[0].data); - - assert_int_equal(destination.array[1].step_large, state_1.step_large); - assert_int_equal(destination.array[1].step_small, state_1.step_small); - assert_null(destination.array[1].handle); - assert_null(destination.array[1].interrupt); - assert_null(destination.array[1].callbacks); - assert_null(destination.array[1].custom); - assert_null(destination.array[1].data); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].step_large, source.step_large); + assert_int_equal(destination.array[0].step_small, source.step_small); + assert_int_equal(destination.array[0].handle, source.handle); + assert_int_equal(destination.array[0].interrupt, source.interrupt); + assert_int_equal(destination.array[0].callbacks, source.callbacks); + assert_int_equal(destination.array[0].custom, source.custom); + assert_int_equal(destination.array[0].data, source.data); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_states_append__returns_data_not(void **state) { - - const int length = 5; - f_states_t source = f_states_t_initialize; - f_states_t destination = f_states_t_initialize; - - { - const f_status_t status = f_states_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_states_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_states_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_states_append__parameter_checking(void **state) { - const int length = 5; - f_states_t data = f_states_t_initialize; + const f_state_t data = f_state_t_initialize; { const f_status_t status = f_states_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-states_append.h index 7afc0e0a8..43d227d61 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_states_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_states_append() - */ -extern void test__f_type_array_states_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_states_append() */ -extern void test__f_type_array_states_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_states_append__parameter_checking(void **state); #endif // _TEST__F_type_array__states_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_append_all.c new file mode 100644 index 000000000..0c7938ca3 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_append_all.c @@ -0,0 +1,95 @@ +#include "test-type_array.h" +#include "test-type_array-states_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_states_append_all__works(void **state) { + + const int length = 5; + f_states_t source = f_states_t_initialize; + f_states_t destination = f_states_t_initialize; + + const f_state_t state_0 = { .step_large = 10, .step_small = 1, .handle = 0, .interrupt = 0, .callbacks = 0, .custom = 0, .data = 0 }; + const f_state_t state_1 = { .step_large = 20, .step_small = 2, .handle = 0, .interrupt = 0, .callbacks = 0, .custom = 0, .data = 0 }; + + { + const f_status_t status = f_states_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + memcpy(&source.array[source.used++], (void *) &state_0, sizeof(f_state_t)); + memcpy(&source.array[source.used++], (void *) &state_1, sizeof(f_state_t)); + + { + const f_status_t status = f_states_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + assert_int_equal(destination.array[0].step_large, state_0.step_large); + assert_int_equal(destination.array[0].step_small, state_0.step_small); + assert_null(destination.array[0].handle); + assert_null(destination.array[0].interrupt); + assert_null(destination.array[0].callbacks); + assert_null(destination.array[0].custom); + assert_null(destination.array[0].data); + + assert_int_equal(destination.array[1].step_large, state_1.step_large); + assert_int_equal(destination.array[1].step_small, state_1.step_small); + assert_null(destination.array[1].handle); + assert_null(destination.array[1].interrupt); + assert_null(destination.array[1].callbacks); + assert_null(destination.array[1].custom); + assert_null(destination.array[1].data); + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_states_append_all__returns_data_not(void **state) { + + const int length = 5; + f_states_t source = f_states_t_initialize; + f_states_t destination = f_states_t_initialize; + + { + const f_status_t status = f_states_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_states_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_states_append_all__parameter_checking(void **state) { + + const f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_states_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-states_append_all.h new file mode 100644 index 000000000..a1f2babcc --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__states_append_all +#define _TEST__F_type_array__states_append_all + +/** + * Test that the function works. + * + * @see f_type_array_states_append_all() + */ +extern void test__f_type_array_states_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_states_append_all() + */ +extern void test__f_type_array_states_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_states_append_all() + */ +extern void test__f_type_array_states_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__states_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_decimate_by.c index 564888c5b..0594ff3ef 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_states_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_states_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_states_decimate_by__parameter_checking(void **state) { const int length = 5; f_states_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-states_decimate_by.h index 4b397bac3..a12f3ce1a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_states_decimate_by__works(void **state); * * @see f_type_array_states_decimate_by() */ -extern void test__f_type_array_states_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_states_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__states_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_decrease_by.c index 886c56863..69f02f385 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_states_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_states_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_states_decrease_by__parameter_checking(void **state) { const int length = 5; f_states_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-states_decrease_by.h index 04cf75b94..6b0e7da0d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_states_decrease_by__works(void **state); * * @see f_type_array_states_decrease_by() */ -extern void test__f_type_array_states_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_states_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__states_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_increase.c index ae612f018..36bd2cb50 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_states_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_states_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_states_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_states_increase__parameter_checking(void **state) { const int length = 5; f_states_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-states_increase.h index a653df20b..f3443ab0f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_states_increase__returns_data_not(void **state); * * @see f_type_array_states_increase() */ -extern void test__f_type_array_states_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_states_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__states_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_increase_by.c index 2de473e85..7fa61bd74 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_states_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_states_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_states_increase_by__parameter_checking(void **state) { const int length = 5; f_states_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-states_increase_by.h index 34a8cb0f8..e78e99eb3 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_states_increase_by__works(void **state); * * @see f_type_array_states_increase_by() */ -extern void test__f_type_array_states_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_states_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__states_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_resize.c index 668e137f1..ada5a9bcf 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_states_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_states_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_states_resize__parameter_checking(void **state) { const int length = 5; f_states_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-states_resize.h index 9b8e35b7c..79e7979a3 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_states_resize__works(void **state); * * @see f_type_array_states_resize() */ -extern void test__f_type_array_states_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_states_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__states_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_adjust.c index a48aa04c1..61b28e3b9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_statess_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_statess_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statess_adjust__parameter_checking(void **state) { const int length = 5; f_statess_t data = f_statess_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-statess_adjust.h index 6537c779d..5cb604e0f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statess_adjust__works(void **state); * * @see f_type_array_statess_adjust() */ -extern void test__f_type_array_statess_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statess_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__statess_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.c index 11877422a..585290aa6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.c @@ -8,67 +8,47 @@ extern "C" { void test__f_type_array_statess_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_statess_t source = f_states_t_initialize; - f_statess_t destination = f_states_t_initialize; + f_states_t source = f_states_t_initialize; + f_statess_t destination = f_statess_t_initialize; - const f_state_t state_0 = { .step_large = 10, .step_small = 1, .handle = 0, .interrupt = 0, .callbacks = 0, .custom = 0, .data = 0 }; - const f_state_t state_1 = { .step_large = 20, .step_small = 2, .handle = 0, .interrupt = 0, .callbacks = 0, .custom = 0, .data = 0 }; + int fake_1 = 1; + int fake_2 = 2; + int fake_3 = 3; + + const f_state_t state_data = macro_f_state_t_initialize(12, 6, 0, 0, (void *) &fake_1, (void *) &fake_2, (void *) &fake_3); { - const f_status_t status = f_statess_resize(length, &source); + const f_status_t status = f_states_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_states_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &state_0, sizeof(f_state_t)); - memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &state_1, sizeof(f_state_t)); - } // for - } + while (source.used < length) { + memcpy(&source.array[source.used++], (void *) &state_data, sizeof(f_state_t)); + } // while { const f_status_t status = f_statess_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - assert_int_equal(destination.array[i].array[0].step_large, state_0.step_large); - assert_int_equal(destination.array[i].array[0].step_small, state_0.step_small); - assert_null(destination.array[i].array[0].handle); - assert_null(destination.array[i].array[0].interrupt); - assert_null(destination.array[i].array[0].callbacks); - assert_null(destination.array[i].array[0].custom); - assert_null(destination.array[i].array[0].data); - - assert_int_equal(destination.array[i].array[1].step_large, state_1.step_large); - assert_int_equal(destination.array[i].array[1].step_small, state_1.step_small); - assert_null(destination.array[i].array[1].handle); - assert_null(destination.array[i].array[1].interrupt); - assert_null(destination.array[i].array[1].callbacks); - assert_null(destination.array[i].array[1].custom); - assert_null(destination.array[i].array[1].data); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + + assert_int_equal(destination.array[0].array[i].step_large, state_data.step_large); + assert_int_equal(destination.array[0].array[i].step_small, state_data.step_small); + assert_int_equal(destination.array[0].array[i].handle, state_data.handle); + assert_int_equal(destination.array[0].array[i].interrupt, state_data.interrupt); + assert_int_equal(destination.array[0].array[i].callbacks, state_data.callbacks); + assert_int_equal(destination.array[0].array[i].custom, state_data.custom); + assert_int_equal(destination.array[0].array[i].data, state_data.data); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -80,11 +60,11 @@ void test__f_type_array_statess_append__works(void **state) { void test__f_type_array_statess_append__returns_data_not(void **state) { const int length = 5; - f_statess_t source = f_states_t_initialize; - f_statess_t destination = f_states_t_initialize; + f_states_t source = f_states_t_initialize; + f_statess_t destination = f_statess_t_initialize; { - const f_status_t status = f_statess_resize(length, &source); + const f_status_t status = f_states_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -97,26 +77,21 @@ void test__f_type_array_statess_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_statess_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statess_append__parameter_checking(void **state) { - const int length = 5; - f_statess_t data = f_states_t_initialize; + f_states_t data = f_states_t_initialize; { const f_status_t status = f_statess_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.h index 7aca8b8e7..54f6bf4f4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_statess_append__returns_data_not(void **state); * * @see f_type_array_statess_append() */ -extern void test__f_type_array_statess_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statess_append__parameter_checking(void **state); #endif // _TEST__F_type_array__statess_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append_all.c new file mode 100644 index 000000000..91463562e --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append_all.c @@ -0,0 +1,119 @@ +#include "test-type_array.h" +#include "test-type_array-statess_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statess_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_statess_t source = f_statess_t_initialize; + f_statess_t destination = f_statess_t_initialize; + + const f_state_t state_0 = { .step_large = 10, .step_small = 1, .handle = 0, .interrupt = 0, .callbacks = 0, .custom = 0, .data = 0 }; + const f_state_t state_1 = { .step_large = 20, .step_small = 2, .handle = 0, .interrupt = 0, .callbacks = 0, .custom = 0, .data = 0 }; + + { + const f_status_t status = f_statess_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_states_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &state_0, sizeof(f_state_t)); + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &state_1, sizeof(f_state_t)); + } // for + } + + { + const f_status_t status = f_statess_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + assert_int_equal(destination.array[i].array[0].step_large, state_0.step_large); + assert_int_equal(destination.array[i].array[0].step_small, state_0.step_small); + assert_null(destination.array[i].array[0].handle); + assert_null(destination.array[i].array[0].interrupt); + assert_null(destination.array[i].array[0].callbacks); + assert_null(destination.array[i].array[0].custom); + assert_null(destination.array[i].array[0].data); + + assert_int_equal(destination.array[i].array[1].step_large, state_1.step_large); + assert_int_equal(destination.array[i].array[1].step_small, state_1.step_small); + assert_null(destination.array[i].array[1].handle); + assert_null(destination.array[i].array[1].interrupt); + assert_null(destination.array[i].array[1].callbacks); + assert_null(destination.array[i].array[1].custom); + assert_null(destination.array[i].array[1].data); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_statess_append_all__returns_data_not(void **state) { + + const int length = 5; + f_statess_t source = f_statess_t_initialize; + f_statess_t destination = f_statess_t_initialize; + + { + const f_status_t status = f_statess_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_statess_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_statess_append_all__parameter_checking(void **state) { + + const f_statess_t data = f_statess_t_initialize; + + { + const f_status_t status = f_statess_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append_all.h new file mode 100644 index 000000000..b8a72ead0 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statess_append_all +#define _TEST__F_type_array__statess_append_all + +/** + * Test that the function works. + * + * @see f_type_array_statess_append_all() + */ +extern void test__f_type_array_statess_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statess_append_all() + */ +extern void test__f_type_array_statess_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statess_append_all() + */ +extern void test__f_type_array_statess_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__statess_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_decimate_by.c index ff8eb9775..037550296 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_statess_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_statess_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statess_decimate_by__parameter_checking(void **state) { const int length = 5; f_statess_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statess_decimate_by.h index 56f8d038a..dae8b9df9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statess_decimate_by__works(void **state); * * @see f_type_array_statess_decimate_by() */ -extern void test__f_type_array_statess_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statess_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statess_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_decrease_by.c index 5f8e2aab3..753ff19b7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_statess_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_statess_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statess_decrease_by__parameter_checking(void **state) { const int length = 5; f_statess_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statess_decrease_by.h index 6b6d36f86..b855d49f4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statess_decrease_by__works(void **state); * * @see f_type_array_statess_decrease_by() */ -extern void test__f_type_array_statess_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statess_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statess_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase.c index 2f09f9b3f..367d9a5ac 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_statess_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_statess_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_statess_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statess_increase__parameter_checking(void **state) { const int length = 5; f_statess_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase.h index fa39f7eb0..d015d5d0c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_statess_increase__returns_data_not(void **state); * * @see f_type_array_statess_increase() */ -extern void test__f_type_array_statess_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statess_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__statess_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase_by.c index 5c7447c48..77070d2d7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_statess_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_statess_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statess_increase_by__parameter_checking(void **state) { const int length = 5; f_statess_t data = f_states_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase_by.h index fca473b2e..a93ffba97 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statess_increase_by__works(void **state); * * @see f_type_array_statess_increase_by() */ -extern void test__f_type_array_statess_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statess_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statess_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_resize.c index 2ef625145..a953b9467 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_statess_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_statess_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statess_resize__parameter_checking(void **state) { const int length = 5; f_statess_t data = f_statess_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-statess_resize.h index 5ec100772..448f6d832 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statess_resize__works(void **state); * * @see f_type_array_statess_resize() */ -extern void test__f_type_array_statess_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statess_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__statess_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_adjust.c index 2c4fb7a07..ba7dcc6bf 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_statuss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_statuss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statuss_adjust__parameter_checking(void **state) { const int length = 5; f_statuss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_adjust.h index 412065f1c..24e5d53d0 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statuss_adjust__works(void **state); * * @see f_type_array_statuss_adjust() */ -extern void test__f_type_array_statuss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statuss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__statuss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append.c index ce5f15052..fb8d90506 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_statuss_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_statuss_t source = f_statuss_t_initialize; + const f_status_t source = 3; f_statuss_t destination = f_statuss_t_initialize; - { - const f_status_t status = f_statuss_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_statuss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_statuss_append__returns_data_not(void **state) { +void test__f_type_array_statuss_append__parameter_checking(void **state) { - const int length = 5; - f_statuss_t source = f_statuss_t_initialize; - f_statuss_t destination = f_statuss_t_initialize; - - { - const f_status_t status = f_statuss_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_statuss_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_statuss_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_statuss_t data = f_statuss_t_initialize; + const f_status_t data = f_status_t_initialize; { const f_status_t status = f_statuss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append.h index e4d1d99b0..6fb277f10 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_statuss_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_statuss_append() - */ -extern void test__f_type_array_statuss_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_statuss_append() */ -extern void test__f_type_array_statuss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statuss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__statuss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append_all.c new file mode 100644 index 000000000..07b1a060c --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-statuss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statuss_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_statuss_t source = f_statuss_t_initialize; + f_statuss_t destination = f_statuss_t_initialize; + + { + const f_status_t status = f_statuss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_statuss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_statuss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_statuss_t source = f_statuss_t_initialize; + f_statuss_t destination = f_statuss_t_initialize; + + { + const f_status_t status = f_statuss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_statuss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_statuss_append_all__parameter_checking(void **state) { + + const f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_statuss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append_all.h new file mode 100644 index 000000000..c870109d3 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statuss_append_all +#define _TEST__F_type_array__statuss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_statuss_append_all() + */ +extern void test__f_type_array_statuss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statuss_append_all() + */ +extern void test__f_type_array_statuss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statuss_append_all() + */ +extern void test__f_type_array_statuss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__statuss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decimate_by.c index ec845a7e4..962080cd8 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_statuss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_statuss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statuss_decimate_by__parameter_checking(void **state) { const int length = 5; f_statuss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decimate_by.h index f6e8bb249..cd317d30d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statuss_decimate_by__works(void **state); * * @see f_type_array_statuss_decimate_by() */ -extern void test__f_type_array_statuss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statuss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statuss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decrease_by.c index 4be9e7663..24bcde4b1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_statuss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_statuss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statuss_decrease_by__parameter_checking(void **state) { const int length = 5; f_statuss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decrease_by.h index 8b8f43b50..52aef547e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statuss_decrease_by__works(void **state); * * @see f_type_array_statuss_decrease_by() */ -extern void test__f_type_array_statuss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statuss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statuss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase.c index 04cfd656e..5d68d7a07 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_statuss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_statuss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_statuss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statuss_increase__parameter_checking(void **state) { const int length = 5; f_statuss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase.h index 6c30bf036..65a9252e2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_statuss_increase__returns_data_not(void **state); * * @see f_type_array_statuss_increase() */ -extern void test__f_type_array_statuss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statuss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__statuss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase_by.c index 7be778bef..f828eaa82 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_statuss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_statuss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statuss_increase_by__parameter_checking(void **state) { const int length = 5; f_statuss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase_by.h index 0f410bfd0..bdf0fb1c2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statuss_increase_by__works(void **state); * * @see f_type_array_statuss_increase_by() */ -extern void test__f_type_array_statuss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statuss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statuss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_resize.c index f73f81e3e..2ecb2a4c6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_statuss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_statuss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statuss_resize__parameter_checking(void **state) { const int length = 5; f_statuss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_resize.h index e4e7ec105..4ce51812a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statuss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statuss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statuss_resize__works(void **state); * * @see f_type_array_statuss_resize() */ -extern void test__f_type_array_statuss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statuss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__statuss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_adjust.c index 1502c3146..d71506985 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_statusss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_statusss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statusss_adjust__parameter_checking(void **state) { const int length = 5; f_statusss_t data = f_statusss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_adjust.h index 9dfb7caaa..2e7f4e8eb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statusss_adjust__works(void **state); * * @see f_type_array_statusss_adjust() */ -extern void test__f_type_array_statusss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statusss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__statusss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append.c index ef10deee9..a0ddc4278 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_statusss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_statusss_t source = f_statuss_t_initialize; - f_statusss_t destination = f_statuss_t_initialize; + f_statuss_t source = f_statuss_t_initialize; + f_statusss_t destination = f_statusss_t_initialize; { - const f_status_t status = f_statusss_resize(length, &source); + const f_status_t status = f_statuss_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_statuss_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_statusss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_statusss_append__works(void **state) { void test__f_type_array_statusss_append__returns_data_not(void **state) { const int length = 5; - f_statusss_t source = f_statuss_t_initialize; - f_statusss_t destination = f_statuss_t_initialize; + f_statuss_t source = f_statuss_t_initialize; + f_statusss_t destination = f_statusss_t_initialize; { - const f_status_t status = f_statusss_resize(length, &source); + const f_status_t status = f_statuss_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_statusss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_statusss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statusss_append__parameter_checking(void **state) { - const int length = 5; - f_statusss_t data = f_statuss_t_initialize; + f_statuss_t data = f_statuss_t_initialize; { const f_status_t status = f_statusss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append.h index f67a8b5b8..89b921e9a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_statusss_append__returns_data_not(void **state); * * @see f_type_array_statusss_append() */ -extern void test__f_type_array_statusss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statusss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__statusss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append_all.c new file mode 100644 index 000000000..b0b13a1eb --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-statusss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statusss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_statusss_t source = f_statusss_t_initialize; + f_statusss_t destination = f_statusss_t_initialize; + + { + const f_status_t status = f_statusss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_statuss_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_statusss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_statusss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_statusss_t source = f_statusss_t_initialize; + f_statusss_t destination = f_statusss_t_initialize; + + { + const f_status_t status = f_statusss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_statusss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_statusss_append_all__parameter_checking(void **state) { + + const f_statusss_t data = f_statusss_t_initialize; + + { + const f_status_t status = f_statusss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append_all.h new file mode 100644 index 000000000..54ac1cff7 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statusss_append_all +#define _TEST__F_type_array__statusss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_statusss_append_all() + */ +extern void test__f_type_array_statusss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statusss_append_all() + */ +extern void test__f_type_array_statusss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statusss_append_all() + */ +extern void test__f_type_array_statusss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__statusss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decimate_by.c index 72474b794..8a7b0411d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_statusss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_statusss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statusss_decimate_by__parameter_checking(void **state) { const int length = 5; f_statusss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decimate_by.h index 87d1f3ce0..79428b90d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statusss_decimate_by__works(void **state); * * @see f_type_array_statusss_decimate_by() */ -extern void test__f_type_array_statusss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statusss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statusss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decrease_by.c index f5b24e3c2..19b69cebc 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_statusss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_statusss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statusss_decrease_by__parameter_checking(void **state) { const int length = 5; f_statusss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decrease_by.h index deaa87a0c..e780d3ffa 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statusss_decrease_by__works(void **state); * * @see f_type_array_statusss_decrease_by() */ -extern void test__f_type_array_statusss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statusss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statusss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase.c index 16a263401..b0476ae49 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_statusss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_statusss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_statusss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statusss_increase__parameter_checking(void **state) { const int length = 5; f_statusss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase.h index faa511e49..18a1cabd1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_statusss_increase__returns_data_not(void **state) * * @see f_type_array_statusss_increase() */ -extern void test__f_type_array_statusss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statusss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__statusss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase_by.c index e4afc46da..0e980331d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_statusss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_statusss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statusss_increase_by__parameter_checking(void **state) { const int length = 5; f_statusss_t data = f_statuss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase_by.h index 934a1d315..203c72ada 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statusss_increase_by__works(void **state); * * @see f_type_array_statusss_increase_by() */ -extern void test__f_type_array_statusss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statusss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__statusss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_resize.c index af2d50ec0..b3ecfda64 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_statusss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_statusss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_statusss_resize__parameter_checking(void **state) { const int length = 5; f_statusss_t data = f_statusss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_resize.h index e893fd2f1..e95a2dee7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statusss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statusss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_statusss_resize__works(void **state); * * @see f_type_array_statusss_resize() */ -extern void test__f_type_array_statusss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_statusss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__statusss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_adjust.c index 9f048e12a..37025d71f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint128s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint128s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128s_adjust__parameter_checking(void **state) { const int length = 5; f_uint128s_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_adjust.h index 44fc7db2c..6315a5dc4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128s_adjust__works(void **state); * * @see f_type_array_uint128s_adjust() */ -extern void test__f_type_array_uint128s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append.c index fcb4011e9..516e45077 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_uint128s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_uint128s_t source = f_uint128s_t_initialize; + const uint128_t source = 3; f_uint128s_t destination = f_uint128s_t_initialize; - { - const f_status_t status = f_uint128s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_uint128s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_uint128s_append__returns_data_not(void **state) { +void test__f_type_array_uint128s_append__parameter_checking(void **state) { - const int length = 5; - f_uint128s_t source = f_uint128s_t_initialize; - f_uint128s_t destination = f_uint128s_t_initialize; - - { - const f_status_t status = f_uint128s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_uint128s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_uint128s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_uint128s_t data = f_uint128s_t_initialize; + const uint128_t data = 0; { const f_status_t status = f_uint128s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append.h index ac82d7c93..93ccaf10a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_uint128s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_uint128s_append() - */ -extern void test__f_type_array_uint128s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_uint128s_append() */ -extern void test__f_type_array_uint128s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append_all.c new file mode 100644 index 000000000..afbad49bc --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-uint128s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint128s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_uint128s_t source = f_uint128s_t_initialize; + f_uint128s_t destination = f_uint128s_t_initialize; + + { + const f_status_t status = f_uint128s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_uint128s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint128s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint128s_t source = f_uint128s_t_initialize; + f_uint128s_t destination = f_uint128s_t_initialize; + + { + const f_status_t status = f_uint128s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint128s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint128s_append_all__parameter_checking(void **state) { + + const f_uint128s_t data = f_uint128s_t_initialize; + + { + const f_status_t status = f_uint128s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append_all.h new file mode 100644 index 000000000..40d61c78c --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint128s_append_all +#define _TEST__F_type_array__uint128s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint128s_append_all() + */ +extern void test__f_type_array_uint128s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint128s_append_all() + */ +extern void test__f_type_array_uint128s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint128s_append_all() + */ +extern void test__f_type_array_uint128s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint128s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decimate_by.c index 2e60f42c3..d082f439f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint128s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint128s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128s_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint128s_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decimate_by.h index 29fad70e2..a4f4356c4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128s_decimate_by__works(void **state); * * @see f_type_array_uint128s_decimate_by() */ -extern void test__f_type_array_uint128s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decrease_by.c index f12052c10..1d6b42ed4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint128s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint128s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128s_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint128s_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decrease_by.h index 96ec7b185..9c21df093 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128s_decrease_by__works(void **state); * * @see f_type_array_uint128s_decrease_by() */ -extern void test__f_type_array_uint128s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase.c index 497c0f39c..5a8143f49 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint128s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint128s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint128s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128s_increase__parameter_checking(void **state) { const int length = 5; f_uint128s_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase.h index ffd3b01cd..94e707935 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint128s_increase__returns_data_not(void **state) * * @see f_type_array_uint128s_increase() */ -extern void test__f_type_array_uint128s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase_by.c index 4e9567544..0cd369700 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint128s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint128s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128s_increase_by__parameter_checking(void **state) { const int length = 5; f_uint128s_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase_by.h index fd71330ee..90317acbd 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128s_increase_by__works(void **state); * * @see f_type_array_uint128s_increase_by() */ -extern void test__f_type_array_uint128s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_resize.c index a44ec733c..65dcf2971 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint128s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint128s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128s_resize__parameter_checking(void **state) { const int length = 5; f_uint128s_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_resize.h index a1ab9bd52..e21448d68 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128s_resize__works(void **state); * * @see f_type_array_uint128s_resize() */ -extern void test__f_type_array_uint128s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_adjust.c index 5e36340a3..224e63542 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint128ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint128ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128ss_adjust__parameter_checking(void **state) { const int length = 5; f_uint128ss_t data = f_uint128ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_adjust.h index 60c4b99b9..3a0bcde02 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128ss_adjust__works(void **state); * * @see f_type_array_uint128ss_adjust() */ -extern void test__f_type_array_uint128ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append.c index e294fd9c0..50ba45dc7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_uint128ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_uint128ss_t source = f_uint128s_t_initialize; - f_uint128ss_t destination = f_uint128s_t_initialize; + f_uint128s_t source = f_uint128s_t_initialize; + f_uint128ss_t destination = f_uint128ss_t_initialize; { - const f_status_t status = f_uint128ss_resize(length, &source); + const f_status_t status = f_uint128s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_uint128s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_uint128ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_uint128ss_append__works(void **state) { void test__f_type_array_uint128ss_append__returns_data_not(void **state) { const int length = 5; - f_uint128ss_t source = f_uint128s_t_initialize; - f_uint128ss_t destination = f_uint128s_t_initialize; + f_uint128s_t source = f_uint128s_t_initialize; + f_uint128ss_t destination = f_uint128ss_t_initialize; { - const f_status_t status = f_uint128ss_resize(length, &source); + const f_status_t status = f_uint128s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_uint128ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_uint128ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128ss_append__parameter_checking(void **state) { - const int length = 5; - f_uint128ss_t data = f_uint128s_t_initialize; + f_uint128s_t data = f_uint128s_t_initialize; { const f_status_t status = f_uint128ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append.h index 1d666ac90..d019beb43 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint128ss_append__returns_data_not(void **state); * * @see f_type_array_uint128ss_append() */ -extern void test__f_type_array_uint128ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append_all.c new file mode 100644 index 000000000..a3ca3c07f --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-uint128ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint128ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_uint128ss_t source = f_uint128ss_t_initialize; + f_uint128ss_t destination = f_uint128ss_t_initialize; + + { + const f_status_t status = f_uint128ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_uint128s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_uint128ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint128ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint128ss_t source = f_uint128ss_t_initialize; + f_uint128ss_t destination = f_uint128ss_t_initialize; + + { + const f_status_t status = f_uint128ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint128ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint128ss_append_all__parameter_checking(void **state) { + + const f_uint128ss_t data = f_uint128ss_t_initialize; + + { + const f_status_t status = f_uint128ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append_all.h new file mode 100644 index 000000000..0b1046601 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint128ss_append_all +#define _TEST__F_type_array__uint128ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint128ss_append_all() + */ +extern void test__f_type_array_uint128ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint128ss_append_all() + */ +extern void test__f_type_array_uint128ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint128ss_append_all() + */ +extern void test__f_type_array_uint128ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint128ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decimate_by.c index 106309aa9..c5f8994f4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint128ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint128ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint128ss_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decimate_by.h index 494d0fee9..763184e56 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128ss_decimate_by__works(void **state); * * @see f_type_array_uint128ss_decimate_by() */ -extern void test__f_type_array_uint128ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decrease_by.c index 8dfc0f1f4..e8d7ee58e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint128ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint128ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint128ss_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decrease_by.h index 3a97b72e6..f6787bcc3 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128ss_decrease_by__works(void **state); * * @see f_type_array_uint128ss_decrease_by() */ -extern void test__f_type_array_uint128ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase.c index 6d5126bed..85cb58e8d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint128ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint128ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint128ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128ss_increase__parameter_checking(void **state) { const int length = 5; f_uint128ss_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase.h index adffcfdeb..98a2cce8a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint128ss_increase__returns_data_not(void **state * * @see f_type_array_uint128ss_increase() */ -extern void test__f_type_array_uint128ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase_by.c index 7a9954293..90ee4a9df 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint128ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint128ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128ss_increase_by__parameter_checking(void **state) { const int length = 5; f_uint128ss_t data = f_uint128s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase_by.h index 0d2d29028..c1950d8b9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128ss_increase_by__works(void **state); * * @see f_type_array_uint128ss_increase_by() */ -extern void test__f_type_array_uint128ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_resize.c index 83f6afa80..b4999f123 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint128ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint128ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint128ss_resize__parameter_checking(void **state) { const int length = 5; f_uint128ss_t data = f_uint128ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_resize.h index db2f98fb0..be44630df 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint128ss_resize__works(void **state); * * @see f_type_array_uint128ss_resize() */ -extern void test__f_type_array_uint128ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint128ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint128ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_adjust.c index 6098400bb..e5845d173 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint16s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint16s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16s_adjust__parameter_checking(void **state) { const int length = 5; f_uint16s_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_adjust.h index 2012422fd..ba5c21f7b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16s_adjust__works(void **state); * * @see f_type_array_uint16s_adjust() */ -extern void test__f_type_array_uint16s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append.c index f00fb0a25..62f6a6543 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_uint16s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_uint16s_t source = f_uint16s_t_initialize; + const uint16_t source = 3; f_uint16s_t destination = f_uint16s_t_initialize; - { - const f_status_t status = f_uint16s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_uint16s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_uint16s_append__returns_data_not(void **state) { +void test__f_type_array_uint16s_append__parameter_checking(void **state) { - const int length = 5; - f_uint16s_t source = f_uint16s_t_initialize; - f_uint16s_t destination = f_uint16s_t_initialize; - - { - const f_status_t status = f_uint16s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_uint16s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_uint16s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_uint16s_t data = f_uint16s_t_initialize; + const uint16_t data = 0; { const f_status_t status = f_uint16s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append.h index a568c77b8..3a111c66d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_uint16s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_uint16s_append() - */ -extern void test__f_type_array_uint16s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_uint16s_append() */ -extern void test__f_type_array_uint16s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append_all.c new file mode 100644 index 000000000..519411b2d --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-uint16s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint16s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_uint16s_t source = f_uint16s_t_initialize; + f_uint16s_t destination = f_uint16s_t_initialize; + + { + const f_status_t status = f_uint16s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_uint16s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint16s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint16s_t source = f_uint16s_t_initialize; + f_uint16s_t destination = f_uint16s_t_initialize; + + { + const f_status_t status = f_uint16s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint16s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint16s_append_all__parameter_checking(void **state) { + + const f_uint16s_t data = f_uint16s_t_initialize; + + { + const f_status_t status = f_uint16s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append_all.h new file mode 100644 index 000000000..db4a986b7 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint16s_append_all +#define _TEST__F_type_array__uint16s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint16s_append_all() + */ +extern void test__f_type_array_uint16s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint16s_append_all() + */ +extern void test__f_type_array_uint16s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint16s_append_all() + */ +extern void test__f_type_array_uint16s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint16s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decimate_by.c index f68ffec34..6dbfbd333 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint16s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint16s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16s_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint16s_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decimate_by.h index 4dce39657..1a7694866 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16s_decimate_by__works(void **state); * * @see f_type_array_uint16s_decimate_by() */ -extern void test__f_type_array_uint16s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decrease_by.c index f3a24bb55..bc68694e1 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint16s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint16s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16s_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint16s_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decrease_by.h index dae04f426..144eda0ba 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16s_decrease_by__works(void **state); * * @see f_type_array_uint16s_decrease_by() */ -extern void test__f_type_array_uint16s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase.c index 728366955..065a40afa 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint16s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint16s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint16s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16s_increase__parameter_checking(void **state) { const int length = 5; f_uint16s_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase.h index a8c7ef5fb..a754c56c4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint16s_increase__returns_data_not(void **state); * * @see f_type_array_uint16s_increase() */ -extern void test__f_type_array_uint16s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase_by.c index 180084978..ca07bdc92 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint16s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint16s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16s_increase_by__parameter_checking(void **state) { const int length = 5; f_uint16s_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase_by.h index 6a327db55..61a7e0f1a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16s_increase_by__works(void **state); * * @see f_type_array_uint16s_increase_by() */ -extern void test__f_type_array_uint16s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_resize.c index 73aab2980..5357df0b9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint16s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint16s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16s_resize__parameter_checking(void **state) { const int length = 5; f_uint16s_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_resize.h index 3bb8875d9..d34513e67 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16s_resize__works(void **state); * * @see f_type_array_uint16s_resize() */ -extern void test__f_type_array_uint16s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_adjust.c index 4aa80afdd..58dce85dd 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint16ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint16ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16ss_adjust__parameter_checking(void **state) { const int length = 5; f_uint16ss_t data = f_uint16ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_adjust.h index 8d66d02b1..427d558b7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16ss_adjust__works(void **state); * * @see f_type_array_uint16ss_adjust() */ -extern void test__f_type_array_uint16ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append.c index 70a2087b9..a89594f5f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_uint16ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_uint16ss_t source = f_uint16s_t_initialize; - f_uint16ss_t destination = f_uint16s_t_initialize; + f_uint16s_t source = f_uint16s_t_initialize; + f_uint16ss_t destination = f_uint16ss_t_initialize; { - const f_status_t status = f_uint16ss_resize(length, &source); + const f_status_t status = f_uint16s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_uint16s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_uint16ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_uint16ss_append__works(void **state) { void test__f_type_array_uint16ss_append__returns_data_not(void **state) { const int length = 5; - f_uint16ss_t source = f_uint16s_t_initialize; - f_uint16ss_t destination = f_uint16s_t_initialize; + f_uint16s_t source = f_uint16s_t_initialize; + f_uint16ss_t destination = f_uint16ss_t_initialize; { - const f_status_t status = f_uint16ss_resize(length, &source); + const f_status_t status = f_uint16s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_uint16ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_uint16ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16ss_append__parameter_checking(void **state) { - const int length = 5; - f_uint16ss_t data = f_uint16s_t_initialize; + f_uint16s_t data = f_uint16s_t_initialize; { const f_status_t status = f_uint16ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append.h index 8da5310cf..3ddc590b3 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint16ss_append__returns_data_not(void **state); * * @see f_type_array_uint16ss_append() */ -extern void test__f_type_array_uint16ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append_all.c new file mode 100644 index 000000000..4f1f37c38 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-uint16ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint16ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_uint16ss_t source = f_uint16ss_t_initialize; + f_uint16ss_t destination = f_uint16ss_t_initialize; + + { + const f_status_t status = f_uint16ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_uint16s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_uint16ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint16ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint16ss_t source = f_uint16ss_t_initialize; + f_uint16ss_t destination = f_uint16ss_t_initialize; + + { + const f_status_t status = f_uint16ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint16ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint16ss_append_all__parameter_checking(void **state) { + + const f_uint16ss_t data = f_uint16ss_t_initialize; + + { + const f_status_t status = f_uint16ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append_all.h new file mode 100644 index 000000000..204816999 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint16ss_append_all +#define _TEST__F_type_array__uint16ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint16ss_append_all() + */ +extern void test__f_type_array_uint16ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint16ss_append_all() + */ +extern void test__f_type_array_uint16ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint16ss_append_all() + */ +extern void test__f_type_array_uint16ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint16ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decimate_by.c index 291cf945f..f02ea0d2f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint16ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint16ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint16ss_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decimate_by.h index 68c690fb5..08b335dbf 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16ss_decimate_by__works(void **state); * * @see f_type_array_uint16ss_decimate_by() */ -extern void test__f_type_array_uint16ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decrease_by.c index c789a8d90..4a547abfe 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint16ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint16ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint16ss_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decrease_by.h index c8bb16997..e9c46e396 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16ss_decrease_by__works(void **state); * * @see f_type_array_uint16ss_decrease_by() */ -extern void test__f_type_array_uint16ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase.c index 58330cf63..b47b0d22c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint16ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint16ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint16ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16ss_increase__parameter_checking(void **state) { const int length = 5; f_uint16ss_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase.h index 9f4472ea9..df1cbf285 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint16ss_increase__returns_data_not(void **state) * * @see f_type_array_uint16ss_increase() */ -extern void test__f_type_array_uint16ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase_by.c index 091537981..4ad84b62d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint16ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint16ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16ss_increase_by__parameter_checking(void **state) { const int length = 5; f_uint16ss_t data = f_uint16s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase_by.h index 6a5d8b3d2..54cc5a3a6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16ss_increase_by__works(void **state); * * @see f_type_array_uint16ss_increase_by() */ -extern void test__f_type_array_uint16ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_resize.c index 77a877c0b..4936f1b5a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint16ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint16ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint16ss_resize__parameter_checking(void **state) { const int length = 5; f_uint16ss_t data = f_uint16ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_resize.h index c34e57295..5f1af71ee 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint16ss_resize__works(void **state); * * @see f_type_array_uint16ss_resize() */ -extern void test__f_type_array_uint16ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint16ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint16ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_adjust.c index b2edc91e4..70af09099 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint32s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint32s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32s_adjust__parameter_checking(void **state) { const int length = 5; f_uint32s_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_adjust.h index b6511831c..4b8587032 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32s_adjust__works(void **state); * * @see f_type_array_uint32s_adjust() */ -extern void test__f_type_array_uint32s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append.c index db0d48211..723abf763 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_uint32s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_uint32s_t source = f_uint32s_t_initialize; + const uint32_t source = 3; f_uint32s_t destination = f_uint32s_t_initialize; - { - const f_status_t status = f_uint32s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_uint32s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_uint32s_append__returns_data_not(void **state) { +void test__f_type_array_uint32s_append__parameter_checking(void **state) { - const int length = 5; - f_uint32s_t source = f_uint32s_t_initialize; - f_uint32s_t destination = f_uint32s_t_initialize; - - { - const f_status_t status = f_uint32s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_uint32s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_uint32s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_uint32s_t data = f_uint32s_t_initialize; + const uint32_t data = 0; { const f_status_t status = f_uint32s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append.h index dbf57e988..884e11e4e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_uint32s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_uint32s_append() - */ -extern void test__f_type_array_uint32s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_uint32s_append() */ -extern void test__f_type_array_uint32s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append_all.c new file mode 100644 index 000000000..43529a0da --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-uint32s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint32s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_uint32s_t source = f_uint32s_t_initialize; + f_uint32s_t destination = f_uint32s_t_initialize; + + { + const f_status_t status = f_uint32s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_uint32s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint32s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint32s_t source = f_uint32s_t_initialize; + f_uint32s_t destination = f_uint32s_t_initialize; + + { + const f_status_t status = f_uint32s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint32s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint32s_append_all__parameter_checking(void **state) { + + const f_uint32s_t data = f_uint32s_t_initialize; + + { + const f_status_t status = f_uint32s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append_all.h new file mode 100644 index 000000000..521e499d7 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint32s_append_all +#define _TEST__F_type_array__uint32s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint32s_append_all() + */ +extern void test__f_type_array_uint32s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint32s_append_all() + */ +extern void test__f_type_array_uint32s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint32s_append_all() + */ +extern void test__f_type_array_uint32s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint32s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decimate_by.c index 57ad5a011..950d1b012 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint32s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint32s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32s_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint32s_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decimate_by.h index a4cd42a16..f549ca6cc 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32s_decimate_by__works(void **state); * * @see f_type_array_uint32s_decimate_by() */ -extern void test__f_type_array_uint32s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decrease_by.c index 4c9be8b17..392052b3e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint32s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint32s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32s_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint32s_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decrease_by.h index d0fa5da0a..35f03bba2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32s_decrease_by__works(void **state); * * @see f_type_array_uint32s_decrease_by() */ -extern void test__f_type_array_uint32s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase.c index bc65739bd..d77df7fcb 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint32s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint32s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint32s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32s_increase__parameter_checking(void **state) { const int length = 5; f_uint32s_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase.h index 842a5b921..e0db8f355 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint32s_increase__returns_data_not(void **state); * * @see f_type_array_uint32s_increase() */ -extern void test__f_type_array_uint32s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase_by.c index f9ab27748..f165f0411 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint32s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint32s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32s_increase_by__parameter_checking(void **state) { const int length = 5; f_uint32s_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase_by.h index dda9416c3..6afbf5d70 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32s_increase_by__works(void **state); * * @see f_type_array_uint32s_increase_by() */ -extern void test__f_type_array_uint32s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_resize.c index 70694db6c..4006ef2a9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint32s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint32s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32s_resize__parameter_checking(void **state) { const int length = 5; f_uint32s_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_resize.h index b16a71402..26a116d37 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32s_resize__works(void **state); * * @see f_type_array_uint32s_resize() */ -extern void test__f_type_array_uint32s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_adjust.c index 5b59bd9ec..d1808091b 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint32ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint32ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32ss_adjust__parameter_checking(void **state) { const int length = 5; f_uint32ss_t data = f_uint32ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_adjust.h index 584611035..5d27154de 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32ss_adjust__works(void **state); * * @see f_type_array_uint32ss_adjust() */ -extern void test__f_type_array_uint32ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append.c index 03e3de445..32cd33806 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_uint32ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_uint32ss_t source = f_uint32s_t_initialize; - f_uint32ss_t destination = f_uint32s_t_initialize; + f_uint32s_t source = f_uint32s_t_initialize; + f_uint32ss_t destination = f_uint32ss_t_initialize; { - const f_status_t status = f_uint32ss_resize(length, &source); + const f_status_t status = f_uint32s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_uint32s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_uint32ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_uint32ss_append__works(void **state) { void test__f_type_array_uint32ss_append__returns_data_not(void **state) { const int length = 5; - f_uint32ss_t source = f_uint32s_t_initialize; - f_uint32ss_t destination = f_uint32s_t_initialize; + f_uint32s_t source = f_uint32s_t_initialize; + f_uint32ss_t destination = f_uint32ss_t_initialize; { - const f_status_t status = f_uint32ss_resize(length, &source); + const f_status_t status = f_uint32s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_uint32ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_uint32ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32ss_append__parameter_checking(void **state) { - const int length = 5; - f_uint32ss_t data = f_uint32s_t_initialize; + f_uint32s_t data = f_uint32s_t_initialize; { const f_status_t status = f_uint32ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append.h index e5ce496b7..fd2cf401f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint32ss_append__returns_data_not(void **state); * * @see f_type_array_uint32ss_append() */ -extern void test__f_type_array_uint32ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append_all.c new file mode 100644 index 000000000..032593afa --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-uint32ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint32ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_uint32ss_t source = f_uint32ss_t_initialize; + f_uint32ss_t destination = f_uint32ss_t_initialize; + + { + const f_status_t status = f_uint32ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_uint32s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_uint32ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint32ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint32ss_t source = f_uint32ss_t_initialize; + f_uint32ss_t destination = f_uint32ss_t_initialize; + + { + const f_status_t status = f_uint32ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint32ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint32ss_append_all__parameter_checking(void **state) { + + const f_uint32ss_t data = f_uint32ss_t_initialize; + + { + const f_status_t status = f_uint32ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append_all.h new file mode 100644 index 000000000..8ca060512 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint32ss_append_all +#define _TEST__F_type_array__uint32ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint32ss_append_all() + */ +extern void test__f_type_array_uint32ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint32ss_append_all() + */ +extern void test__f_type_array_uint32ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint32ss_append_all() + */ +extern void test__f_type_array_uint32ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint32ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decimate_by.c index c3a2a4461..d941d027a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint32ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint32ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint32ss_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decimate_by.h index fb792ee83..50380ba11 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32ss_decimate_by__works(void **state); * * @see f_type_array_uint32ss_decimate_by() */ -extern void test__f_type_array_uint32ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decrease_by.c index 58c0ccd61..f7fd55030 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint32ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint32ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint32ss_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decrease_by.h index 5789def64..695a5c9d4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32ss_decrease_by__works(void **state); * * @see f_type_array_uint32ss_decrease_by() */ -extern void test__f_type_array_uint32ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase.c index 4ecb41bb6..432b3621c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint32ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint32ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint32ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32ss_increase__parameter_checking(void **state) { const int length = 5; f_uint32ss_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase.h index 1fcb7e7a3..18beac0da 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint32ss_increase__returns_data_not(void **state) * * @see f_type_array_uint32ss_increase() */ -extern void test__f_type_array_uint32ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase_by.c index 77c6ba894..07000c365 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint32ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint32ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32ss_increase_by__parameter_checking(void **state) { const int length = 5; f_uint32ss_t data = f_uint32s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase_by.h index 64578c44e..c05511d79 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32ss_increase_by__works(void **state); * * @see f_type_array_uint32ss_increase_by() */ -extern void test__f_type_array_uint32ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_resize.c index a0e214556..16b522ecd 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint32ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint32ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint32ss_resize__parameter_checking(void **state) { const int length = 5; f_uint32ss_t data = f_uint32ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_resize.h index 1d523b8ac..fd1ed4c5a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint32ss_resize__works(void **state); * * @see f_type_array_uint32ss_resize() */ -extern void test__f_type_array_uint32ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint32ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint32ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_adjust.c index 6620d3a2a..433695201 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint64s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint64s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64s_adjust__parameter_checking(void **state) { const int length = 5; f_uint64s_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_adjust.h index 729ce1e50..90f6b3454 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64s_adjust__works(void **state); * * @see f_type_array_uint64s_adjust() */ -extern void test__f_type_array_uint64s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append.c index ebd7dd29c..243e2307e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_uint64s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_uint64s_t source = f_uint64s_t_initialize; + const uint64_t source = 3; f_uint64s_t destination = f_uint64s_t_initialize; - { - const f_status_t status = f_uint64s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_uint64s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_uint64s_append__returns_data_not(void **state) { +void test__f_type_array_uint64s_append__parameter_checking(void **state) { - const int length = 5; - f_uint64s_t source = f_uint64s_t_initialize; - f_uint64s_t destination = f_uint64s_t_initialize; - - { - const f_status_t status = f_uint64s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_uint64s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_uint64s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_uint64s_t data = f_uint64s_t_initialize; + const uint64_t data = 0; { const f_status_t status = f_uint64s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append.h index 052d08c44..2cc3a26b9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_uint64s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_uint64s_append() - */ -extern void test__f_type_array_uint64s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_uint64s_append() */ -extern void test__f_type_array_uint64s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append_all.c new file mode 100644 index 000000000..7b8902c71 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-uint64s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint64s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_uint64s_t source = f_uint64s_t_initialize; + f_uint64s_t destination = f_uint64s_t_initialize; + + { + const f_status_t status = f_uint64s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_uint64s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint64s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint64s_t source = f_uint64s_t_initialize; + f_uint64s_t destination = f_uint64s_t_initialize; + + { + const f_status_t status = f_uint64s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint64s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint64s_append_all__parameter_checking(void **state) { + + const f_uint64s_t data = f_uint64s_t_initialize; + + { + const f_status_t status = f_uint64s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append_all.h new file mode 100644 index 000000000..0a43b5109 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint64s_append_all +#define _TEST__F_type_array__uint64s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint64s_append_all() + */ +extern void test__f_type_array_uint64s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint64s_append_all() + */ +extern void test__f_type_array_uint64s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint64s_append_all() + */ +extern void test__f_type_array_uint64s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint64s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decimate_by.c index 10980dc4a..f2e2f7074 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint64s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint64s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64s_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint64s_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decimate_by.h index 6ea01a527..46c9b0152 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64s_decimate_by__works(void **state); * * @see f_type_array_uint64s_decimate_by() */ -extern void test__f_type_array_uint64s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decrease_by.c index 6b072d24b..09d185811 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint64s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint64s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64s_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint64s_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decrease_by.h index 0706759b0..69cdf74b4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64s_decrease_by__works(void **state); * * @see f_type_array_uint64s_decrease_by() */ -extern void test__f_type_array_uint64s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase.c index b97928b81..5f4e3d09d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint64s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint64s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint64s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64s_increase__parameter_checking(void **state) { const int length = 5; f_uint64s_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase.h index 5fb5e7b3e..76a95f800 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint64s_increase__returns_data_not(void **state); * * @see f_type_array_uint64s_increase() */ -extern void test__f_type_array_uint64s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase_by.c index 0c96224dc..89c33b06f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint64s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint64s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64s_increase_by__parameter_checking(void **state) { const int length = 5; f_uint64s_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase_by.h index 2115798d9..e0395215a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64s_increase_by__works(void **state); * * @see f_type_array_uint64s_increase_by() */ -extern void test__f_type_array_uint64s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_resize.c index 862bd4abc..53e459a6f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint64s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint64s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64s_resize__parameter_checking(void **state) { const int length = 5; f_uint64s_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_resize.h index 22e96d0b7..f28ff4b88 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64s_resize__works(void **state); * * @see f_type_array_uint64s_resize() */ -extern void test__f_type_array_uint64s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_adjust.c index bf51ef632..a069aa3a6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint64ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint64ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64ss_adjust__parameter_checking(void **state) { const int length = 5; f_uint64ss_t data = f_uint64ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_adjust.h index b93e170a5..66269a759 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64ss_adjust__works(void **state); * * @see f_type_array_uint64ss_adjust() */ -extern void test__f_type_array_uint64ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append.c index 69c4a41e4..1e5448435 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_uint64ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_uint64ss_t source = f_uint64s_t_initialize; - f_uint64ss_t destination = f_uint64s_t_initialize; + f_uint64s_t source = f_uint64s_t_initialize; + f_uint64ss_t destination = f_uint64ss_t_initialize; { - const f_status_t status = f_uint64ss_resize(length, &source); + const f_status_t status = f_uint64s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_uint64s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_uint64ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_uint64ss_append__works(void **state) { void test__f_type_array_uint64ss_append__returns_data_not(void **state) { const int length = 5; - f_uint64ss_t source = f_uint64s_t_initialize; - f_uint64ss_t destination = f_uint64s_t_initialize; + f_uint64s_t source = f_uint64s_t_initialize; + f_uint64ss_t destination = f_uint64ss_t_initialize; { - const f_status_t status = f_uint64ss_resize(length, &source); + const f_status_t status = f_uint64s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_uint64ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_uint64ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64ss_append__parameter_checking(void **state) { - const int length = 5; - f_uint64ss_t data = f_uint64s_t_initialize; + f_uint64s_t data = f_uint64s_t_initialize; { const f_status_t status = f_uint64ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append.h index 64913fc95..071d13a5d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint64ss_append__returns_data_not(void **state); * * @see f_type_array_uint64ss_append() */ -extern void test__f_type_array_uint64ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append_all.c new file mode 100644 index 000000000..80edb1f43 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-uint64ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint64ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_uint64ss_t source = f_uint64ss_t_initialize; + f_uint64ss_t destination = f_uint64ss_t_initialize; + + { + const f_status_t status = f_uint64ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_uint64s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_uint64ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint64ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint64ss_t source = f_uint64ss_t_initialize; + f_uint64ss_t destination = f_uint64ss_t_initialize; + + { + const f_status_t status = f_uint64ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint64ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint64ss_append_all__parameter_checking(void **state) { + + const f_uint64ss_t data = f_uint64ss_t_initialize; + + { + const f_status_t status = f_uint64ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append_all.h new file mode 100644 index 000000000..0bc11ed34 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint64ss_append_all +#define _TEST__F_type_array__uint64ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint64ss_append_all() + */ +extern void test__f_type_array_uint64ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint64ss_append_all() + */ +extern void test__f_type_array_uint64ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint64ss_append_all() + */ +extern void test__f_type_array_uint64ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint64ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decimate_by.c index 4bed12f3b..53edea25d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint64ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint64ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint64ss_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decimate_by.h index b3ed09f33..97a969e27 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64ss_decimate_by__works(void **state); * * @see f_type_array_uint64ss_decimate_by() */ -extern void test__f_type_array_uint64ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decrease_by.c index 7fddf9f7f..a5d8132cf 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint64ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint64ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint64ss_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decrease_by.h index 0cabd0537..9927a9438 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64ss_decrease_by__works(void **state); * * @see f_type_array_uint64ss_decrease_by() */ -extern void test__f_type_array_uint64ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase.c index b08052e0b..8338db8f4 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint64ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint64ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint64ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64ss_increase__parameter_checking(void **state) { const int length = 5; f_uint64ss_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase.h index faa336d93..ad9671be5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint64ss_increase__returns_data_not(void **state) * * @see f_type_array_uint64ss_increase() */ -extern void test__f_type_array_uint64ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase_by.c index 0ffde43e6..ae5192f7a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint64ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint64ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64ss_increase_by__parameter_checking(void **state) { const int length = 5; f_uint64ss_t data = f_uint64s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase_by.h index d187b23d9..317326897 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64ss_increase_by__works(void **state); * * @see f_type_array_uint64ss_increase_by() */ -extern void test__f_type_array_uint64ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_resize.c index 94e43db88..c471785b2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint64ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint64ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint64ss_resize__parameter_checking(void **state) { const int length = 5; f_uint64ss_t data = f_uint64ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_resize.h index 5f221661c..acd18bc4a 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint64ss_resize__works(void **state); * * @see f_type_array_uint64ss_resize() */ -extern void test__f_type_array_uint64ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint64ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint64ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_adjust.c index 67fd00d39..33440e2e6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint8s_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint8s_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8s_adjust__parameter_checking(void **state) { const int length = 5; f_uint8s_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_adjust.h index dee94c0ab..d5afab2d6 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8s_adjust__works(void **state); * * @see f_type_array_uint8s_adjust() */ -extern void test__f_type_array_uint8s_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8s_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8s_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append.c index f8ad96dfd..d039c4784 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append.c @@ -7,79 +7,29 @@ extern "C" { void test__f_type_array_uint8s_append__works(void **state) { - const int length = 5; - const int length_used = 2; - f_uint8s_t source = f_uint8s_t_initialize; + const uint8_t source = 3; f_uint8s_t destination = f_uint8s_t_initialize; - { - const f_status_t status = f_uint8s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = source.used + 1; - } // for - { const f_status_t status = f_uint8s_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_array_length_t i = 0; i < source.used; ++i) { - assert_int_equal(destination.array[i], i + 1); - } // for + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0], source); } - free((void *) source.array); free((void *) destination.array); } -void test__f_type_array_uint8s_append__returns_data_not(void **state) { +void test__f_type_array_uint8s_append__parameter_checking(void **state) { - const int length = 5; - f_uint8s_t source = f_uint8s_t_initialize; - f_uint8s_t destination = f_uint8s_t_initialize; - - { - const f_status_t status = f_uint8s_resize(length, &source); - - assert_int_equal(status, F_none); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_uint8s_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - } - - free((void *) source.array); - assert_null(destination.array); -} - -void test__f_type_array_uint8s_append__fails_on_invalid_parameter(void **state) { - - const int length = 5; - f_uint8s_t data = f_uint8s_t_initialize; + const uint8_t data = 0; { const f_status_t status = f_uint8s_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append.h index e0b062aa2..02968f7b7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append.h @@ -17,18 +17,11 @@ */ extern void test__f_type_array_uint8s_append__works(void **state); -/** - * Test that the function returns F_data_not when asked to copy an empty structure. - * - * @see f_type_array_uint8s_append() - */ -extern void test__f_type_array_uint8s_append__returns_data_not(void **state); - /** * Test that the function correctly fails on invalid parameter. * * @see f_type_array_uint8s_append() */ -extern void test__f_type_array_uint8s_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8s_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8s_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append_all.c new file mode 100644 index 000000000..a94ae535d --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append_all.c @@ -0,0 +1,82 @@ +#include "test-type_array.h" +#include "test-type_array-uint8s_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint8s_append_all__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_uint8s_t source = f_uint8s_t_initialize; + f_uint8s_t destination = f_uint8s_t_initialize; + + { + const f_status_t status = f_uint8s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_uint8s_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint8s_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint8s_t source = f_uint8s_t_initialize; + f_uint8s_t destination = f_uint8s_t_initialize; + + { + const f_status_t status = f_uint8s_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint8s_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint8s_append_all__parameter_checking(void **state) { + + const f_uint8s_t data = f_uint8s_t_initialize; + + { + const f_status_t status = f_uint8s_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append_all.h new file mode 100644 index 000000000..039bf1f61 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint8s_append_all +#define _TEST__F_type_array__uint8s_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint8s_append_all() + */ +extern void test__f_type_array_uint8s_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint8s_append_all() + */ +extern void test__f_type_array_uint8s_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint8s_append_all() + */ +extern void test__f_type_array_uint8s_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint8s_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decimate_by.c index 434e3b3dd..40ceac019 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint8s_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint8s_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8s_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint8s_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decimate_by.h index 5575c3a5a..fe4247b6d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8s_decimate_by__works(void **state); * * @see f_type_array_uint8s_decimate_by() */ -extern void test__f_type_array_uint8s_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8s_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8s_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decrease_by.c index 5559b3817..a2baa1bf7 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint8s_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint8s_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8s_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint8s_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decrease_by.h index 5fcb7a445..6157173ce 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8s_decrease_by__works(void **state); * * @see f_type_array_uint8s_decrease_by() */ -extern void test__f_type_array_uint8s_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8s_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8s_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase.c index 16671188c..690bbaf4d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint8s_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint8s_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint8s_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8s_increase__parameter_checking(void **state) { const int length = 5; f_uint8s_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase.h index 18cf51442..77be55444 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint8s_increase__returns_data_not(void **state); * * @see f_type_array_uint8s_increase() */ -extern void test__f_type_array_uint8s_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8s_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8s_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase_by.c index 8fb4be53b..f507bd1e8 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint8s_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint8s_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8s_increase_by__parameter_checking(void **state) { const int length = 5; f_uint8s_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase_by.h index 34783da4f..7c8206f8c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8s_increase_by__works(void **state); * * @see f_type_array_uint8s_increase_by() */ -extern void test__f_type_array_uint8s_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8s_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8s_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_resize.c index 86d997e9b..83b457a69 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint8s_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint8s_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8s_resize__parameter_checking(void **state) { const int length = 5; f_uint8s_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_resize.h index a19fa0f34..8f258e3d3 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8s_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8s_resize__works(void **state); * * @see f_type_array_uint8s_resize() */ -extern void test__f_type_array_uint8s_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8s_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8s_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_adjust.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_adjust.c index 8d4d4a550..ec3eed98f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_adjust.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_adjust.c @@ -21,7 +21,7 @@ void test__f_type_array_uint8ss_adjust__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint8ss_adjust__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8ss_adjust__parameter_checking(void **state) { const int length = 5; f_uint8ss_t data = f_uint8ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_adjust.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_adjust.h index 223dce3ee..b6d8dfb32 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_adjust.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_adjust.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8ss_adjust__works(void **state); * * @see f_type_array_uint8ss_adjust() */ -extern void test__f_type_array_uint8ss_adjust__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8ss_adjust__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8ss_adjust diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append.c index e9c6fed43..650d761a5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append.c @@ -8,53 +8,34 @@ extern "C" { void test__f_type_array_uint8ss_append__works(void **state) { const int length = 5; - const int length_inner = 2; - f_uint8ss_t source = f_uint8s_t_initialize; - f_uint8ss_t destination = f_uint8s_t_initialize; + f_uint8s_t source = f_uint8s_t_initialize; + f_uint8ss_t destination = f_uint8ss_t_initialize; { - const f_status_t status = f_uint8ss_resize(length, &source); + const f_status_t status = f_uint8s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); assert_int_equal(source.size, length); } - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_uint8s_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_none); - - for (f_array_length_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = i + 1; - } // for - } // for - } + for (; source.used < length; ++source.used) { + source.array[source.used] = source.used + 1; + } // for { const f_status_t status = f_uint8ss_append(source, &destination); assert_int_equal(status, F_none); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + assert_int_equal(destination.array[0].size, source.used); - for (f_array_length_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_array_length_t j = 0; j < length_inner; ++j) { - assert_int_equal(destination.array[i].array[j], j + 1); - } // for + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + assert_int_equal(destination.array[0].array[i], i + 1); } // for } - for (f_array_length_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - for (f_array_length_t i = 0; i < destination.used; ++i) { free((void *) destination.array[i].array); } // for @@ -66,11 +47,11 @@ void test__f_type_array_uint8ss_append__works(void **state) { void test__f_type_array_uint8ss_append__returns_data_not(void **state) { const int length = 5; - f_uint8ss_t source = f_uint8s_t_initialize; - f_uint8ss_t destination = f_uint8s_t_initialize; + f_uint8s_t source = f_uint8s_t_initialize; + f_uint8ss_t destination = f_uint8ss_t_initialize; { - const f_status_t status = f_uint8ss_resize(length, &source); + const f_status_t status = f_uint8s_resize(length, &source); assert_int_equal(status, F_none); assert_int_equal(source.used, 0); @@ -83,26 +64,21 @@ void test__f_type_array_uint8ss_append__returns_data_not(void **state) { assert_int_equal(status, F_data_not); assert_int_equal(destination.used, 0); assert_int_equal(destination.size, 0); + assert_null(destination.array); } free((void *) source.array); - assert_null(destination.array); } -void test__f_type_array_uint8ss_append__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8ss_append__parameter_checking(void **state) { - const int length = 5; - f_uint8ss_t data = f_uint8s_t_initialize; + f_uint8s_t data = f_uint8s_t_initialize; { const f_status_t status = f_uint8ss_append(data, 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 diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append.h index 62e245177..c7f66334f 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint8ss_append__returns_data_not(void **state); * * @see f_type_array_uint8ss_append() */ -extern void test__f_type_array_uint8ss_append__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8ss_append__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8ss_append diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append_all.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append_all.c new file mode 100644 index 000000000..5a4d14df3 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append_all.c @@ -0,0 +1,105 @@ +#include "test-type_array.h" +#include "test-type_array-uint8ss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_uint8ss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_uint8ss_t source = f_uint8ss_t_initialize; + f_uint8ss_t destination = f_uint8ss_t_initialize; + + { + const f_status_t status = f_uint8ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_uint8s_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_uint8ss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_uint8ss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_uint8ss_t source = f_uint8ss_t_initialize; + f_uint8ss_t destination = f_uint8ss_t_initialize; + + { + const f_status_t status = f_uint8ss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_uint8ss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_type_array_uint8ss_append_all__parameter_checking(void **state) { + + const f_uint8ss_t data = f_uint8ss_t_initialize; + + { + const f_status_t status = f_uint8ss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append_all.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append_all.h new file mode 100644 index 000000000..8ec2cb0c1 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__uint8ss_append_all +#define _TEST__F_type_array__uint8ss_append_all + +/** + * Test that the function works. + * + * @see f_type_array_uint8ss_append_all() + */ +extern void test__f_type_array_uint8ss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_uint8ss_append_all() + */ +extern void test__f_type_array_uint8ss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_uint8ss_append_all() + */ +extern void test__f_type_array_uint8ss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_type_array__uint8ss_append_all diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decimate_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decimate_by.c index c8418fbb8..b9cca5db9 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decimate_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decimate_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint8ss_decimate_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint8ss_decimate_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8ss_decimate_by__parameter_checking(void **state) { const int length = 5; f_uint8ss_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decimate_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decimate_by.h index 70c6812c2..f92c29405 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decimate_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decimate_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8ss_decimate_by__works(void **state); * * @see f_type_array_uint8ss_decimate_by() */ -extern void test__f_type_array_uint8ss_decimate_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8ss_decimate_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8ss_decimate_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decrease_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decrease_by.c index 9c5fac8d8..61a91cb51 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decrease_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decrease_by.c @@ -29,7 +29,7 @@ void test__f_type_array_uint8ss_decrease_by__works(void **state) { assert_null(data.array); } -void test__f_type_array_uint8ss_decrease_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8ss_decrease_by__parameter_checking(void **state) { const int length = 5; f_uint8ss_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decrease_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decrease_by.h index 21c4271a6..d78af8dc8 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decrease_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_decrease_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8ss_decrease_by__works(void **state); * * @see f_type_array_uint8ss_decrease_by() */ -extern void test__f_type_array_uint8ss_decrease_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8ss_decrease_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8ss_decrease_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase.c index 1f608f782..99f761228 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase.c @@ -25,7 +25,7 @@ void test__f_type_array_uint8ss_increase__works(void **state) { assert_int_equal(status, F_none); assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); } free((void *) data.array); @@ -55,7 +55,7 @@ void test__f_type_array_uint8ss_increase__returns_data_not(void **state) { free((void *) data.array); } -void test__f_type_array_uint8ss_increase__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8ss_increase__parameter_checking(void **state) { const int length = 5; f_uint8ss_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase.h index 88b7ac1c5..a82b67d4e 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase.h @@ -29,6 +29,6 @@ extern void test__f_type_array_uint8ss_increase__returns_data_not(void **state); * * @see f_type_array_uint8ss_increase() */ -extern void test__f_type_array_uint8ss_increase__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8ss_increase__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8ss_increase diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase_by.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase_by.c index 8bb2b87ee..2d6e55c1c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase_by.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase_by.c @@ -31,7 +31,7 @@ void test__f_type_array_uint8ss_increase_by__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint8ss_increase_by__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8ss_increase_by__parameter_checking(void **state) { const int length = 5; f_uint8ss_t data = f_uint8s_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase_by.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase_by.h index 0ab87795a..e0bc0ecf5 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase_by.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_increase_by.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8ss_increase_by__works(void **state); * * @see f_type_array_uint8ss_increase_by() */ -extern void test__f_type_array_uint8ss_increase_by__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8ss_increase_by__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8ss_increase_by diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_resize.c b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_resize.c index c0f346b83..251db7571 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_resize.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_resize.c @@ -21,7 +21,7 @@ void test__f_type_array_uint8ss_resize__works(void **state) { free((void *) data.array); } -void test__f_type_array_uint8ss_resize__fails_on_invalid_parameter(void **state) { +void test__f_type_array_uint8ss_resize__parameter_checking(void **state) { const int length = 5; f_uint8ss_t data = f_uint8ss_t_initialize; diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_resize.h b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_resize.h index b0180491b..69a471866 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_resize.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_resize.h @@ -22,6 +22,6 @@ extern void test__f_type_array_uint8ss_resize__works(void **state); * * @see f_type_array_uint8ss_resize() */ -extern void test__f_type_array_uint8ss_resize__fails_on_invalid_parameter(void **state); +extern void test__f_type_array_uint8ss_resize__parameter_checking(void **state); #endif // _TEST__F_type_array__uint8ss_resize diff --git a/level_0/f_type_array/tests/unit/c/test-type_array.c b/level_0/f_type_array/tests/unit/c/test-type_array.c index ce1c7cf73..fded1e594 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array.c @@ -18,514 +18,621 @@ int main(void) { const struct CMUnitTest tests[] = { cmocka_unit_test(test__f_type_array_array_lengths_adjust__works), - cmocka_unit_test(test__f_type_array_array_lengths_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengths_append__works), - cmocka_unit_test(test__f_type_array_array_lengths_append__returns_data_not), - cmocka_unit_test(test__f_type_array_array_lengths_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengths_append_all__works), + cmocka_unit_test(test__f_type_array_array_lengths_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_array_lengths_decimate_by__works), - cmocka_unit_test(test__f_type_array_array_lengths_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengths_decrease_by__works), - cmocka_unit_test(test__f_type_array_array_lengths_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengths_increase__works), cmocka_unit_test(test__f_type_array_array_lengths_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_array_lengths_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengths_increase_by__works), - cmocka_unit_test(test__f_type_array_array_lengths_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengths_resize__works), - cmocka_unit_test(test__f_type_array_array_lengths_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengthss_adjust__works), - cmocka_unit_test(test__f_type_array_array_lengthss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengthss_append__works), cmocka_unit_test(test__f_type_array_array_lengthss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_array_lengthss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengthss_append_all__works), + cmocka_unit_test(test__f_type_array_array_lengthss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_array_lengthss_decimate_by__works), - cmocka_unit_test(test__f_type_array_array_lengthss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengthss_decrease_by__works), - cmocka_unit_test(test__f_type_array_array_lengthss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengthss_increase__works), cmocka_unit_test(test__f_type_array_array_lengthss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_array_lengthss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengthss_increase_by__works), - cmocka_unit_test(test__f_type_array_array_lengthss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_array_lengthss_resize__works), - cmocka_unit_test(test__f_type_array_array_lengthss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cells_adjust__works), - cmocka_unit_test(test__f_type_array_cells_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cells_append__works), - cmocka_unit_test(test__f_type_array_cells_append__returns_data_not), - cmocka_unit_test(test__f_type_array_cells_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cells_append_all__works), + cmocka_unit_test(test__f_type_array_cells_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_cells_decimate_by__works), - cmocka_unit_test(test__f_type_array_cells_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cells_decrease_by__works), - cmocka_unit_test(test__f_type_array_cells_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cells_increase__works), cmocka_unit_test(test__f_type_array_cells_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_cells_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cells_increase_by__works), - cmocka_unit_test(test__f_type_array_cells_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cells_resize__works), - cmocka_unit_test(test__f_type_array_cells_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cellss_adjust__works), - cmocka_unit_test(test__f_type_array_cellss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cellss_append__works), cmocka_unit_test(test__f_type_array_cellss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_cellss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cellss_append_all__works), + cmocka_unit_test(test__f_type_array_cellss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_cellss_decimate_by__works), - cmocka_unit_test(test__f_type_array_cellss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cellss_decrease_by__works), - cmocka_unit_test(test__f_type_array_cellss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cellss_increase__works), cmocka_unit_test(test__f_type_array_cellss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_cellss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cellss_increase_by__works), - cmocka_unit_test(test__f_type_array_cellss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_cellss_resize__works), - cmocka_unit_test(test__f_type_array_cellss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_ids_adjust__works), - cmocka_unit_test(test__f_type_array_fll_ids_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_ids_append__works), - cmocka_unit_test(test__f_type_array_fll_ids_append__returns_data_not), - cmocka_unit_test(test__f_type_array_fll_ids_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_ids_append_all__works), + cmocka_unit_test(test__f_type_array_fll_ids_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_fll_ids_decimate_by__works), - cmocka_unit_test(test__f_type_array_fll_ids_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_ids_decrease_by__works), - cmocka_unit_test(test__f_type_array_fll_ids_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_ids_increase__works), cmocka_unit_test(test__f_type_array_fll_ids_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_fll_ids_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_ids_increase_by__works), - cmocka_unit_test(test__f_type_array_fll_ids_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_ids_resize__works), - cmocka_unit_test(test__f_type_array_fll_ids_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_idss_adjust__works), - cmocka_unit_test(test__f_type_array_fll_idss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_idss_append__works), cmocka_unit_test(test__f_type_array_fll_idss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_fll_idss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_idss_append_all__works), + cmocka_unit_test(test__f_type_array_fll_idss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_fll_idss_decimate_by__works), - cmocka_unit_test(test__f_type_array_fll_idss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_idss_decrease_by__works), - cmocka_unit_test(test__f_type_array_fll_idss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_idss_increase__works), cmocka_unit_test(test__f_type_array_fll_idss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_fll_idss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_idss_increase_by__works), - cmocka_unit_test(test__f_type_array_fll_idss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_fll_idss_resize__works), - cmocka_unit_test(test__f_type_array_fll_idss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8s_adjust__works), - cmocka_unit_test(test__f_type_array_int8s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8s_append__works), - cmocka_unit_test(test__f_type_array_int8s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int8s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int8s_append_all__works), + cmocka_unit_test(test__f_type_array_int8s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int8s_decimate_by__works), - cmocka_unit_test(test__f_type_array_int8s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8s_decrease_by__works), - cmocka_unit_test(test__f_type_array_int8s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8s_increase__works), cmocka_unit_test(test__f_type_array_int8s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int8s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8s_increase_by__works), - cmocka_unit_test(test__f_type_array_int8s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8s_resize__works), - cmocka_unit_test(test__f_type_array_int8s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8ss_adjust__works), - cmocka_unit_test(test__f_type_array_int8ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8ss_append__works), cmocka_unit_test(test__f_type_array_int8ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int8ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int8ss_append_all__works), + cmocka_unit_test(test__f_type_array_int8ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int8ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_int8ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_int8ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8ss_increase__works), cmocka_unit_test(test__f_type_array_int8ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int8ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8ss_increase_by__works), - cmocka_unit_test(test__f_type_array_int8ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int8ss_resize__works), - cmocka_unit_test(test__f_type_array_int8ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16s_adjust__works), - cmocka_unit_test(test__f_type_array_int16s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16s_append__works), - cmocka_unit_test(test__f_type_array_int16s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int16s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int16s_append_all__works), + cmocka_unit_test(test__f_type_array_int16s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int16s_decimate_by__works), - cmocka_unit_test(test__f_type_array_int16s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16s_decrease_by__works), - cmocka_unit_test(test__f_type_array_int16s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16s_increase__works), cmocka_unit_test(test__f_type_array_int16s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int16s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16s_increase_by__works), - cmocka_unit_test(test__f_type_array_int16s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16s_resize__works), - cmocka_unit_test(test__f_type_array_int16s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16ss_adjust__works), - cmocka_unit_test(test__f_type_array_int16ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16ss_append__works), cmocka_unit_test(test__f_type_array_int16ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int16ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int16ss_append_all__works), + cmocka_unit_test(test__f_type_array_int16ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int16ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_int16ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_int16ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16ss_increase__works), cmocka_unit_test(test__f_type_array_int16ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int16ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16ss_increase_by__works), - cmocka_unit_test(test__f_type_array_int16ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int16ss_resize__works), - cmocka_unit_test(test__f_type_array_int16ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32s_adjust__works), - cmocka_unit_test(test__f_type_array_int32s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32s_append__works), - cmocka_unit_test(test__f_type_array_int32s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int32s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int32s_append_all__works), + cmocka_unit_test(test__f_type_array_int32s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int32s_decimate_by__works), - cmocka_unit_test(test__f_type_array_int32s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32s_decrease_by__works), - cmocka_unit_test(test__f_type_array_int32s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32s_increase__works), cmocka_unit_test(test__f_type_array_int32s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int32s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32s_increase_by__works), - cmocka_unit_test(test__f_type_array_int32s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32s_resize__works), - cmocka_unit_test(test__f_type_array_int32s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32ss_adjust__works), - cmocka_unit_test(test__f_type_array_int32ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32ss_append__works), cmocka_unit_test(test__f_type_array_int32ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int32ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int32ss_append_all__works), + cmocka_unit_test(test__f_type_array_int32ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int32ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_int32ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_int32ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32ss_increase__works), cmocka_unit_test(test__f_type_array_int32ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int32ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32ss_increase_by__works), - cmocka_unit_test(test__f_type_array_int32ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int32ss_resize__works), - cmocka_unit_test(test__f_type_array_int32ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64s_adjust__works), - cmocka_unit_test(test__f_type_array_int64s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64s_append__works), - cmocka_unit_test(test__f_type_array_int64s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int64s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int64s_append_all__works), + cmocka_unit_test(test__f_type_array_int64s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int64s_decimate_by__works), - cmocka_unit_test(test__f_type_array_int64s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64s_decrease_by__works), - cmocka_unit_test(test__f_type_array_int64s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64s_increase__works), cmocka_unit_test(test__f_type_array_int64s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int64s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64s_increase_by__works), - cmocka_unit_test(test__f_type_array_int64s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64s_resize__works), - cmocka_unit_test(test__f_type_array_int64s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64ss_adjust__works), - cmocka_unit_test(test__f_type_array_int64ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64ss_append__works), cmocka_unit_test(test__f_type_array_int64ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int64ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int64ss_append_all__works), + cmocka_unit_test(test__f_type_array_int64ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int64ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_int64ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_int64ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64ss_increase__works), cmocka_unit_test(test__f_type_array_int64ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int64ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64ss_increase_by__works), - cmocka_unit_test(test__f_type_array_int64ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int64ss_resize__works), - cmocka_unit_test(test__f_type_array_int64ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128s_adjust__works), - cmocka_unit_test(test__f_type_array_int128s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128s_append__works), - cmocka_unit_test(test__f_type_array_int128s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int128s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int128s_append_all__works), + cmocka_unit_test(test__f_type_array_int128s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int128s_decimate_by__works), - cmocka_unit_test(test__f_type_array_int128s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128s_decrease_by__works), - cmocka_unit_test(test__f_type_array_int128s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128s_increase__works), cmocka_unit_test(test__f_type_array_int128s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int128s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128s_increase_by__works), - cmocka_unit_test(test__f_type_array_int128s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128s_resize__works), - cmocka_unit_test(test__f_type_array_int128s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128ss_adjust__works), - cmocka_unit_test(test__f_type_array_int128ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128ss_append__works), cmocka_unit_test(test__f_type_array_int128ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_int128ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_int128ss_append_all__works), + cmocka_unit_test(test__f_type_array_int128ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_int128ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_int128ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_int128ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128ss_increase__works), cmocka_unit_test(test__f_type_array_int128ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_int128ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128ss_increase_by__works), - cmocka_unit_test(test__f_type_array_int128ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_int128ss_resize__works), - cmocka_unit_test(test__f_type_array_int128ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_states_adjust__works), - cmocka_unit_test(test__f_type_array_states_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_states_append__works), - cmocka_unit_test(test__f_type_array_states_append__returns_data_not), - cmocka_unit_test(test__f_type_array_states_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_states_append_all__works), + cmocka_unit_test(test__f_type_array_states_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_states_decimate_by__works), - cmocka_unit_test(test__f_type_array_states_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_states_decrease_by__works), - cmocka_unit_test(test__f_type_array_states_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_states_increase__works), cmocka_unit_test(test__f_type_array_states_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_states_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_states_increase_by__works), - cmocka_unit_test(test__f_type_array_states_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_states_resize__works), - cmocka_unit_test(test__f_type_array_states_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statess_adjust__works), - cmocka_unit_test(test__f_type_array_statess_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statess_append__works), cmocka_unit_test(test__f_type_array_statess_append__returns_data_not), - cmocka_unit_test(test__f_type_array_statess_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statess_append_all__works), + cmocka_unit_test(test__f_type_array_statess_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_statess_decimate_by__works), - cmocka_unit_test(test__f_type_array_statess_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statess_decrease_by__works), - cmocka_unit_test(test__f_type_array_statess_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statess_increase__works), cmocka_unit_test(test__f_type_array_statess_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_statess_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statess_increase_by__works), - cmocka_unit_test(test__f_type_array_statess_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statess_resize__works), - cmocka_unit_test(test__f_type_array_statess_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statuss_adjust__works), - cmocka_unit_test(test__f_type_array_statuss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statuss_append__works), - cmocka_unit_test(test__f_type_array_statuss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_statuss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statuss_append_all__works), + cmocka_unit_test(test__f_type_array_statuss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_statuss_decimate_by__works), - cmocka_unit_test(test__f_type_array_statuss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statuss_decrease_by__works), - cmocka_unit_test(test__f_type_array_statuss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statuss_increase__works), cmocka_unit_test(test__f_type_array_statuss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_statuss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statuss_increase_by__works), - cmocka_unit_test(test__f_type_array_statuss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statuss_resize__works), - cmocka_unit_test(test__f_type_array_statuss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statusss_adjust__works), - cmocka_unit_test(test__f_type_array_statusss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statusss_append__works), cmocka_unit_test(test__f_type_array_statusss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_statusss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statusss_append_all__works), + cmocka_unit_test(test__f_type_array_statusss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_statusss_decimate_by__works), - cmocka_unit_test(test__f_type_array_statusss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statusss_decrease_by__works), - cmocka_unit_test(test__f_type_array_statusss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statusss_increase__works), cmocka_unit_test(test__f_type_array_statusss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_statusss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statusss_increase_by__works), - cmocka_unit_test(test__f_type_array_statusss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_statusss_resize__works), - cmocka_unit_test(test__f_type_array_statusss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8s_adjust__works), - cmocka_unit_test(test__f_type_array_uint8s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8s_append__works), - cmocka_unit_test(test__f_type_array_uint8s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint8s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint8s_append_all__works), + cmocka_unit_test(test__f_type_array_uint8s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint8s_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint8s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8s_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint8s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8s_increase__works), cmocka_unit_test(test__f_type_array_uint8s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint8s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8s_increase_by__works), - cmocka_unit_test(test__f_type_array_uint8s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8s_resize__works), - cmocka_unit_test(test__f_type_array_uint8s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8ss_adjust__works), - cmocka_unit_test(test__f_type_array_uint8ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8ss_append__works), cmocka_unit_test(test__f_type_array_uint8ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint8ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint8ss_append_all__works), + cmocka_unit_test(test__f_type_array_uint8ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint8ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint8ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint8ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8ss_increase__works), cmocka_unit_test(test__f_type_array_uint8ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint8ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8ss_increase_by__works), - cmocka_unit_test(test__f_type_array_uint8ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint8ss_resize__works), - cmocka_unit_test(test__f_type_array_uint8ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16s_adjust__works), - cmocka_unit_test(test__f_type_array_uint16s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16s_append__works), - cmocka_unit_test(test__f_type_array_uint16s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint16s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint16s_append_all__works), + cmocka_unit_test(test__f_type_array_uint16s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint16s_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint16s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16s_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint16s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16s_increase__works), cmocka_unit_test(test__f_type_array_uint16s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint16s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16s_increase_by__works), - cmocka_unit_test(test__f_type_array_uint16s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16s_resize__works), - cmocka_unit_test(test__f_type_array_uint16s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16ss_adjust__works), - cmocka_unit_test(test__f_type_array_uint16ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16ss_append__works), cmocka_unit_test(test__f_type_array_uint16ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint16ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint16ss_append_all__works), + cmocka_unit_test(test__f_type_array_uint16ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint16ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint16ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint16ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16ss_increase__works), cmocka_unit_test(test__f_type_array_uint16ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint16ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16ss_increase_by__works), - cmocka_unit_test(test__f_type_array_uint16ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint16ss_resize__works), - cmocka_unit_test(test__f_type_array_uint16ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32s_adjust__works), - cmocka_unit_test(test__f_type_array_uint32s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32s_append__works), - cmocka_unit_test(test__f_type_array_uint32s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint32s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint32s_append_all__works), + cmocka_unit_test(test__f_type_array_uint32s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint32s_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint32s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32s_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint32s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32s_increase__works), cmocka_unit_test(test__f_type_array_uint32s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint32s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32s_increase_by__works), - cmocka_unit_test(test__f_type_array_uint32s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32s_resize__works), - cmocka_unit_test(test__f_type_array_uint32s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32ss_adjust__works), - cmocka_unit_test(test__f_type_array_uint32ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32ss_append__works), cmocka_unit_test(test__f_type_array_uint32ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint32ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint32ss_append_all__works), + cmocka_unit_test(test__f_type_array_uint32ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint32ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint32ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint32ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32ss_increase__works), cmocka_unit_test(test__f_type_array_uint32ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint32ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32ss_increase_by__works), - cmocka_unit_test(test__f_type_array_uint32ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint32ss_resize__works), - cmocka_unit_test(test__f_type_array_uint32ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64s_adjust__works), - cmocka_unit_test(test__f_type_array_uint64s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64s_append__works), - cmocka_unit_test(test__f_type_array_uint64s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint64s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint64s_append_all__works), + cmocka_unit_test(test__f_type_array_uint64s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint64s_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint64s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64s_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint64s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64s_increase__works), cmocka_unit_test(test__f_type_array_uint64s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint64s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64s_increase_by__works), - cmocka_unit_test(test__f_type_array_uint64s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64s_resize__works), - cmocka_unit_test(test__f_type_array_uint64s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64ss_adjust__works), - cmocka_unit_test(test__f_type_array_uint64ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64ss_append__works), cmocka_unit_test(test__f_type_array_uint64ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint64ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint64ss_append_all__works), + cmocka_unit_test(test__f_type_array_uint64ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint64ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint64ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint64ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64ss_increase__works), cmocka_unit_test(test__f_type_array_uint64ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint64ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64ss_increase_by__works), - cmocka_unit_test(test__f_type_array_uint64ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint64ss_resize__works), - cmocka_unit_test(test__f_type_array_uint64ss_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128s_adjust__works), - cmocka_unit_test(test__f_type_array_uint128s_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128s_append__works), - cmocka_unit_test(test__f_type_array_uint128s_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint128s_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint128s_append_all__works), + cmocka_unit_test(test__f_type_array_uint128s_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint128s_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint128s_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128s_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint128s_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128s_increase__works), cmocka_unit_test(test__f_type_array_uint128s_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint128s_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128s_increase_by__works), - cmocka_unit_test(test__f_type_array_uint128s_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128s_resize__works), - cmocka_unit_test(test__f_type_array_uint128s_resize__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128ss_adjust__works), - cmocka_unit_test(test__f_type_array_uint128ss_adjust__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128ss_append__works), cmocka_unit_test(test__f_type_array_uint128ss_append__returns_data_not), - cmocka_unit_test(test__f_type_array_uint128ss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_uint128ss_append_all__works), + cmocka_unit_test(test__f_type_array_uint128ss_append_all__returns_data_not), cmocka_unit_test(test__f_type_array_uint128ss_decimate_by__works), - cmocka_unit_test(test__f_type_array_uint128ss_decimate_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128ss_decrease_by__works), - cmocka_unit_test(test__f_type_array_uint128ss_decrease_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128ss_increase__works), cmocka_unit_test(test__f_type_array_uint128ss_increase__returns_data_not), - cmocka_unit_test(test__f_type_array_uint128ss_increase__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128ss_increase_by__works), - cmocka_unit_test(test__f_type_array_uint128ss_increase_by__fails_on_invalid_parameter), cmocka_unit_test(test__f_type_array_uint128ss_resize__works), - cmocka_unit_test(test__f_type_array_uint128ss_resize__fails_on_invalid_parameter), + + #ifndef _di_level_0_parameter_checking_ + cmocka_unit_test(test__f_type_array_array_lengths_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengths_append__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengths_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengths_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengths_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengths_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengths_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengths_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_array_lengthss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengthss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengthss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengthss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengthss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengthss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengthss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_array_lengthss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_cells_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_cells_append__parameter_checking), + cmocka_unit_test(test__f_type_array_cells_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_cells_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_cells_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_cells_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_cells_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_cells_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_cellss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_cellss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_cellss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_cellss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_cellss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_cellss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_cellss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_cellss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_fll_ids_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_ids_append__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_ids_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_ids_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_ids_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_ids_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_ids_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_ids_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_fll_idss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_idss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_idss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_idss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_idss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_idss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_idss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_fll_idss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int8s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int8s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int8s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int8s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int8s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int8s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int8s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int8s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int8ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int8ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int8ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int8ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int8ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int8ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int8ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int8ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int16s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int16s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int16s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int16s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int16s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int16s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int16s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int16s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int16ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int16ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int16ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int16ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int16ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int16ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int16ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int16ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int32s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int32s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int32s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int32s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int32s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int32s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int32s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int32s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int32ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int32ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int32ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int32ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int32ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int32ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int32ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int32ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int64s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int64s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int64s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int64s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int64s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int64s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int64s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int64s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int64ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int64ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int64ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int64ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int64ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int64ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int64ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int64ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int128s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int128s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int128s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int128s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int128s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int128s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int128s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int128s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_int128ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_int128ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_int128ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_int128ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int128ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int128ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_int128ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_int128ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_states_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_states_append__parameter_checking), + cmocka_unit_test(test__f_type_array_states_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_states_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_states_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_states_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_states_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_states_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_statess_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_statess_append__parameter_checking), + cmocka_unit_test(test__f_type_array_statess_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_statess_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statess_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statess_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_statess_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statess_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_statuss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_statuss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_statuss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_statuss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statuss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statuss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_statuss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statuss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_statusss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_statusss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_statusss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_statusss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statusss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statusss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_statusss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_statusss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint8s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint8ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint8ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint16s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint16ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint16ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint32s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint32ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint32ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint64s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint64ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint64ss_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint128s_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128s_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128s_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128s_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128s_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128s_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128s_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128s_resize__parameter_checking), + + cmocka_unit_test(test__f_type_array_uint128ss_adjust__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128ss_append__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128ss_append_all__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128ss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128ss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128ss_increase__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128ss_increase_by__parameter_checking), + cmocka_unit_test(test__f_type_array_uint128ss_resize__parameter_checking), + #endif // _di_level_0_parameter_checking_ }; return cmocka_run_group_tests(tests, setup, setdown); diff --git a/level_0/f_type_array/tests/unit/c/test-type_array.h b/level_0/f_type_array/tests/unit/c/test-type_array.h index 32990594c..4c210fb3d 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array.h @@ -27,6 +27,7 @@ // Test includes. #include "test-type_array-array_lengths_adjust.h" #include "test-type_array-array_lengths_append.h" +#include "test-type_array-array_lengths_append_all.h" #include "test-type_array-array_lengths_decimate_by.h" #include "test-type_array-array_lengths_decrease_by.h" #include "test-type_array-array_lengths_increase.h" @@ -34,6 +35,7 @@ #include "test-type_array-array_lengths_resize.h" #include "test-type_array-array_lengthss_adjust.h" #include "test-type_array-array_lengthss_append.h" +#include "test-type_array-array_lengthss_append_all.h" #include "test-type_array-array_lengthss_decimate_by.h" #include "test-type_array-array_lengthss_decrease_by.h" #include "test-type_array-array_lengthss_increase.h" @@ -41,6 +43,7 @@ #include "test-type_array-array_lengthss_resize.h" #include "test-type_array-cells_adjust.h" #include "test-type_array-cells_append.h" +#include "test-type_array-cells_append_all.h" #include "test-type_array-cells_decimate_by.h" #include "test-type_array-cells_decrease_by.h" #include "test-type_array-cells_increase.h" @@ -48,6 +51,7 @@ #include "test-type_array-cells_resize.h" #include "test-type_array-cellss_adjust.h" #include "test-type_array-cellss_append.h" +#include "test-type_array-cellss_append_all.h" #include "test-type_array-cellss_decimate_by.h" #include "test-type_array-cellss_decrease_by.h" #include "test-type_array-cellss_increase.h" @@ -55,6 +59,7 @@ #include "test-type_array-cellss_resize.h" #include "test-type_array-fll_ids_adjust.h" #include "test-type_array-fll_ids_append.h" +#include "test-type_array-fll_ids_append_all.h" #include "test-type_array-fll_ids_decimate_by.h" #include "test-type_array-fll_ids_decrease_by.h" #include "test-type_array-fll_ids_increase.h" @@ -62,6 +67,7 @@ #include "test-type_array-fll_ids_resize.h" #include "test-type_array-fll_idss_adjust.h" #include "test-type_array-fll_idss_append.h" +#include "test-type_array-fll_idss_append_all.h" #include "test-type_array-fll_idss_decimate_by.h" #include "test-type_array-fll_idss_decrease_by.h" #include "test-type_array-fll_idss_increase.h" @@ -69,6 +75,7 @@ #include "test-type_array-fll_idss_resize.h" #include "test-type_array-int8s_adjust.h" #include "test-type_array-int8s_append.h" +#include "test-type_array-int8s_append_all.h" #include "test-type_array-int8s_decimate_by.h" #include "test-type_array-int8s_decrease_by.h" #include "test-type_array-int8s_increase.h" @@ -76,6 +83,7 @@ #include "test-type_array-int8s_resize.h" #include "test-type_array-int8ss_adjust.h" #include "test-type_array-int8ss_append.h" +#include "test-type_array-int8ss_append_all.h" #include "test-type_array-int8ss_decimate_by.h" #include "test-type_array-int8ss_decrease_by.h" #include "test-type_array-int8ss_increase.h" @@ -83,6 +91,7 @@ #include "test-type_array-int8ss_resize.h" #include "test-type_array-int16s_adjust.h" #include "test-type_array-int16s_append.h" +#include "test-type_array-int16s_append_all.h" #include "test-type_array-int16s_decimate_by.h" #include "test-type_array-int16s_decrease_by.h" #include "test-type_array-int16s_increase.h" @@ -90,6 +99,7 @@ #include "test-type_array-int16s_resize.h" #include "test-type_array-int16ss_adjust.h" #include "test-type_array-int16ss_append.h" +#include "test-type_array-int16ss_append_all.h" #include "test-type_array-int16ss_decimate_by.h" #include "test-type_array-int16ss_decrease_by.h" #include "test-type_array-int16ss_increase.h" @@ -97,6 +107,7 @@ #include "test-type_array-int16ss_resize.h" #include "test-type_array-int32s_adjust.h" #include "test-type_array-int32s_append.h" +#include "test-type_array-int32s_append_all.h" #include "test-type_array-int32s_decimate_by.h" #include "test-type_array-int32s_decrease_by.h" #include "test-type_array-int32s_increase.h" @@ -104,6 +115,7 @@ #include "test-type_array-int32s_resize.h" #include "test-type_array-int32ss_adjust.h" #include "test-type_array-int32ss_append.h" +#include "test-type_array-int32ss_append_all.h" #include "test-type_array-int32ss_decimate_by.h" #include "test-type_array-int32ss_decrease_by.h" #include "test-type_array-int32ss_increase.h" @@ -111,6 +123,7 @@ #include "test-type_array-int32ss_resize.h" #include "test-type_array-int64s_adjust.h" #include "test-type_array-int64s_append.h" +#include "test-type_array-int64s_append_all.h" #include "test-type_array-int64s_decimate_by.h" #include "test-type_array-int64s_decrease_by.h" #include "test-type_array-int64s_increase.h" @@ -118,6 +131,7 @@ #include "test-type_array-int64s_resize.h" #include "test-type_array-int64ss_adjust.h" #include "test-type_array-int64ss_append.h" +#include "test-type_array-int64ss_append_all.h" #include "test-type_array-int64ss_decimate_by.h" #include "test-type_array-int64ss_decrease_by.h" #include "test-type_array-int64ss_increase.h" @@ -125,6 +139,7 @@ #include "test-type_array-int64ss_resize.h" #include "test-type_array-int128s_adjust.h" #include "test-type_array-int128s_append.h" +#include "test-type_array-int128s_append_all.h" #include "test-type_array-int128s_decimate_by.h" #include "test-type_array-int128s_decrease_by.h" #include "test-type_array-int128s_increase.h" @@ -132,6 +147,7 @@ #include "test-type_array-int128s_resize.h" #include "test-type_array-int128ss_adjust.h" #include "test-type_array-int128ss_append.h" +#include "test-type_array-int128ss_append_all.h" #include "test-type_array-int128ss_decimate_by.h" #include "test-type_array-int128ss_decrease_by.h" #include "test-type_array-int128ss_increase.h" @@ -139,6 +155,7 @@ #include "test-type_array-int128ss_resize.h" #include "test-type_array-states_adjust.h" #include "test-type_array-states_append.h" +#include "test-type_array-states_append_all.h" #include "test-type_array-states_decimate_by.h" #include "test-type_array-states_decrease_by.h" #include "test-type_array-states_increase.h" @@ -146,6 +163,7 @@ #include "test-type_array-states_resize.h" #include "test-type_array-statess_adjust.h" #include "test-type_array-statess_append.h" +#include "test-type_array-statess_append_all.h" #include "test-type_array-statess_decimate_by.h" #include "test-type_array-statess_decrease_by.h" #include "test-type_array-statess_increase.h" @@ -153,6 +171,7 @@ #include "test-type_array-statess_resize.h" #include "test-type_array-statuss_adjust.h" #include "test-type_array-statuss_append.h" +#include "test-type_array-statuss_append_all.h" #include "test-type_array-statuss_decimate_by.h" #include "test-type_array-statuss_decrease_by.h" #include "test-type_array-statuss_increase.h" @@ -160,6 +179,7 @@ #include "test-type_array-statuss_resize.h" #include "test-type_array-statusss_adjust.h" #include "test-type_array-statusss_append.h" +#include "test-type_array-statusss_append_all.h" #include "test-type_array-statusss_decimate_by.h" #include "test-type_array-statusss_decrease_by.h" #include "test-type_array-statusss_increase.h" @@ -167,6 +187,7 @@ #include "test-type_array-statusss_resize.h" #include "test-type_array-uint8s_adjust.h" #include "test-type_array-uint8s_append.h" +#include "test-type_array-uint8s_append_all.h" #include "test-type_array-uint8s_decimate_by.h" #include "test-type_array-uint8s_decrease_by.h" #include "test-type_array-uint8s_increase.h" @@ -174,6 +195,7 @@ #include "test-type_array-uint8s_resize.h" #include "test-type_array-uint8ss_adjust.h" #include "test-type_array-uint8ss_append.h" +#include "test-type_array-uint8ss_append_all.h" #include "test-type_array-uint8ss_decimate_by.h" #include "test-type_array-uint8ss_decrease_by.h" #include "test-type_array-uint8ss_increase.h" @@ -181,6 +203,7 @@ #include "test-type_array-uint8ss_resize.h" #include "test-type_array-uint16s_adjust.h" #include "test-type_array-uint16s_append.h" +#include "test-type_array-uint16s_append_all.h" #include "test-type_array-uint16s_decimate_by.h" #include "test-type_array-uint16s_decrease_by.h" #include "test-type_array-uint16s_increase.h" @@ -188,6 +211,7 @@ #include "test-type_array-uint16s_resize.h" #include "test-type_array-uint16ss_adjust.h" #include "test-type_array-uint16ss_append.h" +#include "test-type_array-uint16ss_append_all.h" #include "test-type_array-uint16ss_decimate_by.h" #include "test-type_array-uint16ss_decrease_by.h" #include "test-type_array-uint16ss_increase.h" @@ -195,6 +219,7 @@ #include "test-type_array-uint16ss_resize.h" #include "test-type_array-uint32s_adjust.h" #include "test-type_array-uint32s_append.h" +#include "test-type_array-uint32s_append_all.h" #include "test-type_array-uint32s_decimate_by.h" #include "test-type_array-uint32s_decrease_by.h" #include "test-type_array-uint32s_increase.h" @@ -202,6 +227,7 @@ #include "test-type_array-uint32s_resize.h" #include "test-type_array-uint32ss_adjust.h" #include "test-type_array-uint32ss_append.h" +#include "test-type_array-uint32ss_append_all.h" #include "test-type_array-uint32ss_decimate_by.h" #include "test-type_array-uint32ss_decrease_by.h" #include "test-type_array-uint32ss_increase.h" @@ -209,6 +235,7 @@ #include "test-type_array-uint32ss_resize.h" #include "test-type_array-uint64s_adjust.h" #include "test-type_array-uint64s_append.h" +#include "test-type_array-uint64s_append_all.h" #include "test-type_array-uint64s_decimate_by.h" #include "test-type_array-uint64s_decrease_by.h" #include "test-type_array-uint64s_increase.h" @@ -216,6 +243,7 @@ #include "test-type_array-uint64s_resize.h" #include "test-type_array-uint64ss_adjust.h" #include "test-type_array-uint64ss_append.h" +#include "test-type_array-uint64ss_append_all.h" #include "test-type_array-uint64ss_decimate_by.h" #include "test-type_array-uint64ss_decrease_by.h" #include "test-type_array-uint64ss_increase.h" @@ -223,6 +251,7 @@ #include "test-type_array-uint64ss_resize.h" #include "test-type_array-uint128s_adjust.h" #include "test-type_array-uint128s_append.h" +#include "test-type_array-uint128s_append_all.h" #include "test-type_array-uint128s_decimate_by.h" #include "test-type_array-uint128s_decrease_by.h" #include "test-type_array-uint128s_increase.h" @@ -230,6 +259,7 @@ #include "test-type_array-uint128s_resize.h" #include "test-type_array-uint128ss_adjust.h" #include "test-type_array-uint128ss_append.h" +#include "test-type_array-uint128ss_append_all.h" #include "test-type_array-uint128ss_decimate_by.h" #include "test-type_array-uint128ss_decrease_by.h" #include "test-type_array-uint128ss_increase.h" diff --git a/level_0/f_utf/c/utf/private-string.c b/level_0/f_utf/c/utf/private-string.c index fe639e246..507daa979 100644 --- a/level_0/f_utf/c/utf/private-string.c +++ b/level_0/f_utf/c/utf/private-string.c @@ -75,17 +75,16 @@ extern "C" { #if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) f_status_t private_f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t *dynamic) { - f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_utf_string_t), (void **) & dynamic->string); + const f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_utf_string_t), (void **) & dynamic->string); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - dynamic->size = length; + dynamic->size = length; - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } + if (dynamic->used > dynamic->size) { + dynamic->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) @@ -108,16 +107,15 @@ extern "C" { f_status_t private_f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *dynamic) { const f_status_t status = f_memory_resize(dynamic->size, length, sizeof(f_utf_string_t), (void **) & dynamic->string); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - dynamic->size = length; + dynamic->size = length; - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } + if (dynamic->used > dynamic->size) { + dynamic->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) @@ -137,16 +135,15 @@ extern "C" { } // for status = f_memory_adjust(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - dynamics->size = length; + dynamics->size = length; - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } + if (dynamics->used > dynamics->size) { + dynamics->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) @@ -189,16 +186,15 @@ extern "C" { } // for status = f_memory_resize(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - dynamics->size = length; + dynamics->size = length; - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } + if (dynamics->used > dynamics->size) { + dynamics->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) @@ -221,16 +217,15 @@ extern "C" { } // for status = f_memory_adjust(map_multis->size, length, sizeof(f_utf_string_map_multi_t), (void **) & map_multis->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - map_multis->size = length; + map_multis->size = length; - if (map_multis->used > map_multis->size) { - map_multis->used = length; - } + if (map_multis->used > map_multis->size) { + map_multis->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) @@ -253,16 +248,15 @@ extern "C" { } // for status = f_memory_resize(map_multis->size, length, sizeof(f_utf_string_map_multi_t), (void **) & map_multis->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - map_multis->size = length; + map_multis->size = length; - if (map_multis->used > map_multis->size) { - map_multis->used = length; - } + if (map_multis->used > map_multis->size) { + map_multis->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) @@ -285,16 +279,15 @@ extern "C" { } // for status = f_memory_adjust(maps->size, length, sizeof(f_utf_string_map_t), (void **) & maps->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - maps->size = length; + maps->size = length; - if (maps->used > maps->size) { - maps->used = length; - } + if (maps->used > maps->size) { + maps->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) @@ -317,16 +310,15 @@ extern "C" { } // for status = f_memory_resize(maps->size, length, sizeof(f_utf_string_map_t), (void **) & maps->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - maps->size = length; + maps->size = length; - if (maps->used > maps->size) { - maps->used = length; - } + if (maps->used > maps->size) { + maps->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) @@ -351,6 +343,7 @@ extern "C" { } destination->used = destination->used + length; + return F_none; } #endif // !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) @@ -443,16 +436,15 @@ extern "C" { } // for status = f_memory_adjust(triples->size, length, sizeof(f_utf_string_triple_t), (void **) & triples->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - triples->size = length; + triples->size = length; - if (triples->used > triples->size) { - triples->used = length; - } + if (triples->used > triples->size) { + triples->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) @@ -478,16 +470,15 @@ extern "C" { } // for status = f_memory_resize(triples->size, length, sizeof(f_utf_string_triple_t), (void **) & triples->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - triples->size = length; + triples->size = length; - if (triples->used > triples->size) { - triples->used = length; - } + if (triples->used > triples->size) { + triples->used = length; } - return status; + return F_none; } #endif // !defined(_di_f_utf_string_triples_decrease_) || !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 27f2c4971..79c0a42ff 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -10,7 +10,7 @@ extern "C" { f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quoted, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t * const destination) { f_status_t status = F_none; - f_string_range_t destination_range = macro_f_string_range_t_initialize(destination->used); + f_string_range_t destination_range = macro_f_string_range_t_initialize2(destination->used); f_array_length_t i = 0; uint8_t width = 0; @@ -188,7 +188,7 @@ extern "C" { f_status_t private_fl_fss_basic_list_write_object_trim(const f_array_length_t used_start, f_state_t state, f_string_dynamic_t * const destination) { f_status_t status = F_none; - f_string_range_t destination_range = macro_f_string_range_t_initialize(destination->used); + f_string_range_t destination_range = macro_f_string_range_t_initialize2(destination->used); f_array_length_t i = 0; uint8_t width = 0; diff --git a/level_2/fll_fss/c/fss/basic.c b/level_2/fll_fss/c/fss/basic.c index 8e6382e0b..51e5fb50a 100644 --- a/level_2/fll_fss/c/fss/basic.c +++ b/level_2/fll_fss/c/fss/basic.c @@ -158,7 +158,7 @@ extern "C" { #endif // _di_level_2_parameter_checking_ f_status_t status = 0; - f_string_range_t range = macro_f_string_range_t_initialize(object.used); + f_string_range_t range = macro_f_string_range_t_initialize2(object.used); status = fl_fss_basic_object_write(object, quote, f_fss_complete_full_e, state, &range, destination); diff --git a/level_2/fll_fss/c/fss/basic_list.c b/level_2/fll_fss/c/fss/basic_list.c index e660048e7..f19a4dde4 100644 --- a/level_2/fll_fss/c/fss/basic_list.c +++ b/level_2/fll_fss/c/fss/basic_list.c @@ -135,7 +135,7 @@ extern "C" { #endif // _di_level_2_parameter_checking_ f_status_t status = 0; - f_string_range_t range = macro_f_string_range_t_initialize(object.used); + f_string_range_t range = macro_f_string_range_t_initialize2(object.used); status = fl_fss_basic_list_object_write(object, f_fss_complete_full_e, state, &range, destination); diff --git a/level_2/fll_fss/c/fss/embedded_list.c b/level_2/fll_fss/c/fss/embedded_list.c index b83899f70..006b1d182 100644 --- a/level_2/fll_fss/c/fss/embedded_list.c +++ b/level_2/fll_fss/c/fss/embedded_list.c @@ -132,7 +132,7 @@ extern "C" { #endif // _di_level_2_parameter_checking_ f_status_t status = 0; - f_string_range_t range = macro_f_string_range_t_initialize(object.used); + f_string_range_t range = macro_f_string_range_t_initialize2(object.used); status = fl_fss_embedded_list_object_write(object, f_fss_complete_full_e, state, &range, destination); diff --git a/level_2/fll_fss/c/fss/extended.c b/level_2/fll_fss/c/fss/extended.c index d8ec86656..98ad6bd73 100644 --- a/level_2/fll_fss/c/fss/extended.c +++ b/level_2/fll_fss/c/fss/extended.c @@ -197,7 +197,7 @@ extern "C" { #endif // _di_level_2_parameter_checking_ f_status_t status = 0; - f_string_range_t range = macro_f_string_range_t_initialize(object.used); + f_string_range_t range = macro_f_string_range_t_initialize2(object.used); status = fl_fss_extended_object_write(object, quote, f_fss_complete_full_e, state, &range, destination); diff --git a/level_2/fll_fss/c/fss/extended_list.c b/level_2/fll_fss/c/fss/extended_list.c index a6df5f436..4c7e85b61 100644 --- a/level_2/fll_fss/c/fss/extended_list.c +++ b/level_2/fll_fss/c/fss/extended_list.c @@ -132,7 +132,7 @@ extern "C" { #endif // _di_level_2_parameter_checking_ f_status_t status = 0; - f_string_range_t range = macro_f_string_range_t_initialize(object.used); + f_string_range_t range = macro_f_string_range_t_initialize2(object.used); status = fl_fss_extended_list_object_write(object, f_fss_complete_full_e, state, &range, destination); diff --git a/level_2/fll_fss/c/fss/payload.c b/level_2/fll_fss/c/fss/payload.c index 10ea51098..35a14006d 100644 --- a/level_2/fll_fss/c/fss/payload.c +++ b/level_2/fll_fss/c/fss/payload.c @@ -183,7 +183,7 @@ extern "C" { #endif // _di_level_2_parameter_checking_ f_status_t status = 0; - f_string_range_t range = macro_f_string_range_t_initialize(object.used); + f_string_range_t range = macro_f_string_range_t_initialize2(object.used); status = fl_fss_basic_list_object_write(object, trim ? f_fss_complete_full_trim_e : f_fss_complete_full_e, state, &range, destination); diff --git a/level_2/fll_iki/c/iki.c b/level_2/fll_iki/c/iki.c index 43061e4a2..08d875599 100644 --- a/level_2/fll_iki/c/iki.c +++ b/level_2/fll_iki/c/iki.c @@ -13,7 +13,7 @@ extern "C" { if (escaped->used > escaped->size) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ - const f_string_range_t range = macro_f_string_range_t_initialize(content.used); + const f_string_range_t range = macro_f_string_range_t_initialize2(content.used); return private_fll_iki_content_partial_escape(content, range, quote.string[0], escaped); } @@ -55,7 +55,7 @@ extern "C" { if (unescaped->used > unescaped->size) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ - const f_string_range_t range = macro_f_string_range_t_initialize(content.used); + const f_string_range_t range = macro_f_string_range_t_initialize2(content.used); return private_fll_iki_content_partial_unescape(content, range, quote.string[0], unescaped); } diff --git a/level_3/control/c/private-control.c b/level_3/control/c/private-control.c index 532e229cc..4b8016e70 100644 --- a/level_3/control/c/private-control.c +++ b/level_3/control/c/private-control.c @@ -331,7 +331,7 @@ extern "C" { { f_state_t state = macro_f_state_t_initialize(control_allocation_large_d, control_allocation_small_d, 0, &control_signal_state_interrupt_fss, 0, (void *) main, 0); - f_string_range_t range_packet = macro_f_string_range_t_initialize(data->cache.large.used); + f_string_range_t range_packet = macro_f_string_range_t_initialize2(data->cache.large.used); status = fll_fss_basic_list_read(data->cache.large, state, &range_packet, &data->cache.packet_objects, &data->cache.packet_contents, &data->cache.delimits, 0, 0); if (F_status_is_error(status)) return status; diff --git a/level_3/controller/c/common/private-process.c b/level_3/controller/c/common/private-process.c index 0dd3bce73..a5846261f 100644 --- a/level_3/controller/c/common/private-process.c +++ b/level_3/controller/c/common/private-process.c @@ -29,19 +29,16 @@ extern "C" { #ifndef _di_controller_pids_resize_ f_status_t controller_pids_resize(const f_array_length_t length, controller_pids_t * const pids) { - f_status_t status = F_none; - - status = f_memory_resize(pids->size, length, sizeof(controller_rule_t), (void **) & pids->array); + const f_status_t status = f_memory_resize(pids->size, length, sizeof(controller_rule_t), (void **) & pids->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - pids->size = length; + pids->size = length; - if (pids->used > pids->size) { - pids->used = length; - } + if (pids->used > pids->size) { + pids->used = length; } - return status; + return F_none; } #endif // _di_controller_pids_resize_ @@ -114,9 +111,9 @@ extern "C" { } // for status = f_memory_resize(processs->size, length, sizeof(controller_process_t), (void **) & processs->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status) && length) { - + if (length) { controller_process_t *process = 0; // The lock must be initialized, but only once, so initialize immediately upon allocation. @@ -147,11 +144,10 @@ extern "C" { return status; } - else { - for (f_array_length_t i = 0; i < controller_rule_action_type__enum_size_e; ++i) { - process->rule.status[i] = F_known_not; - } // for - } + + for (f_array_length_t i = 0; i < controller_rule_action_type__enum_size_e; ++i) { + process->rule.status[i] = F_known_not; + } // for } // for processs->size = length; @@ -161,7 +157,7 @@ extern "C" { } } - return status; + return F_none; } #endif // _di_controller_processs_resize_ diff --git a/level_3/controller/c/common/private-rule.c b/level_3/controller/c/common/private-rule.c index 8fbc54bb6..a638272a3 100644 --- a/level_3/controller/c/common/private-rule.c +++ b/level_3/controller/c/common/private-rule.c @@ -155,16 +155,15 @@ extern "C" { } // for const f_status_t status = f_memory_resize(ons->size, length, sizeof(controller_rule_on_t), (void **) & ons->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - ons->size = length; + ons->size = length; - if (ons->used > ons->size) { - ons->used = length; - } + if (ons->used > ons->size) { + ons->used = length; } - return status; + return F_none; } #endif // _di_controller_rule_ons_resize_ @@ -204,16 +203,15 @@ extern "C" { } // for const f_status_t status = f_memory_resize(rules->size, length, sizeof(controller_rule_t), (void **) & rules->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - rules->size = length; + rules->size = length; - if (rules->used > rules->size) { - rules->used = length; - } + if (rules->used > rules->size) { + rules->used = length; } - return status; + return F_none; } #endif // _di_controller_rules_resize_ diff --git a/level_3/controller/c/common/private-task.c b/level_3/controller/c/common/private-task.c index c86ae4618..08f5396fc 100644 --- a/level_3/controller/c/common/private-task.c +++ b/level_3/controller/c/common/private-task.c @@ -112,16 +112,15 @@ extern "C" { } // for const f_status_t status = f_memory_resize(tasks->size, length, sizeof(controller_task_t), (void **) & tasks->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - tasks->size = length; + tasks->size = length; - if (tasks->used > tasks->size) { - tasks->used = length; - } + if (tasks->used > tasks->size) { + tasks->used = length; } - return status; + return F_none; } #endif // _di_controller_tasks_resize_ diff --git a/level_3/controller/c/controller/private-controller.c b/level_3/controller/c/controller/private-controller.c index 7e8150540..77c60d740 100644 --- a/level_3/controller/c/controller/private-controller.c +++ b/level_3/controller/c/controller/private-controller.c @@ -207,7 +207,7 @@ extern "C" { if (F_status_is_error_not(status)) { f_number_unsigned_t number = 0; - f_string_range_t range = macro_f_string_range_t_initialize(pid_buffer.used); + f_string_range_t range = macro_f_string_range_t_initialize2(pid_buffer.used); for (; range.start < pid_buffer.used; ++range.start) { if (!isspace(pid_buffer.string[range.start])) break; @@ -260,7 +260,7 @@ extern "C" { if (F_status_is_error_not(status)) { f_number_unsigned_t number = 0; - f_string_range_t range = macro_f_string_range_t_initialize(pid_buffer.used); + f_string_range_t range = macro_f_string_range_t_initialize2(pid_buffer.used); for (; range.start < pid_buffer.used; ++range.start) { if (!isspace(pid_buffer.string[range.start])) break; @@ -362,7 +362,7 @@ extern "C" { } if (destination->used >= setting->path_current.used) { - const f_string_range_t range = macro_f_string_range_t_initialize(setting->path_current.used); + const f_string_range_t range = macro_f_string_range_t_initialize2(setting->path_current.used); if (fl_string_dynamic_partial_compare(*destination, setting->path_current, range, range) == F_equal_to) { f_array_length_t length = destination->used - setting->path_current.used; diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index 6b98acd87..8a4e5ebcf 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -1642,7 +1642,7 @@ extern "C" { if (cache->buffer_file.used) { controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_entry, global.thread); f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large_d, controller_common_allocation_small_d, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); - f_string_range_t range = macro_f_string_range_t_initialize(cache->buffer_file.used); + f_string_range_t range = macro_f_string_range_t_initialize2(cache->buffer_file.used); status = fll_fss_basic_list_read(cache->buffer_file, state, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments); diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 33155949c..ef932beb0 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -418,7 +418,7 @@ extern "C" { state.step_small = controller_common_allocation_iki_small_d; state.interrupt = &controller_thread_signal_state_iki; - f_string_range_t range_iki = macro_f_string_range_t_initialize(actions->array[actions->used].parameters.array[0].used); + f_string_range_t range_iki = macro_f_string_range_t_initialize2(actions->array[actions->used].parameters.array[0].used); status = fl_iki_read(state, &actions->array[actions->used].parameters.array[0], &range_iki, &actions->array[actions->used].ikis.array[0]); @@ -729,7 +729,7 @@ extern "C" { state.step_small = controller_common_allocation_iki_small_d; state.interrupt = &controller_thread_signal_state_iki; - f_string_range_t range_iki = macro_f_string_range_t_initialize(actions->array[actions->used].parameters.array[0].used); + f_string_range_t range_iki = macro_f_string_range_t_initialize2(actions->array[actions->used].parameters.array[0].used); status = fl_iki_read(state, &actions->array[actions->used].parameters.array[0], &range_iki, &actions->array[actions->used].ikis.array[0]); @@ -928,7 +928,7 @@ extern "C" { status = f_string_maps_append_all(source.parameter, &destination->parameter); if (F_status_is_error(status)) return status; - status = f_string_dynamics_append(source.environment, &destination->environment); + status = f_string_dynamics_append_all(source.environment, &destination->environment); if (F_status_is_error(status)) return status; if (source.ons.used) { @@ -944,21 +944,21 @@ extern "C" { if (source.ons.array[i].need.used) { destination->ons.array[i].need.used = 0; - status = f_string_dynamics_append(source.ons.array[i].need, &destination->ons.array[i].need); + status = f_string_dynamics_append_all(source.ons.array[i].need, &destination->ons.array[i].need); if (F_status_is_error(status)) return status; } if (source.ons.array[i].want.used) { destination->ons.array[i].want.used = 0; - status = f_string_dynamics_append(source.ons.array[i].want, &destination->ons.array[i].want); + status = f_string_dynamics_append_all(source.ons.array[i].want, &destination->ons.array[i].want); if (F_status_is_error(status)) return status; } if (source.ons.array[i].wish.used) { destination->ons.array[i].wish.used = 0; - status = f_string_dynamics_append(source.ons.array[i].wish, &destination->ons.array[i].wish); + status = f_string_dynamics_append_all(source.ons.array[i].wish, &destination->ons.array[i].wish); if (F_status_is_error(status)) return status; } } // for @@ -966,7 +966,7 @@ extern "C" { destination->ons.used = source.ons.used; } - status = f_int32s_append(source.affinity, &destination->affinity); + status = f_int32s_append_all(source.affinity, &destination->affinity); if (F_status_is_error(status)) return status; if (source.capability) { @@ -977,7 +977,7 @@ extern "C" { status = f_control_group_copy(source.cgroup, &destination->cgroup); if (F_status_is_error(status)) return status; - status = f_int32s_append(source.groups, &destination->groups); + status = f_int32s_append_all(source.groups, &destination->groups); if (F_status_is_error(status)) return status; status = f_limit_sets_copy(source.limits, &destination->limits); @@ -1017,6 +1017,7 @@ extern "C" { if (F_status_is_error(status)) return status; for (j = 0; j < controller_rule_action_type_execute__enum_size_e; ++j) { + item_destination->reruns[j].is = item_source->reruns[j].is; item_destination->reruns[j].failure.count = item_source->reruns[j].failure.count; item_destination->reruns[j].failure.delay = item_source->reruns[j].failure.delay; @@ -1038,10 +1039,10 @@ extern "C" { action_destination->parameters.used = 0; action_destination->ikis.used = 0; - status = f_string_dynamics_append(action_source->parameters, &action_destination->parameters); + status = f_string_dynamics_append_all(action_source->parameters, &action_destination->parameters); if (F_status_is_error(status)) return status; - status = f_iki_datas_append(action_source->ikis, &action_destination->ikis); + status = f_iki_datas_append_all(action_source->ikis, &action_destination->ikis); if (F_status_is_error(status)) return status; } // for @@ -2343,7 +2344,7 @@ extern "C" { f_status_t status = F_none; controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large_d, controller_common_allocation_small_d, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); - f_string_range_t range = macro_f_string_range_t_initialize(cache->buffer_item.used); + f_string_range_t range = macro_f_string_range_t_initialize2(cache->buffer_item.used); f_array_length_t last = 0; uint8_t type = 0; @@ -3808,7 +3809,7 @@ extern "C" { if (cache->buffer_file.used) { controller_state_interrupt_t custom = macro_controller_state_interrupt_t_initialize(is_normal, global.thread); f_state_t state = macro_f_state_t_initialize(controller_common_allocation_large_d, controller_common_allocation_small_d, 0, &controller_thread_signal_state_fss, 0, (void *) &custom, 0); - f_string_range_t range = macro_f_string_range_t_initialize(cache->buffer_file.used); + f_string_range_t range = macro_f_string_range_t_initialize2(cache->buffer_file.used); status = fll_fss_basic_list_read(cache->buffer_file, state, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments); @@ -3968,7 +3969,7 @@ extern "C" { f_status_t status = F_none; f_status_t status_return = F_none; - f_string_range_t range = macro_f_string_range_t_initialize(cache->buffer_item.used); + f_string_range_t range = macro_f_string_range_t_initialize2(cache->buffer_item.used); f_string_range_t range2 = f_string_range_t_initialize; { diff --git a/level_3/controller/c/rule/private-rule.h b/level_3/controller/c/rule/private-rule.h index ced35c531..504c0fd4c 100644 --- a/level_3/controller/c/rule/private-rule.h +++ b/level_3/controller/c/rule/private-rule.h @@ -202,19 +202,21 @@ extern "C" { * * Errors (with error bit) from: f_capability_copy(). * Errors (with error bit) from: f_control_group_copy(). + * Errors (with error bit) from: f_iki_datas_append_all(). + * Errors (with error bit) from: f_int32s_append_all(). * Errors (with error bit) from: f_limit_sets_copy(). * Errors (with error bit) from: f_string_dynamic_append(). - * Errors (with error bit) from: f_string_dynamics_append(). + * Errors (with error bit) from: f_string_dynamics_append_all(). * Errors (with error bit) from: f_string_maps_append_all(). - * Errors (with error bit) from: f_int32s_append(). * * @see f_capability_copy() * @see f_control_group_copy() + * @see f_iki_datas_append_all() + * @see f_int32s_append_all() * @see f_limit_sets_append() * @see f_string_dynamic_append() - * @see f_string_dynamics_append() + * @see f_string_dynamics_append_all() * @see f_string_maps_append_all() - * @see f_int32s_append() */ #ifndef _di_controller_rule_copy_ extern f_status_t controller_rule_copy(const controller_rule_t source, controller_rule_t *destination) F_attribute_visibility_internal_d; diff --git a/level_3/fake/c/private-build-load.c b/level_3/fake/c/private-build-load.c index 1699d0fa3..8bc3fa259 100644 --- a/level_3/fake/c/private-build-load.c +++ b/level_3/fake/c/private-build-load.c @@ -105,7 +105,7 @@ extern "C" { } if (F_status_is_error_not(*status)) { - f_string_range_t range = macro_f_string_range_t_initialize(buffer.used); + f_string_range_t range = macro_f_string_range_t_initialize2(buffer.used); f_fss_delimits_t delimits = f_fss_delimits_t_initialize; { diff --git a/level_3/fake/c/private-make-load_fakefile.c b/level_3/fake/c/private-make-load_fakefile.c index 4f04124fd..6396e8499 100644 --- a/level_3/fake/c/private-make-load_fakefile.c +++ b/level_3/fake/c/private-make-load_fakefile.c @@ -48,7 +48,7 @@ extern "C" { f_fss_contents_t list_contents = f_fss_contents_t_initialize; { - f_string_range_t range = macro_f_string_range_t_initialize(data_make->buffer.used); + f_string_range_t range = macro_f_string_range_t_initialize2(data_make->buffer.used); f_fss_delimits_t delimits = f_fss_delimits_t_initialize; f_fss_comments_t comments = f_fss_comments_t_initialize; diff --git a/level_3/fake/c/private-make-operate.c b/level_3/fake/c/private-make-operate.c index ffd4ddfd0..f9b79c914 100644 --- a/level_3/fake/c/private-make-operate.c +++ b/level_3/fake/c/private-make-operate.c @@ -156,9 +156,9 @@ extern "C" { const f_string_static_t vocabulary_define = macro_f_string_static_t_initialize2(F_iki_vocabulary_0002_define_s, F_iki_vocabulary_0002_define_s_length); const f_string_static_t vocabulary_parameter = macro_f_string_static_t_initialize2(F_iki_vocabulary_0002_parameter_s, F_iki_vocabulary_0002_parameter_s_length); - const f_string_range_t range_context = macro_f_string_range_t_initialize(F_iki_vocabulary_0002_context_s_length); - const f_string_range_t range_define = macro_f_string_range_t_initialize(F_iki_vocabulary_0002_define_s_length); - const f_string_range_t range_parameter = macro_f_string_range_t_initialize(F_iki_vocabulary_0002_parameter_s_length); + const f_string_range_t range_context = macro_f_string_range_t_initialize2(F_iki_vocabulary_0002_context_s_length); + const f_string_range_t range_define = macro_f_string_range_t_initialize2(F_iki_vocabulary_0002_define_s_length); + const f_string_range_t range_parameter = macro_f_string_range_t_initialize2(F_iki_vocabulary_0002_parameter_s_length); f_iki_data_t iki_data = f_iki_data_t_initialize; diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 615614048..f7b152be8 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -26,7 +26,7 @@ extern "C" { return F_status_set_error(F_false); } - const f_string_range_t range = macro_f_string_range_t_initialize(data_make->path.stack.array[0].used); + const f_string_range_t range = macro_f_string_range_t_initialize2(data_make->path.stack.array[0].used); if (range.start <= range.stop) { status = fl_string_dynamic_partial_compare(data_make->path.stack.array[0], data_make->path_cache, range, range); diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index fae9d9e13..06361a980 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -619,7 +619,7 @@ f_status_t firewall_perform_commands(firewall_main_t * const main, const firewal { f_state_t state = f_state_t_initialize; - f_string_range_t input = macro_f_string_range_t_initialize(local_buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(local_buffer.used); status = fll_fss_basic_read(local_buffer, state, &input, &basic_objects, &basic_contents, 0, &delimits, 0); } @@ -1193,7 +1193,7 @@ f_status_t firewall_buffer_rules(firewall_main_t * const main, const f_string_st { f_state_t state = f_state_t_initialize; - f_string_range_t input = macro_f_string_range_t_initialize(local->buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(local->buffer.used); status = fll_fss_basic_list_read(local->buffer, state, &input, &local->chain_objects, &local->chain_contents, &delimits, 0, &comments); } diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 3393043bd..3bee38758 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -456,7 +456,7 @@ extern "C" { --length; } - f_string_range_t range = macro_f_string_range_t_initialize(length); + f_string_range_t range = macro_f_string_range_t_initialize2(length); // Ignore leading plus sign. if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { diff --git a/level_3/fss_basic_list_read/c/private-common.c b/level_3/fss_basic_list_read/c/private-common.c index 0a3a24646..f706c11bc 100644 --- a/level_3/fss_basic_list_read/c/private-common.c +++ b/level_3/fss_basic_list_read/c/private-common.c @@ -44,16 +44,15 @@ extern "C" { } // for const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_basic_list_read_depth_t), (void **) & depths->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - depths->size = length; + depths->size = length; - if (depths->used > depths->size) { - depths->used = length; - } + if (depths->used > depths->size) { + depths->used = length; } - return status; + return F_none; } #endif // _di_fss_basic_list_read_depths_resize_ diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index 704a32aaf..0778eafb5 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -244,7 +244,7 @@ extern "C" { f_status_t fss_basic_list_read_load(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_basic_list_read_common_allocation_large_d, fss_basic_list_read_common_allocation_small_d, 0, 0, 0, 0, 0); - f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; data->delimits_content.used = 0; diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index df2fe435b..62ce652ce 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -326,7 +326,7 @@ extern "C" { const f_array_length_t index = main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.used - 1]; if (main->parameters.arguments.array[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize(main->parameters.arguments.array[index].used); + f_string_range_t range = macro_f_string_range_t_initialize2(main->parameters.arguments.array[index].used); for (; range.start < main->parameters.arguments.array[index].used; ++range.start) { diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 46d18c425..654c9da24 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -451,7 +451,7 @@ extern "C" { --length; } - f_string_range_t range = macro_f_string_range_t_initialize(length); + f_string_range_t range = macro_f_string_range_t_initialize2(length); // Ignore leading plus sign. if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { diff --git a/level_3/fss_basic_read/c/private-common.c b/level_3/fss_basic_read/c/private-common.c index 1961d073e..37a08b9a4 100644 --- a/level_3/fss_basic_read/c/private-common.c +++ b/level_3/fss_basic_read/c/private-common.c @@ -43,16 +43,15 @@ extern "C" { } // for const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_basic_read_depth_t), (void **) & depths->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - depths->size = length; + depths->size = length; - if (depths->used > depths->size) { - depths->used = length; - } + if (depths->used > depths->size) { + depths->used = length; } - return status; + return F_none; } #endif // _di_fss_basic_read_depths_resize_ diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index c58189c81..3c033ca7b 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -212,7 +212,7 @@ extern "C" { f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_basic_read_common_allocation_large_d, fss_basic_read_common_allocation_small_d, 0, 0, 0, 0, 0); - f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits.used = 0; data->quotes.used = 0; diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index 92c08bef8..b9a980631 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -325,7 +325,7 @@ extern "C" { // Even though this standard does not utilize this parameter, provide the validation for consistency. if (argv[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); + f_string_range_t range = macro_f_string_range_t_initialize2(argv[index].used); for (; range.start < argv[index].used; ++range.start) { diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index de023961c..ad65cd987 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -374,7 +374,7 @@ extern "C" { --length; } - f_string_range_t range = macro_f_string_range_t_initialize(length); + f_string_range_t range = macro_f_string_range_t_initialize2(length); // Ignore leading plus sign. if (argv[index].string[0] == f_string_ascii_plus_s.string[0]) { diff --git a/level_3/fss_embedded_list_read/c/private-read.c b/level_3/fss_embedded_list_read/c/private-read.c index 901abc307..a0c4eee18 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -240,7 +240,7 @@ extern "C" { { f_state_t state = macro_f_state_t_initialize(fss_embedded_list_read_common_allocation_large_d, fss_embedded_list_read_common_allocation_small_d, 0, 0, 0, 0, 0); - f_string_range_t input = macro_f_string_range_t_initialize(main->buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(main->buffer.used); objects_delimits->used = 0; contents_delimits->used = 0; diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c index 718da78f5..fd9e08239 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c @@ -327,7 +327,7 @@ extern "C" { const f_array_length_t index = main->parameters.array[fss_embedded_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_embedded_list_write_parameter_prepend_e].values.used - 1]; if (argv[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); + f_string_range_t range = macro_f_string_range_t_initialize2(argv[index].used); for (; range.start < argv[index].used; ++range.start) { diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 7dbfd1959..fd33c8874 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -451,7 +451,7 @@ extern "C" { --length; } - f_string_range_t range = macro_f_string_range_t_initialize(length); + f_string_range_t range = macro_f_string_range_t_initialize2(length); // Ignore leading plus sign. if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { diff --git a/level_3/fss_extended_list_read/c/private-common.c b/level_3/fss_extended_list_read/c/private-common.c index a9862584f..083e43b98 100644 --- a/level_3/fss_extended_list_read/c/private-common.c +++ b/level_3/fss_extended_list_read/c/private-common.c @@ -44,16 +44,15 @@ extern "C" { } // for const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_extended_list_read_depth_t), (void **) & depths->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - depths->size = length; + depths->size = length; - if (depths->used > depths->size) { - depths->used = length; - } + if (depths->used > depths->size) { + depths->used = length; } - return status; + return F_none; } #endif // _di_fss_extended_list_read_depths_resize_ diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index f298769b9..134d73b43 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -234,7 +234,7 @@ extern "C" { f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_extended_list_read_common_allocation_large_d, fss_extended_list_read_common_allocation_small_d, 0, 0, 0, 0, 0); - f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; data->delimits_content.used = 0; diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.c b/level_3/fss_extended_list_write/c/fss_extended_list_write.c index 4304d2e64..16cd23c48 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.c @@ -326,7 +326,7 @@ extern "C" { const f_array_length_t index = main->parameters.array[fss_extended_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_extended_list_write_parameter_prepend_e].values.used - 1]; if (argv[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); + f_string_range_t range = macro_f_string_range_t_initialize2(argv[index].used); for (; range.start < argv[index].used; ++range.start) { diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index becbad10f..36e9e55ca 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -454,7 +454,7 @@ extern "C" { --length; } - f_string_range_t range = macro_f_string_range_t_initialize(length); + f_string_range_t range = macro_f_string_range_t_initialize2(length); // Ignore leading plus sign. if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { diff --git a/level_3/fss_extended_read/c/private-common.c b/level_3/fss_extended_read/c/private-common.c index 9e850e69c..7c9f9f452 100644 --- a/level_3/fss_extended_read/c/private-common.c +++ b/level_3/fss_extended_read/c/private-common.c @@ -45,16 +45,15 @@ extern "C" { } // for const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_extended_read_depth_t), (void **) & depths->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - depths->size = length; + depths->size = length; - if (depths->used > depths->size) { - depths->used = length; - } + if (depths->used > depths->size) { + depths->used = length; } - return status; + return F_none; } #endif // _di_fss_extended_read_depths_resize_ diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index c9d4c5c0e..d23d8d468 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -247,7 +247,7 @@ extern "C" { f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_extended_read_common_allocation_large_d, fss_extended_read_common_allocation_small_d, 0, 0, 0, 0, 0); - f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; data->delimits_content.used = 0; diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index 3bf4f47dc..fa2d30178 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -337,7 +337,7 @@ extern "C" { // Even though this standard does not utilize this parameter, provide the validation for consistency. if (argv[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); + f_string_range_t range = macro_f_string_range_t_initialize2(argv[index].used); for (; range.start < argv[index].used; ++range.start) { diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 0a77e9453..233a04ce1 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -229,7 +229,7 @@ extern "C" { else if (main->parameters.array[fss_identify_parameter_name_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_identify_parameter_name_e].values.array[main->parameters.array[fss_identify_parameter_name_e].values.used - 1]; const f_array_length_t length = data.argv[index].used; - const f_string_range_t range = macro_f_string_range_t_initialize(length); + const f_string_range_t range = macro_f_string_range_t_initialize2(length); if (length == 0) { flockfile(main->error.to.stream); diff --git a/level_3/fss_identify/c/private-identify.c b/level_3/fss_identify/c/private-identify.c index e397fd119..ed623ffef 100644 --- a/level_3/fss_identify/c/private-identify.c +++ b/level_3/fss_identify/c/private-identify.c @@ -156,7 +156,7 @@ extern "C" { if (mode) { f_array_length_t number = 0; - f_string_range_t range = macro_f_string_range_t_initialize(data->name.used); + f_string_range_t range = macro_f_string_range_t_initialize2(data->name.used); for (f_array_length_t i = 0; i < data->name.used; ++i) { diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c index a21240d3f..5f9ac54b0 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -474,7 +474,7 @@ extern "C" { --length; } - f_string_range_t range = macro_f_string_range_t_initialize(length); + f_string_range_t range = macro_f_string_range_t_initialize2(length); // Ignore leading plus sign. if (data.argv[index].string[0] == f_string_ascii_plus_s.string[0]) { diff --git a/level_3/fss_payload_read/c/private-common.c b/level_3/fss_payload_read/c/private-common.c index af4159537..b7191026d 100644 --- a/level_3/fss_payload_read/c/private-common.c +++ b/level_3/fss_payload_read/c/private-common.c @@ -50,16 +50,15 @@ extern "C" { } // for const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_payload_read_depth_t), (void **) & depths->array); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - depths->size = length; + depths->size = length; - if (depths->used > depths->size) { - depths->used = length; - } + if (depths->used > depths->size) { + depths->used = length; } - return status; + return F_none; } #endif // _di_fss_payload_read_depths_resize_ diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index 47e0f45bd..7efc8a8c3 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -243,7 +243,7 @@ extern "C" { f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t * const data) { f_state_t state = macro_f_state_t_initialize(fss_payload_read_common_allocation_large_d, fss_payload_read_common_allocation_small_d, 0, 0, 0, 0, 0); - f_string_range_t input = macro_f_string_range_t_initialize(data->buffer.used); + f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; data->delimits_content.used = 0; diff --git a/level_3/fss_payload_write/c/fss_payload_write.c b/level_3/fss_payload_write/c/fss_payload_write.c index 2b5756ad8..d35c01ca4 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.c +++ b/level_3/fss_payload_write/c/fss_payload_write.c @@ -330,7 +330,7 @@ extern "C" { const f_array_length_t index = main->parameters.array[fss_payload_write_parameter_prepend_e].values.array[main->parameters.array[fss_payload_write_parameter_prepend_e].values.used - 1]; if (argv[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); + f_string_range_t range = macro_f_string_range_t_initialize2(argv[index].used); for (; range.start < argv[index].used; range.start++) { diff --git a/level_3/iki_read/c/private-print.c b/level_3/iki_read/c/private-print.c index eabeb71d3..a0071ea16 100644 --- a/level_3/iki_read/c/private-print.c +++ b/level_3/iki_read/c/private-print.c @@ -23,7 +23,7 @@ extern "C" { f_print_dynamic(substitutions.array[i].with, main->output.to.stream); } else { - f_string_range_t range = macro_f_string_range_t_initialize2(iki_data.variable.array[index].start, iki_data.content.array[index].start - 1); + f_string_range_t range = macro_f_string_range_t_initialize(iki_data.variable.array[index].start, iki_data.content.array[index].start - 1); f_print_dynamic_partial(main->buffer, range, main->output.to.stream); diff --git a/level_3/iki_read/c/private-read.c b/level_3/iki_read/c/private-read.c index f126463e6..40874db8f 100644 --- a/level_3/iki_read/c/private-read.c +++ b/level_3/iki_read/c/private-read.c @@ -42,7 +42,7 @@ extern "C" { f_iki_data_t iki_data = f_iki_data_t_initialize; if (main->parameters.array[iki_read_parameter_whole_e].result == f_console_result_found_e) { - f_string_range_t buffer_range = macro_f_string_range_t_initialize(main->buffer.used); + f_string_range_t buffer_range = macro_f_string_range_t_initialize2(main->buffer.used); status = iki_read_process_at(main, &buffer_range); @@ -69,7 +69,7 @@ extern "C" { status = iki_read_process_buffer_total(main, &iki_data); } else { - f_string_range_t buffer_range = macro_f_string_range_t_initialize(main->buffer.used); + f_string_range_t buffer_range = macro_f_string_range_t_initialize2(main->buffer.used); status = iki_read_process_at(main, &buffer_range); @@ -332,7 +332,7 @@ extern "C" { } // for if (name_missed) { - macro_f_memory_structure_increment(status, names, 1, F_iki_default_allocation_step_d, macro_f_string_dynamics_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, names, 1, F_iki_default_allocation_small_d, macro_f_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "macro_f_memory_structure_increment", F_true); @@ -454,7 +454,7 @@ extern "C" { f_status_t iki_read_process_buffer_total(iki_read_main_t * const main, f_iki_data_t *iki_data) { f_status_t status = F_none; - f_string_range_t range = macro_f_string_range_t_initialize(main->buffer.used); + f_string_range_t range = macro_f_string_range_t_initialize2(main->buffer.used); status = iki_read_process_at(main, &range); @@ -579,7 +579,7 @@ extern "C" { for (j = 0; j < vocabulary->used; ++j) { if (fl_string_dynamic_partial_compare_string(main->parameters.arguments.array[index].string, main->buffer, main->parameters.arguments.array[index].used, vocabulary->array[j]) == F_equal_to) { - macro_f_memory_structure_increment(status, substitutionss[j], 1, F_iki_default_allocation_step_d, macro_iki_read_substitutions_t_resize, F_array_too_large); + macro_f_memory_structure_increment(status, substitutionss[j], 1, F_iki_default_allocation_small_d, macro_iki_read_substitutions_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; index = parameter->values.array[i + 1];