From a8622f6e1e3fb7b080bb1b0517838b515d149341 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 13 Mar 2022 22:10:17 -0500 Subject: [PATCH] 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. --- build/level_0/settings | 14 +- build/monolithic/settings | 14 +- level_0/f_control_group/c/control_group.c | 2 +- level_0/f_control_group/c/control_group.h | 4 +- level_0/f_fss/c/fss/comment.h | 2 +- level_0/f_fss/c/fss/common.h | 2 +- level_0/f_fss/c/fss/delimit.h | 2 +- level_0/f_fss/c/private-fss.c | 66 +- level_0/f_iki/c/iki.h | 1 + level_0/f_iki/c/iki/common.c | 185 ----- level_0/f_iki/c/iki/common.h | 245 +----- level_0/f_iki/c/iki/data.c | 334 ++++++++ level_0/f_iki/c/iki/data.h | 421 ++++++++++ level_0/f_iki/c/iki/private-data.c | 221 +++++ level_0/f_iki/c/iki/private-data.h | 175 ++++ level_0/f_iki/c/private-iki.c | 76 -- level_0/f_iki/c/private-iki.h | 114 ++- level_0/f_iki/data/build/settings | 4 +- level_0/f_iki/data/build/settings-tests | 4 +- .../tests/unit/c/test-iki-content_partial_is.c | 40 +- level_0/f_iki/tests/unit/c/test-iki-datas_adjust.c | 42 + level_0/f_iki/tests/unit/c/test-iki-datas_adjust.h | 27 + level_0/f_iki/tests/unit/c/test-iki-datas_append.c | 111 +++ level_0/f_iki/tests/unit/c/test-iki-datas_append.h | 27 + .../f_iki/tests/unit/c/test-iki-datas_append_all.c | 161 ++++ .../f_iki/tests/unit/c/test-iki-datas_append_all.h | 34 + .../tests/unit/c/test-iki-datas_decimate_by.c | 50 ++ .../tests/unit/c/test-iki-datas_decimate_by.h | 27 + .../tests/unit/c/test-iki-datas_decrease_by.c | 50 ++ .../tests/unit/c/test-iki-datas_decrease_by.h | 27 + .../f_iki/tests/unit/c/test-iki-datas_increase.c | 76 ++ .../f_iki/tests/unit/c/test-iki-datas_increase.h | 34 + .../tests/unit/c/test-iki-datas_increase_by.c | 52 ++ .../tests/unit/c/test-iki-datas_increase_by.h | 27 + level_0/f_iki/tests/unit/c/test-iki-datas_resize.c | 42 + level_0/f_iki/tests/unit/c/test-iki-datas_resize.h | 27 + .../f_iki/tests/unit/c/test-iki-datass_adjust.c | 42 + .../f_iki/tests/unit/c/test-iki-datass_adjust.h | 27 + .../f_iki/tests/unit/c/test-iki-datass_append.c | 166 ++++ .../f_iki/tests/unit/c/test-iki-datass_append.h | 34 + .../tests/unit/c/test-iki-datass_append_all.c | 182 ++++ .../tests/unit/c/test-iki-datass_append_all.h | 34 + .../tests/unit/c/test-iki-datass_decimate_by.c | 50 ++ .../tests/unit/c/test-iki-datass_decimate_by.h | 27 + .../tests/unit/c/test-iki-datass_decrease_by.c | 50 ++ .../tests/unit/c/test-iki-datass_decrease_by.h | 27 + .../f_iki/tests/unit/c/test-iki-datass_increase.c | 76 ++ .../f_iki/tests/unit/c/test-iki-datass_increase.h | 34 + .../tests/unit/c/test-iki-datass_increase_by.c | 52 ++ .../tests/unit/c/test-iki-datass_increase_by.h | 27 + .../f_iki/tests/unit/c/test-iki-datass_resize.c | 42 + .../f_iki/tests/unit/c/test-iki-datass_resize.h | 27 + .../tests/unit/c/test-iki-object_partial_is.c | 40 +- level_0/f_iki/tests/unit/c/test-iki-read.c | 124 +-- level_0/f_iki/tests/unit/c/test-iki.c | 43 + level_0/f_iki/tests/unit/c/test-iki.h | 16 + level_0/f_memory/c/private-memory.c | 11 +- level_0/f_string/c/private-string.c | 904 +------------------- level_0/f_string/c/private-string.h | 914 --------------------- level_0/f_string/c/string.h | 1 + level_0/f_string/c/string/dynamic.c | 318 ++++--- level_0/f_string/c/string/dynamic.h | 72 +- level_0/f_string/c/string/map.c | 343 +------- level_0/f_string/c/string/map.h | 273 ------ level_0/f_string/c/string/map_multi.c | 305 +++++++ level_0/f_string/c/string/map_multi.h | 472 +++++++++++ level_0/f_string/c/string/private-dynamic.c | 218 +++++ level_0/f_string/c/string/private-dynamic.h | 382 +++++++++ level_0/f_string/c/string/private-map.c | 160 ++++ level_0/f_string/c/string/private-map.h | 152 ++++ level_0/f_string/c/string/private-map_multi.c | 160 ++++ level_0/f_string/c/string/private-map_multi.h | 152 ++++ level_0/f_string/c/string/private-quantity.c | 125 +++ level_0/f_string/c/string/private-quantity.h | 152 ++++ level_0/f_string/c/string/private-range.c | 125 +++ level_0/f_string/c/string/private-range.h | 152 ++++ level_0/f_string/c/string/private-triple.c | 172 ++++ level_0/f_string/c/string/private-triple.h | 152 ++++ level_0/f_string/c/string/quantity.c | 113 ++- level_0/f_string/c/string/quantity.h | 66 +- level_0/f_string/c/string/range.c | 112 ++- level_0/f_string/c/string/range.h | 70 +- level_0/f_string/c/string/triple.c | 123 ++- level_0/f_string/c/string/triple.h | 54 +- level_0/f_string/data/build/settings | 4 +- level_0/f_string/data/build/settings-tests | 56 ++ level_0/f_string/data/build/testfile | 45 + .../tests/unit/c/test-string-dynamics_adjust.c | 42 + .../tests/unit/c/test-string-dynamics_adjust.h | 27 + .../tests/unit/c/test-string-dynamics_append.c | 40 + .../tests/unit/c/test-string-dynamics_append.h | 27 + .../tests/unit/c/test-string-dynamics_append_all.c | 101 +++ .../tests/unit/c/test-string-dynamics_append_all.h | 34 + .../unit/c/test-string-dynamics_decimate_by.c | 50 ++ .../unit/c/test-string-dynamics_decimate_by.h | 27 + .../unit/c/test-string-dynamics_decrease_by.c | 50 ++ .../unit/c/test-string-dynamics_decrease_by.h | 27 + .../tests/unit/c/test-string-dynamics_increase.c | 76 ++ .../tests/unit/c/test-string-dynamics_increase.h | 34 + .../unit/c/test-string-dynamics_increase_by.c | 52 ++ .../unit/c/test-string-dynamics_increase_by.h | 27 + .../tests/unit/c/test-string-dynamics_resize.c | 42 + .../tests/unit/c/test-string-dynamics_resize.h | 27 + .../tests/unit/c/test-string-dynamicss_adjust.c | 42 + .../tests/unit/c/test-string-dynamicss_adjust.h | 27 + .../tests/unit/c/test-string-dynamicss_append.c | 102 +++ .../tests/unit/c/test-string-dynamicss_append.h | 34 + .../unit/c/test-string-dynamicss_append_all.c | 130 +++ .../unit/c/test-string-dynamicss_append_all.h | 34 + .../unit/c/test-string-dynamicss_decimate_by.c | 50 ++ .../unit/c/test-string-dynamicss_decimate_by.h | 27 + .../unit/c/test-string-dynamicss_decrease_by.c | 50 ++ .../unit/c/test-string-dynamicss_decrease_by.h | 27 + .../tests/unit/c/test-string-dynamicss_increase.c | 76 ++ .../tests/unit/c/test-string-dynamicss_increase.h | 34 + .../unit/c/test-string-dynamicss_increase_by.c | 52 ++ .../unit/c/test-string-dynamicss_increase_by.h | 27 + .../tests/unit/c/test-string-dynamicss_resize.c | 42 + .../tests/unit/c/test-string-dynamicss_resize.h | 27 + .../tests/unit/c/test-string-map_multis_adjust.c | 42 + .../tests/unit/c/test-string-map_multis_adjust.h | 27 + .../tests/unit/c/test-string-map_multis_append.c | 81 ++ .../tests/unit/c/test-string-map_multis_append.h | 27 + .../unit/c/test-string-map_multis_append_all.c | 126 +++ .../unit/c/test-string-map_multis_append_all.h | 34 + .../unit/c/test-string-map_multis_decimate_by.c | 50 ++ .../unit/c/test-string-map_multis_decimate_by.h | 27 + .../unit/c/test-string-map_multis_decrease_by.c | 50 ++ .../unit/c/test-string-map_multis_decrease_by.h | 27 + .../tests/unit/c/test-string-map_multis_increase.c | 76 ++ .../tests/unit/c/test-string-map_multis_increase.h | 34 + .../unit/c/test-string-map_multis_increase_by.c | 52 ++ .../unit/c/test-string-map_multis_increase_by.h | 27 + .../tests/unit/c/test-string-map_multis_resize.c | 42 + .../tests/unit/c/test-string-map_multis_resize.h | 27 + .../tests/unit/c/test-string-map_multiss_adjust.c | 42 + .../tests/unit/c/test-string-map_multiss_adjust.h | 27 + .../tests/unit/c/test-string-map_multiss_append.c | 142 ++++ .../tests/unit/c/test-string-map_multiss_append.h | 34 + .../unit/c/test-string-map_multiss_append_all.c | 169 ++++ .../unit/c/test-string-map_multiss_append_all.h | 34 + .../unit/c/test-string-map_multiss_decimate_by.c | 50 ++ .../unit/c/test-string-map_multiss_decimate_by.h | 27 + .../unit/c/test-string-map_multiss_decrease_by.c | 50 ++ .../unit/c/test-string-map_multiss_decrease_by.h | 27 + .../unit/c/test-string-map_multiss_increase.c | 76 ++ .../unit/c/test-string-map_multiss_increase.h | 34 + .../unit/c/test-string-map_multiss_increase_by.c | 52 ++ .../unit/c/test-string-map_multiss_increase_by.h | 27 + .../tests/unit/c/test-string-map_multiss_resize.c | 42 + .../tests/unit/c/test-string-map_multiss_resize.h | 27 + .../tests/unit/c/test-string-maps_adjust.c | 42 + .../tests/unit/c/test-string-maps_adjust.h | 27 + .../tests/unit/c/test-string-maps_append.c | 63 ++ .../tests/unit/c/test-string-maps_append.h | 27 + .../tests/unit/c/test-string-maps_append_all.c | 112 +++ .../tests/unit/c/test-string-maps_append_all.h | 34 + .../tests/unit/c/test-string-maps_decimate_by.c | 50 ++ .../tests/unit/c/test-string-maps_decimate_by.h | 27 + .../tests/unit/c/test-string-maps_decrease_by.c | 50 ++ .../tests/unit/c/test-string-maps_decrease_by.h | 27 + .../tests/unit/c/test-string-maps_increase.c | 76 ++ .../tests/unit/c/test-string-maps_increase.h | 34 + .../tests/unit/c/test-string-maps_increase_by.c | 52 ++ .../tests/unit/c/test-string-maps_increase_by.h | 27 + .../tests/unit/c/test-string-maps_resize.c | 42 + .../tests/unit/c/test-string-maps_resize.h | 27 + .../tests/unit/c/test-string-mapss_adjust.c | 42 + .../tests/unit/c/test-string-mapss_adjust.h | 27 + .../tests/unit/c/test-string-mapss_append.c | 120 +++ .../tests/unit/c/test-string-mapss_append.h | 34 + .../tests/unit/c/test-string-mapss_append_all.c | 147 ++++ .../tests/unit/c/test-string-mapss_append_all.h | 34 + .../tests/unit/c/test-string-mapss_decimate_by.c | 50 ++ .../tests/unit/c/test-string-mapss_decimate_by.h | 27 + .../tests/unit/c/test-string-mapss_decrease_by.c | 50 ++ .../tests/unit/c/test-string-mapss_decrease_by.h | 27 + .../tests/unit/c/test-string-mapss_increase.c | 76 ++ .../tests/unit/c/test-string-mapss_increase.h | 34 + .../tests/unit/c/test-string-mapss_increase_by.c | 52 ++ .../tests/unit/c/test-string-mapss_increase_by.h | 27 + .../tests/unit/c/test-string-mapss_resize.c | 42 + .../tests/unit/c/test-string-mapss_resize.h | 27 + .../tests/unit/c/test-string-quantitys_adjust.c | 42 + .../tests/unit/c/test-string-quantitys_adjust.h | 27 + .../tests/unit/c/test-string-quantitys_append.c | 38 + .../tests/unit/c/test-string-quantitys_append.h | 27 + .../unit/c/test-string-quantitys_append_all.c | 77 ++ .../unit/c/test-string-quantitys_append_all.h | 34 + .../unit/c/test-string-quantitys_decimate_by.c | 50 ++ .../unit/c/test-string-quantitys_decimate_by.h | 27 + .../unit/c/test-string-quantitys_decrease_by.c | 50 ++ .../unit/c/test-string-quantitys_decrease_by.h | 27 + .../tests/unit/c/test-string-quantitys_increase.c | 76 ++ .../tests/unit/c/test-string-quantitys_increase.h | 34 + .../unit/c/test-string-quantitys_increase_by.c | 52 ++ .../unit/c/test-string-quantitys_increase_by.h | 27 + .../tests/unit/c/test-string-quantitys_resize.c | 42 + .../tests/unit/c/test-string-quantitys_resize.h | 27 + .../tests/unit/c/test-string-quantityss_adjust.c | 42 + .../tests/unit/c/test-string-quantityss_adjust.h | 27 + .../tests/unit/c/test-string-quantityss_append.c | 76 ++ .../tests/unit/c/test-string-quantityss_append.h | 34 + .../unit/c/test-string-quantityss_append_all.c | 93 +++ .../unit/c/test-string-quantityss_append_all.h | 34 + .../unit/c/test-string-quantityss_decimate_by.c | 50 ++ .../unit/c/test-string-quantityss_decimate_by.h | 27 + .../unit/c/test-string-quantityss_decrease_by.c | 50 ++ .../unit/c/test-string-quantityss_decrease_by.h | 27 + .../tests/unit/c/test-string-quantityss_increase.c | 76 ++ .../tests/unit/c/test-string-quantityss_increase.h | 34 + .../unit/c/test-string-quantityss_increase_by.c | 52 ++ .../unit/c/test-string-quantityss_increase_by.h | 27 + .../tests/unit/c/test-string-quantityss_resize.c | 42 + .../tests/unit/c/test-string-quantityss_resize.h | 27 + .../tests/unit/c/test-string-ranges_adjust.c | 42 + .../tests/unit/c/test-string-ranges_adjust.h | 27 + .../tests/unit/c/test-string-ranges_append.c | 39 + .../tests/unit/c/test-string-ranges_append.h | 27 + .../tests/unit/c/test-string-ranges_append_all.c | 76 ++ .../tests/unit/c/test-string-ranges_append_all.h | 34 + .../tests/unit/c/test-string-ranges_decimate_by.c | 50 ++ .../tests/unit/c/test-string-ranges_decimate_by.h | 27 + .../tests/unit/c/test-string-ranges_decrease_by.c | 50 ++ .../tests/unit/c/test-string-ranges_decrease_by.h | 27 + .../tests/unit/c/test-string-ranges_increase.c | 76 ++ .../tests/unit/c/test-string-ranges_increase.h | 34 + .../tests/unit/c/test-string-ranges_increase_by.c | 52 ++ .../tests/unit/c/test-string-ranges_increase_by.h | 27 + .../tests/unit/c/test-string-ranges_resize.c | 42 + .../tests/unit/c/test-string-ranges_resize.h | 27 + .../tests/unit/c/test-string-rangess_adjust.c | 42 + .../tests/unit/c/test-string-rangess_adjust.h | 27 + .../tests/unit/c/test-string-rangess_append.c | 76 ++ .../tests/unit/c/test-string-rangess_append.h | 34 + .../tests/unit/c/test-string-rangess_append_all.c | 93 +++ .../tests/unit/c/test-string-rangess_append_all.h | 34 + .../tests/unit/c/test-string-rangess_decimate_by.c | 50 ++ .../tests/unit/c/test-string-rangess_decimate_by.h | 27 + .../tests/unit/c/test-string-rangess_decrease_by.c | 50 ++ .../tests/unit/c/test-string-rangess_decrease_by.h | 27 + .../tests/unit/c/test-string-rangess_increase.c | 76 ++ .../tests/unit/c/test-string-rangess_increase.h | 34 + .../tests/unit/c/test-string-rangess_increase_by.c | 52 ++ .../tests/unit/c/test-string-rangess_increase_by.h | 27 + .../tests/unit/c/test-string-rangess_resize.c | 42 + .../tests/unit/c/test-string-rangess_resize.h | 27 + .../tests/unit/c/test-string-triples_adjust.c | 42 + .../tests/unit/c/test-string-triples_adjust.h | 27 + .../tests/unit/c/test-string-triples_append.c | 50 ++ .../tests/unit/c/test-string-triples_append.h | 27 + .../tests/unit/c/test-string-triples_append_all.c | 96 +++ .../tests/unit/c/test-string-triples_append_all.h | 34 + .../tests/unit/c/test-string-triples_decimate_by.c | 50 ++ .../tests/unit/c/test-string-triples_decimate_by.h | 27 + .../tests/unit/c/test-string-triples_decrease_by.c | 50 ++ .../tests/unit/c/test-string-triples_decrease_by.h | 27 + .../tests/unit/c/test-string-triples_increase.c | 76 ++ .../tests/unit/c/test-string-triples_increase.h | 34 + .../tests/unit/c/test-string-triples_increase_by.c | 52 ++ .../tests/unit/c/test-string-triples_increase_by.h | 27 + .../tests/unit/c/test-string-triples_resize.c | 42 + .../tests/unit/c/test-string-triples_resize.h | 27 + .../tests/unit/c/test-string-tripless_adjust.c | 42 + .../tests/unit/c/test-string-tripless_adjust.h | 27 + .../tests/unit/c/test-string-tripless_append.c | 96 +++ .../tests/unit/c/test-string-tripless_append.h | 34 + .../tests/unit/c/test-string-tripless_append_all.c | 122 +++ .../tests/unit/c/test-string-tripless_append_all.h | 34 + .../unit/c/test-string-tripless_decimate_by.c | 50 ++ .../unit/c/test-string-tripless_decimate_by.h | 27 + .../unit/c/test-string-tripless_decrease_by.c | 50 ++ .../unit/c/test-string-tripless_decrease_by.h | 27 + .../tests/unit/c/test-string-tripless_increase.c | 76 ++ .../tests/unit/c/test-string-tripless_increase.h | 34 + .../unit/c/test-string-tripless_increase_by.c | 52 ++ .../unit/c/test-string-tripless_increase_by.h | 27 + .../tests/unit/c/test-string-tripless_resize.c | 42 + .../tests/unit/c/test-string-tripless_resize.h | 27 + level_0/f_string/tests/unit/c/test-string.c | 276 +++++++ level_0/f_string/tests/unit/c/test-string.h | 167 ++++ level_0/f_thread/c/private-thread.c | 275 +++---- level_0/f_type/c/type.h | 36 +- level_0/f_type_array/c/type_array.h | 5 + level_0/f_type_array/c/type_array/array_length.c | 60 +- level_0/f_type_array/c/type_array/array_length.h | 52 +- level_0/f_type_array/c/type_array/cell.c | 53 +- level_0/f_type_array/c/type_array/cell.h | 52 +- level_0/f_type_array/c/type_array/fll_id.c | 53 +- level_0/f_type_array/c/type_array/fll_id.h | 54 +- level_0/f_type_array/c/type_array/int128.c | 293 ++----- level_0/f_type_array/c/type_array/int128.h | 386 +-------- level_0/f_type_array/c/type_array/int16.c | 293 ++----- level_0/f_type_array/c/type_array/int16.h | 386 +-------- level_0/f_type_array/c/type_array/int32.c | 293 ++----- level_0/f_type_array/c/type_array/int32.h | 386 +-------- level_0/f_type_array/c/type_array/int64.c | 293 ++----- level_0/f_type_array/c/type_array/int64.h | 388 +-------- level_0/f_type_array/c/type_array/int8.c | 293 ++----- level_0/f_type_array/c/type_array/int8.h | 388 +-------- .../c/type_array/private-array_length.c | 68 +- .../c/type_array/private-array_length.h | 29 +- level_0/f_type_array/c/type_array/private-cell.c | 71 +- level_0/f_type_array/c/type_array/private-cell.h | 31 +- level_0/f_type_array/c/type_array/private-fll_id.c | 75 +- level_0/f_type_array/c/type_array/private-fll_id.h | 31 +- level_0/f_type_array/c/type_array/private-int128.c | 180 +--- level_0/f_type_array/c/type_array/private-int128.h | 159 +--- level_0/f_type_array/c/type_array/private-int16.c | 176 +--- level_0/f_type_array/c/type_array/private-int16.h | 159 +--- level_0/f_type_array/c/type_array/private-int32.c | 176 +--- level_0/f_type_array/c/type_array/private-int32.h | 159 +--- level_0/f_type_array/c/type_array/private-int64.c | 176 +--- level_0/f_type_array/c/type_array/private-int64.h | 159 +--- level_0/f_type_array/c/type_array/private-int8.c | 176 +--- level_0/f_type_array/c/type_array/private-int8.h | 159 +--- level_0/f_type_array/c/type_array/private-state.c | 85 +- level_0/f_type_array/c/type_array/private-state.h | 31 +- level_0/f_type_array/c/type_array/private-status.c | 68 +- level_0/f_type_array/c/type_array/private-status.h | 31 +- .../f_type_array/c/type_array/private-uint128.c | 126 +++ .../f_type_array/c/type_array/private-uint128.h | 175 ++++ level_0/f_type_array/c/type_array/private-uint16.c | 126 +++ level_0/f_type_array/c/type_array/private-uint16.h | 175 ++++ level_0/f_type_array/c/type_array/private-uint32.c | 126 +++ level_0/f_type_array/c/type_array/private-uint32.h | 175 ++++ level_0/f_type_array/c/type_array/private-uint64.c | 126 +++ level_0/f_type_array/c/type_array/private-uint64.h | 175 ++++ level_0/f_type_array/c/type_array/private-uint8.c | 126 +++ level_0/f_type_array/c/type_array/private-uint8.h | 175 ++++ level_0/f_type_array/c/type_array/state.c | 53 +- level_0/f_type_array/c/type_array/state.h | 52 +- level_0/f_type_array/c/type_array/status.c | 53 +- level_0/f_type_array/c/type_array/status.h | 52 +- level_0/f_type_array/c/type_array/uint128.c | 290 +++++++ level_0/f_type_array/c/type_array/uint128.h | 377 +++++++++ level_0/f_type_array/c/type_array/uint16.c | 290 +++++++ level_0/f_type_array/c/type_array/uint16.h | 377 +++++++++ level_0/f_type_array/c/type_array/uint32.c | 290 +++++++ level_0/f_type_array/c/type_array/uint32.h | 377 +++++++++ level_0/f_type_array/c/type_array/uint64.c | 290 +++++++ level_0/f_type_array/c/type_array/uint64.h | 379 +++++++++ level_0/f_type_array/c/type_array/uint8.c | 290 +++++++ level_0/f_type_array/c/type_array/uint8.h | 379 +++++++++ level_0/f_type_array/data/build/settings | 6 +- level_0/f_type_array/data/build/settings-tests | 60 +- .../unit/c/test-type_array-array_lengths_adjust.c | 2 +- .../unit/c/test-type_array-array_lengths_adjust.h | 2 +- .../unit/c/test-type_array-array_lengths_append.c | 60 +- .../unit/c/test-type_array-array_lengths_append.h | 9 +- .../c/test-type_array-array_lengths_append_all.c | 82 ++ .../c/test-type_array-array_lengths_append_all.h | 34 + .../c/test-type_array-array_lengths_decimate_by.c | 2 +- .../c/test-type_array-array_lengths_decimate_by.h | 2 +- .../c/test-type_array-array_lengths_decrease_by.c | 2 +- .../c/test-type_array-array_lengths_decrease_by.h | 2 +- .../c/test-type_array-array_lengths_increase.c | 4 +- .../c/test-type_array-array_lengths_increase.h | 2 +- .../c/test-type_array-array_lengths_increase_by.c | 2 +- .../c/test-type_array-array_lengths_increase_by.h | 2 +- .../unit/c/test-type_array-array_lengths_resize.c | 2 +- .../unit/c/test-type_array-array_lengths_resize.h | 2 +- .../unit/c/test-type_array-array_lengthss_adjust.c | 2 +- .../unit/c/test-type_array-array_lengthss_adjust.h | 2 +- .../unit/c/test-type_array-array_lengthss_append.c | 57 +- .../unit/c/test-type_array-array_lengthss_append.h | 2 +- .../c/test-type_array-array_lengthss_append_all.c | 105 +++ .../c/test-type_array-array_lengthss_append_all.h | 34 + .../c/test-type_array-array_lengthss_decimate_by.c | 2 +- .../c/test-type_array-array_lengthss_decimate_by.h | 2 +- .../c/test-type_array-array_lengthss_decrease_by.c | 2 +- .../c/test-type_array-array_lengthss_decrease_by.h | 2 +- .../c/test-type_array-array_lengthss_increase.c | 4 +- .../c/test-type_array-array_lengthss_increase.h | 2 +- .../c/test-type_array-array_lengthss_increase_by.c | 2 +- .../c/test-type_array-array_lengthss_increase_by.h | 2 +- .../unit/c/test-type_array-array_lengthss_resize.c | 2 +- .../unit/c/test-type_array-array_lengthss_resize.h | 2 +- .../tests/unit/c/test-type_array-cells_adjust.c | 2 +- .../tests/unit/c/test-type_array-cells_adjust.h | 2 +- .../tests/unit/c/test-type_array-cells_append.c | 64 +- .../tests/unit/c/test-type_array-cells_append.h | 9 +- .../unit/c/test-type_array-cells_append_all.c | 85 ++ .../unit/c/test-type_array-cells_append_all.h | 34 + .../unit/c/test-type_array-cells_decimate_by.c | 2 +- .../unit/c/test-type_array-cells_decimate_by.h | 2 +- .../unit/c/test-type_array-cells_decrease_by.c | 2 +- .../unit/c/test-type_array-cells_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-cells_increase.c | 4 +- .../tests/unit/c/test-type_array-cells_increase.h | 2 +- .../unit/c/test-type_array-cells_increase_by.c | 2 +- .../unit/c/test-type_array-cells_increase_by.h | 2 +- .../tests/unit/c/test-type_array-cells_resize.c | 2 +- .../tests/unit/c/test-type_array-cells_resize.h | 2 +- .../tests/unit/c/test-type_array-cellss_adjust.c | 2 +- .../tests/unit/c/test-type_array-cellss_adjust.h | 2 +- .../tests/unit/c/test-type_array-cellss_append.c | 62 +- .../tests/unit/c/test-type_array-cellss_append.h | 2 +- .../unit/c/test-type_array-cellss_append_all.c | 109 +++ .../unit/c/test-type_array-cellss_append_all.h | 34 + .../unit/c/test-type_array-cellss_decimate_by.c | 2 +- .../unit/c/test-type_array-cellss_decimate_by.h | 2 +- .../unit/c/test-type_array-cellss_decrease_by.c | 2 +- .../unit/c/test-type_array-cellss_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-cellss_increase.c | 4 +- .../tests/unit/c/test-type_array-cellss_increase.h | 2 +- .../unit/c/test-type_array-cellss_increase_by.c | 2 +- .../unit/c/test-type_array-cellss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-cellss_resize.c | 2 +- .../tests/unit/c/test-type_array-cellss_resize.h | 2 +- .../tests/unit/c/test-type_array-fll_ids_adjust.c | 2 +- .../tests/unit/c/test-type_array-fll_ids_adjust.h | 2 +- .../tests/unit/c/test-type_array-fll_ids_append.c | 66 +- .../tests/unit/c/test-type_array-fll_ids_append.h | 9 +- .../unit/c/test-type_array-fll_ids_append_all.c | 87 ++ .../unit/c/test-type_array-fll_ids_append_all.h | 34 + .../unit/c/test-type_array-fll_ids_decimate_by.c | 2 +- .../unit/c/test-type_array-fll_ids_decimate_by.h | 2 +- .../unit/c/test-type_array-fll_ids_decrease_by.c | 2 +- .../unit/c/test-type_array-fll_ids_decrease_by.h | 2 +- .../unit/c/test-type_array-fll_ids_increase.c | 4 +- .../unit/c/test-type_array-fll_ids_increase.h | 2 +- .../unit/c/test-type_array-fll_ids_increase_by.c | 2 +- .../unit/c/test-type_array-fll_ids_increase_by.h | 2 +- .../tests/unit/c/test-type_array-fll_ids_resize.c | 2 +- .../tests/unit/c/test-type_array-fll_ids_resize.h | 2 +- .../tests/unit/c/test-type_array-fll_idss_adjust.c | 2 +- .../tests/unit/c/test-type_array-fll_idss_adjust.h | 2 +- .../tests/unit/c/test-type_array-fll_idss_append.c | 65 +- .../tests/unit/c/test-type_array-fll_idss_append.h | 2 +- .../unit/c/test-type_array-fll_idss_append_all.c | 111 +++ .../unit/c/test-type_array-fll_idss_append_all.h | 34 + .../unit/c/test-type_array-fll_idss_decimate_by.c | 2 +- .../unit/c/test-type_array-fll_idss_decimate_by.h | 2 +- .../unit/c/test-type_array-fll_idss_decrease_by.c | 2 +- .../unit/c/test-type_array-fll_idss_decrease_by.h | 2 +- .../unit/c/test-type_array-fll_idss_increase.c | 4 +- .../unit/c/test-type_array-fll_idss_increase.h | 2 +- .../unit/c/test-type_array-fll_idss_increase_by.c | 2 +- .../unit/c/test-type_array-fll_idss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-fll_idss_resize.c | 2 +- .../tests/unit/c/test-type_array-fll_idss_resize.h | 2 +- .../tests/unit/c/test-type_array-int128s_adjust.c | 2 +- .../tests/unit/c/test-type_array-int128s_adjust.h | 2 +- .../tests/unit/c/test-type_array-int128s_append.c | 60 +- .../tests/unit/c/test-type_array-int128s_append.h | 9 +- .../unit/c/test-type_array-int128s_append_all.c | 82 ++ .../unit/c/test-type_array-int128s_append_all.h | 34 + .../unit/c/test-type_array-int128s_decimate_by.c | 2 +- .../unit/c/test-type_array-int128s_decimate_by.h | 2 +- .../unit/c/test-type_array-int128s_decrease_by.c | 2 +- .../unit/c/test-type_array-int128s_decrease_by.h | 2 +- .../unit/c/test-type_array-int128s_increase.c | 4 +- .../unit/c/test-type_array-int128s_increase.h | 2 +- .../unit/c/test-type_array-int128s_increase_by.c | 2 +- .../unit/c/test-type_array-int128s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int128s_resize.c | 2 +- .../tests/unit/c/test-type_array-int128s_resize.h | 2 +- .../tests/unit/c/test-type_array-int128ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-int128ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-int128ss_append.c | 58 +- .../tests/unit/c/test-type_array-int128ss_append.h | 2 +- .../unit/c/test-type_array-int128ss_append_all.c | 105 +++ .../unit/c/test-type_array-int128ss_append_all.h | 34 + .../unit/c/test-type_array-int128ss_decimate_by.c | 2 +- .../unit/c/test-type_array-int128ss_decimate_by.h | 2 +- .../unit/c/test-type_array-int128ss_decrease_by.c | 2 +- .../unit/c/test-type_array-int128ss_decrease_by.h | 2 +- .../unit/c/test-type_array-int128ss_increase.c | 4 +- .../unit/c/test-type_array-int128ss_increase.h | 2 +- .../unit/c/test-type_array-int128ss_increase_by.c | 2 +- .../unit/c/test-type_array-int128ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int128ss_resize.c | 2 +- .../tests/unit/c/test-type_array-int128ss_resize.h | 2 +- .../tests/unit/c/test-type_array-int16s_adjust.c | 2 +- .../tests/unit/c/test-type_array-int16s_adjust.h | 2 +- .../tests/unit/c/test-type_array-int16s_append.c | 60 +- .../tests/unit/c/test-type_array-int16s_append.h | 9 +- .../unit/c/test-type_array-int16s_append_all.c | 82 ++ .../unit/c/test-type_array-int16s_append_all.h | 34 + .../unit/c/test-type_array-int16s_decimate_by.c | 2 +- .../unit/c/test-type_array-int16s_decimate_by.h | 2 +- .../unit/c/test-type_array-int16s_decrease_by.c | 2 +- .../unit/c/test-type_array-int16s_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-int16s_increase.c | 4 +- .../tests/unit/c/test-type_array-int16s_increase.h | 2 +- .../unit/c/test-type_array-int16s_increase_by.c | 2 +- .../unit/c/test-type_array-int16s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int16s_resize.c | 2 +- .../tests/unit/c/test-type_array-int16s_resize.h | 2 +- .../tests/unit/c/test-type_array-int16ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-int16ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-int16ss_append.c | 58 +- .../tests/unit/c/test-type_array-int16ss_append.h | 2 +- .../unit/c/test-type_array-int16ss_append_all.c | 105 +++ .../unit/c/test-type_array-int16ss_append_all.h | 34 + .../unit/c/test-type_array-int16ss_decimate_by.c | 2 +- .../unit/c/test-type_array-int16ss_decimate_by.h | 2 +- .../unit/c/test-type_array-int16ss_decrease_by.c | 2 +- .../unit/c/test-type_array-int16ss_decrease_by.h | 2 +- .../unit/c/test-type_array-int16ss_increase.c | 4 +- .../unit/c/test-type_array-int16ss_increase.h | 2 +- .../unit/c/test-type_array-int16ss_increase_by.c | 2 +- .../unit/c/test-type_array-int16ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int16ss_resize.c | 2 +- .../tests/unit/c/test-type_array-int16ss_resize.h | 2 +- .../tests/unit/c/test-type_array-int32s_adjust.c | 2 +- .../tests/unit/c/test-type_array-int32s_adjust.h | 2 +- .../tests/unit/c/test-type_array-int32s_append.c | 60 +- .../tests/unit/c/test-type_array-int32s_append.h | 9 +- .../unit/c/test-type_array-int32s_append_all.c | 82 ++ .../unit/c/test-type_array-int32s_append_all.h | 34 + .../unit/c/test-type_array-int32s_decimate_by.c | 2 +- .../unit/c/test-type_array-int32s_decimate_by.h | 2 +- .../unit/c/test-type_array-int32s_decrease_by.c | 2 +- .../unit/c/test-type_array-int32s_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-int32s_increase.c | 4 +- .../tests/unit/c/test-type_array-int32s_increase.h | 2 +- .../unit/c/test-type_array-int32s_increase_by.c | 2 +- .../unit/c/test-type_array-int32s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int32s_resize.c | 2 +- .../tests/unit/c/test-type_array-int32s_resize.h | 2 +- .../tests/unit/c/test-type_array-int32ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-int32ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-int32ss_append.c | 58 +- .../tests/unit/c/test-type_array-int32ss_append.h | 2 +- .../unit/c/test-type_array-int32ss_append_all.c | 105 +++ .../unit/c/test-type_array-int32ss_append_all.h | 34 + .../unit/c/test-type_array-int32ss_decimate_by.c | 2 +- .../unit/c/test-type_array-int32ss_decimate_by.h | 2 +- .../unit/c/test-type_array-int32ss_decrease_by.c | 2 +- .../unit/c/test-type_array-int32ss_decrease_by.h | 2 +- .../unit/c/test-type_array-int32ss_increase.c | 4 +- .../unit/c/test-type_array-int32ss_increase.h | 2 +- .../unit/c/test-type_array-int32ss_increase_by.c | 2 +- .../unit/c/test-type_array-int32ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int32ss_resize.c | 2 +- .../tests/unit/c/test-type_array-int32ss_resize.h | 2 +- .../tests/unit/c/test-type_array-int64s_adjust.c | 2 +- .../tests/unit/c/test-type_array-int64s_adjust.h | 2 +- .../tests/unit/c/test-type_array-int64s_append.c | 60 +- .../tests/unit/c/test-type_array-int64s_append.h | 9 +- .../unit/c/test-type_array-int64s_append_all.c | 82 ++ .../unit/c/test-type_array-int64s_append_all.h | 34 + .../unit/c/test-type_array-int64s_decimate_by.c | 2 +- .../unit/c/test-type_array-int64s_decimate_by.h | 2 +- .../unit/c/test-type_array-int64s_decrease_by.c | 2 +- .../unit/c/test-type_array-int64s_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-int64s_increase.c | 4 +- .../tests/unit/c/test-type_array-int64s_increase.h | 2 +- .../unit/c/test-type_array-int64s_increase_by.c | 2 +- .../unit/c/test-type_array-int64s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int64s_resize.c | 2 +- .../tests/unit/c/test-type_array-int64s_resize.h | 2 +- .../tests/unit/c/test-type_array-int64ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-int64ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-int64ss_append.c | 58 +- .../tests/unit/c/test-type_array-int64ss_append.h | 2 +- .../unit/c/test-type_array-int64ss_append_all.c | 105 +++ .../unit/c/test-type_array-int64ss_append_all.h | 34 + .../unit/c/test-type_array-int64ss_decimate_by.c | 2 +- .../unit/c/test-type_array-int64ss_decimate_by.h | 2 +- .../unit/c/test-type_array-int64ss_decrease_by.c | 2 +- .../unit/c/test-type_array-int64ss_decrease_by.h | 2 +- .../unit/c/test-type_array-int64ss_increase.c | 4 +- .../unit/c/test-type_array-int64ss_increase.h | 2 +- .../unit/c/test-type_array-int64ss_increase_by.c | 2 +- .../unit/c/test-type_array-int64ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int64ss_resize.c | 2 +- .../tests/unit/c/test-type_array-int64ss_resize.h | 2 +- .../tests/unit/c/test-type_array-int8s_adjust.c | 2 +- .../tests/unit/c/test-type_array-int8s_adjust.h | 2 +- .../tests/unit/c/test-type_array-int8s_append.c | 60 +- .../tests/unit/c/test-type_array-int8s_append.h | 9 +- .../unit/c/test-type_array-int8s_append_all.c | 82 ++ .../unit/c/test-type_array-int8s_append_all.h | 34 + .../unit/c/test-type_array-int8s_decimate_by.c | 2 +- .../unit/c/test-type_array-int8s_decimate_by.h | 2 +- .../unit/c/test-type_array-int8s_decrease_by.c | 2 +- .../unit/c/test-type_array-int8s_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-int8s_increase.c | 4 +- .../tests/unit/c/test-type_array-int8s_increase.h | 2 +- .../unit/c/test-type_array-int8s_increase_by.c | 2 +- .../unit/c/test-type_array-int8s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int8s_resize.c | 2 +- .../tests/unit/c/test-type_array-int8s_resize.h | 2 +- .../tests/unit/c/test-type_array-int8ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-int8ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-int8ss_append.c | 58 +- .../tests/unit/c/test-type_array-int8ss_append.h | 2 +- .../unit/c/test-type_array-int8ss_append_all.c | 105 +++ .../unit/c/test-type_array-int8ss_append_all.h | 34 + .../unit/c/test-type_array-int8ss_decimate_by.c | 2 +- .../unit/c/test-type_array-int8ss_decimate_by.h | 2 +- .../unit/c/test-type_array-int8ss_decrease_by.c | 2 +- .../unit/c/test-type_array-int8ss_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-int8ss_increase.c | 4 +- .../tests/unit/c/test-type_array-int8ss_increase.h | 2 +- .../unit/c/test-type_array-int8ss_increase_by.c | 2 +- .../unit/c/test-type_array-int8ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-int8ss_resize.c | 2 +- .../tests/unit/c/test-type_array-int8ss_resize.h | 2 +- .../tests/unit/c/test-type_array-states_adjust.c | 2 +- .../tests/unit/c/test-type_array-states_adjust.h | 2 +- .../tests/unit/c/test-type_array-states_append.c | 83 +- .../tests/unit/c/test-type_array-states_append.h | 9 +- .../unit/c/test-type_array-states_append_all.c | 95 +++ .../unit/c/test-type_array-states_append_all.h | 34 + .../unit/c/test-type_array-states_decimate_by.c | 2 +- .../unit/c/test-type_array-states_decimate_by.h | 2 +- .../unit/c/test-type_array-states_decrease_by.c | 2 +- .../unit/c/test-type_array-states_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-states_increase.c | 4 +- .../tests/unit/c/test-type_array-states_increase.h | 2 +- .../unit/c/test-type_array-states_increase_by.c | 2 +- .../unit/c/test-type_array-states_increase_by.h | 2 +- .../tests/unit/c/test-type_array-states_resize.c | 2 +- .../tests/unit/c/test-type_array-states_resize.h | 2 +- .../tests/unit/c/test-type_array-statess_adjust.c | 2 +- .../tests/unit/c/test-type_array-statess_adjust.h | 2 +- .../tests/unit/c/test-type_array-statess_append.c | 85 +- .../tests/unit/c/test-type_array-statess_append.h | 2 +- .../unit/c/test-type_array-statess_append_all.c | 119 +++ .../unit/c/test-type_array-statess_append_all.h | 34 + .../unit/c/test-type_array-statess_decimate_by.c | 2 +- .../unit/c/test-type_array-statess_decimate_by.h | 2 +- .../unit/c/test-type_array-statess_decrease_by.c | 2 +- .../unit/c/test-type_array-statess_decrease_by.h | 2 +- .../unit/c/test-type_array-statess_increase.c | 4 +- .../unit/c/test-type_array-statess_increase.h | 2 +- .../unit/c/test-type_array-statess_increase_by.c | 2 +- .../unit/c/test-type_array-statess_increase_by.h | 2 +- .../tests/unit/c/test-type_array-statess_resize.c | 2 +- .../tests/unit/c/test-type_array-statess_resize.h | 2 +- .../tests/unit/c/test-type_array-statuss_adjust.c | 2 +- .../tests/unit/c/test-type_array-statuss_adjust.h | 2 +- .../tests/unit/c/test-type_array-statuss_append.c | 60 +- .../tests/unit/c/test-type_array-statuss_append.h | 9 +- .../unit/c/test-type_array-statuss_append_all.c | 82 ++ .../unit/c/test-type_array-statuss_append_all.h | 34 + .../unit/c/test-type_array-statuss_decimate_by.c | 2 +- .../unit/c/test-type_array-statuss_decimate_by.h | 2 +- .../unit/c/test-type_array-statuss_decrease_by.c | 2 +- .../unit/c/test-type_array-statuss_decrease_by.h | 2 +- .../unit/c/test-type_array-statuss_increase.c | 4 +- .../unit/c/test-type_array-statuss_increase.h | 2 +- .../unit/c/test-type_array-statuss_increase_by.c | 2 +- .../unit/c/test-type_array-statuss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-statuss_resize.c | 2 +- .../tests/unit/c/test-type_array-statuss_resize.h | 2 +- .../tests/unit/c/test-type_array-statusss_adjust.c | 2 +- .../tests/unit/c/test-type_array-statusss_adjust.h | 2 +- .../tests/unit/c/test-type_array-statusss_append.c | 58 +- .../tests/unit/c/test-type_array-statusss_append.h | 2 +- .../unit/c/test-type_array-statusss_append_all.c | 105 +++ .../unit/c/test-type_array-statusss_append_all.h | 34 + .../unit/c/test-type_array-statusss_decimate_by.c | 2 +- .../unit/c/test-type_array-statusss_decimate_by.h | 2 +- .../unit/c/test-type_array-statusss_decrease_by.c | 2 +- .../unit/c/test-type_array-statusss_decrease_by.h | 2 +- .../unit/c/test-type_array-statusss_increase.c | 4 +- .../unit/c/test-type_array-statusss_increase.h | 2 +- .../unit/c/test-type_array-statusss_increase_by.c | 2 +- .../unit/c/test-type_array-statusss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-statusss_resize.c | 2 +- .../tests/unit/c/test-type_array-statusss_resize.h | 2 +- .../tests/unit/c/test-type_array-uint128s_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint128s_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint128s_append.c | 60 +- .../tests/unit/c/test-type_array-uint128s_append.h | 9 +- .../unit/c/test-type_array-uint128s_append_all.c | 82 ++ .../unit/c/test-type_array-uint128s_append_all.h | 34 + .../unit/c/test-type_array-uint128s_decimate_by.c | 2 +- .../unit/c/test-type_array-uint128s_decimate_by.h | 2 +- .../unit/c/test-type_array-uint128s_decrease_by.c | 2 +- .../unit/c/test-type_array-uint128s_decrease_by.h | 2 +- .../unit/c/test-type_array-uint128s_increase.c | 4 +- .../unit/c/test-type_array-uint128s_increase.h | 2 +- .../unit/c/test-type_array-uint128s_increase_by.c | 2 +- .../unit/c/test-type_array-uint128s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint128s_resize.c | 2 +- .../tests/unit/c/test-type_array-uint128s_resize.h | 2 +- .../unit/c/test-type_array-uint128ss_adjust.c | 2 +- .../unit/c/test-type_array-uint128ss_adjust.h | 2 +- .../unit/c/test-type_array-uint128ss_append.c | 58 +- .../unit/c/test-type_array-uint128ss_append.h | 2 +- .../unit/c/test-type_array-uint128ss_append_all.c | 105 +++ .../unit/c/test-type_array-uint128ss_append_all.h | 34 + .../unit/c/test-type_array-uint128ss_decimate_by.c | 2 +- .../unit/c/test-type_array-uint128ss_decimate_by.h | 2 +- .../unit/c/test-type_array-uint128ss_decrease_by.c | 2 +- .../unit/c/test-type_array-uint128ss_decrease_by.h | 2 +- .../unit/c/test-type_array-uint128ss_increase.c | 4 +- .../unit/c/test-type_array-uint128ss_increase.h | 2 +- .../unit/c/test-type_array-uint128ss_increase_by.c | 2 +- .../unit/c/test-type_array-uint128ss_increase_by.h | 2 +- .../unit/c/test-type_array-uint128ss_resize.c | 2 +- .../unit/c/test-type_array-uint128ss_resize.h | 2 +- .../tests/unit/c/test-type_array-uint16s_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint16s_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint16s_append.c | 60 +- .../tests/unit/c/test-type_array-uint16s_append.h | 9 +- .../unit/c/test-type_array-uint16s_append_all.c | 82 ++ .../unit/c/test-type_array-uint16s_append_all.h | 34 + .../unit/c/test-type_array-uint16s_decimate_by.c | 2 +- .../unit/c/test-type_array-uint16s_decimate_by.h | 2 +- .../unit/c/test-type_array-uint16s_decrease_by.c | 2 +- .../unit/c/test-type_array-uint16s_decrease_by.h | 2 +- .../unit/c/test-type_array-uint16s_increase.c | 4 +- .../unit/c/test-type_array-uint16s_increase.h | 2 +- .../unit/c/test-type_array-uint16s_increase_by.c | 2 +- .../unit/c/test-type_array-uint16s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint16s_resize.c | 2 +- .../tests/unit/c/test-type_array-uint16s_resize.h | 2 +- .../tests/unit/c/test-type_array-uint16ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint16ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint16ss_append.c | 58 +- .../tests/unit/c/test-type_array-uint16ss_append.h | 2 +- .../unit/c/test-type_array-uint16ss_append_all.c | 105 +++ .../unit/c/test-type_array-uint16ss_append_all.h | 34 + .../unit/c/test-type_array-uint16ss_decimate_by.c | 2 +- .../unit/c/test-type_array-uint16ss_decimate_by.h | 2 +- .../unit/c/test-type_array-uint16ss_decrease_by.c | 2 +- .../unit/c/test-type_array-uint16ss_decrease_by.h | 2 +- .../unit/c/test-type_array-uint16ss_increase.c | 4 +- .../unit/c/test-type_array-uint16ss_increase.h | 2 +- .../unit/c/test-type_array-uint16ss_increase_by.c | 2 +- .../unit/c/test-type_array-uint16ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint16ss_resize.c | 2 +- .../tests/unit/c/test-type_array-uint16ss_resize.h | 2 +- .../tests/unit/c/test-type_array-uint32s_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint32s_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint32s_append.c | 60 +- .../tests/unit/c/test-type_array-uint32s_append.h | 9 +- .../unit/c/test-type_array-uint32s_append_all.c | 82 ++ .../unit/c/test-type_array-uint32s_append_all.h | 34 + .../unit/c/test-type_array-uint32s_decimate_by.c | 2 +- .../unit/c/test-type_array-uint32s_decimate_by.h | 2 +- .../unit/c/test-type_array-uint32s_decrease_by.c | 2 +- .../unit/c/test-type_array-uint32s_decrease_by.h | 2 +- .../unit/c/test-type_array-uint32s_increase.c | 4 +- .../unit/c/test-type_array-uint32s_increase.h | 2 +- .../unit/c/test-type_array-uint32s_increase_by.c | 2 +- .../unit/c/test-type_array-uint32s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint32s_resize.c | 2 +- .../tests/unit/c/test-type_array-uint32s_resize.h | 2 +- .../tests/unit/c/test-type_array-uint32ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint32ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint32ss_append.c | 58 +- .../tests/unit/c/test-type_array-uint32ss_append.h | 2 +- .../unit/c/test-type_array-uint32ss_append_all.c | 105 +++ .../unit/c/test-type_array-uint32ss_append_all.h | 34 + .../unit/c/test-type_array-uint32ss_decimate_by.c | 2 +- .../unit/c/test-type_array-uint32ss_decimate_by.h | 2 +- .../unit/c/test-type_array-uint32ss_decrease_by.c | 2 +- .../unit/c/test-type_array-uint32ss_decrease_by.h | 2 +- .../unit/c/test-type_array-uint32ss_increase.c | 4 +- .../unit/c/test-type_array-uint32ss_increase.h | 2 +- .../unit/c/test-type_array-uint32ss_increase_by.c | 2 +- .../unit/c/test-type_array-uint32ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint32ss_resize.c | 2 +- .../tests/unit/c/test-type_array-uint32ss_resize.h | 2 +- .../tests/unit/c/test-type_array-uint64s_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint64s_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint64s_append.c | 60 +- .../tests/unit/c/test-type_array-uint64s_append.h | 9 +- .../unit/c/test-type_array-uint64s_append_all.c | 82 ++ .../unit/c/test-type_array-uint64s_append_all.h | 34 + .../unit/c/test-type_array-uint64s_decimate_by.c | 2 +- .../unit/c/test-type_array-uint64s_decimate_by.h | 2 +- .../unit/c/test-type_array-uint64s_decrease_by.c | 2 +- .../unit/c/test-type_array-uint64s_decrease_by.h | 2 +- .../unit/c/test-type_array-uint64s_increase.c | 4 +- .../unit/c/test-type_array-uint64s_increase.h | 2 +- .../unit/c/test-type_array-uint64s_increase_by.c | 2 +- .../unit/c/test-type_array-uint64s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint64s_resize.c | 2 +- .../tests/unit/c/test-type_array-uint64s_resize.h | 2 +- .../tests/unit/c/test-type_array-uint64ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint64ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint64ss_append.c | 58 +- .../tests/unit/c/test-type_array-uint64ss_append.h | 2 +- .../unit/c/test-type_array-uint64ss_append_all.c | 105 +++ .../unit/c/test-type_array-uint64ss_append_all.h | 34 + .../unit/c/test-type_array-uint64ss_decimate_by.c | 2 +- .../unit/c/test-type_array-uint64ss_decimate_by.h | 2 +- .../unit/c/test-type_array-uint64ss_decrease_by.c | 2 +- .../unit/c/test-type_array-uint64ss_decrease_by.h | 2 +- .../unit/c/test-type_array-uint64ss_increase.c | 4 +- .../unit/c/test-type_array-uint64ss_increase.h | 2 +- .../unit/c/test-type_array-uint64ss_increase_by.c | 2 +- .../unit/c/test-type_array-uint64ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint64ss_resize.c | 2 +- .../tests/unit/c/test-type_array-uint64ss_resize.h | 2 +- .../tests/unit/c/test-type_array-uint8s_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint8s_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint8s_append.c | 60 +- .../tests/unit/c/test-type_array-uint8s_append.h | 9 +- .../unit/c/test-type_array-uint8s_append_all.c | 82 ++ .../unit/c/test-type_array-uint8s_append_all.h | 34 + .../unit/c/test-type_array-uint8s_decimate_by.c | 2 +- .../unit/c/test-type_array-uint8s_decimate_by.h | 2 +- .../unit/c/test-type_array-uint8s_decrease_by.c | 2 +- .../unit/c/test-type_array-uint8s_decrease_by.h | 2 +- .../tests/unit/c/test-type_array-uint8s_increase.c | 4 +- .../tests/unit/c/test-type_array-uint8s_increase.h | 2 +- .../unit/c/test-type_array-uint8s_increase_by.c | 2 +- .../unit/c/test-type_array-uint8s_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint8s_resize.c | 2 +- .../tests/unit/c/test-type_array-uint8s_resize.h | 2 +- .../tests/unit/c/test-type_array-uint8ss_adjust.c | 2 +- .../tests/unit/c/test-type_array-uint8ss_adjust.h | 2 +- .../tests/unit/c/test-type_array-uint8ss_append.c | 58 +- .../tests/unit/c/test-type_array-uint8ss_append.h | 2 +- .../unit/c/test-type_array-uint8ss_append_all.c | 105 +++ .../unit/c/test-type_array-uint8ss_append_all.h | 34 + .../unit/c/test-type_array-uint8ss_decimate_by.c | 2 +- .../unit/c/test-type_array-uint8ss_decimate_by.h | 2 +- .../unit/c/test-type_array-uint8ss_decrease_by.c | 2 +- .../unit/c/test-type_array-uint8ss_decrease_by.h | 2 +- .../unit/c/test-type_array-uint8ss_increase.c | 4 +- .../unit/c/test-type_array-uint8ss_increase.h | 2 +- .../unit/c/test-type_array-uint8ss_increase_by.c | 2 +- .../unit/c/test-type_array-uint8ss_increase_by.h | 2 +- .../tests/unit/c/test-type_array-uint8ss_resize.c | 2 +- .../tests/unit/c/test-type_array-uint8ss_resize.h | 2 +- .../f_type_array/tests/unit/c/test-type_array.c | 557 ++++++++----- .../f_type_array/tests/unit/c/test-type_array.h | 30 + level_0/f_utf/c/utf/private-string.c | 113 ++- level_1/fl_fss/c/private-fss.c | 4 +- level_2/fll_fss/c/fss/basic.c | 2 +- level_2/fll_fss/c/fss/basic_list.c | 2 +- level_2/fll_fss/c/fss/embedded_list.c | 2 +- level_2/fll_fss/c/fss/extended.c | 2 +- level_2/fll_fss/c/fss/extended_list.c | 2 +- level_2/fll_fss/c/fss/payload.c | 2 +- level_2/fll_iki/c/iki.c | 4 +- level_3/control/c/private-control.c | 2 +- level_3/controller/c/common/private-process.c | 30 +- level_3/controller/c/common/private-rule.c | 22 +- level_3/controller/c/common/private-task.c | 11 +- .../controller/c/controller/private-controller.c | 6 +- level_3/controller/c/entry/private-entry.c | 2 +- level_3/controller/c/rule/private-rule.c | 27 +- level_3/controller/c/rule/private-rule.h | 10 +- level_3/fake/c/private-build-load.c | 2 +- level_3/fake/c/private-make-load_fakefile.c | 2 +- level_3/fake/c/private-make-operate.c | 6 +- level_3/fake/c/private-make.c | 2 +- level_3/firewall/c/private-firewall.c | 4 +- .../fss_basic_list_read/c/fss_basic_list_read.c | 2 +- level_3/fss_basic_list_read/c/private-common.c | 11 +- level_3/fss_basic_list_read/c/private-read.c | 2 +- .../fss_basic_list_write/c/fss_basic_list_write.c | 2 +- level_3/fss_basic_read/c/fss_basic_read.c | 2 +- level_3/fss_basic_read/c/private-common.c | 11 +- level_3/fss_basic_read/c/private-read.c | 2 +- level_3/fss_basic_write/c/fss_basic_write.c | 2 +- .../c/fss_embedded_list_read.c | 2 +- level_3/fss_embedded_list_read/c/private-read.c | 2 +- .../c/fss_embedded_list_write.c | 2 +- .../c/fss_extended_list_read.c | 2 +- level_3/fss_extended_list_read/c/private-common.c | 11 +- level_3/fss_extended_list_read/c/private-read.c | 2 +- .../c/fss_extended_list_write.c | 2 +- level_3/fss_extended_read/c/fss_extended_read.c | 2 +- level_3/fss_extended_read/c/private-common.c | 11 +- level_3/fss_extended_read/c/private-read.c | 2 +- level_3/fss_extended_write/c/fss_extended_write.c | 2 +- level_3/fss_identify/c/fss_identify.c | 2 +- level_3/fss_identify/c/private-identify.c | 2 +- level_3/fss_payload_read/c/fss_payload_read.c | 2 +- level_3/fss_payload_read/c/private-common.c | 11 +- level_3/fss_payload_read/c/private-read.c | 2 +- level_3/fss_payload_write/c/fss_payload_write.c | 2 +- level_3/iki_read/c/private-print.c | 2 +- level_3/iki_read/c/private-read.c | 10 +- 877 files changed, 27861 insertions(+), 10577 deletions(-) create mode 100644 level_0/f_iki/c/iki/data.c create mode 100644 level_0/f_iki/c/iki/data.h create mode 100644 level_0/f_iki/c/iki/private-data.c create mode 100644 level_0/f_iki/c/iki/private-data.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_adjust.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_adjust.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_append.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_append.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_append_all.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_append_all.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_decimate_by.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_decimate_by.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_decrease_by.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_decrease_by.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_increase.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_increase.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_increase_by.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_increase_by.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_resize.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datas_resize.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_adjust.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_adjust.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_append.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_append.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_append_all.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_append_all.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_decimate_by.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_decimate_by.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_decrease_by.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_decrease_by.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_increase.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_increase.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_increase_by.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_increase_by.h create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_resize.c create mode 100644 level_0/f_iki/tests/unit/c/test-iki-datass_resize.h create mode 100644 level_0/f_string/c/string/map_multi.c create mode 100644 level_0/f_string/c/string/map_multi.h create mode 100644 level_0/f_string/c/string/private-dynamic.c create mode 100644 level_0/f_string/c/string/private-dynamic.h create mode 100644 level_0/f_string/c/string/private-map.c create mode 100644 level_0/f_string/c/string/private-map.h create mode 100644 level_0/f_string/c/string/private-map_multi.c create mode 100644 level_0/f_string/c/string/private-map_multi.h create mode 100644 level_0/f_string/c/string/private-quantity.c create mode 100644 level_0/f_string/c/string/private-quantity.h create mode 100644 level_0/f_string/c/string/private-range.c create mode 100644 level_0/f_string/c/string/private-range.h create mode 100644 level_0/f_string/c/string/private-triple.c create mode 100644 level_0/f_string/c/string/private-triple.h create mode 100644 level_0/f_string/data/build/settings-tests create mode 100644 level_0/f_string/data/build/testfile create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_adjust.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_adjust.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_append.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_append.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_append_all.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_append_all.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_increase.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_increase.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_increase_by.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_increase_by.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_resize.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_resize.h create mode 100644 level_0/f_string/tests/unit/c/test-string.c create mode 100644 level_0/f_string/tests/unit/c/test-string.h create mode 100644 level_0/f_type_array/c/type_array/private-uint128.c create mode 100644 level_0/f_type_array/c/type_array/private-uint128.h create mode 100644 level_0/f_type_array/c/type_array/private-uint16.c create mode 100644 level_0/f_type_array/c/type_array/private-uint16.h create mode 100644 level_0/f_type_array/c/type_array/private-uint32.c create mode 100644 level_0/f_type_array/c/type_array/private-uint32.h create mode 100644 level_0/f_type_array/c/type_array/private-uint64.c create mode 100644 level_0/f_type_array/c/type_array/private-uint64.h create mode 100644 level_0/f_type_array/c/type_array/private-uint8.c create mode 100644 level_0/f_type_array/c/type_array/private-uint8.h create mode 100644 level_0/f_type_array/c/type_array/uint128.c create mode 100644 level_0/f_type_array/c/type_array/uint128.h create mode 100644 level_0/f_type_array/c/type_array/uint16.c create mode 100644 level_0/f_type_array/c/type_array/uint16.h create mode 100644 level_0/f_type_array/c/type_array/uint32.c create mode 100644 level_0/f_type_array/c/type_array/uint32.h create mode 100644 level_0/f_type_array/c/type_array/uint64.c create mode 100644 level_0/f_type_array/c/type_array/uint64.h create mode 100644 level_0/f_type_array/c/type_array/uint8.c create mode 100644 level_0/f_type_array/c/type_array/uint8.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-array_lengths_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-array_lengthss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-cells_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-cells_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-cellss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-cellss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-fll_ids_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-fll_idss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int128s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int128s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int128ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int16s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int16s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int16ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int32s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int32s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int32ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int64s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int64s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int64ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int8s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int8s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-int8ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-states_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-states_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-statess_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-statess_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-statuss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-statuss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-statusss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-statusss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint128s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint128ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint16s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint16ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint32s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint32ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint64s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint64ss_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint8s_append_all.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append_all.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-uint8ss_append_all.h diff --git a/build/level_0/settings b/build/level_0/settings index fedeaef..bf18cfc 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 eb6c0fa..6984a24 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 1b55f67..d947009 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 f738f58..629e8dd 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 399a4af..bd258cb 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 6fc61a7..c3be49f 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 91a3442..ee9d09a 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 5c952fa..66ed67e 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 fd79afb..ded0ee5 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 6fc4869..566a314 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 c0e25ae..38a56ac 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 0000000..d25f6d3 --- /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 0000000..5fd8d56 --- /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 0000000..9be4bc3 --- /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 0000000..bac0cb7 --- /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 dba7008..d972285 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 6fed860..bed8a0a 100644 --- a/level_0/f_iki/c/private-iki.h +++ b/level_0/f_iki/c/private-iki.h @@ -16,6 +16,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. * * Intended to be shared to each of the different implementation variations. @@ -42,6 +70,30 @@ extern "C" { #endif // !defined(_di_f_iki_datas_adjust_) || !defined(_di_f_iki_datas_decimate_by_) /** + * Private implementation for appending the iki_data array. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source iki_datas to append. + * @param destination + * The destination lengths the source is appended onto. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_iki_datas_append_all() + * @see f_iki_datass_append() + * @see f_iki_datass_append_all() + */ +#if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_) + extern f_status_t private_f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_) + +/** * Private implementation for resizing the iki_datas array. * * Intended to be shared to each of the different implementation variations. @@ -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 f185d97..74a91ce 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 4a1264a..e015d53 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 96ba579..5e135bd 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 0000000..e528630 --- /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 0000000..69d3c54 --- /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 0000000..f81780f --- /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 0000000..1467f37 --- /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 0000000..e01ec3c --- /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 0000000..35c22e3 --- /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 0000000..d0dbd0e --- /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 0000000..8206822 --- /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 0000000..3bd1865 --- /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 0000000..fe33755 --- /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 0000000..16fe997 --- /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 0000000..289e2ba --- /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 0000000..ba53394 --- /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 0000000..2c8ddb9 --- /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 0000000..e647f00 --- /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 0000000..915f835 --- /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 0000000..d6f562d --- /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 0000000..304ea41 --- /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 0000000..e69b5e0 --- /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 0000000..924d4a2 --- /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 0000000..9351919 --- /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 0000000..688b573 --- /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 0000000..8866b8a --- /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 0000000..7642275 --- /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 0000000..dea8c3f --- /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 0000000..c022ce7 --- /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 0000000..a2e3912 --- /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 0000000..43b7f66 --- /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 0000000..24e07c4 --- /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 0000000..f77e196 --- /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 0000000..852ef54 --- /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 0000000..9ee0a01 --- /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 562d548..63a39c6 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 a96c4c2..163c262 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 633c380..8e46be3 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 c1bc15e..4e5c148 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 a4cea45..7a3aef3 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 10710c3..8636c97 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 c76fce0..8217b5f 100644 --- a/level_0/f_string/c/private-string.h +++ b/level_0/f_string/c/private-string.h @@ -88,602 +88,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_) /** - * 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(). * * Intended to be shared to each of the different implementation variations. @@ -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 8a853ec..19746fa 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 fc1cee0..c462b0e 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 126bfa3..be5e8aa 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,10 +1037,31 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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,10 +1215,31 @@ 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. * * This will resize making the array smaller based on (size - given length). diff --git a/level_0/f_string/c/string/map.c b/level_0/f_string/c/string/map.c index 7bcfb7d..a3ea797 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 c54d47d..2f7e391 100644 --- a/level_0/f_string/c/string/map.h +++ b/level_0/f_string/c/string/map.h @@ -114,279 +114,6 @@ extern "C" { #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. * * @param length 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 0000000..27faa0c --- /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 0000000..afcb054 --- /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 0000000..b452066 --- /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 0000000..582dd3a --- /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 0000000..da7a9b1 --- /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 0000000..e5de81d --- /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 0000000..b7f9604 --- /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 0000000..da722db --- /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 0000000..9056663 --- /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 0000000..0699786 --- /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 0000000..2091fa3 --- /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 0000000..6449c3b --- /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 0000000..3f46a3e --- /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 0000000..a8b2878 --- /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 a192300..7a6c12d 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 f3603e7..fc1b925 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,10 +147,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -284,6 +304,46 @@ extern "C" { #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. * * This will resize making the array smaller based on (size - given length). diff --git a/level_0/f_string/c/string/range.c b/level_0/f_string/c/string/range.c index 8daf267..b1caca5 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 44db0ce..b241e81 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,10 +145,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -285,6 +305,46 @@ extern "C" { #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. * * This will resize making the array smaller based on (size - given length). diff --git a/level_0/f_string/c/string/triple.c b/level_0/f_string/c/string/triple.c index d2ba928..76aba19 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 dea8f04..442e05b 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,10 +160,31 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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,10 +337,31 @@ 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. * * This will resize making the array smaller based on (size - given length). diff --git a/level_0/f_string/data/build/settings b/level_0/f_string/data/build/settings index 2329764..bb29b47 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 0000000..db3478f --- /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 0000000..263cfb4 --- /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 0000000..bababe1 --- /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 0000000..0ec0a1b --- /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 0000000..8f05603 --- /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 0000000..aa9476f --- /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 0000000..6f75af5 --- /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 0000000..bdc6e26 --- /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 0000000..65f5200 --- /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 0000000..4bb4859 --- /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 0000000..3103997 --- /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 0000000..ac932c5 --- /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 0000000..90ab94e --- /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 0000000..ef937df --- /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 0000000..e781c22 --- /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 0000000..2d4caed --- /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 0000000..8f0cb8d --- /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 0000000..89a0897 --- /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 0000000..6c316ef --- /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 0000000..a3f62a1 --- /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 0000000..47e47df --- /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 0000000..7bbd5d9 --- /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 0000000..6b55e46 --- /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 0000000..d578deb --- /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 0000000..e4b27bd --- /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 0000000..21c20ab --- /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 0000000..f824afb --- /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 0000000..d733800 --- /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 0000000..251c021 --- /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 0000000..e75f05c --- /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 0000000..dec5bba --- /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 0000000..a9f0804 --- /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 0000000..f80e04d --- /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 0000000..d9b0ed5 --- /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 0000000..54f12b4 --- /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 0000000..423ce7a --- /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 0000000..e736359 --- /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 0000000..80b548f --- /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 0000000..573203e --- /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 0000000..35b98d6 --- /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 0000000..2af9695 --- /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 0000000..c34a755 --- /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 0000000..faf283c --- /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 0000000..f747957 --- /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 0000000..ad9c765 --- /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 0000000..ee42b96 --- /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 0000000..875ab3b --- /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 0000000..2996ae8 --- /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 0000000..e246488 --- /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 0000000..ba2a4ac --- /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 0000000..ee7956f --- /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 0000000..65d2820 --- /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 0000000..8fb8580 --- /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 0000000..84505b8 --- /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 0000000..cdec36b --- /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 0000000..b33f80e --- /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 0000000..53746a0 --- /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 0000000..3409869 --- /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 0000000..1c018c2 --- /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 0000000..336e944 --- /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 0000000..f87c902 --- /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 0000000..3a658b8 --- /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 0000000..14b0e87 --- /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 0000000..ec3489c --- /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 0000000..31f6b1a --- /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 0000000..a6420ec --- /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 0000000..700a7e3 --- /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 0000000..ae45a65 --- /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 0000000..226ce34 --- /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 0000000..8cac92f --- /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 0000000..d985f05 --- /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 0000000..aa6ae70 --- /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 0000000..ee9cd18 --- /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 0000000..bfe898b --- /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 0000000..cd6f88e --- /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 0000000..669c782 --- /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 0000000..fa1e369 --- /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 0000000..459fbdf --- /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 0000000..0d0cd23 --- /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 0000000..70f17dd --- /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 0000000..38f41e7 --- /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 0000000..347deef --- /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 0000000..5bf50cb --- /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 0000000..3799104 --- /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 0000000..1c5f2fe --- /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 0000000..b2f64cd --- /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 0000000..d1639cc --- /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 0000000..9ef0fb9 --- /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 0000000..7058683 --- /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 0000000..41796e6 --- /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 0000000..1af9f57 --- /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 0000000..05900c4 --- /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 0000000..60cfccc --- /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 0000000..37f3aa8 --- /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 0000000..b208f85 --- /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 0000000..697e5e2 --- /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 0000000..bf99ffe --- /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 0000000..b12feda --- /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 0000000..cb9562f --- /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 0000000..ef22e01 --- /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 0000000..61101fb --- /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 0000000..34bf1f8 --- /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 0000000..5d761c5 --- /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 0000000..d79e2e2 --- /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 0000000..f83ab49 --- /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 0000000..c691a9f --- /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 0000000..fe517a0 --- /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 0000000..f867bee --- /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 0000000..c319869 --- /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 0000000..7631810 --- /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 0000000..6e77fc4 --- /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 0000000..02e9da1 --- /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 0000000..76bd355 --- /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 0000000..bc764bd --- /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 0000000..cbaa424 --- /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 0000000..7a1f6b8 --- /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 0000000..ff8ee23 --- /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 0000000..72a7f25 --- /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 0000000..17c0174 --- /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 0000000..edd12ee --- /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 0000000..cf1d197 --- /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 0000000..2ea5057 --- /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 0000000..99e87b6 --- /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 0000000..cbce24f --- /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 0000000..bf108ad --- /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 0000000..505a80b --- /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 0000000..7ef6cfc --- /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 0000000..0dc61ad --- /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 0000000..e4cb92a --- /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 0000000..202dfd9 --- /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 0000000..3c8b05d --- /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 0000000..66ed77f --- /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 0000000..b126fb0 --- /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 0000000..13217c8 --- /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 0000000..733848f --- /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 0000000..7fb7310 --- /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 0000000..624857b --- /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 0000000..064bdb4 --- /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 0000000..7ff01c5 --- /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 0000000..8c45530 --- /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 0000000..220e7c7 --- /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 0000000..1746e7c --- /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 0000000..4034fcb --- /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 0000000..8c3a5de --- /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 0000000..1bc2660 --- /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 0000000..7b68c77 --- /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 0000000..e1bd333 --- /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 0000000..186b872 --- /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 0000000..0af7459 --- /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 0000000..b6c910f --- /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 0000000..25a4f8e --- /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 0000000..62f0abc --- /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 0000000..5b5fd75 --- /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 0000000..1d84604 --- /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 0000000..1562f87 --- /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 0000000..6eda626 --- /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 0000000..5b7c054 --- /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 0000000..292798d --- /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 0000000..4ca9b58 --- /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 0000000..f97a74e --- /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 0000000..a199759 --- /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 0000000..dd3c4e0 --- /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 0000000..dc0a159 --- /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 0000000..03e6031 --- /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 0000000..a593ff6 --- /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 0000000..166be5b --- /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 0000000..f62e0e3 --- /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 0000000..a8b2317 --- /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 0000000..252970f --- /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 0000000..ac4f00a --- /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 0000000..a40a6fd --- /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 0000000..5d105a4 --- /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 0000000..850ef10 --- /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 0000000..c33997c --- /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 0000000..ba44462 --- /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 0000000..473ba1d --- /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 0000000..b249fe1 --- /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 0000000..d4d59f5 --- /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 0000000..ed99162 --- /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 0000000..c1df06e --- /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 0000000..4bca45e --- /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 0000000..bf0eae5 --- /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 0000000..e657a4c --- /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 0000000..300ab8a --- /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 0000000..cb7fe80 --- /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 0000000..bd71647 --- /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 0000000..0e47248 --- /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 0000000..7a03b8b --- /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 0000000..9d65e02 --- /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 0000000..43283e5 --- /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 0000000..fc8d3e6 --- /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 0000000..1f7983b --- /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 0000000..142d886 --- /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 0000000..166d681 --- /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 0000000..1508cd3 --- /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 0000000..ac58762 --- /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 8336058..98d163c 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 4db4cec..b3a8d5a 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 401bb7d..fdb4769 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 3479ab4..47929ec 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 34c8873..cbd3360 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 d18372d..90221be 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 034b617..ad111f3 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 ddd25be..b64be65 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 6560a6a..03b6277 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 59b1ee1..983caee 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 232ad7a..df505a1 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 48773a5..9221c93 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 22b28f5..8fc0c2a 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 701349e..5425634 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 7ec1864..9d3f4cf 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 687ad22..128f61f 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 21df242..8ec4a6c 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 c23258f..055d252 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 c88e49e..65f2bd0 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 f83dc8e..a5569ea 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 d65214e..3fdf528 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,14 +53,39 @@ 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. * * Intended to be shared to each of the different implementation variations. 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 61237d9..7758230 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 e665dcb..32b5a07 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. 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 42deb31..ddf172a 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 c6db12e..b7d14d3 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. 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 0ce66e8..d241cd4 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 919b47c..f410fea 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. @@ -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 76a0f22..2cd16d8 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 ade08c4..f5b972d 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. @@ -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 10f910d..5ced250 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 920021f..1898bb8 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. @@ -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 e3c12d8..1063d7f 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 741065d..7bdde5e 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. @@ -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 7b5cb2d..32e9835 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 101e111..4a31370 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. @@ -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 4990b51..0ac6f92 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 d661688..b999c3b 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. 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 024372b..8e68dd5 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 5e328f2..4bce1fb 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,23 +44,48 @@ 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. * * Intended to be shared to each of the different implementation variations. 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 0000000..7a14d27 --- /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 0000000..b0678eb --- /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 0000000..bb49cf1 --- /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 0000000..d52a3b7 --- /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 0000000..5f9105a --- /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 0000000..fd97ca4 --- /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 0000000..b2d99b3 --- /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 0000000..912f940 --- /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 0000000..3956357 --- /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 0000000..8f7704e --- /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 d416b9b..d9efd28 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 cf63b29..8a58724 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 2eb4a37..b602cbd 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 196cabb..6d62148 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,10 +52,30 @@ 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. * * This will resize making the array smaller based on (size - given length). @@ -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 0000000..9afaf3c --- /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 0000000..4634384 --- /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 0000000..c56edf4 --- /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 0000000..31aa62f --- /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 0000000..4c4e5bf --- /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 0000000..a061778 --- /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 0000000..ec8a048 --- /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 0000000..0398898 --- /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 0000000..eaa88d8 --- /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 0000000..d9f7cf6 --- /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 8db5207..ac828fd 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 4fcb2bd..8873b42 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 90c9a84..d58020d 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 431fa82..f59c7d3 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 db56b66..8e63f94 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 366669e..de1290c 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 @@ -18,17 +18,10 @@ 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 0000000..144a80d --- /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 0000000..0cf641b --- /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 f248032..5150b8f 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 ae95997..84d569f 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 c6c9ba8..92f4366 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 3197742..131b6d9 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 8aacad3..5b88f60 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 9e5d4c1..bf89633 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 98f4680..bb83dce 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 99cfc30..820cfa3 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 5ac1498..1c655c4 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 297f223..648b40f 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 1de770f..a691c7e 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 c75c5ae..49ac75a 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 161c263..53d7abd 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 451b2e0..26855d6 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 0000000..213257b --- /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 0000000..497d99c --- /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 e01550a..911307f 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 f1ca465..b424803 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 2c83fba..0a092ad 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 02b5980..75c840d 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 089e8e7..d5ada76 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 88a71cb..6788793 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 8fa1835..5bbbbf1 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 05eb526..789f8e1 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 2435445..a2d030f 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 a8fd772..0011f32 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 a221c69..4dbf3a4 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 49443d3..53d4c63 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 605d3a0..1951456 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 e514584..ba16169 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 @@ -18,17 +18,10 @@ 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 0000000..071c2b1 --- /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 0000000..31cd259 --- /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 d415836..a9bf7b0 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 0d3fcbc..b689fff 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 93dee61..bd44d1b 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 abb091e..09d89d3 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 926ad2c..7842295 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 cf7d408..81964f4 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 3a53c53..ed71d46 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 b55f081..f3daa78 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 af1fec9..35e6699 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 f263e6b..b89bdf8 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 aadc7cd..b44fcf2 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 1111bdc..b4d07e7 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 4f6d345..9cbefbd 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 74f4c78..cc48725 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 0000000..b7a1932 --- /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 0000000..2721cdd --- /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 4c0dcad..abc400c 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 93509ee..3f43825 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 a8e8e1b..8fe429d 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 b3cdd0a..9b5e4b0 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 c34df58..577bd62 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 e5ce06b..74ca065 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 b0828ff..07e7c37 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 16267cf..9152f1d 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 fed4516..79fb875 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 03c7df1..a0977f0 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 c382c7d..658031e 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 d63264d..486be6f 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 c230324..e208d80 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 3b051fd..a665436 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 @@ -18,17 +18,10 @@ 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 0000000..1b12eb0 --- /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 0000000..4093df1 --- /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 ca014f3..fa796a4 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 36a0149..cd4471d 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 a2ef8a5..a60e139 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 8d47fe0..9506bca 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 6ce6d10..a359f31 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 313b6d6..f5e8d87 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 96a11ac..e3b60b6 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 5a98667..159d816 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 2e75994..a5b56ed 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 7f034bb..7ae4f84 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 188e147..979b56d 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 98f5d37..6dfdf95 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 bb7dd28..a08c604 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 43a851e..9cbc569 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 0000000..774d9c7 --- /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 0000000..baa023d --- /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 52ea712..168f7d4 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 30f011e..c4edbe3 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 8525726..3f7f826 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 21fa831..35a43c3 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 9915a6f..d7e5a57 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 5a9773a..358ba3e 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 764ae83..05ba92e 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 0636d44..cf8687e 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 451a722..e0891ee 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 9d8db27..4284015 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 0c92b26..3463b16 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 58bb505..467b522 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 56f8057..b905964 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 95f3f1d..0ad1cba 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 @@ -18,17 +18,10 @@ 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 0000000..281f207 --- /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 0000000..a63f610 --- /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 b2cc9e5..f9276b0 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 b8d393a..27c95e5 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 09b6760..af81902 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 82a6108..614d3b5 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 30b8d75..35aa7ad 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 2ef2e4d..daf6bdb 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 48ff216..37583da 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 e5b74b8..b1c35bf 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 399d9b3..19b6c13 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 4b1752d..4d4c60d 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 dc07786..7bdd283 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 9adcfba..21c0fa8 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 e38f4eb..c67b66d 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 ee97741..e27c025 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 0000000..26f33bc --- /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 0000000..8c0339f --- /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 6e082c8..1a6c370 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 75aa4f2..b4a3647 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 d622f36..a8ac1f4 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 9afeb06..f7f4da9 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 c234ff5..d0cfcc1 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 97c4c28..5751599 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 43e6d7b..8588735 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 9844d55..dbb6090 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 149159b..72eaa3f 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 3760115..821daa2 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 529453a..3f0931e 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 6fa6214..9376cd3 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 d4133b9..163f197 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 98a2ddc..173530c 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 @@ -18,17 +18,10 @@ 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 0000000..19506b0 --- /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 0000000..2a4637c --- /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 cb4452c..9fff75d 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 80a5218..f77b1ae 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 e6cd758..3d30dc1 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 56bacd4..b7a215d 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 26eaf90..0d7fe4b 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 e1c208e..8a9c1cb 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 dbad485..2f717ae 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 719c920..37e7b4d 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 450e07d..c632a9e 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 e1627b7..5f2933e 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 5bb4fc8..3055b17 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 efb8582..c241255 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 f1e23dc..36ee09d 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 c40ed3b..7bab07f 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 0000000..08d3123 --- /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 0000000..8d9fe34 --- /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 ac36f8d..fd7040e 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 1384c68..2bd7c2f 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 67ba87c..ed3a454 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 a8813c9..f5d687a 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 db43470..f1d8273 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 032a4bb..c0b275d 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 ffccc6e..cbb4a29 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 0d02ffb..78956ec 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 078b770..7a4e892 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 b57993d..6f962b7 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 3cc76bf..8aafe65 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 cf4f06d..913daa8 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 596cddc..c384176 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 6133021..4c22e28 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 @@ -18,17 +18,10 @@ 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 0000000..dc8bfbc --- /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 0000000..ed79d51 --- /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 cd2d362..d6b5032 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 6fbb447..ee9a6af 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 e0d167a..71279a4 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 fad9c5e..ed428af 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 a2d11f6..a6d4022 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 d7536cd..7fe8cf5 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 4e4a8af..c89ce82 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 95ed773..8be454e 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 db4251d..fdc0204 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 64fb507..82f054e 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 c25b621..a973a03 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 8d9200c..a105b7b 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 038ad3a..b4d67f9 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 7caf1fe..5d56e68 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 0000000..c002afa --- /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 0000000..8aaeae7 --- /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 7e3f686..0fdb7e5 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 722bb59..2fc576d 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 688c10a..99a0826 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 1fc42cd..9fa8247 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 35bfac7..a3160a4 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 8fdccb3..ae844df 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 30e121b..47f49fd 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 09b2d95..e2ec6e5 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 8805d36..c53d81e 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 aee14e1..32e26a8 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 fb63404..252565b 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 090b24d..fca10f4 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 4bb91c6..2515eeb 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 8bec71b..050b258 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 @@ -18,17 +18,10 @@ 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 0000000..dae1f31 --- /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 0000000..ae20d0c --- /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 c3ae4c9..18cb0f7 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 31123c6..3cd695b 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 426014f..93d4de8 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 e79a317..9f7fcdc 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 90b472b..2aaf4f5 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 7538f33..ec62ee0 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 4e04bfc..7749300 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 38dbd1a..f8bd91a 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 da472e9..f2cf58d 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 a70d30f..7de4876 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 0804f0a..5bb533e 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 8c25372..af32364 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 826772b..f0bba2e 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 ea50420..69065b9 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 0000000..bd4b667 --- /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 0000000..6052ec5 --- /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 9e08407..03567e8 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 9636e80..a813fff 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 f49a6e5..f2909c0 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 ef1adf1..966ce27 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 45159b1..b0e7054 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 ac70919..2549016 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 f3e11f0..206def8 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 3857a06..689f658 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 b2a5f35..cceffaf 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 e1cee1d..4d85702 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 46c1973..f857eb0 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 800cd33..6fea315 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 5d4ecb1..8412a3e 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 3bda741..221938d 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 @@ -18,17 +18,10 @@ 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 0000000..79279e3 --- /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 0000000..28e46c8 --- /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 744cb0d..388ed49 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 873be7f..269b5d7 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 118d7e8..e5cfb1e 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 de0ee34..61b3b84 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 2d6de2a..37d9220 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 cf688ba..99012ea 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 5fae4cd..d847d52 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 a0d242e..0b903ac 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 b182886..c367b73 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 df99311..bf0e9ce 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 2c185fe..d230abd 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 ba46d8b..6e982b8 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 e6ed2aa..5372566 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 238c7de..57a27ab 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 0000000..6aeb35f --- /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 0000000..2ce922d --- /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 6523a9d..373da63 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 19afd6c..aba8411 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 ae62dd7..67e3342 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 3944b7d..2925c24 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 009e260..39445e0 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 5b08bab..1d18bb6 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 bb20da4..dc4f64e 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 5668e6f..1c80719 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 7201880..49b9f42 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 b3eaf47..42dda37 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 7bbd14c..4337c99 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 ef92edc..dbc993a 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 7c6e95b..849dae4 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 7afc0e0..43d227d 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 @@ -18,17 +18,10 @@ 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 0000000..0c7938c --- /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 0000000..a1f2bab --- /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 564888c..0594ff3 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 4b397ba..a12f3ce 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 886c568..69f02f3 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 04cf75b..6b0e7da 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 ae612f0..36bd2cb 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 a653df2..f3443ab 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 2de473e..7fa61bd 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 34a8cb0..e78e99e 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 668e137..ada5a9b 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 9b8e35b..79e7979 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 a48aa04..61b28e3 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 6537c77..5cb604e 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 1187742..585290a 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 7aca8b8..54f6bf4 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 0000000..9146356 --- /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 0000000..b8a72ea --- /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 ff8eb97..0375502 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 56f8d03..dae8b9d 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 5f8e2aa..753ff19 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 6b6d36f..b855d49 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 2f09f9b..367d9a5 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 fa39f7e..d015d5d 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 5c7447c..77070d2 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 fca473b..a93ffba 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 2ef6251..a953b94 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 5ec1007..448f6d8 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 2c4fb7a..ba7dcc6 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 412065f..24e5d53 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 ce5f150..fb8d905 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 e4d1d99..6fb277f 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 @@ -18,17 +18,10 @@ 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 0000000..07b1a06 --- /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 0000000..c870109 --- /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 ec845a7..962080c 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 f6e8bb2..cd317d3 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 4be9e76..24bcde4 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 8b8f43b..52aef54 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 04cfd65..5d68d7a 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 6c30bf0..65a9252 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 7be778b..f828eaa 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 0f410bf..bdf0fb1 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 f73f81e..2ecb2a4 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 e4e7ec1..4ce5181 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 1502c31..d715069 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 9dfb7ca..2e7f4e8 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 ef10dee..a0ddc42 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 f67a8b5..89b921e 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 0000000..b0b13a1 --- /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 0000000..54ac1cf --- /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 72474b7..8a7b041 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 87d1f3c..79428b9 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 f5b24e3..19b69ce 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 deaa87a..e780d3f 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 16a2634..b0476ae 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 faa511e..18a1cab 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 e4afc46..0e98033 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 934a1d3..203c72a 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 af2d50e..b3ecfda 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 e893fd2..e95a2de 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 9f048e1..37025d7 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 44fc7db..6315a5d 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 fcb4011..516e450 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 ac82d7c..93ccaf1 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 @@ -18,17 +18,10 @@ 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 0000000..afbad49 --- /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 0000000..40d61c7 --- /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 2e60f42..d082f43 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 29fad70..a4f4356 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 f12052c..1d6b42e 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 96ec7b1..9c21df0 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 497c0f3..5a8143f 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 ffd3b01..94e7079 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 4e95675..0cd3697 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 fd71330..90317ac 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 a44ec73..65dcf29 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 a1ab9bd..e21448d 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 5e36340..224e635 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 60c4b99..3a0bcde 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 e294fd9..50ba45d 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 1d666ac..d019beb 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 0000000..a3ca3c0 --- /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 0000000..0b10466 --- /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 106309a..c5f8994 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 494d0fe..763184e 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 8dfc0f1..e8d7ee5 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 3a97b72..f6787bc 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 6d5126b..85cb58e 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 adffcfd..98a2cce 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 7a99542..90ee4a9 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 0d2d290..c1950d8 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 83f6afa..b4999f1 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 db2f98f..be44630 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 6098400..e5845d1 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 2012422..ba5c21f 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 f00fb0a..62f6a65 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 a568c77..3a111c6 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 @@ -18,17 +18,10 @@ 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 0000000..519411b --- /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 0000000..db4a986 --- /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 f68ffec..6dbfbd3 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 4dce396..1a76948 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 f3a24bb..bc68694 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 dae04f4..144eda0 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 7283669..065a40a 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 a8c7ef5..a754c56 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 1800849..ca07bdc 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 6a327db..61a7e0f 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 73aab29..5357df0 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 3bb8875..d34513e 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 4aa80af..58dce85 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 8d66d02..427d558 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 70a2087..a89594f 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 8da5310..3ddc590 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 0000000..4f1f37c --- /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 0000000..2048169 --- /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 291cf94..f02ea0d 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 68c690f..08b335d 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 c789a8d..4a547ab 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 c8bb169..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 58330cf..b47b0d2 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 9f4472e..df1cbf2 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 0915379..4ad84b6 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 6a5d8b3..54cc5a3 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 77a877c..4936f1b 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 c34e572..5f1af71 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 b2edc91..70af090 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 b651183..4b85870 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 db0d482..723abf7 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 dbf57e9..884e11e 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 @@ -18,17 +18,10 @@ 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 0000000..43529a0 --- /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 0000000..521e499 --- /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 57ad5a0..950d1b0 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 a4cd42a..f549ca6 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 4c9be8b..392052b 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 d0fa5da..35f03bb 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 bc65739..d77df7f 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 842a5b9..e0db8f3 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 f9ab277..f165f04 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 dda9416..6afbf5d 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 70694db..4006ef2 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 b16a714..26a116d 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 5b59bd9..d180809 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 5846110..5d27154 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 03e3de4..32cd338 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 e5ce496..fd2cf40 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 0000000..032593a --- /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 0000000..8ca0605 --- /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 c3a2a44..d941d02 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 fb792ee..50380ba 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 58c0ccd..f7fd550 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 5789def..695a5c9 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 4ecb41b..432b362 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 1fcb7e7..18beac0 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 77c6ba8..07000c3 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 64578c4..c05511d 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 a0e2145..16b522e 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 1d523b8..fd1ed4c 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 6620d3a..4336952 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 729ce1e..90f6b34 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 ebd7dd2..243e230 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 052d08c..2cc3a26 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 @@ -18,17 +18,10 @@ 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 0000000..7b8902c --- /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 0000000..0a43b51 --- /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 10980dc..f2e2f70 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 6ea01a5..46c9b01 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 6b072d2..09d1858 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 0706759..69cdf74 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 b97928b..5f4e3d0 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 5fb5e7b..76a95f8 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 0c96224..89c33b0 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 2115798..e039521 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 862bd4a..53e459a 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 22e96d0..f28ff4b 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 bf51ef6..a069aa3 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 b93e170..66269a7 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 69c4a41..1e54484 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 64913fc..071d13a 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 0000000..80edb1f --- /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 0000000..0bc11ed --- /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 4bed12f..53edea2 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 b3ed09f..97a969e 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 7fddf9f..a5d8132 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 0cabd05..9927a94 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 b08052e..8338db8 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 faa336d..ad9671b 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 0ffde43..ae5192f 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 d187b23..3173268 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 94e43db..c471785 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 5f22166..acd18bc 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 67fd00d..33440e2 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 dee94c0..d5afab2 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 f8ad96d..d039c47 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 e0b062a..02968f7 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 @@ -18,17 +18,10 @@ 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 0000000..a94ae53 --- /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 0000000..039bf1f --- /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 434e3b3..40ceac0 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 5575c3a..fe4247b 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 5559b38..a2baa1b 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 5fcb7a4..6157173 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 1667118..690bbaf 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 18cf514..77be554 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 8fb4be5..f507bd1 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 34783da..7c8206f 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 86d997e..83b457a 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 a19fa0f..8f258e3 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 8d4d4a5..ec3eed9 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 223dce3..b6d8dfb 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 e9c6fed..650d761 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 62e2451..c7f6633 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 0000000..5a4d14d --- /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 0000000..8ec2cb0 --- /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 c8418fb..b9cca5d 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 70c6812..f92c294 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 9c5fac8..61a91cb 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 21c4271..d78af8d 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 1f608f7..99f7612 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 88b7ac1..a82b67d 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 8bb2b87..2d6e55c 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 0ab8779..e0bc0ec 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 c0f346b..251db75 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 b018049..69a4718 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 ce1c7cf..fded1e5 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 3299059..4c210fb 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 fe639e2..507daa9 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 27f2c49..79c0a42 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 8e6382e..51e5fb5 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 e660048..f19a4dd 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 b83899f..006b1d1 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 d8ec866..98ad6bd 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 a6df5f4..4c7e85b 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 10ea510..35a1400 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 43061e4..08d8755 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 532e229..4b8016e 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 0dd3bce..a584626 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 8fbc54b..a638272 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 c86ae46..08f5396 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 7e81505..77c60d7 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 6b98acd..8a4e5eb 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 3315594..ef932be 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 ced35c5..504c0fd 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 1699d0f..8bc3fa2 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 4f04124..6396e84 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 ffd4ddf..f9b79c9 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 6156140..f7b152b 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 fae9d9e..06361a9 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 3393043..3bee387 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 0a3a246..f706c11 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 704a32a..0778eaf 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 df2fe43..62ce652 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 46d18c4..654c9da 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 1961d07..37a08b9 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 c58189c..3c033ca 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 92c08be..b9a9806 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 de02396..ad65cd9 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 901abc3..a0c4eee 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 718da78..fd9e082 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 7dbfd19..fd33c88 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 a986258..083e43b 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 f298769..134d73b 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 4304d2e..16cd23c 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 becbad1..36e9e55 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 9e850e6..7c9f9f4 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 c9d4c5c..d23d8d4 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 3bf4f47..fa2d301 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 0a77e94..233a04c 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 e397fd1..ed623ff 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 a21240d..5f9ac54 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 af41595..b719102 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 47e0f45..7efc8a8 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 2b5756a..d35c01c 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 eabeb71..a0071ea 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 f126463..40874db 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]; -- 1.8.3.1