From a5353381e6947d3da63ac7738ef6798d685d24bb Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 26 Aug 2023 20:36:18 -0500 Subject: [PATCH] Progress: Continue re-designing of the memory logic, focusing on unit tests for recent changes to f_string_dynamic_t and similar. This adds some test files that I did a git add on but forgot to do the git commit with. Update many of the unit tests and fix any mistakes discovered. --- build/level_0/settings | 8 +- build/monolithic/settings | 6 - build/stand_alone/byte_dump.settings | 2 +- build/stand_alone/fake.config.h | 75 ++---- build/stand_alone/fake.settings | 2 +- build/stand_alone/firewall.settings | 2 +- build/stand_alone/utf8.settings | 2 +- level_0/f_console/c/console.c | 2 +- level_0/f_console/c/console.h | 4 +- .../unit/c/test-console-environment_process.c | 4 +- .../tests/unit/c/test-environment-get_all.c | 2 +- level_0/f_file/tests/unit/c/test-file-read.c | 2 +- level_0/f_file/tests/unit/c/test-file-read_block.c | 2 +- level_0/f_file/tests/unit/c/test-file-read_until.c | 4 +- level_0/f_fss/c/fss/item.c | 12 +- level_0/f_fss/c/fss/item.h | 24 +- level_0/f_fss/c/fss/named.c | 36 +-- level_0/f_fss/c/fss/named.h | 37 +-- level_0/f_fss/c/fss/nest.c | 12 +- level_0/f_fss/c/fss/nest.h | 10 +- level_0/f_fss/c/fss/private-item.c | 40 --- level_0/f_fss/c/fss/private-item.h | 80 ------ level_0/f_fss/c/fss/private-named.c | 76 ------ level_0/f_fss/c/fss/private-named.h | 144 ----------- level_0/f_fss/c/fss/private-nest.c | 79 ------ level_0/f_fss/c/fss/private-nest.h | 132 ---------- level_0/f_fss/c/fss/private-set.c | 76 ------ level_0/f_fss/c/fss/private-set.h | 136 ---------- level_0/f_fss/c/fss/private-set_quote.c | 100 -------- level_0/f_fss/c/fss/private-set_quote.h | 150 ----------- level_0/f_fss/c/fss/private-simple_packet.c | 168 ------------ level_0/f_fss/c/fss/private-simple_packet.h | 284 --------------------- level_0/f_fss/c/fss/set.c | 24 +- level_0/f_fss/c/fss/set.h | 32 ++- level_0/f_fss/c/fss/set_quote.c | 38 +-- level_0/f_fss/c/fss/set_quote.h | 24 -- level_0/f_fss/c/fss/simple_packet.c | 22 +- level_0/f_fss/c/fss/simple_packet.h | 20 +- level_0/f_fss/data/build/settings-mocks | 7 +- level_0/f_fss/data/build/settings-tests | 19 +- level_0/f_fss/tests/unit/c/mock-fss.c | 68 ----- level_0/f_fss/tests/unit/c/mock-fss.h | 10 - level_0/f_fss/tests/unit/c/test-fss-item_delete.c | 58 +++++ level_0/f_fss/tests/unit/c/test-fss-item_delete.h | 34 +++ level_0/f_fss/tests/unit/c/test-fss-item_destroy.c | 58 +++++ level_0/f_fss/tests/unit/c/test-fss-item_destroy.h | 34 +++ .../tests/unit/c/test-fss-items_delete_callback.c | 26 +- .../tests/unit/c/test-fss-items_destroy_callback.c | 26 +- .../tests/unit/c/test-fss-itemss_delete_callback.c | 12 +- .../unit/c/test-fss-itemss_destroy_callback.c | 16 +- level_0/f_fss/tests/unit/c/test-fss-named_delete.c | 99 +++++++ level_0/f_fss/tests/unit/c/test-fss-named_delete.h | 34 +++ .../f_fss/tests/unit/c/test-fss-named_destroy.c | 99 +++++++ .../f_fss/tests/unit/c/test-fss-named_destroy.h | 34 +++ .../tests/unit/c/test-fss-nameds_delete_callback.c | 58 +++-- .../unit/c/test-fss-nameds_destroy_callback.c | 58 +++-- .../unit/c/test-fss-namedss_delete_callback.c | 28 +- .../unit/c/test-fss-namedss_destroy_callback.c | 34 +-- level_0/f_fss/tests/unit/c/test-fss-nest_delete.c | 80 ++++++ level_0/f_fss/tests/unit/c/test-fss-nest_delete.h | 34 +++ level_0/f_fss/tests/unit/c/test-fss-nest_destroy.c | 80 ++++++ level_0/f_fss/tests/unit/c/test-fss-nest_destroy.h | 34 +++ .../tests/unit/c/test-fss-nests_delete_callback.c | 44 ++-- .../tests/unit/c/test-fss-nests_destroy_callback.c | 44 ++-- .../tests/unit/c/test-fss-nestss_delete_callback.c | 12 +- .../unit/c/test-fss-nestss_destroy_callback.c | 20 +- level_0/f_fss/tests/unit/c/test-fss-set_delete.c | 65 +++++ level_0/f_fss/tests/unit/c/test-fss-set_delete.h | 34 +++ level_0/f_fss/tests/unit/c/test-fss-set_destroy.c | 65 +++++ level_0/f_fss/tests/unit/c/test-fss-set_destroy.h | 34 +++ .../f_fss/tests/unit/c/test-fss-set_quote_delete.c | 76 ++++++ .../f_fss/tests/unit/c/test-fss-set_quote_delete.h | 34 +++ .../tests/unit/c/test-fss-set_quote_destroy.c | 76 ++++++ .../tests/unit/c/test-fss-set_quote_destroy.h | 34 +++ .../unit/c/test-fss-set_quotes_delete_callback.c | 71 ++++-- .../unit/c/test-fss-set_quotes_destroy_callback.c | 71 ++++-- .../unit/c/test-fss-set_quotess_delete_callback.c | 36 +-- .../unit/c/test-fss-set_quotess_destroy_callback.c | 42 +-- .../tests/unit/c/test-fss-sets_delete_callback.c | 42 +-- .../tests/unit/c/test-fss-sets_destroy_callback.c | 42 +-- .../tests/unit/c/test-fss-setss_delete_callback.c | 16 +- .../tests/unit/c/test-fss-setss_destroy_callback.c | 22 +- .../tests/unit/c/test-fss-simple_packet_delete.c | 58 +++++ .../tests/unit/c/test-fss-simple_packet_delete.h | 34 +++ .../tests/unit/c/test-fss-simple_packet_destroy.c | 58 +++++ .../tests/unit/c/test-fss-simple_packet_destroy.h | 34 +++ level_0/f_fss/tests/unit/c/test-fss.c | 70 ++++- level_0/f_fss/tests/unit/c/test-fss.h | 40 ++- level_0/f_iki/c/iki.c | 12 +- level_0/f_iki/c/iki/data.c | 66 ++--- level_0/f_iki/c/iki/data.h | 10 - level_0/f_iki/data/build/settings-mocks | 2 - level_0/f_iki/tests/unit/c/mock-iki.c | 34 --- level_0/f_iki/tests/unit/c/mock-iki.h | 6 - level_0/f_iki/tests/unit/c/test-iki-datas_append.c | 6 +- .../f_iki/tests/unit/c/test-iki-datas_append_all.c | 6 +- .../tests/unit/c/test-iki-datas_delete_callback.c | 69 ++--- .../tests/unit/c/test-iki-datas_destroy_callback.c | 69 ++--- .../f_iki/tests/unit/c/test-iki-datass_append.c | 6 +- .../tests/unit/c/test-iki-datass_append_all.c | 6 +- .../tests/unit/c/test-iki-datass_delete_callback.c | 48 ++-- .../unit/c/test-iki-datass_destroy_callback.c | 54 ++-- level_0/f_limit/tests/unit/c/test-limit.c | 8 +- level_0/f_path/tests/unit/c/test-path.c | 1 - level_0/f_serialize/c/serialize.c | 8 +- level_0/f_serialize/c/serialize.h | 4 +- .../unit/c/test-serialize-from_simple_range.c | 4 +- level_0/f_string/c/private-string.c | 56 ++-- level_0/f_string/c/string/dynamics.c | 34 ++- level_0/f_string/c/string/dynamicss.c | 28 +- level_0/f_string/c/string/map_multis.c | 185 ++++++++------ level_0/f_string/c/string/map_multis.h | 141 +++------- level_0/f_string/c/string/map_multiss.c | 230 ++++++++++------- level_0/f_string/c/string/map_multiss.h | 141 +++------- level_0/f_string/c/string/maps.c | 148 +++++------ level_0/f_string/c/string/maps.h | 141 +++------- level_0/f_string/c/string/mapss.c | 194 +++++++------- level_0/f_string/c/string/mapss.h | 142 +++-------- level_0/f_string/c/string/private-dynamics.c | 54 ---- level_0/f_string/c/string/private-dynamics.h | 76 ------ level_0/f_string/c/string/private-map_multis.c | 96 ------- level_0/f_string/c/string/private-map_multis.h | 109 -------- level_0/f_string/c/string/private-map_multiss.c | 43 ---- level_0/f_string/c/string/private-map_multiss.h | 74 ------ level_0/f_string/c/string/private-maps.c | 77 ------ level_0/f_string/c/string/private-maps.h | 108 -------- level_0/f_string/c/string/private-mapss.c | 42 --- level_0/f_string/c/string/private-mapss.h | 74 ------ level_0/f_string/c/string/private-quantityss.c | 42 --- level_0/f_string/c/string/private-quantityss.h | 74 ------ level_0/f_string/c/string/private-ranges.c | 29 --- level_0/f_string/c/string/private-ranges.h | 48 ---- level_0/f_string/c/string/private-rangess.c | 42 --- level_0/f_string/c/string/private-rangess.h | 74 ------ level_0/f_string/c/string/private-triples.c | 89 ------- level_0/f_string/c/string/private-triples.h | 148 ----------- level_0/f_string/c/string/private-tripless.c | 42 --- level_0/f_string/c/string/private-tripless.h | 72 ------ level_0/f_string/c/string/quantitys.c | 73 +----- level_0/f_string/c/string/quantitys.h | 133 ---------- level_0/f_string/c/string/quantityss.c | 156 +++++------ level_0/f_string/c/string/quantityss.h | 141 +++------- level_0/f_string/c/string/range.c | 1 - level_0/f_string/c/string/ranges.c | 63 ----- level_0/f_string/c/string/ranges.h | 135 ---------- level_0/f_string/c/string/rangess.c | 155 +++++------ level_0/f_string/c/string/rangess.h | 142 +++-------- level_0/f_string/c/string/triples.c | 193 ++++++-------- level_0/f_string/c/string/triples.h | 141 +++------- level_0/f_string/c/string/tripless.c | 209 ++++++++------- level_0/f_string/c/string/tripless.h | 141 +++------- level_0/f_string/data/build/settings | 6 - level_0/f_string/data/build/settings-mocks | 71 ++++++ level_0/f_string/data/build/settings-tests | 19 +- level_0/f_string/data/build/testfile | 2 +- level_0/f_string/tests/unit/c/mock-string.c | 46 ++++ level_0/f_string/tests/unit/c/mock-string.h | 44 ++++ level_0/f_string/tests/unit/c/test-string-append.h | 2 +- .../tests/unit/c/test-string-append_assure.h | 2 +- .../unit/c/test-string-append_assure_nulless.h | 2 +- .../tests/unit/c/test-string-append_nulless.h | 2 +- .../tests/unit/c/test-string-dynamic_append.h | 2 +- .../unit/c/test-string-dynamic_append_assure.h | 2 +- .../c/test-string-dynamic_append_assure_nulless.h | 2 +- .../unit/c/test-string-dynamic_append_nulless.h | 2 +- .../tests/unit/c/test-string-dynamic_mash.h | 2 +- .../unit/c/test-string-dynamic_mash_nulless.h | 2 +- .../tests/unit/c/test-string-dynamic_mish.h | 2 +- .../unit/c/test-string-dynamic_mish_nulless.h | 2 +- .../unit/c/test-string-dynamic_partial_append.h | 2 +- .../c/test-string-dynamic_partial_append_assure.h | 2 +- ...-string-dynamic_partial_append_assure_nulless.h | 2 +- .../c/test-string-dynamic_partial_append_nulless.h | 2 +- .../unit/c/test-string-dynamic_partial_mash.h | 2 +- .../c/test-string-dynamic_partial_mash_nulless.h | 2 +- .../unit/c/test-string-dynamic_partial_mish.h | 2 +- .../c/test-string-dynamic_partial_mish_nulless.h | 2 +- .../unit/c/test-string-dynamic_partial_prepend.h | 2 +- .../c/test-string-dynamic_partial_prepend_assure.h | 2 +- ...string-dynamic_partial_prepend_assure_nulless.h | 2 +- .../test-string-dynamic_partial_prepend_nulless.h | 2 +- .../tests/unit/c/test-string-dynamic_prepend.h | 2 +- .../unit/c/test-string-dynamic_prepend_assure.h | 2 +- .../c/test-string-dynamic_prepend_assure_nulless.h | 2 +- .../unit/c/test-string-dynamic_prepend_nulless.h | 2 +- .../tests/unit/c/test-string-dynamic_seek_line.h | 2 +- .../unit/c/test-string-dynamic_seek_line_to.h | 2 +- .../tests/unit/c/test-string-dynamic_seek_to.h | 2 +- .../tests/unit/c/test-string-dynamic_terminate.h | 2 +- .../unit/c/test-string-dynamic_terminate_after.h | 2 +- .../tests/unit/c/test-string-dynamics_append.h | 2 +- .../tests/unit/c/test-string-dynamics_append_all.h | 2 +- .../unit/c/test-string-dynamics_delete_callback.c | 52 ++++ .../unit/c/test-string-dynamics_delete_callback.h | 27 ++ .../unit/c/test-string-dynamics_destroy_callback.c | 52 ++++ .../unit/c/test-string-dynamics_destroy_callback.h | 27 ++ .../tests/unit/c/test-string-dynamicss_append.h | 2 +- .../unit/c/test-string-dynamicss_append_all.h | 2 +- .../unit/c/test-string-dynamicss_delete_callback.c | 57 +++++ .../unit/c/test-string-dynamicss_delete_callback.h | 27 ++ .../c/test-string-dynamicss_destroy_callback.c | 57 +++++ .../c/test-string-dynamicss_destroy_callback.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.h | 2 +- .../unit/c/test-string-map_multis_append_all.c | 4 +- .../unit/c/test-string-map_multis_append_all.h | 2 +- .../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 -- .../c/test-string-map_multis_delete_callback.c | 103 ++++++++ .../c/test-string-map_multis_delete_callback.h | 27 ++ .../c/test-string-map_multis_destroy_callback.c | 103 ++++++++ .../c/test-string-map_multis_destroy_callback.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 | 4 +- .../tests/unit/c/test-string-map_multiss_append.h | 2 +- .../unit/c/test-string-map_multiss_append_all.c | 6 +- .../unit/c/test-string-map_multiss_append_all.h | 2 +- .../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 -- .../c/test-string-map_multiss_delete_callback.c | 57 +++++ .../c/test-string-map_multiss_delete_callback.h | 27 ++ .../c/test-string-map_multiss_destroy_callback.c | 57 +++++ .../c/test-string-map_multiss_destroy_callback.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.h | 2 +- .../tests/unit/c/test-string-maps_append_all.c | 4 +- .../tests/unit/c/test-string-maps_append_all.h | 2 +- .../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 -- .../unit/c/test-string-maps_delete_callback.c | 77 ++++++ .../unit/c/test-string-maps_delete_callback.h | 27 ++ .../unit/c/test-string-maps_destroy_callback.c | 77 ++++++ .../unit/c/test-string-maps_destroy_callback.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 | 4 +- .../tests/unit/c/test-string-mapss_append.h | 2 +- .../tests/unit/c/test-string-mapss_append_all.c | 6 +- .../tests/unit/c/test-string-mapss_append_all.h | 2 +- .../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 -- .../unit/c/test-string-mapss_delete_callback.c | 57 +++++ .../unit/c/test-string-mapss_delete_callback.h | 27 ++ .../unit/c/test-string-mapss_destroy_callback.c | 57 +++++ .../unit/c/test-string-mapss_destroy_callback.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 -- level_0/f_string/tests/unit/c/test-string-mash.h | 2 +- .../tests/unit/c/test-string-mash_nulless.h | 2 +- level_0/f_string/tests/unit/c/test-string-mish.h | 2 +- .../tests/unit/c/test-string-mish_nulless.h | 2 +- .../f_string/tests/unit/c/test-string-prepend.h | 2 +- .../tests/unit/c/test-string-prepend_assure.h | 2 +- .../unit/c/test-string-prepend_assure_nulless.h | 2 +- .../tests/unit/c/test-string-prepend_nulless.h | 2 +- .../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.h | 2 +- .../unit/c/test-string-quantitys_append_all.c | 2 +- .../unit/c/test-string-quantitys_append_all.h | 2 +- .../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 | 2 +- .../tests/unit/c/test-string-quantityss_append.h | 2 +- .../unit/c/test-string-quantityss_append_all.c | 2 +- .../unit/c/test-string-quantityss_append_all.h | 2 +- .../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 -- .../c/test-string-quantityss_delete_callback.c | 57 +++++ .../c/test-string-quantityss_delete_callback.h | 27 ++ .../c/test-string-quantityss_destroy_callback.c | 57 +++++ .../c/test-string-quantityss_destroy_callback.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.h | 2 +- .../tests/unit/c/test-string-ranges_append_all.c | 2 +- .../tests/unit/c/test-string-ranges_append_all.h | 2 +- .../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 | 2 +- .../tests/unit/c/test-string-rangess_append.h | 2 +- .../tests/unit/c/test-string-rangess_append_all.c | 2 +- .../tests/unit/c/test-string-rangess_append_all.h | 2 +- .../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 -- .../unit/c/test-string-rangess_delete_callback.c | 57 +++++ .../unit/c/test-string-rangess_delete_callback.h | 27 ++ .../unit/c/test-string-rangess_destroy_callback.c | 57 +++++ .../unit/c/test-string-rangess_destroy_callback.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 -- .../f_string/tests/unit/c/test-string-seek_line.h | 2 +- .../tests/unit/c/test-string-seek_line_to.h | 2 +- .../f_string/tests/unit/c/test-string-seek_to.h | 2 +- .../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.h | 2 +- .../tests/unit/c/test-string-triples_append_all.c | 2 +- .../tests/unit/c/test-string-triples_append_all.h | 2 +- .../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 -- .../unit/c/test-string-triples_delete_callback.c | 102 ++++++++ .../unit/c/test-string-triples_delete_callback.h | 27 ++ .../unit/c/test-string-triples_destroy_callback.c | 102 ++++++++ .../unit/c/test-string-triples_destroy_callback.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 | 2 +- .../tests/unit/c/test-string-tripless_append.h | 2 +- .../tests/unit/c/test-string-tripless_append_all.c | 2 +- .../tests/unit/c/test-string-tripless_append_all.h | 2 +- .../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 -- .../unit/c/test-string-tripless_delete_callback.c | 57 +++++ .../unit/c/test-string-tripless_delete_callback.h | 27 ++ .../unit/c/test-string-tripless_destroy_callback.c | 57 +++++ .../unit/c/test-string-tripless_destroy_callback.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 | 206 +++++---------- level_0/f_string/tests/unit/c/test-string.h | 80 ++---- level_1/fl_environment/c/environment.c | 32 +-- level_1/fl_environment/c/environment.h | 8 +- level_1/fl_fss/c/fss/basic.c | 2 +- level_1/fl_fss/c/fss/basic.h | 4 +- level_1/fl_fss/c/fss/basic_list.c | 4 +- level_1/fl_fss/c/fss/basic_list.h | 10 +- level_1/fl_fss/c/fss/embedded_list.c | 44 ++-- level_1/fl_fss/c/fss/embedded_list.h | 10 +- level_1/fl_fss/c/fss/extended.c | 2 +- level_1/fl_fss/c/fss/extended.h | 6 +- level_1/fl_fss/c/fss/extended_list.c | 4 +- level_1/fl_fss/c/fss/extended_list.h | 10 +- level_2/fll_fss/c/fss.c | 8 +- level_2/fll_fss/c/fss/basic.c | 9 +- level_2/fll_fss/c/fss/basic.h | 4 - level_2/fll_fss/c/fss/basic_list.c | 8 +- level_2/fll_fss/c/fss/basic_list.h | 4 - level_2/fll_fss/c/fss/embedded_list.h | 4 - level_2/fll_fss/c/fss/extended.c | 6 +- level_2/fll_fss/c/fss/extended.h | 4 - level_2/fll_fss/c/fss/extended_list.c | 9 +- level_2/fll_fss/c/fss/extended_list.h | 4 - level_2/fll_fss/c/fss/payload.c | 13 +- level_2/fll_fss/c/fss/payload.h | 4 - level_3/control/c/main/common.c | 4 +- level_3/control/c/main/common/type.c | 12 +- level_3/control/c/main/common/type.h | 3 +- level_3/controller/c/common/private-cache.c | 12 +- level_3/controller/c/common/private-cache.h | 3 +- level_3/controller/c/common/private-rule.c | 4 +- level_3/controller/c/common/private-setting.c | 8 +- level_3/controller/c/entry/private-entry.c | 18 +- level_3/controller/c/entry/private-entry.h | 4 +- level_3/controller/c/rule/private-rule.c | 4 +- level_3/controller/c/rule/private-rule.h | 2 - level_3/fake/c/main/build/load.c | 4 +- level_3/fake/c/main/common.c | 6 +- level_3/fake/c/main/common.h | 1 - level_3/fake/c/main/common/print.c | 1 - level_3/fake/c/main/common/print.h | 1 - level_3/fake/c/main/common/type.c | 10 +- level_3/fake/c/main/make/load_fakefile.c | 20 +- level_3/fake/c/main/make/load_fakefile.h | 4 +- level_3/fake/c/main/make/operate_process_type.c | 4 +- level_3/fake/c/main/make/operate_process_type.h | 2 - level_3/firewall/c/private-firewall.c | 16 +- level_3/fss_read/c/main/common/print.c | 5 +- level_3/fss_read/c/main/common/print.h | 5 +- level_3/fss_read/c/main/common/type.c | 6 +- level_3/fss_read/c/main/common/type.h | 2 - level_3/fss_write/c/main/common.c | 8 +- level_3/fss_write/c/main/common/print.c | 4 - level_3/fss_write/c/main/common/print.h | 4 - level_3/fss_write/c/main/fss_write.c | 8 +- level_3/fss_write/c/payload/fss_write.c | 4 +- level_3/iki_read/c/main/common.c | 12 +- level_3/iki_read/c/main/common.h | 6 - level_3/iki_read/c/main/common/print.c | 2 - level_3/iki_read/c/main/common/print.h | 2 - level_3/iki_read/c/main/common/type.c | 9 +- 462 files changed, 5642 insertions(+), 11191 deletions(-) delete mode 100644 level_0/f_fss/c/fss/private-item.c delete mode 100644 level_0/f_fss/c/fss/private-item.h delete mode 100644 level_0/f_fss/c/fss/private-named.c delete mode 100644 level_0/f_fss/c/fss/private-named.h delete mode 100644 level_0/f_fss/c/fss/private-nest.c delete mode 100644 level_0/f_fss/c/fss/private-nest.h delete mode 100644 level_0/f_fss/c/fss/private-set.c delete mode 100644 level_0/f_fss/c/fss/private-set.h delete mode 100644 level_0/f_fss/c/fss/private-set_quote.c delete mode 100644 level_0/f_fss/c/fss/private-set_quote.h delete mode 100644 level_0/f_fss/c/fss/private-simple_packet.c delete mode 100644 level_0/f_fss/c/fss/private-simple_packet.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-item_delete.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-item_delete.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-item_destroy.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-item_destroy.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-named_delete.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-named_delete.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-named_destroy.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-named_destroy.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-nest_delete.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-nest_delete.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-nest_destroy.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-nest_destroy.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-set_delete.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-set_delete.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-set_destroy.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-set_destroy.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-set_quote_delete.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-set_quote_delete.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-set_quote_destroy.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-set_quote_destroy.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-simple_packet_delete.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-simple_packet_delete.h create mode 100644 level_0/f_fss/tests/unit/c/test-fss-simple_packet_destroy.c create mode 100644 level_0/f_fss/tests/unit/c/test-fss-simple_packet_destroy.h delete mode 100644 level_0/f_string/c/string/private-dynamics.c delete mode 100644 level_0/f_string/c/string/private-dynamics.h delete mode 100644 level_0/f_string/c/string/private-map_multis.c delete mode 100644 level_0/f_string/c/string/private-map_multis.h delete mode 100644 level_0/f_string/c/string/private-map_multiss.c delete mode 100644 level_0/f_string/c/string/private-map_multiss.h delete mode 100644 level_0/f_string/c/string/private-maps.c delete mode 100644 level_0/f_string/c/string/private-maps.h delete mode 100644 level_0/f_string/c/string/private-mapss.c delete mode 100644 level_0/f_string/c/string/private-mapss.h delete mode 100644 level_0/f_string/c/string/private-quantityss.c delete mode 100644 level_0/f_string/c/string/private-quantityss.h delete mode 100644 level_0/f_string/c/string/private-ranges.c delete mode 100644 level_0/f_string/c/string/private-ranges.h delete mode 100644 level_0/f_string/c/string/private-rangess.c delete mode 100644 level_0/f_string/c/string/private-rangess.h delete mode 100644 level_0/f_string/c/string/private-triples.c delete mode 100644 level_0/f_string/c/string/private-triples.h delete mode 100644 level_0/f_string/c/string/private-tripless.c delete mode 100644 level_0/f_string/c/string/private-tripless.h create mode 100644 level_0/f_string/data/build/settings-mocks create mode 100644 level_0/f_string/tests/unit/c/mock-string.c create mode 100644 level_0/f_string/tests/unit/c/mock-string.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamics_destroy_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-dynamicss_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.c delete 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_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multis_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.c delete 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_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-map_multiss_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_decrease_by.c delete 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_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-maps_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-maps_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.c delete 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_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-mapss_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantitys_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.c delete 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_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-quantityss_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-ranges_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.c delete 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_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-rangess_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_decrease_by.c delete 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_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-triples_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-triples_resize.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_adjust.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_adjust.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.c delete 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_delete_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_delete_callback.h create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_destroy_callback.c create mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_destroy_callback.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_increase.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_increase.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_increase_by.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_increase_by.h delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_resize.c delete mode 100644 level_0/f_string/tests/unit/c/test-string-tripless_resize.h diff --git a/build/level_0/settings b/build/level_0/settings index fc8e543..203deb9 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -62,12 +62,6 @@ build_sources_library socket.c socket/address.c socket/socket.c build_sources_library status_string.c build_sources_library string.c build_sources_library private-string.c string/common.c -build_sources_library string/private-dynamics.c -build_sources_library string/private-maps.c string/private-mapss.c -build_sources_library string/private-map_multis.c string/private-map_multiss.c -build_sources_library string/private-quantitys.c string/private-quantityss.c -build_sources_library string/private-ranges.c string/private-rangess.c -build_sources_library string/private-triples.c string/private-tripless.c build_sources_library string/dynamic.c string/dynamics.c string/dynamicss.c build_sources_library string/map.c string/maps.c string/mapss.c build_sources_library string/map_multi.c string/map_multis.c string/map_multiss.c @@ -86,8 +80,8 @@ build_sources_library utf/map_multi.c utf/map_multis.c utf/map_multiss.c build_sources_library utf/static.c utf/statics.c utf/staticss.c build_sources_library utf/string.c utf/triple.c utf/triples.c utf/tripless.c build_sources_library utf/private-dynamic.c utf/private-dynamics.c utf/private-dynamicss.c -build_sources_library utf/private-maps.c utf/private-mapss.c build_sources_library utf/private-map_multis.c utf/private-map_multiss.c +build_sources_library utf/private-maps.c utf/private-mapss.c build_sources_library utf/private-string.c build_sources_library utf/private-triples.c utf/private-tripless.c diff --git a/build/monolithic/settings b/build/monolithic/settings index 6199846..1e19131 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -62,12 +62,6 @@ build_sources_library level_0/socket.c level_0/socket/address.c level_0/socket/s build_sources_library level_0/status_string.c build_sources_library level_0/string.c build_sources_library level_0/private-string.c level_0/string/common.c -build_sources_library level_0/string/private-dynamics.c -build_sources_library level_0/string/private-maps.c level_0/string/private-mapss.c -build_sources_library level_0/string/private-map_multis.c level_0/string/private-map_multiss.c -build_sources_library level_0/string/private-quantitys.c level_0/string/private-quantityss.c -build_sources_library level_0/string/private-ranges.c level_0/string/private-rangess.c -build_sources_library level_0/string/private-triples.c level_0/string/private-tripless.c build_sources_library level_0/string/dynamic.c level_0/string/dynamics.c level_0/string/dynamicss.c build_sources_library level_0/string/map.c level_0/string/maps.c level_0/string/mapss.c build_sources_library level_0/string/map_multi.c level_0/string/map_multis.c level_0/string/map_multiss.c diff --git a/build/stand_alone/byte_dump.settings b/build/stand_alone/byte_dump.settings index 962ba91..320f7d1 100644 --- a/build/stand_alone/byte_dump.settings +++ b/build/stand_alone/byte_dump.settings @@ -31,7 +31,7 @@ build_sources_program fll/level_0/memory.c fll/level_0/private-memory.c fll/leve build_sources_program fll/level_0/pipe.c build_sources_program fll/level_0/print.c fll/level_0/private-print.c fll/level_0/print/common.c fll/level_0/print/to.c fll/level_0/print/private-to.c build_sources_program fll/level_0/signal.c -build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c fll/level_0/string/dynamic.c fll/level_0/string/map.c fll/level_0/string/map_multi.c fll/level_0/string/private-map.c fll/level_0/string/private-map_multi.c fll/level_0/string/private-quantity.c fll/level_0/string/private-range.c fll/level_0/string/private-triple.c fll/level_0/string/quantity.c fll/level_0/string/range.c fll/level_0/string/static.c fll/level_0/string/triple.c +build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c fll/level_0/string/dynamic.c fll/level_0/string/map.c fll/level_0/string/map_multi.cfll/level_0/string/quantity.c fll/level_0/string/range.c fll/level_0/string/static.c fll/level_0/string/triple.c build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/private-utf_alphabetic.c fll/level_0/private-utf_combining.c fll/level_0/private-utf_control.c fll/level_0/private-utf_digit.c fll/level_0/private-utf_emoji.c fll/level_0/private-utf_numeric.c fll/level_0/private-utf_phonetic.c fll/level_0/private-utf_private.c fll/level_0/private-utf_punctuation.c fll/level_0/private-utf_subscript.c fll/level_0/private-utf_superscript.c fll/level_0/private-utf_symbol.c fll/level_0/private-utf_unassigned.c fll/level_0/private-utf_valid.c fll/level_0/private-utf_whitespace.c fll/level_0/private-utf_wide.c fll/level_0/private-utf_word.c fll/level_0/private-utf_zero_width.c build_sources_program fll/level_0/utf/common.c fll/level_0/utf/convert.c fll/level_0/utf/dynamic.c fll/level_0/utf/is.c fll/level_0/utf/is_character.c fll/level_0/utf/map.c fll/level_0/utf/map_multi.c fll/level_0/utf/static.c fll/level_0/utf/string.c fll/level_0/utf/triple.c fll/level_0/utf/private-dynamic.c fll/level_0/utf/private-map.c fll/level_0/utf/private-map_multi.c fll/level_0/utf/private-triple.c fll/level_0/utf/private-string.c diff --git a/build/stand_alone/fake.config.h b/build/stand_alone/fake.config.h index dc358ba..779efde 100644 --- a/build/stand_alone/fake.config.h +++ b/build/stand_alone/fake.config.h @@ -1441,41 +1441,25 @@ //#define _di_f_string_empty_s_ //#define _di_f_string_eol_s_ //#define _di_f_string_format_s_ -#define _di_f_string_map_multis_adjust_ #define _di_f_string_map_multis_append_ #define _di_f_string_map_multis_append_all_ -#define _di_f_string_map_multis_decimate_by_ -#define _di_f_string_map_multis_decrease_by_ -//#define _di_f_string_map_multis_increase_ -#define _di_f_string_map_multis_increase_by_ -//#define _di_f_string_map_multis_resize_ -#define _di_f_string_map_multiss_adjust_ +//#define _di_f_string_map_multis_delete_callback_ +#define _di_f_string_map_multis_destroy_callback_ #define _di_f_string_map_multiss_append_ #define _di_f_string_map_multiss_append_all_ -#define _di_f_string_map_multiss_decimate_by_ -#define _di_f_string_map_multiss_decrease_by_ -#define _di_f_string_map_multiss_increase_ -#define _di_f_string_map_multiss_increase_by_ -#define _di_f_string_map_multiss_resize_ +#define _di_f_string_map_multiss_delete_callback_ +#define _di_f_string_map_multiss_destroy_callback_ #define _di_f_string_map_multiss_t_ //#define _di_f_string_map_multis_t_ //#define _di_f_string_map_multi_t_ -#define _di_f_string_maps_adjust_ //#define _di_f_string_maps_append_ #define _di_f_string_maps_append_all_ -#define _di_f_string_maps_decimate_by_ -#define _di_f_string_maps_decrease_by_ -//#define _di_f_string_maps_increase_ -//#define _di_f_string_maps_increase_by_ -//#define _di_f_string_maps_resize_ -#define _di_f_string_mapss_adjust_ +//#define _di_f_string_maps_delete_callback_ +#define _di_f_string_maps_destroy_callback_ #define _di_f_string_mapss_append_ #define _di_f_string_mapss_append_all_ -#define _di_f_string_mapss_decimate_by_ -#define _di_f_string_mapss_decrease_by_ -#define _di_f_string_mapss_increase_ -#define _di_f_string_mapss_increase_by_ -#define _di_f_string_mapss_resize_ +#define _di_f_string_mapss_delete_callback_ +#define _di_f_string_mapss_destroy_callback_ #define _di_f_string_mapss_t_ //#define _di_f_string_maps_t_ //#define _di_f_string_map_t_ @@ -1489,42 +1473,22 @@ #define _di_f_string_prepend_assure_ #define _di_f_string_prepend_assure_nulless_ #define _di_f_string_prepend_nulless_ -#define _di_f_string_quantitys_adjust_ #define _di_f_string_quantitys_append_ #define _di_f_string_quantitys_append_all_ -#define _di_f_string_quantitys_decimate_by_ -#define _di_f_string_quantitys_decrease_by_ -#define _di_f_string_quantitys_increase_ -#define _di_f_string_quantitys_increase_by_ -#define _di_f_string_quantitys_resize_ -#define _di_f_string_quantityss_adjust_ #define _di_f_string_quantityss_append_ #define _di_f_string_quantityss_append_all_ -#define _di_f_string_quantityss_decimate_by_ -#define _di_f_string_quantityss_decrease_by_ -#define _di_f_string_quantityss_increase_ -#define _di_f_string_quantityss_increase_by_ -#define _di_f_string_quantityss_resize_ +#define _di_f_string_quantityss_delete_callback_ +#define _di_f_string_quantityss_destroy_callback_ #define _di_f_string_quantityss_t_ #define _di_f_string_quantitys_t_ #define _di_f_string_quantity_t_ #define _di_f_string_range_empty_c_ -#define _di_f_string_ranges_adjust_ #define _di_f_string_ranges_append_ #define _di_f_string_ranges_append_all_ -#define _di_f_string_ranges_decimate_by_ -#define _di_f_string_ranges_decrease_by_ -//#define _di_f_string_ranges_increase_ -#define _di_f_string_ranges_increase_by_ -//#define _di_f_string_ranges_resize_ -#define _di_f_string_rangess_adjust_ #define _di_f_string_rangess_append_ #define _di_f_string_rangess_append_all_ -#define _di_f_string_rangess_decimate_by_ -#define _di_f_string_rangess_decrease_by_ -//#define _di_f_string_rangess_increase_ -#define _di_f_string_rangess_increase_by_ -//#define _di_f_string_rangess_resize_ +//#define _di_f_string_rangess_delete_callback_ +#define _di_f_string_rangess_destroy_callback_ //#define _di_f_string_rangess_t_ //#define _di_f_string_ranges_t_ //#define _di_f_string_range_t_ @@ -1536,22 +1500,15 @@ //#define _di_f_string_statics_t_ //#define _di_f_string_static_t_ //#define _di_f_string_t_ -#define _di_f_string_triples_adjust_ #define _di_f_string_triples_append_ #define _di_f_string_triples_append_all_ -#define _di_f_string_triples_decimate_by_ -#define _di_f_string_triples_decrease_by_ -#define _di_f_string_triples_increase_ -#define _di_f_string_triples_increase_by_ -#define _di_f_string_triples_resize_ +#define _di_f_string_triples_delete_callback_ +#define _di_f_string_triples_destroy_callback_ #define _di_f_string_tripless_adjust_ #define _di_f_string_tripless_append_ #define _di_f_string_tripless_append_all_ -#define _di_f_string_tripless_decimate_by_ -#define _di_f_string_tripless_decrease_by_ -#define _di_f_string_tripless_increase_ -#define _di_f_string_tripless_increase_by_ -#define _di_f_string_tripless_resize_ +#define _di_f_string_tripless_delete_callback_ +#define _di_f_string_tripless_destroy_callback_ #define _di_f_string_tripless_t_ #define _di_f_string_triples_t_ #define _di_f_string_triple_t_ diff --git a/build/stand_alone/fake.settings b/build/stand_alone/fake.settings index bb225e2..abbcbb1 100644 --- a/build/stand_alone/fake.settings +++ b/build/stand_alone/fake.settings @@ -54,7 +54,7 @@ build_sources_program fll/level_0/pipe.c build_sources_program fll/level_0/print.c fll/level_0/private-print.c fll/level_0/print/common.c fll/level_0/print/to.c fll/level_0/print/private-to.c build_sources_program fll/level_0/rip.c fll/level_0/rip/utf.c fll/level_0/private-rip.c fll/level_0/rip/private-utf.c build_sources_program fll/level_0/signal.c -build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c fll/level_0/string/private-dynamics.c fll/level_0/string/private-maps.c fll/level_0/string/private-mapss.c fll/level_0/string/private-map_multis.c fll/level_0/string/private-map_multiss.c fll/level_0/string/private-quantitys.c fll/level_0/string/private-quantityss.c fll/level_0/string/private-ranges.c fll/level_0/string/private-rangess.c fll/level_0/string/private-triples.c fll/level_0/string/private-tripless.c +build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c build_sources_program fll/level_0/string/dynamic.c fll/level_0/string/dynamics.c fll/level_0/string/dynamicss.c fll/level_0/string/map.c fll/level_0/string/maps.c fll/level_0/string/mapss.c fll/level_0/string/map_multi.c fll/level_0/string/map_multis.c fll/level_0/string/map_multiss.c fll/level_0/string/quantity.c fll/level_0/string/quantitys.c fll/level_0/string/quantityss.c fll/level_0/string/range.c fll/level_0/string/ranges.c fll/level_0/string/rangess.c fll/level_0/string/static.c fll/level_0/string/statics.c fll/level_0/string/staticss.c fll/level_0/string/triple.c fll/level_0/string/triples.c fll/level_0/string/tripless.c build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/private-utf_alphabetic.c fll/level_0/private-utf_combining.c fll/level_0/private-utf_control.c fll/level_0/private-utf_digit.c fll/level_0/private-utf_emoji.c fll/level_0/private-utf_numeric.c fll/level_0/private-utf_phonetic.c fll/level_0/private-utf_private.c fll/level_0/private-utf_punctuation.c fll/level_0/private-utf_subscript.c fll/level_0/private-utf_superscript.c fll/level_0/private-utf_symbol.c fll/level_0/private-utf_unassigned.c fll/level_0/private-utf_valid.c fll/level_0/private-utf_whitespace.c fll/level_0/private-utf_wide.c fll/level_0/private-utf_word.c fll/level_0/private-utf_zero_width.c diff --git a/build/stand_alone/firewall.settings b/build/stand_alone/firewall.settings index f812271..ae4f259 100644 --- a/build/stand_alone/firewall.settings +++ b/build/stand_alone/firewall.settings @@ -40,7 +40,7 @@ build_sources_program fll/level_0/path.c fll/level_0/private-path.c fll/level_0/ build_sources_program fll/level_0/pipe.c build_sources_program fll/level_0/print.c fll/level_0/private-print.c fll/level_0/print/common.c fll/level_0/print/to.c fll/level_0/print/private-to.c build_sources_program fll/level_0/signal.c -build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c fll/level_0/string/dynamic.c fll/level_0/string/map.c fll/level_0/string/map_multi.c fll/level_0/string/private-map.c fll/level_0/string/private-map_multi.c fll/level_0/string/private-quantity.c fll/level_0/string/private-range.c fll/level_0/string/private-triple.c fll/level_0/string/quantity.c fll/level_0/string/range.c fll/level_0/string/static.c fll/level_0/string/triple.c +build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c fll/level_0/string/dynamic.c fll/level_0/string/map.c fll/level_0/string/map_multi.c fll/level_0/string/quantity.c fll/level_0/string/range.c fll/level_0/string/static.c fll/level_0/string/triple.c build_sources_program fll/level_0/thread.c fll/level_0/private-thread.c fll/level_0/thread/attribute.c fll/level_0/thread/barrier.c fll/level_0/thread/barrier_attribute.c fll/level_0/thread/condition.c fll/level_0/thread/condition_attribute.c fll/level_0/thread/id.c fll/level_0/thread/key.c fll/level_0/thread/lock.c fll/level_0/thread/lock_attribute.c fll/level_0/thread/mutex.c fll/level_0/thread/mutex_attribute.c fll/level_0/thread/once.c fll/level_0/thread/semaphore.c fll/level_0/thread/set.c fll/level_0/thread/spin.c build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/private-utf_alphabetic.c fll/level_0/private-utf_combining.c fll/level_0/private-utf_control.c fll/level_0/private-utf_digit.c fll/level_0/private-utf_emoji.c fll/level_0/private-utf_numeric.c fll/level_0/private-utf_phonetic.c fll/level_0/private-utf_private.c fll/level_0/private-utf_punctuation.c fll/level_0/private-utf_subscript.c fll/level_0/private-utf_superscript.c fll/level_0/private-utf_symbol.c fll/level_0/private-utf_unassigned.c fll/level_0/private-utf_valid.c fll/level_0/private-utf_whitespace.c fll/level_0/private-utf_wide.c fll/level_0/private-utf_word.c fll/level_0/private-utf_zero_width.c diff --git a/build/stand_alone/utf8.settings b/build/stand_alone/utf8.settings index 00ce151..8a0175e 100644 --- a/build/stand_alone/utf8.settings +++ b/build/stand_alone/utf8.settings @@ -31,7 +31,7 @@ build_sources_program fll/level_0/memory.c fll/level_0/private-memory.c fll/leve build_sources_program fll/level_0/pipe.c build_sources_program fll/level_0/print.c fll/level_0/private-print.c fll/level_0/print/common.c fll/level_0/print/to.c fll/level_0/print/private-to.c build_sources_program fll/level_0/signal.c -build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c fll/level_0/string/private-dynamics.c fll/level_0/string/private-maps.c fll/level_0/string/private-mapss.c fll/level_0/string/private-map_multis.c fll/level_0/string/private-map_multiss.c fll/level_0/string/private-quantitys.c fll/level_0/string/private-quantityss.c fll/level_0/string/private-ranges.c fll/level_0/string/private-rangess.c fll/level_0/string/private-triples.c fll/level_0/string/private-tripless.c +build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c build_sources_program fll/level_0/string/dynamic.c fll/level_0/string/dynamics.c fll/level_0/string/dynamicss.c fll/level_0/string/map.c fll/level_0/string/maps.c fll/level_0/string/mapss.c fll/level_0/string/map_multi.c fll/level_0/string/map_multis.c fll/level_0/string/map_multiss.c fll/level_0/string/quantity.c fll/level_0/string/quantitys.c fll/level_0/string/quantityss.c fll/level_0/string/range.c fll/level_0/string/ranges.c fll/level_0/string/rangess.c fll/level_0/string/static.c fll/level_0/string/statics.c fll/level_0/string/staticss.c fll/level_0/string/triple.c fll/level_0/string/triples.c fll/level_0/string/tripless.c build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/private-utf_alphabetic.c fll/level_0/private-utf_combining.c fll/level_0/private-utf_control.c fll/level_0/private-utf_digit.c fll/level_0/private-utf_emoji.c fll/level_0/private-utf_numeric.c fll/level_0/private-utf_phonetic.c fll/level_0/private-utf_private.c fll/level_0/private-utf_punctuation.c fll/level_0/private-utf_subscript.c fll/level_0/private-utf_superscript.c fll/level_0/private-utf_symbol.c fll/level_0/private-utf_unassigned.c fll/level_0/private-utf_valid.c fll/level_0/private-utf_whitespace.c fll/level_0/private-utf_wide.c fll/level_0/private-utf_word.c fll/level_0/private-utf_zero_width.c diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index 1858f1c..141426c 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -22,7 +22,7 @@ extern "C" { if (!total) return F_data_not; { - const f_status_t status = f_string_maps_increase_by(total, environment); + const f_status_t status = f_memory_array_increase_by(total, sizeof(f_string_map_t), (void **) &environment->array, &environment->used, &environment->size); if (F_status_is_error(status)) return status; } diff --git a/level_0/f_console/c/console.h b/level_0/f_console/c/console.h index 11d0b3c..4aed088 100644 --- a/level_0/f_console/c/console.h +++ b/level_0/f_console/c/console.h @@ -44,9 +44,9 @@ extern "C" { * F_okay on success. * F_data_not if the arguments.envp pointer is NULL or there are no environment variables in arguments.envp. * - * Errors (with error bit) from: f_string_maps_increase_by(). + * Errors (with error bit) from: f_memory_array_increase_by(). * - * @see f_string_maps_increase_by() + * @see f_memory_array_increase_by() */ #ifndef _di_f_console_environment_process_ extern f_status_t f_console_environment_process(const f_console_arguments_t arguments, f_string_maps_t * const environment); diff --git a/level_0/f_console/tests/unit/c/test-console-environment_process.c b/level_0/f_console/tests/unit/c/test-console-environment_process.c index 8a6f841..c103ce9 100644 --- a/level_0/f_console/tests/unit/c/test-console-environment_process.c +++ b/level_0/f_console/tests/unit/c/test-console-environment_process.c @@ -23,7 +23,7 @@ void test__f_console_environment_process__data_not(void **state) { assert_int_equal(status, F_data_not); } - f_string_maps_resize(0, &maps); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &maps.array, &maps.used, &maps.size, &f_string_maps_delete_callback); } // for } @@ -112,7 +112,7 @@ void test__f_console_environment_process__works(void **state) { } // for } - f_string_maps_resize(0, &maps); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &maps.array, &maps.used, &maps.size, &f_string_maps_delete_callback); } #ifdef __cplusplus diff --git a/level_0/f_environment/tests/unit/c/test-environment-get_all.c b/level_0/f_environment/tests/unit/c/test-environment-get_all.c index 32cfff3..d469f12 100644 --- a/level_0/f_environment/tests/unit/c/test-environment-get_all.c +++ b/level_0/f_environment/tests/unit/c/test-environment-get_all.c @@ -34,7 +34,7 @@ void test__f_environment_get_all__works(void **state) { assert_string_equal(environment.array[0].value.string, value.string); } - f_string_maps_resize(0, &environment); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &environment.array, &environment.used, &environment.size, &f_string_maps_delete_callback); } #ifdef __cplusplus diff --git a/level_0/f_file/tests/unit/c/test-file-read.c b/level_0/f_file/tests/unit/c/test-file-read.c index 9b8e433..dedac9c 100644 --- a/level_0/f_file/tests/unit/c/test-file-read.c +++ b/level_0/f_file/tests/unit/c/test-file-read.c @@ -122,7 +122,7 @@ void test__f_file_read__works(void **state) { const f_status_t status = f_file_read(file, &buffer); // Ensure string ends in NULL so that assert_string_equal() can be used. - f_string_dynamic_increase_by(1, &buffer); + f_memory_array_increase_by(1, sizeof(f_char_t), (void **) &buffer.string, &buffer.used, &buffer.size); buffer.string[buffer.used] = 0; assert_int_equal(status, F_okay_eof); diff --git a/level_0/f_file/tests/unit/c/test-file-read_block.c b/level_0/f_file/tests/unit/c/test-file-read_block.c index 49fbe93..1d397ed 100644 --- a/level_0/f_file/tests/unit/c/test-file-read_block.c +++ b/level_0/f_file/tests/unit/c/test-file-read_block.c @@ -112,7 +112,7 @@ void test__f_file_read_block__works(void **state) { const f_status_t status = f_file_read_block(file, &buffer); // Ensure string ends in NULL so that assert_string_equal() can be used. - f_string_dynamic_increase_by(1, &buffer); + f_memory_array_increase_by(1, sizeof(f_char_t), (void **) &buffer.string, &buffer.used, &buffer.size); buffer.string[buffer.used] = 0; assert_int_equal(status, F_okay); diff --git a/level_0/f_file/tests/unit/c/test-file-read_until.c b/level_0/f_file/tests/unit/c/test-file-read_until.c index 6d72140..5a4a01b 100644 --- a/level_0/f_file/tests/unit/c/test-file-read_until.c +++ b/level_0/f_file/tests/unit/c/test-file-read_until.c @@ -117,7 +117,7 @@ void test__f_file_read_until__works(void **state) { const f_status_t status = f_file_read_until(file, 6, &buffer); // Ensure string ends in NULL so that assert_string_equal() can be used. - f_string_dynamic_increase_by(1, &buffer); + f_memory_array_increase_by(1, sizeof(f_char_t), (void **) &buffer.string, &buffer.used, &buffer.size); buffer.string[buffer.used] = 0; assert_int_equal(status, F_okay_stop); @@ -141,7 +141,7 @@ void test__f_file_read_until__works(void **state) { const f_status_t status = f_file_read_until(file, 6, &buffer); // Ensure string ends in NULL so that assert_string_equal() can be used. - f_string_dynamic_increase_by(1, &buffer); + f_memory_array_increase_by(1, sizeof(f_char_t), (void **) &buffer.string, &buffer.used, &buffer.size); buffer.string[buffer.used] = 0; assert_int_equal(status, F_okay_eof); diff --git a/level_0/f_fss/c/fss/item.c b/level_0/f_fss/c/fss/item.c index 39acd56..a0f1149 100644 --- a/level_0/f_fss/c/fss/item.c +++ b/level_0/f_fss/c/fss/item.c @@ -10,7 +10,7 @@ extern "C" { if (!item) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return f_string_ranges_resize(0, &item->content); + return f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &item->content.array, &item->content.used, &item->content.size); } #endif // _di_f_fss_item_delete_ @@ -20,7 +20,7 @@ extern "C" { if (!item) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return f_string_ranges_adjust(0, &item->content); + return f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &item->content.array, &item->content.used, &item->content.size); } #endif // _di_f_fss_item_destroy_ @@ -33,7 +33,7 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_resize(0, &array[i].content); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].content.array, &array[i].content.used, &array[i].content.size); if (F_status_is_error(status)) return status; } // for } @@ -51,7 +51,7 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_adjust(0, &array[i].content); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].content.array, &array[i].content.used, &array[i].content.size); if (F_status_is_error(status)) return status; } // for } @@ -72,7 +72,7 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_resize(0, &array[i].array[j].content); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array[j].content.array, &array[i].array[j].content.used, &array[i].array[j].content.size); if (F_status_is_error(status)) return status; } // for @@ -99,7 +99,7 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_adjust(0, &array[i].array[j].content); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array[j].content.array, &array[i].array[j].content.used, &array[i].array[j].content.size); if (F_status_is_error(status)) return status; } // for diff --git a/level_0/f_fss/c/fss/item.h b/level_0/f_fss/c/fss/item.h index c80cebf..c3ccb51 100644 --- a/level_0/f_fss/c/fss/item.h +++ b/level_0/f_fss/c/fss/item.h @@ -126,9 +126,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_memory_array_resize(). * - * @see f_string_ranges_resize() + * @see f_memory_array_resize() */ #ifndef _di_f_fss_item_delete_ extern f_status_t f_fss_item_delete(f_fss_item_t * const item); @@ -145,9 +145,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). * - * @see f_string_ranges_adjust() + * @see f_memory_array_adjust() */ #ifndef _di_f_fss_item_destroy_ extern f_status_t f_fss_item_destroy(f_fss_item_t * const item); @@ -173,9 +173,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_memory_array_resize(). * - * @see f_string_ranges_resize() + * @see f_memory_array_resize() */ #ifndef _di_f_fss_items_delete_callback_ extern f_status_t f_fss_items_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -201,9 +201,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). * - * @see f_string_ranges_adjust() + * @see f_memory_array_adjust() */ #ifndef _di_f_fss_items_destroy_callback_ extern f_status_t f_fss_items_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -229,9 +229,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_memory_array_resize(). * - * @see f_string_ranges_resize() + * @see f_memory_array_resize() */ #ifndef _di_f_fss_itemss_delete_callback_ extern f_status_t f_fss_itemss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -257,9 +257,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). * - * @see f_string_ranges_adjust() + * @see f_memory_array_adjust() */ #ifndef _di_f_fss_itemss_destroy_callback_ extern f_status_t f_fss_itemss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); diff --git a/level_0/f_fss/c/fss/named.c b/level_0/f_fss/c/fss/named.c index 2142914..57801bc 100644 --- a/level_0/f_fss/c/fss/named.c +++ b/level_0/f_fss/c/fss/named.c @@ -11,13 +11,13 @@ extern "C" { #endif // _di_level_0_parameter_checking_ { - f_status_t status = f_string_ranges_resize(0, &named->objects); + f_status_t status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &named->objects.array, &named->objects.used, &named->objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &named->contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &named->contents.array, &named->contents.used, &named->contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; - status = f_memory_arrays_resize(0, sizeof(uint8_t), (void **) &named->quotess.array, &named->quotess.used, &named->quotess.size, &f_uint8ss_delete_callback); + status = f_memory_arrays_resize(0, sizeof(f_uint8s_t), (void **) &named->quotess.array, &named->quotess.used, &named->quotess.size, &f_uint8ss_delete_callback); if (F_status_is_error(status)) return status; } @@ -32,13 +32,13 @@ extern "C" { #endif // _di_level_0_parameter_checking_ { - f_status_t status = f_string_ranges_adjust(0, &named->objects); + f_status_t status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &named->objects.array, &named->objects.used, &named->objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &named->contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &named->contents.array, &named->contents.used, &named->contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; - status = f_memory_arrays_adjust(0, sizeof(uint8_t), (void **) &named->quotess.array, &named->quotess.used, &named->quotess.size, &f_uint8ss_destroy_callback); + status = f_memory_arrays_adjust(0, sizeof(f_uint8s_t), (void **) &named->quotess.array, &named->quotess.used, &named->quotess.size, &f_uint8ss_destroy_callback); if (F_status_is_error(status)) return status; } @@ -55,13 +55,13 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_resize(0, &array[i].objects); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].objects.array, &array[i].objects.used, &array[i].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &array[i].contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &array[i].contents.array, &array[i].contents.used, &array[i].contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; - status = f_memory_arrays_resize(0, sizeof(uint8_t), (void **) &array[i].quotess.array, &array[i].quotess.used, &array[i].quotess.size, &f_uint8ss_delete_callback); + status = f_memory_arrays_resize(0, sizeof(f_uint8s_t), (void **) &array[i].quotess.array, &array[i].quotess.used, &array[i].quotess.size, &f_uint8ss_delete_callback); if (F_status_is_error(status)) return status; } // for } @@ -79,13 +79,13 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_adjust(0, &array[i].objects); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].objects.array, &array[i].objects.used, &array[i].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &array[i].contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &array[i].contents.array, &array[i].contents.used, &array[i].contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; - status = f_memory_arrays_adjust(0, sizeof(uint8_t), (void **) &array[i].quotess.array, &array[i].quotess.used, &array[i].quotess.size, &f_uint8ss_destroy_callback); + status = f_memory_arrays_adjust(0, sizeof(f_uint8s_t), (void **) &array[i].quotess.array, &array[i].quotess.used, &array[i].quotess.size, &f_uint8ss_destroy_callback); if (F_status_is_error(status)) return status; } // for } @@ -106,13 +106,13 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_resize(0, &array[i].array[j].objects); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array[j].objects.array, &array[i].array[j].objects.used, &array[i].array[j].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &array[i].array[j].contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &array[i].array[j].contents.array, &array[i].array[j].contents.used, &array[i].array[j].contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; - status = f_memory_arrays_resize(0, sizeof(uint8_t), (void **) &array[i].array[j].quotess.array, &array[i].array[j].quotess.used, &array[i].array[j].quotess.size, &f_uint8ss_delete_callback); + status = f_memory_arrays_resize(0, sizeof(f_uint8s_t), (void **) &array[i].array[j].quotess.array, &array[i].array[j].quotess.used, &array[i].array[j].quotess.size, &f_uint8ss_delete_callback); if (F_status_is_error(status)) return status; } // for @@ -139,13 +139,13 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_adjust(0, &array[i].array[j].objects); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array[j].objects.array, &array[i].array[j].objects.used, &array[i].array[j].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &array[i].array[j].contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &array[i].array[j].contents.array, &array[i].array[j].contents.used, &array[i].array[j].contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; - status = f_memory_arrays_adjust(0, sizeof(uint8_t), (void **) &array[i].array[j].quotess.array, &array[i].array[j].quotess.used, &array[i].array[j].quotess.size, &f_uint8ss_destroy_callback); + status = f_memory_arrays_adjust(0, sizeof(f_uint8s_t), (void **) &array[i].array[j].quotess.array, &array[i].array[j].quotess.used, &array[i].array[j].quotess.size, &f_uint8ss_destroy_callback); if (F_status_is_error(status)) return status; } // for diff --git a/level_0/f_fss/c/fss/named.h b/level_0/f_fss/c/fss/named.h index 41bab47..d048b13 100644 --- a/level_0/f_fss/c/fss/named.h +++ b/level_0/f_fss/c/fss/named.h @@ -40,6 +40,7 @@ extern "C" { #define f_fss_named_t_initialize { f_string_range_t_initialize, f_string_ranges_t_initialize, f_string_rangess_t_initialize, f_uint8ss_t_initialize } #define macro_f_fss_named_t_initialize_1(name, objects, contents, quotess) macro_f_number_unsigneds_t_initialize_1(name, objects, contents, quotess) + #define macro_f_fss_named_t_initialize_2(name) macro_f_number_unsigneds_t_initialize_1(name, f_string_ranges_t_initialize, f_string_rangess_t_initialize, f_uint8ss_t_initialize) #define macro_f_fss_named_t_clear(named) \ macro_f_string_range_t_clear(named.name) \ @@ -107,12 +108,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_memory_arrays_resize(). * - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() + * @see f_memory_array_resize() * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_named_delete_ @@ -130,12 +129,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). * Errors (with error bit) from: f_memory_arrays_adjust(). * - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() + * @see f_memory_array_adjust() * @see f_memory_arrays_adjust() */ #ifndef _di_f_fss_named_destroy_ @@ -162,12 +159,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_memory_arrays_resize(). * - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() + * @see f_memory_arrays_resize() * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_nameds_delete_callback_ @@ -194,12 +189,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). * Errors (with error bit) from: f_memory_arrays_adjust(). * - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() + * @see f_memory_array_adjust() * @see f_memory_arrays_adjust() */ #ifndef _di_f_fss_nameds_destroy_callback_ @@ -226,12 +219,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_memory_arrays_resize(). * - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() + * @see f_memory_array_resize() * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_namedss_delete_callback_ @@ -258,12 +249,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). * Errors (with error bit) from: f_memory_arrays_adjust(). * - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() + * @see f_memory_array_adjust() * @see f_memory_arrays_adjust() */ #ifndef _di_f_fss_namedss_destroy_callback_ diff --git a/level_0/f_fss/c/fss/nest.c b/level_0/f_fss/c/fss/nest.c index f41ae0c..c0acd1d 100644 --- a/level_0/f_fss/c/fss/nest.c +++ b/level_0/f_fss/c/fss/nest.c @@ -18,7 +18,7 @@ extern "C" { for (j = 0; j < nest->depth[i].size; ++j) { - status = f_string_ranges_resize(0, &nest->depth[i].array[j].content); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &nest->depth[i].array[j].content.array, &nest->depth[i].array[j].content.used, &nest->depth[i].array[j].content.size); if (F_status_is_error(status)) return status; } // for @@ -47,7 +47,7 @@ extern "C" { for (j = 0; j < nest->depth[i].size; ++j) { - status = f_string_ranges_adjust(0, &nest->depth[i].array[j].content); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &nest->depth[i].array[j].content.array, &nest->depth[i].array[j].content.used, &nest->depth[i].array[j].content.size); if (F_status_is_error(status)) return status; } // for @@ -77,7 +77,7 @@ extern "C" { for (k = 0; k < array[i].depth[j].size; ++k) { - status = f_string_ranges_resize(0, &array[i].depth[j].array[k].content); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].depth[j].array[k].content.array, &array[i].depth[j].array[k].content.used, &array[i].depth[j].array[k].content.size); if (F_status_is_error(status)) return status; } // for @@ -113,7 +113,7 @@ extern "C" { for (k = 0; k < array[i].depth[j].size; ++k) { - status = f_string_ranges_adjust(0, &array[i].depth[j].array[k].content); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].depth[j].array[k].content.array, &array[i].depth[j].array[k].content.used, &array[i].depth[j].array[k].content.size); if (F_status_is_error(status)) return status; } // for @@ -152,7 +152,7 @@ extern "C" { for (l = 0; l < array[i].array[j].depth[k].size; ++l) { - status = f_string_ranges_resize(0, &array[i].array[j].depth[k].array[l].content); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array[j].depth[k].array[l].content.array, &array[i].array[j].depth[k].array[l].content.used, &array[i].array[j].depth[k].array[l].content.size); if (F_status_is_error(status)) return status; } // for @@ -197,7 +197,7 @@ extern "C" { for (l = 0; l < array[i].array[j].depth[k].size; ++l) { - status = f_string_ranges_adjust(0, &array[i].array[j].depth[k].array[l].content); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array[j].depth[k].array[l].content.array, &array[i].array[j].depth[k].array[l].content.used, &array[i].array[j].depth[k].array[l].content.size); if (F_status_is_error(status)) return status; } // for diff --git a/level_0/f_fss/c/fss/nest.h b/level_0/f_fss/c/fss/nest.h index b04567e..05e1a38 100644 --- a/level_0/f_fss/c/fss/nest.h +++ b/level_0/f_fss/c/fss/nest.h @@ -103,9 +103,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_memory_array_resize(). * - * @see f_string_ranges_resize() + * @see f_memory_array_resize() */ #ifndef _di_f_fss_nest_delete_ extern f_status_t f_fss_nest_delete(f_fss_nest_t * const nest); @@ -122,11 +122,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). * - * @see f_memory_array_resize() - * @see f_string_ranges_resize() + * @see f_memory_array_adjust() */ #ifndef _di_f_fss_nest_destroy_ extern f_status_t f_fss_nest_destroy(f_fss_nest_t * const nest); diff --git a/level_0/f_fss/c/fss/private-item.c b/level_0/f_fss/c/fss/private-item.c deleted file mode 100644 index 6437f6a..0000000 --- a/level_0/f_fss/c/fss/private-item.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "../fss.h" -#include "private-item.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) || !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) - f_status_t private_f_fss_items_adjust(const f_number_unsigned_t length, f_fss_items_t * const items) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < items->size; ++i) { - - status = f_string_ranges_adjust(0, &items->array[i].content); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_fss_item_t), (void **) &items->array, &items->used, &items->size); - } -#endif // !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) || !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) - -#if !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) || !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) - f_status_t private_f_fss_items_resize(const f_number_unsigned_t length, f_fss_items_t * const items) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < items->size; ++i) { - - status = f_string_ranges_resize(0, &items->array[i].content); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_fss_item_t), (void **) &items->array, &items->used, &items->size); - } -#endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) || !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_fss/c/fss/private-item.h b/level_0/f_fss/c/fss/private-item.h deleted file mode 100644 index ffb2e5c..0000000 --- a/level_0/f_fss/c/fss/private-item.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: FSS - * API Version: 0.7 - * 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_fss_item_h -#define _PRIVATE_F_fss_item_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 items - * The items to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * Errors (with error bit) from: f_string_dynamic_adjust(). - * - * @see f_memory_array_adjust() - * @see f_string_dynamic_adjust() - * - * @see f_fss_items_adjust() - * @see f_fss_items_decimate_by() - * @see f_fss_nest_adjust() - * @see f_fss_nest_decimate_by() - */ -#if !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) || !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) - extern f_status_t private_f_fss_items_adjust(const f_number_unsigned_t length, f_fss_items_t * const items) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) || !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_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 items - * The items to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_fss_items_decrease_by() - * @see f_fss_items_resize() - * @see f_fss_nest_decrease_by() - * @see f_fss_nest_resize() - */ -#if !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) || !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) - extern f_status_t private_f_fss_items_resize(const f_number_unsigned_t length, f_fss_items_t * const items) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) || !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_fss_item_h diff --git a/level_0/f_fss/c/fss/private-named.c b/level_0/f_fss/c/fss/private-named.c deleted file mode 100644 index 2b6dbc3..0000000 --- a/level_0/f_fss/c/fss/private-named.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "../fss.h" -#include "private-named.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) - f_status_t private_f_fss_named_adjust(const f_number_unsigned_t length, f_fss_named_t * const named) { - - f_status_t status = f_string_ranges_adjust(length, &named->objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_adjust(length, &named->contents); - if (F_status_is_error(status)) return status; - - status = f_memory_arrays_adjust(length, sizeof(f_uint8s_t), (void **) &named->quotess.array, &named->quotess.used, &named->quotess.size, &f_uint8s_delete_callback); - if (F_status_is_error(status)) return status; - - return F_okay; - } -#endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) - -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_named_increase_) || !defined(_di_f_fss_named_increase_by_) || !defined(_di_f_fss_nameds_resize_) - f_status_t private_f_fss_named_resize(const f_number_unsigned_t length, f_fss_named_t * const named) { - - f_status_t status = f_string_ranges_resize(length, &named->objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_resize(length, &named->contents); - if (F_status_is_error(status)) return status; - - status = f_memory_arrays_resize(length, sizeof(f_uint8s_t), (void **) &named->quotess.array, &named->quotess.used, &named->quotess.size, &f_uint8s_delete_callback); - if (F_status_is_error(status)) return status; - - return F_okay; - } -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_named_increase_) || !defined(_di_f_fss_named_increase_by_) || !defined(_di_f_fss_nameds_resize_) - -#if !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) - f_status_t private_f_fss_nameds_adjust(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < nameds->size; ++i) { - - status = private_f_fss_named_adjust(0, &nameds->array[i]); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_fss_named_t), (void **) &nameds->array, &nameds->used, &nameds->size); - } -#endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) - -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) - f_status_t private_f_fss_nameds_resize(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < nameds->size; ++i) { - - status = private_f_fss_named_resize(0, &nameds->array[i]); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_fss_named_t), (void **) &nameds->array, &nameds->used, &nameds->size); - } -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_fss/c/fss/private-named.h b/level_0/f_fss/c/fss/private-named.h deleted file mode 100644 index 3f8e4fc..0000000 --- a/level_0/f_fss/c/fss/private-named.h +++ /dev/null @@ -1,144 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: FSS - * API Version: 0.7 - * 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_fss_named_h -#define _PRIVATE_F_fss_named_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 named - * The named to adjust. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_arrays_adjust(). - * Errors (with error bit) from: macro_f_string_ranges_t_adjust(). - * Errors (with error bit) from: macro_f_string_rangess_t_adjust(). - * - * @see f_memory_arrays_adjust() - * @see macro_f_string_ranges_t_adjust() - * @see macro_f_string_rangess_t_adjust() - * - * @see f_fss_nameds_adjust() - * @see f_fss_nameds_decimate_by() - */ -#if !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) - extern f_status_t private_f_fss_named_adjust(const f_number_unsigned_t length, f_fss_named_t * const named) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_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 named - * The named to resize. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_arrays_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). - * - * @see f_memory_arrays_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() - * - * @see f_fss_nameds_decrease_by() - * @see f_fss_nameds_resize() - */ -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) - extern f_status_t private_f_fss_named_resize(const f_number_unsigned_t length, f_fss_named_t * const named) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param nameds - * The nameds to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * Errors (with error bit) from: f_memory_arrays_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). - * - * @see f_memory_array_adjust() - * @see f_memory_arrays_adjust() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() - * - * @see f_fss_nameds_adjust() - * @see f_fss_nameds_decimate_by() - */ -#if !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) - extern f_status_t private_f_fss_nameds_adjust(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_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 nameds - * The nameds to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_memory_arrays_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). - * - * @see f_memory_array_resize() - * @see f_memory_arrays_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() - * - * @see f_fss_nameds_decrease_by() - * @see f_fss_nameds_increase() - * @see f_fss_nameds_increase_by() - * @see f_fss_nameds_resize() - */ -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_named_increase_) || !defined(_di_f_fss_named_increase_by_) || !defined(_di_f_fss_nameds_resize_) - extern f_status_t private_f_fss_nameds_resize(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_named_increase_) || !defined(_di_f_fss_named_increase_by_) || !defined(_di_f_fss_nameds_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_fss_named_h diff --git a/level_0/f_fss/c/fss/private-nest.c b/level_0/f_fss/c/fss/private-nest.c deleted file mode 100644 index 4b42204..0000000 --- a/level_0/f_fss/c/fss/private-nest.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "../fss.h" -#include "private-item.h" -#include "private-nest.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) - f_status_t private_f_fss_nest_adjust(const f_number_unsigned_t length, f_fss_nest_t * const nest) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < nest->size; ++i) { - - status = private_f_fss_items_adjust(0, &nest->depth[i]); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_fss_items_t), (void **) &nest->depth, &nest->used, &nest->size); - } -#endif // !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) - -#if !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) - f_status_t private_f_fss_nest_resize(const f_number_unsigned_t length, f_fss_nest_t * const nest) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < nest->size; ++i) { - - status = private_f_fss_items_resize(0, &nest->depth[i]); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_fss_items_t), (void **) &nest->depth, &nest->used, &nest->size); - } -#endif // !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) - -#if !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_decimate_by_) - f_status_t private_f_fss_nests_adjust(const f_number_unsigned_t length, f_fss_nests_t *nests) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < nests->size; ++i) { - - status = private_f_fss_nest_adjust(0, &nests->array[i]); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_fss_nest_t), (void **) &nests->array, &nests->used, &nests->size); - } -#endif // !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_decimate_by_) - -#if !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_) - f_status_t private_f_fss_nests_resize(const f_number_unsigned_t length, f_fss_nests_t * const nests) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < nests->size; ++i) { - - status = private_f_fss_nest_resize(0, &nests->array[i]); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_fss_nest_t), (void **) &nests->array, &nests->used, &nests->size); - } -#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_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_fss/c/fss/private-nest.h b/level_0/f_fss/c/fss/private-nest.h deleted file mode 100644 index 1d2e7da..0000000 --- a/level_0/f_fss/c/fss/private-nest.h +++ /dev/null @@ -1,132 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: FSS - * API Version: 0.7 - * 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_fss_nest_h -#define _PRIVATE_F_fss_nest_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 nest - * The nest to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * Errors (with error bit) from: f_string_dynamic_adjust(). - * - * @see f_memory_array_adjust() - * @see f_string_dynamic_adjust() - * - * @see f_fss_nests_adjust() - * @see f_fss_nests_decimate_by() - */ -#if !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) - extern f_status_t private_f_fss_nest_adjust(const f_number_unsigned_t length, f_fss_nest_t * const nest) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_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 nest - * The nest to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_fss_nests_decrease_by() - * @see f_fss_nests_resize() - */ -#if !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) - extern f_status_t private_f_fss_nest_resize(const f_number_unsigned_t length, f_fss_nest_t * const nest) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param nests - * The nests to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * Errors (with error bit) from: f_string_dynamic_adjust(). - * - * @see f_memory_array_adjust() - * @see f_string_dynamic_adjust() - * - * @see f_fss_nests_adjust() - * @see f_fss_nests_decimate_by() - */ -#if !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_decimate_by_) - extern f_status_t private_f_fss_nests_adjust(const f_number_unsigned_t length, f_fss_nests_t * const nests) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_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 nests - * The nests to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_fss_nests_decrease_by() - * @see f_fss_nests_increase() - * @see f_fss_nests_increase_by() - * @see f_fss_nests_resize() - */ -#if !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_) - extern f_status_t private_f_fss_nests_resize(const f_number_unsigned_t length, f_fss_nests_t * const nests) F_attribute_visibility_internal_d; -#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_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_fss_nest_h diff --git a/level_0/f_fss/c/fss/private-set.c b/level_0/f_fss/c/fss/private-set.c deleted file mode 100644 index 3c443a0..0000000 --- a/level_0/f_fss/c/fss/private-set.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "../fss.h" -#include "private-set.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_fss_set_adjust_) || !defined(_di_f_fss_set_decimate_by_) - f_status_t private_f_fss_set_adjust(const f_number_unsigned_t length, f_fss_set_t * const set) { - - f_status_t status = f_string_ranges_adjust(length, &set->objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_adjust(length, &set->contents); - if (F_status_is_error(status)) return status; - - return F_okay; - } -#endif // !defined(_di_f_fss_set_adjust_) || !defined(_di_f_fss_set_decimate_by_) - -#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) - f_status_t private_f_fss_set_resize(const f_number_unsigned_t length, f_fss_set_t *set) { - - f_status_t status = f_string_ranges_resize(length, &set->objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_resize(length, &set->contents); - if (F_status_is_error(status)) return status; - - return F_okay; - } -#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) - -#if !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_decimate_by_) - f_status_t private_f_fss_sets_adjust(const f_number_unsigned_t length, f_fss_sets_t * const sets) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < sets->size; ++i) { - - status = f_string_ranges_adjust(0, &sets->array[i].objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_adjust(0, &sets->array[i].contents); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_fss_set_t), (void **) &sets->array, &sets->used, &sets->size); - } -#endif // !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_decimate_by_) - -#if !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_resize_) - f_status_t private_f_fss_sets_resize(const f_number_unsigned_t length, f_fss_sets_t * const sets) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < sets->size; ++i) { - - status = f_string_ranges_resize(0, &sets->array[i].objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_resize(0, &sets->array[i].contents); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_fss_set_t), (void **) &sets->array, &sets->used, &sets->size); - } -#endif // !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_fss/c/fss/private-set.h b/level_0/f_fss/c/fss/private-set.h deleted file mode 100644 index 808c5ad..0000000 --- a/level_0/f_fss/c/fss/private-set.h +++ /dev/null @@ -1,136 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: FSS - * API Version: 0.7 - * 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_fss_set_h -#define _PRIVATE_F_fss_set_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 set - * The set to adjust. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). - * - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() - * - * @see f_fss_set_adjust() - * @see f_fss_set_decimate_by() - */ -#if !defined(_di_f_fss_set_adjust_) || !defined(_di_f_fss_set_decimate_by_) - extern f_status_t private_f_fss_set_adjust(const f_number_unsigned_t length, f_fss_set_t * const set) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_adjust_) || !defined(_di_f_fss_set_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 set - * The set to resize. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). - * - * @see f_string_ranges_resize - * @see f_string_rangess_resize()() - * - * @see f_fss_set_decrease_by() - * @see f_fss_set_increase() - * @see f_fss_set_increase_by() - * @see f_fss_set_resize() - */ -#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) - extern f_status_t private_f_fss_set_resize(const f_number_unsigned_t length, f_fss_set_t * const set) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param sets - * The sets to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). - * - * @see f_memory_array_adjust() - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() - * - * @see f_fss_sets_adjust() - * @see f_fss_sets_decimate_by() - */ -#if !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_decimate_by_) - extern f_status_t private_f_fss_sets_adjust(const f_number_unsigned_t length, f_fss_sets_t * const sets) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_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 sets - * The sets to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). - * - * @see f_memory_array_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() - * - * @see f_fss_sets_decrease_by() - * @see f_fss_sets_resize() - */ -#if !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_resize_) - extern f_status_t private_f_fss_sets_resize(const f_number_unsigned_t length, f_fss_sets_t * const sets) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_fss_set_h diff --git a/level_0/f_fss/c/fss/private-set_quote.c b/level_0/f_fss/c/fss/private-set_quote.c deleted file mode 100644 index 3d6e54b..0000000 --- a/level_0/f_fss/c/fss/private-set_quote.c +++ /dev/null @@ -1,100 +0,0 @@ -#include "../fss.h" -#include "private-set_quote.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_fss_set_quote_adjust_) || !defined(_di_f_fss_set_quote_decimate_by_) - f_status_t private_f_fss_set_quote_adjust(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote) { - - f_status_t status = f_string_ranges_adjust(length, &set_quote->objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_adjust(length, &set_quote->contents); - if (F_status_is_error(status)) return status; - - status = f_memory_array_adjust(length, sizeof(uint8_t), (void **) &set_quote->objects_quote.array, &set_quote->objects_quote.used, &set_quote->objects_quote.size); - if (F_status_is_error(status)) return status; - - status = f_memory_arrays_adjust(length, sizeof(f_uint8s_t), (void **) &set_quote->contents_quote.array, &set_quote->contents_quote.used, &set_quote->contents_quote.size, &f_uint8s_delete_callback); - if (F_status_is_error(status)) return status; - - return F_okay; - } -#endif // !defined(_di_f_fss_set_quote_adjust_) || !defined(_di_f_fss_set_quote_decimate_by_) - -#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) - f_status_t private_f_fss_set_quote_resize(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote) { - - f_status_t status = f_string_ranges_resize(length, &set_quote->objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_resize(length, &set_quote->contents); - if (F_status_is_error(status)) return status; - - status = f_memory_array_resize(length, sizeof(uint8_t), (void **) &set_quote->objects_quote.array, &set_quote->objects_quote.used, &set_quote->objects_quote.size); - if (F_status_is_error(status)) return status; - - status = f_memory_arrays_resize(length, sizeof(f_uint8s_t), (void **) &set_quote->contents_quote.array, &set_quote->contents_quote.used, &set_quote->contents_quote.size, &f_uint8s_delete_callback); - if (F_status_is_error(status)) return status; - - return F_okay; - } -#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) - -#if !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_decimate_by_) - f_status_t private_f_fss_set_quotes_adjust(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < set_quotes->size; ++i) { - - status = f_string_ranges_adjust(0, &set_quotes->array[i].objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_adjust(0, &set_quotes->array[i].contents); - if (F_status_is_error(status)) return status; - - status = f_memory_array_adjust(0, sizeof(uint8_t), (void **) &set_quotes->array[i].objects_quote.array, &set_quotes->array[i].objects_quote.used, &set_quotes->array[i].objects_quote.size); - if (F_status_is_error(status)) return status; - - status = f_memory_arrays_adjust(0, sizeof(f_uint8s_t), (void **) &set_quotes->array[i].contents_quote.array, &set_quotes->array[i].contents_quote.used, &set_quotes->array[i].contents_quote.size, &f_uint8s_delete_callback); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_fss_set_quote_t), (void **) &set_quotes->array, &set_quotes->used, &set_quotes->size); - } -#endif // !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_decimate_by_) - -#if !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_resize_) - f_status_t private_f_fss_set_quotes_resize(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < set_quotes->size; ++i) { - - status = f_string_ranges_resize(0, &set_quotes->array[i].objects); - if (F_status_is_error(status)) return status; - - status = f_string_rangess_resize(0, &set_quotes->array[i].contents); - if (F_status_is_error(status)) return status; - - status = f_memory_array_resize(0, sizeof(uint8_t), (void **) &set_quotes->array[i].objects_quote.array, &set_quotes->array[i].objects_quote.used, &set_quotes->array[i].objects_quote.size); - if (F_status_is_error(status)) return status; - - status = f_memory_arrays_resize(0, sizeof(f_uint8s_t), (void **) &set_quotes->array[i].contents_quote.array, &set_quotes->array[i].contents_quote.used, &set_quotes->array[i].contents_quote.size, &f_uint8s_delete_callback); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_fss_set_quote_t), (void **) &set_quotes->array, &set_quotes->used, &set_quotes->size); - } -#endif // !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_fss/c/fss/private-set_quote.h b/level_0/f_fss/c/fss/private-set_quote.h deleted file mode 100644 index 15fb877..0000000 --- a/level_0/f_fss/c/fss/private-set_quote.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: FSS - * API Version: 0.7 - * 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_fss_set_quote_h -#define _PRIVATE_F_fss_set_quote_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 set_quote - * The set_quote to adjust. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_memory_arrays_resize(). - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). - * - * @see f_memory_array_resize() - * @see f_memory_arrays_resize() - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() - * - * @see f_fss_set_quote_adjust() - * @see f_fss_set_quote_decimate_by() - */ -#if !defined(_di_f_fss_set_quote_adjust_) || !defined(_di_f_fss_set_quote_decimate_by_) - extern f_status_t private_f_fss_set_quote_adjust(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_quote_adjust_) || !defined(_di_f_fss_set_quote_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 set_quote - * The set_quote to resize. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_memory_arrays_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). - * - * @see f_memory_array_resize() - * @see f_memory_arrays_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() - * - * @see f_fss_set_quote_decrease_by() - * @see f_fss_set_quote_resize() - */ -#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_resize_) - extern f_status_t private_f_fss_set_quote_resize(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param set_quotes - * The set_quotes to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * Errors (with error bit) from: f_memory_arrays_adjust(). - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). - * - * @see f_memory_array_adjust() - * @see f_memory_arrays_adjust() - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() - * - * @see f_fss_set_quotes_decrease_by() - * @see f_fss_set_quotes_adjust() - * @see f_memory_adjust() - */ -#if !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_decimate_by_) - extern f_status_t private_f_fss_set_quotes_adjust(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_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 set_quotes - * The set_quotes to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * Errors (with error bit) from: f_memory_arrays_adjust(). - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). - * - * @see f_memory_array_adjust() - * @see f_memory_arrays_adjust() - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() - * - * @see f_fss_set_quotes_decrease_by() - * @see f_fss_set_quotes_increase() - * @see f_fss_set_quotes_increase_by() - * @see f_fss_set_quotes_resize() - * @see f_memory_resize() - */ -#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) - extern f_status_t private_f_fss_set_quotes_resize(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_fss_set_quote_h diff --git a/level_0/f_fss/c/fss/private-simple_packet.c b/level_0/f_fss/c/fss/private-simple_packet.c deleted file mode 100644 index 1fa9913..0000000 --- a/level_0/f_fss/c/fss/private-simple_packet.c +++ /dev/null @@ -1,168 +0,0 @@ -#include "../fss.h" -#include "private-simple_packet.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_rangess_append_) - extern f_status_t private_f_fss_simple_packet_ranges_append(const f_fss_simple_packet_range_t source, f_fss_simple_packet_ranges_t *destination) { - - const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_fss_simple_packet_range_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - - destination->array[destination->used++] = source; - - return F_okay; - } -#endif // !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_rangess_append_) - -#if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_) - extern f_status_t private_f_fss_simple_packet_ranges_append_all(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_ranges_t *destination) { - - { - const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fss_simple_packet_range_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - } - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - destination->array[destination->used++] = source.array[i]; - } // for - - return F_okay; - } -#endif // !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_) - -#if !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_) - f_status_t private_f_fss_simple_packet_rangess_adjust(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < rangess->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_fss_simple_packet_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_fss_simple_packet_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size); - } -#endif // !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_) - -#if !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) - f_status_t private_f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < rangess->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_fss_simple_packet_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_fss_simple_packet_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size); - } -#endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) - -#if !defined(_di_f_fss_simple_packets_adjust_) || !defined(_di_f_fss_simple_packets_decimate_by_) - f_status_t private_f_fss_simple_packets_adjust(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < packets->size; ++i) { - - status = f_string_dynamic_adjust(0, &packets->array[i].payload); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_fss_simple_packet_t), (void **) &packets->array, &packets->used, &packets->size); - } -#endif // !defined(_di_f_fss_simple_packets_adjust_) || !defined(_di_f_fss_simple_packets_decimate_by_) - -#if !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packetss_append_) - extern f_status_t private_f_fss_simple_packets_append(const f_fss_simple_packet_t source, f_fss_simple_packets_t *destination) { - - const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_fss_simple_packet_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - - destination->array[destination->used++] = source; - - return F_okay; - } -#endif // !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packetss_append_) - -#if !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packets_append_all_) || !defined(_di_f_fss_simple_packetss_append_all_) - extern f_status_t private_f_fss_simple_packets_append_all(const f_fss_simple_packets_t source, f_fss_simple_packets_t *destination) { - - { - const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fss_simple_packet_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - } - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - destination->array[destination->used++] = source.array[i]; - } // for - - return F_okay; - } -#endif // !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packets_append_all_) || !defined(_di_f_fss_simple_packetss_append_all_) - -#if !defined(_di_f_fss_simple_packets_decrease_by_) || !defined(_di_f_fss_simple_packets_resize_) - f_status_t private_f_fss_simple_packets_resize(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < packets->size; ++i) { - - status = f_memory_array(0, sizeof(f_char_t), (void **) &packets->array[i].payload.string, &packets->array[i].payload.used, &packets->array[i].payload.size); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_fss_simple_packet_t), (void **) &packets->array, &packets->used, &packets->size); - } -#endif // !defined(_di_f_fss_simple_packets_decrease_by_) || !defined(_di_f_fss_simple_packets_resize_) - -#if !defined(_di_f_fss_simple_packetss_adjust_) || !defined(_di_f_fss_simple_packetss_decimate_by_) - f_status_t private_f_fss_simple_packetss_adjust(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < packetss->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_fss_simple_packet_t), (void **) &packetss->array[i].array, &packetss->array[i].used, &packetss->array[i].size); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_fss_simple_packets_t), (void **) &packetss->array, &packetss->used, &packetss->size); - } -#endif // !defined(_di_f_fss_simple_packetss_adjust_) || !defined(_di_f_fss_simple_packetss_decimate_by_) - -#if !defined(_di_f_fss_simple_packetss_decrease_by_) || !defined(_di_f_fss_simple_packetss_resize_) - f_status_t private_f_fss_simple_packetss_resize(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) { - - { - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < packetss->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_fss_simple_packet_t), (void **) &packetss->array[i].array, &packetss->array[i].used, &packetss->array[i].size); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_fss_simple_packets_t), (void **) &packetss->array, &packetss->used, &packetss->size); - } -#endif // !defined(_di_f_fss_simple_packetss_decrease_by_) || !defined(_di_f_fss_simple_packetss_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_fss/c/fss/private-simple_packet.h b/level_0/f_fss/c/fss/private-simple_packet.h deleted file mode 100644 index c64619d..0000000 --- a/level_0/f_fss/c/fss/private-simple_packet.h +++ /dev/null @@ -1,284 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: FSS - * API Version: 0.7 - * 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_fss_simple_packet_h -#define _PRIVATE_F_fss_simple_packet_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Private implementation for appending the range array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source range to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * Success from f_memory_array_increase(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase(). - * - * @see f_memory_array_increase() - * - * @see f_fss_simple_packet_ranges_append() - * @see f_fss_simple_packet_rangess_append() - */ -#if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_rangess_append_) - extern f_status_t private_f_fss_simple_packet_ranges_append(const f_fss_simple_packet_range_t source, f_fss_simple_packet_ranges_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_rangess_append_) - -/** - * Private implementation for appending the range array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source ranges to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * Success from f_memory_array_increase_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase_by(). - * - * @see f_memory_array_increase_by() - * - * @see f_fss_simple_packet_ranges_append_all() - * @see f_fss_simple_packet_rangess_append() - * @see f_fss_simple_packet_rangess_append_all() - */ -#if !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_) - extern f_status_t private_f_fss_simple_packet_ranges_append_all(const f_fss_simple_packet_ranges_t source, f_fss_simple_packet_ranges_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packet_ranges_append_) || !defined(_di_f_fss_simple_packet_ranges_append_all_) || !defined(_di_f_fss_simple_packet_rangess_append_all_) - -/** - * Private implementation for resizing the rangess array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param rangess - * The rangess array to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * - * @see f_memory_array_adjust() - * - * @see f_fss_simple_packet_rangess_decrease_by() - * @see f_fss_simple_packet_rangess_adjust() - */ -#if !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_) - extern f_status_t private_f_fss_simple_packet_rangess_adjust(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packet_rangess_adjust_) || !defined(_di_f_fss_simple_packet_rangess_decimate_by_) - -/** - * Private implementation for resizing the rangess array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param rangess - * The rangess array to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_fss_simple_packet_rangess_decrease_by() - * @see f_fss_simple_packet_rangess_resize() - */ -#if !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) - extern f_status_t private_f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_) - -/** - * Private implementation for resizing the simple packet array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param packets - * The simple packet array to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * - * @see f_memory_array_adjust() - * - * @see f_fss_simple_packets_decrease_by() - * @see f_fss_simple_packets_adjust() - */ -#if !defined(_di_f_fss_simple_packets_adjust_) || !defined(_di_f_fss_simple_packets_decimate_by_) - extern f_status_t private_f_fss_simple_packets_adjust(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packets_adjust_) || !defined(_di_f_fss_simple_packets_decimate_by_) - -/** - * Private implementation for appending the simple packet array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source simple packet to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * Success from f_memory_array_increase(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase(). - * - * @see f_memory_array_increase() - * - * @see f_fss_simple_packets_append() - * @see f_fss_simple_packetss_append() - */ -#if !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packetss_append_) - extern f_status_t private_f_fss_simple_packets_append(const f_fss_simple_packet_t source, f_fss_simple_packets_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packetss_append_) - -/** - * Private implementation for appending the simple packet array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source simple packets to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * Success from f_memory_array_increase_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase_by(). - * - * @see f_memory_array_increase_by() - * - * @see f_fss_simple_packets_append_all() - * @see f_fss_simple_packetss_append() - * @see f_fss_simple_packetss_append_all() - */ -#if !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packets_append_all_) || !defined(_di_f_fss_simple_packetss_append_all_) - extern f_status_t private_f_fss_simple_packets_append_all(const f_fss_simple_packets_t source, f_fss_simple_packets_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packets_append_all_) || !defined(_di_f_fss_simple_packetss_append_all_) - -/** - * Private implementation for resizing the simple packet array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param packets - * The simple packet array to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_fss_simple_packets_decrease_by() - * @see f_fss_simple_packets_resize() - */ -#if !defined(_di_f_fss_simple_packets_decrease_by_) || !defined(_di_f_fss_simple_packets_resize_) - extern f_status_t private_f_fss_simple_packets_resize(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packets_decrease_by_) || !defined(_di_f_fss_simple_packets_resize_) - -/** - * Private implementation for resizing the simple packets array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param packetss - * The simple packets array to adjust. - * - * @return - * Success from f_memory_array_adjust(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * - * @see f_memory_array_adjust() - * - * @see f_fss_simple_packetss_decrease_by() - * @see f_fss_simple_packetss_adjust() - */ -#if !defined(_di_f_fss_simple_packetss_adjust_) || !defined(_di_f_fss_simple_packetss_decimate_by_) - extern f_status_t private_f_fss_simple_packetss_adjust(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packetss_adjust_) || !defined(_di_f_fss_simple_packetss_decimate_by_) - -/** - * Private implementation for resizing the simple packets array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param packetss - * The simple packets array to resize. - * - * @return - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_fss_simple_packetss_decrease_by() - * @see f_fss_simple_packetss_resize() - */ -#if !defined(_di_f_fss_simple_packetss_decrease_by_) || !defined(_di_f_fss_simple_packetss_resize_) - extern f_status_t private_f_fss_simple_packetss_resize(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_simple_packetss_decrease_by_) || !defined(_di_f_fss_simple_packetss_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_fss_simple_packet_h diff --git a/level_0/f_fss/c/fss/set.c b/level_0/f_fss/c/fss/set.c index 6a98008..7563c59 100644 --- a/level_0/f_fss/c/fss/set.c +++ b/level_0/f_fss/c/fss/set.c @@ -11,10 +11,10 @@ extern "C" { #endif // _di_level_0_parameter_checking_ { - f_status_t status = f_string_ranges_resize(0, &set->objects); + f_status_t status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &set->objects.array, &set->objects.used, &set->objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &set->contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &set->contents.array, &set->contents.used, &set->contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; } @@ -29,10 +29,10 @@ extern "C" { #endif // _di_level_0_parameter_checking_ { - f_status_t status = f_string_ranges_adjust(0, &set->objects); + f_status_t status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &set->objects.array, &set->objects.used, &set->objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &set->contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &set->contents.array, &set->contents.used, &set->contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; } @@ -49,10 +49,10 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_resize(0, &array[i].objects); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].objects.array, &array[i].objects.used, &array[i].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &array[i].contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &array[i].contents.array, &array[i].contents.used, &array[i].contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; } // for } @@ -70,10 +70,10 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_adjust(0, &array[i].objects); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].objects.array, &array[i].objects.used, &array[i].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &array[i].contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &array[i].contents.array, &array[i].contents.used, &array[i].contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; } // for } @@ -94,10 +94,10 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_resize(0, &array[i].array[j].objects); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array[j].objects.array, &array[i].array[j].objects.used, &array[i].array[j].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &array[i].array[j].contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &array[i].array[j].contents.array, &array[i].array[j].contents.used, &array[i].array[j].contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; } // for @@ -124,10 +124,10 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_adjust(0, &array[i].array[j].objects); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array[j].objects.array, &array[i].array[j].objects.used, &array[i].array[j].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &array[i].array[j].contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &array[i].array[j].contents.array, &array[i].array[j].contents.used, &array[i].array[j].contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; } // for diff --git a/level_0/f_fss/c/fss/set.h b/level_0/f_fss/c/fss/set.h index f011e78..fdd98ec 100644 --- a/level_0/f_fss/c/fss/set.h +++ b/level_0/f_fss/c/fss/set.h @@ -100,11 +100,11 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_memory_arrays_resize(). * - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_set_delete_ extern f_status_t f_fss_set_delete(f_fss_set_t * const set); @@ -121,11 +121,11 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). + * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_memory_arrays_adjust(). * - * @see f_string_ranges_adjust - * @see f_string_rangess_adjust()() + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ #ifndef _di_f_fss_set_destroy_ extern f_status_t f_fss_set_destroy(f_fss_set_t * const set); @@ -152,8 +152,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_memory_arrays_resize(). * * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_sets_delete_callback_ extern f_status_t f_fss_sets_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -179,9 +181,11 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_memory_arrays_resize(). * - * @see f_memory_array_adjust() + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_sets_destroy_callback_ extern f_status_t f_fss_sets_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -208,8 +212,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_memory_arrays_resize(). * * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_setss_delete_callback_ extern f_status_t f_fss_setss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -235,9 +241,11 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_memory_arrays_resize(). * - * @see f_memory_array_adjust() + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_setss_destroy_callback_ extern f_status_t f_fss_setss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); diff --git a/level_0/f_fss/c/fss/set_quote.c b/level_0/f_fss/c/fss/set_quote.c index f29a02a..6a75cd6 100644 --- a/level_0/f_fss/c/fss/set_quote.c +++ b/level_0/f_fss/c/fss/set_quote.c @@ -11,16 +11,16 @@ extern "C" { #endif // _di_level_0_parameter_checking_ { - f_status_t status = f_string_ranges_resize(0, &set_quote->objects); + f_status_t status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &set_quote->objects.array, &set_quote->objects.used, &set_quote->objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &set_quote->contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &set_quote->contents.array, &set_quote->contents.used, &set_quote->contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; status = f_memory_array_resize(0, sizeof(uint8_t), (void **) &set_quote->objects_quote.array, &set_quote->objects_quote.used, &set_quote->objects_quote.size); if (F_status_is_error(status)) return status; - status = f_memory_arrays_resize(0, sizeof(uint8_t), (void **) &set_quote->contents_quote.array, &set_quote->contents_quote.used, &set_quote->contents_quote.size, &f_uint8ss_delete_callback); + status = f_memory_arrays_resize(0, sizeof(f_uint8s_t), (void **) &set_quote->contents_quote.array, &set_quote->contents_quote.used, &set_quote->contents_quote.size, &f_uint8ss_delete_callback); if (F_status_is_error(status)) return status; } @@ -35,16 +35,16 @@ extern "C" { #endif // _di_level_0_parameter_checking_ { - f_status_t status = f_string_ranges_adjust(0, &set_quote->objects); + f_status_t status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &set_quote->objects.array, &set_quote->objects.used, &set_quote->objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &set_quote->contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &set_quote->contents.array, &set_quote->contents.used, &set_quote->contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; status = f_memory_array_adjust(0, sizeof(uint8_t), (void **) &set_quote->objects_quote.array, &set_quote->objects_quote.used, &set_quote->objects_quote.size); if (F_status_is_error(status)) return status; - status = f_memory_arrays_adjust(0, sizeof(uint8_t), (void **) &set_quote->contents_quote.array, &set_quote->contents_quote.used, &set_quote->contents_quote.size, &f_uint8ss_destroy_callback); + status = f_memory_arrays_adjust(0, sizeof(f_uint8s_t), (void **) &set_quote->contents_quote.array, &set_quote->contents_quote.used, &set_quote->contents_quote.size, &f_uint8ss_destroy_callback); if (F_status_is_error(status)) return status; } @@ -61,16 +61,16 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_resize(0, &array[i].objects); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].objects.array, &array[i].objects.used, &array[i].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &array[i].contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &array[i].contents.array, &array[i].contents.used, &array[i].contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; status = f_memory_array_resize(0, sizeof(uint8_t), (void **) &array[i].objects_quote.array, &array[i].objects_quote.used, &array[i].objects_quote.size); if (F_status_is_error(status)) return status; - status = f_memory_arrays_resize(0, sizeof(uint8_t), (void **) &array[i].contents_quote.array, &array[i].contents_quote.used, &array[i].contents_quote.size, &f_uint8ss_delete_callback); + status = f_memory_arrays_resize(0, sizeof(f_uint8s_t), (void **) &array[i].contents_quote.array, &array[i].contents_quote.used, &array[i].contents_quote.size, &f_uint8ss_delete_callback); if (F_status_is_error(status)) return status; } // for } @@ -88,16 +88,16 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_adjust(0, &array[i].objects); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].objects.array, &array[i].objects.used, &array[i].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &array[i].contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &array[i].contents.array, &array[i].contents.used, &array[i].contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; status = f_memory_array_adjust(0, sizeof(uint8_t), (void **) &array[i].objects_quote.array, &array[i].objects_quote.used, &array[i].objects_quote.size); if (F_status_is_error(status)) return status; - status = f_memory_arrays_adjust(0, sizeof(uint8_t), (void **) &array[i].contents_quote.array, &array[i].contents_quote.used, &array[i].contents_quote.size, &f_uint8ss_destroy_callback); + status = f_memory_arrays_adjust(0, sizeof(f_uint8s_t), (void **) &array[i].contents_quote.array, &array[i].contents_quote.used, &array[i].contents_quote.size, &f_uint8ss_destroy_callback); if (F_status_is_error(status)) return status; } // for } @@ -118,16 +118,16 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_resize(0, &array[i].array[j].objects); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array[j].objects.array, &array[i].array[j].objects.used, &array[i].array[j].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_resize(0, &array[i].array[j].contents); + status = f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &array[i].array[j].contents.array, &array[i].array[j].contents.used, &array[i].array[j].contents.size, &f_string_rangess_delete_callback); if (F_status_is_error(status)) return status; status = f_memory_array_resize(0, sizeof(uint8_t), (void **) &array[i].array[j].objects_quote.array, &array[i].array[j].objects_quote.used, &array[i].array[j].objects_quote.size); if (F_status_is_error(status)) return status; - status = f_memory_arrays_resize(0, sizeof(uint8_t), (void **) &array[i].array[j].contents_quote.array, &array[i].array[j].contents_quote.used, &array[i].array[j].contents_quote.size, &f_uint8ss_delete_callback); + status = f_memory_arrays_resize(0, sizeof(f_uint8s_t), (void **) &array[i].array[j].contents_quote.array, &array[i].array[j].contents_quote.used, &array[i].array[j].contents_quote.size, &f_uint8ss_delete_callback); if (F_status_is_error(status)) return status; } // for @@ -154,21 +154,21 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_adjust(0, &array[i].array[j].objects); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array[j].objects.array, &array[i].array[j].objects.used, &array[i].array[j].objects.size); if (F_status_is_error(status)) return status; - status = f_string_rangess_adjust(0, &array[i].array[j].contents); + status = f_memory_arrays_adjust(0, sizeof(f_string_ranges_t), (void **) &array[i].array[j].contents.array, &array[i].array[j].contents.used, &array[i].array[j].contents.size, &f_string_rangess_destroy_callback); if (F_status_is_error(status)) return status; status = f_memory_array_adjust(0, sizeof(uint8_t), (void **) &array[i].array[j].objects_quote.array, &array[i].array[j].objects_quote.used, &array[i].array[j].objects_quote.size); if (F_status_is_error(status)) return status; - status = f_memory_arrays_adjust(0, sizeof(uint8_t), (void **) &array[i].array[j].contents_quote.array, &array[i].array[j].contents_quote.used, &array[i].array[j].contents_quote.size, &f_uint8ss_destroy_callback); + status = f_memory_arrays_adjust(0, sizeof(f_uint8s_t), (void **) &array[i].array[j].contents_quote.array, &array[i].array[j].contents_quote.used, &array[i].array[j].contents_quote.size, &f_uint8ss_destroy_callback); if (F_status_is_error(status)) return status; } // for if (array[i].size) { - status = f_memory_array_resize(0, sizeof(f_fss_set_quote_t), (void **) &array[i].array, &array[i].used, &array[i].size); + status = f_memory_array_adjust(0, sizeof(f_fss_set_quote_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; } } // for diff --git a/level_0/f_fss/c/fss/set_quote.h b/level_0/f_fss/c/fss/set_quote.h index 697a8f5..70093ef 100644 --- a/level_0/f_fss/c/fss/set_quote.h +++ b/level_0/f_fss/c/fss/set_quote.h @@ -109,13 +109,9 @@ extern "C" { * * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_memory_arrays_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). * * @see f_memory_array_resize() * @see f_memory_arrays_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() */ #ifndef _di_f_fss_set_quote_delete_ extern f_status_t f_fss_set_quote_delete(f_fss_set_quote_t * const set_quote); @@ -134,13 +130,9 @@ extern "C" { * * Errors (with error bit) from: f_memory_array_adjust(). * Errors (with error bit) from: f_memory_arrays_adjust(). - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). * * @see f_memory_array_adjust() * @see f_memory_arrays_adjust() - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() */ #ifndef _di_f_fss_set_quote_destroy_ extern f_status_t f_fss_set_quote_destroy(f_fss_set_quote_t * const set_quote); @@ -168,13 +160,9 @@ extern "C" { * * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_memory_arrays_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). * * @see f_memory_array_resize() * @see f_memory_arrays_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() */ #ifndef _di_f_fss_set_quotes_delete_callback_ extern f_status_t f_fss_set_quotes_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -202,13 +190,9 @@ extern "C" { * * Errors (with error bit) from: f_memory_array_adjust(). * Errors (with error bit) from: f_memory_arrays_adjust(). - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). * * @see f_memory_array_adjust() * @see f_memory_arrays_adjust() - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() */ #ifndef _di_f_fss_set_quotes_destroy_callback_ extern f_status_t f_fss_set_quotes_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -236,13 +220,9 @@ extern "C" { * * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_memory_arrays_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). - * Errors (with error bit) from: f_string_rangess_resize(). * * @see f_memory_array_resize() * @see f_memory_arrays_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() */ #ifndef _di_f_fss_set_quotess_delete_callback_ extern f_status_t f_fss_set_quotess_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -270,13 +250,9 @@ extern "C" { * * Errors (with error bit) from: f_memory_array_adjust(). * Errors (with error bit) from: f_memory_arrays_adjust(). - * Errors (with error bit) from: f_string_ranges_adjust(). - * Errors (with error bit) from: f_string_rangess_adjust(). * * @see f_memory_array_adjust() * @see f_memory_arrays_adjust() - * @see f_string_ranges_adjust() - * @see f_string_rangess_adjust() */ #ifndef _di_f_fss_set_quotess_destroy_callback_ extern f_status_t f_fss_set_quotess_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); diff --git a/level_0/f_fss/c/fss/simple_packet.c b/level_0/f_fss/c/fss/simple_packet.c index 50de7b0..f76e60e 100644 --- a/level_0/f_fss/c/fss/simple_packet.c +++ b/level_0/f_fss/c/fss/simple_packet.c @@ -5,22 +5,32 @@ extern "C" { #endif #ifndef _di_f_fss_simple_packet_delete_ - f_status_t f_fss_simple_packet_delete(f_fss_simple_packet_t * const packet) { + f_status_t f_fss_simple_packet_delete(f_fss_simple_packet_t * const simple_packet) { #ifndef _di_level_0_parameter_checking_ - if (!packet) return F_status_set_error(F_parameter); + if (!simple_packet) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return f_memory_array_resize(0, sizeof(f_char_t), (void **) &packet->payload.string, &packet->payload.used, &packet->payload.size); + { + const f_status_t status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &simple_packet->payload.string, &simple_packet->payload.used, &simple_packet->payload.size); + if (F_status_is_error(status)) return status; + } + + return F_okay; } #endif // _di_f_fss_simple_packet_delete_ #ifndef _di_f_fss_simple_packet_destroy_ - f_status_t f_fss_simple_packet_destroy(f_fss_simple_packet_t * const packet) { + f_status_t f_fss_simple_packet_destroy(f_fss_simple_packet_t * const simple_packet) { #ifndef _di_level_0_parameter_checking_ - if (!packet) return F_status_set_error(F_parameter); + if (!simple_packet) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return f_memory_array_adjust(0, sizeof(f_char_t), (void **) &packet->payload.string, &packet->payload.used, &packet->payload.size); + { + const f_status_t status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &simple_packet->payload.string, &simple_packet->payload.used, &simple_packet->payload.size); + if (F_status_is_error(status)) return status; + } + + return F_okay; } #endif // _di_f_fss_simple_packet_destroy_ diff --git a/level_0/f_fss/c/fss/simple_packet.h b/level_0/f_fss/c/fss/simple_packet.h index 33f6669..e1ef287 100644 --- a/level_0/f_fss/c/fss/simple_packet.h +++ b/level_0/f_fss/c/fss/simple_packet.h @@ -193,10 +193,10 @@ extern "C" { #endif // _di_f_fss_simple_packet_rangess_t_ /** - * Delete a simple packet. + * Delete a FSS-000F (Simple Packet). * - * @param packet - * The simple packet to delete. + * @param simple_packet + * The FSS-000F (Simple Packet) to delete. * * @return * F_okay on success. @@ -204,18 +204,20 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_resize(). + * Errors (with error bit) from: f_memory_arrays_resize(). * * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ #ifndef _di_f_fss_simple_packet_delete_ - extern f_status_t f_fss_simple_packet_delete(f_fss_simple_packet_t * const packet); + extern f_status_t f_fss_simple_packet_delete(f_fss_simple_packet_t * const simple_packet); #endif // _di_f_fss_simple_packet_delete_ /** - * Destroy a simple packet. + * Destroy a FSS-000F (Simple Packet). * - * @param packet - * The simple packet to destroy. + * @param simple_packet + * The FSS-000F (Simple Packet) to destroy. * * @return * F_okay on success. @@ -223,11 +225,13 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_memory_arrays_adjust(). * * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ #ifndef _di_f_fss_simple_packet_destroy_ - extern f_status_t f_fss_simple_packet_destroy(f_fss_simple_packet_t * const packet); + extern f_status_t f_fss_simple_packet_destroy(f_fss_simple_packet_t * const simple_packet); #endif // _di_f_fss_simple_packet_destroy_ /** diff --git a/level_0/f_fss/data/build/settings-mocks b/level_0/f_fss/data/build/settings-mocks index f1ed649..4c5a30a 100644 --- a/level_0/f_fss/data/build/settings-mocks +++ b/level_0/f_fss/data/build/settings-mocks @@ -30,7 +30,8 @@ build_language c build_libraries -lc build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_utf -build_sources_library fss.c fss/common.c fss/item.c fss/named.c fss/nest.c fss/quote.c fss/set.c fss/set_quote.c fss/simple_packet.c ../../tests/unit/c/mock-fss.c +build_sources_library fss.c fss/common.c fss/item.c fss/named.c fss/nest.c fss/quote.c fss/set.c fss/set_quote.c fss/simple_packet.c +build_sources_library ../../tests/unit/c/mock-fss.c build_sources_headers fss.h fss/common.h fss/item.h fss/named.h fss/nest.h fss/quote.h fss/set.h fss/set_quote.h fss/simple_packet.h @@ -65,7 +66,3 @@ flags -Wl,--wrap=f_memory_array_adjust flags -Wl,--wrap=f_memory_array_resize flags -Wl,--wrap=f_memory_arrays_adjust flags -Wl,--wrap=f_memory_arrays_resize -flags -Wl,--wrap=f_string_ranges_adjust -flags -Wl,--wrap=f_string_ranges_resize -flags -Wl,--wrap=f_string_rangess_adjust -flags -Wl,--wrap=f_string_rangess_resize diff --git a/level_0/f_fss/data/build/settings-tests b/level_0/f_fss/data/build/settings-tests index dd57ac0..0ea8923 100644 --- a/level_0/f_fss/data/build/settings-tests +++ b/level_0/f_fss/data/build/settings-tests @@ -26,13 +26,18 @@ build_libraries -lc -lcmocka build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_utf -lf_fss build_sources_program test-fss-apply_delimit.c test-fss-apply_delimit_range.c test-fss-count_lines.c test-fss-count_lines_range.c test-fss-fail_utf.c test-fss-fail_utf_to_false.c test-fss-is_combining.c test-fss-is_graph.c test-fss-is_space.c test-fss-is_zero_width.c test-fss-seek_to_eol.c test-fss-skip_past_delimit.c test-fss-skip_past_space.c - -build_sources_program test-fss-items_destroy_callback.c test-fss-items_delete_callback.c test-fss-itemss_destroy_callback.c test-fss-itemss_delete_callback.c -build_sources_program test-fss-nameds_destroy_callback.c test-fss-nameds_delete_callback.c test-fss-namedss_destroy_callback.c test-fss-namedss_delete_callback.c -build_sources_program test-fss-nests_destroy_callback.c test-fss-nests_delete_callback.c test-fss-nestss_destroy_callback.c test-fss-nestss_delete_callback.c -build_sources_program test-fss-sets_destroy_callback.c test-fss-sets_delete_callback.c test-fss-setss_destroy_callback.c test-fss-setss_delete_callback.c -build_sources_program test-fss-set_quotes_destroy_callback.c test-fss-set_quotes_delete_callback.c test-fss-set_quotess_destroy_callback.c test-fss-set_quotess_delete_callback.c -build_sources_program test-fss-simple_packets_destroy_callback.c test-fss-simple_packets_delete_callback.c test-fss-simple_packetss_destroy_callback.c test-fss-simple_packetss_delete_callback.c +build_sources_program test-fss-item_delete.c test-fss-item_destroy.c +build_sources_program test-fss-items_delete_callback.c test-fss-items_destroy_callback.c test-fss-itemss_delete_callback.c test-fss-itemss_destroy_callback.c +build_sources_program test-fss-named_delete.c test-fss-named_destroy.c +build_sources_program test-fss-nameds_delete_callback.c test-fss-nameds_destroy_callback.c test-fss-namedss_delete_callback.c test-fss-namedss_destroy_callback.c +build_sources_program test-fss-nest_delete.c test-fss-nest_destroy.c +build_sources_program test-fss-nests_delete_callback.c test-fss-nests_destroy_callback.c test-fss-nestss_delete_callback.c test-fss-nestss_destroy_callback.c +build_sources_program test-fss-set_delete.c test-fss-set_destroy.c +build_sources_program test-fss-sets_delete_callback.c test-fss-sets_destroy_callback.c test-fss-setss_delete_callback.c test-fss-setss_destroy_callback.c +build_sources_program test-fss-set_quote_delete.c test-fss-set_quote_destroy.c +build_sources_program test-fss-set_quotes_delete_callback.c test-fss-set_quotes_destroy_callback.c test-fss-set_quotess_delete_callback.c test-fss-set_quotess_destroy_callback.c +build_sources_program test-fss-simple_packet_delete.c test-fss-simple_packet_destroy.c +build_sources_program test-fss-simple_packets_delete_callback.c test-fss-simple_packets_destroy_callback.c test-fss-simple_packetss_delete_callback.c test-fss-simple_packetss_destroy_callback.c build_sources_program test-fss.c diff --git a/level_0/f_fss/tests/unit/c/mock-fss.c b/level_0/f_fss/tests/unit/c/mock-fss.c index 7f1d864..abcaaa5 100644 --- a/level_0/f_fss/tests/unit/c/mock-fss.c +++ b/level_0/f_fss/tests/unit/c/mock-fss.c @@ -75,74 +75,6 @@ f_status_t __wrap_f_memory_arrays_resize(const f_number_unsigned_t length, const return mock_type(f_status_t); } -f_status_t __wrap_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure) { - - if (mock_unwrap) { - return __real_f_string_ranges_adjust(length, structure); - } - - if (!structure) return F_status_set_error(F_parameter_not); - - const bool failure = mock_type(bool); - - if (failure) return mock_type(f_status_t); - - structure->size = length; - - return mock_type(f_status_t); -} - -f_status_t __wrap_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure) { - - if (mock_unwrap) { - return __real_f_string_ranges_resize(length, structure); - } - - if (!structure) return F_status_set_error(F_parameter_not); - - const bool failure = mock_type(bool); - - if (failure) return mock_type(f_status_t); - - structure->size = length; - - return mock_type(f_status_t); -} - -f_status_t __wrap_f_string_rangess_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure) { - - if (mock_unwrap) { - return __real_f_string_rangess_adjust(length, structure); - } - - if (!structure) return F_status_set_error(F_parameter_not); - - const bool failure = mock_type(bool); - - if (failure) return mock_type(f_status_t); - - structure->size = length; - - return mock_type(f_status_t); -} - -f_status_t __wrap_f_string_rangess_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure) { - - if (mock_unwrap) { - return __real_f_string_rangess_resize(length, structure); - } - - if (!structure) return F_status_set_error(F_parameter_not); - - const bool failure = mock_type(bool); - - if (failure) return mock_type(f_status_t); - - structure->size = length; - - return mock_type(f_status_t); -} - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_fss/tests/unit/c/mock-fss.h b/level_0/f_fss/tests/unit/c/mock-fss.h index 029174b..46ba698 100644 --- a/level_0/f_fss/tests/unit/c/mock-fss.h +++ b/level_0/f_fss/tests/unit/c/mock-fss.h @@ -36,21 +36,11 @@ extern f_status_t __real_f_memory_array_resize(const f_number_unsigned_t length, extern f_status_t __real_f_memory_arrays_adjust(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array)); extern f_status_t __real_f_memory_arrays_resize(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array)); -extern f_status_t __real_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure); -extern f_status_t __real_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure); -extern f_status_t __real_f_string_rangess_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure); -extern f_status_t __real_f_string_rangess_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure); - extern f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); extern f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); extern f_status_t __wrap_f_memory_arrays_adjust(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array)); extern f_status_t __wrap_f_memory_arrays_resize(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size, f_status_t (*callback)(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array)); -extern f_status_t __wrap_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure); -extern f_status_t __wrap_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure); -extern f_status_t __wrap_f_string_rangess_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure); -extern f_status_t __wrap_f_string_rangess_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure); - //extern long __wrap_sysconf(int name); #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-item_delete.c b/level_0/f_fss/tests/unit/c/test-fss-item_delete.c new file mode 100644 index 0000000..4c310f4 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-item_delete.c @@ -0,0 +1,58 @@ +#include "test-fss.h" +#include "test-fss-item_delete.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_item_delete__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_item_t data = f_fss_item_t_initialize; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_item_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_item_delete__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_item_delete(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_item_delete__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_item_t data = f_fss_item_t_initialize; + + { + const f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &data.content.array, &data.content.used, &data.content.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_item_delete(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.content.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-item_delete.h b/level_0/f_fss/tests/unit/c/test-fss-item_delete.h new file mode 100644 index 0000000..1a36aa6 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-item_delete.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__item_delete +#define _TEST__F_fss__item_delete + +/** + * Test that the function fails. + * + * @see f_fss_item_delete() + */ +extern void test__f_fss_item_delete__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_item_delete() + */ +extern void test__f_fss_item_delete__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_item_delete() + */ +extern void test__f_fss_item_delete__works(void **state); + +#endif // _TEST__F_fss__item_delete diff --git a/level_0/f_fss/tests/unit/c/test-fss-item_destroy.c b/level_0/f_fss/tests/unit/c/test-fss-item_destroy.c new file mode 100644 index 0000000..5731daf --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-item_destroy.c @@ -0,0 +1,58 @@ +#include "test-fss.h" +#include "test-fss-item_destroy.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_item_destroy__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_item_t data = f_fss_item_t_initialize; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_item_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_item_destroy__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_item_destroy(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_item_destroy__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_item_t data = f_fss_item_t_initialize; + + { + const f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &data.content.array, &data.content.used, &data.content.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_item_destroy(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.content.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-item_destroy.h b/level_0/f_fss/tests/unit/c/test-fss-item_destroy.h new file mode 100644 index 0000000..d1a5d48 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-item_destroy.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__item_destroy +#define _TEST__F_fss__item_destroy + +/** + * Test that the function fails. + * + * @see f_fss_item_destroy() + */ +extern void test__f_fss_item_destroy__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_item_destroy() + */ +extern void test__f_fss_item_destroy__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_item_destroy() + */ +extern void test__f_fss_item_destroy__works(void **state); + +#endif // _TEST__F_fss__item_destroy diff --git a/level_0/f_fss/tests/unit/c/test-fss-items_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-items_delete_callback.c index 6424a54..7d64b62 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-items_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-items_delete_callback.c @@ -16,8 +16,8 @@ void test__f_fss_items_delete_callback__fails(void **state) { f_fss_items_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_items_delete_callback(0, 1, (void *) datas_array); @@ -28,22 +28,28 @@ void test__f_fss_items_delete_callback__fails(void **state) { void test__f_fss_items_delete_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_item_t data = f_fss_item_t_initialize; - f_fss_item_t data_array[] = { data }; - f_fss_items_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_fss_items_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_fss_items_t datas = f_fss_items_t_initialize; + { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_item_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].content.array, &datas.array[0].content.used, &datas.array[0].content.size); + assert_int_equal(status, F_okay); + } - const f_status_t status = f_fss_items_delete_callback(0, length, (void *) datas_array); + { + const f_status_t status = f_fss_items_delete_callback(0, length, (void *) datas.array); assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].content.size, 0); } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-items_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-items_destroy_callback.c index 24f8426..f77b19e 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-items_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-items_destroy_callback.c @@ -16,8 +16,8 @@ void test__f_fss_items_destroy_callback__fails(void **state) { f_fss_items_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_items_destroy_callback(0, 1, (void *) datas_array); @@ -28,22 +28,28 @@ void test__f_fss_items_destroy_callback__fails(void **state) { void test__f_fss_items_destroy_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_item_t data = f_fss_item_t_initialize; - f_fss_item_t data_array[] = { data }; - f_fss_items_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_fss_items_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_fss_items_t datas = f_fss_items_t_initialize; + { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_item_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].content.array, &datas.array[0].content.used, &datas.array[0].content.size); + assert_int_equal(status, F_okay); + } - const f_status_t status = f_fss_items_destroy_callback(0, length, (void *) datas_array); + { + const f_status_t status = f_fss_items_destroy_callback(0, length, (void *) datas.array); assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].content.size, 0); } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-itemss_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-itemss_delete_callback.c index 9f747d7..10fb65a 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-itemss_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-itemss_delete_callback.c @@ -16,8 +16,8 @@ void test__f_fss_itemss_delete_callback__fails(void **state) { f_fss_items_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_itemss_delete_callback(0, 1, (void *) datas_array); @@ -25,8 +25,8 @@ void test__f_fss_itemss_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, true); will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); @@ -39,7 +39,7 @@ void test__f_fss_itemss_delete_callback__fails(void **state) { void test__f_fss_itemss_delete_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -53,7 +53,7 @@ void test__f_fss_itemss_delete_callback__works(void **state) { status = f_memory_array_resize(1, sizeof(f_fss_item_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_resize(1, &datass.array[0].array[0].content); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].content.array, &datass.array[0].array[0].content.used, &datass.array[0].array[0].content.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-itemss_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-itemss_destroy_callback.c index d96264b..18e875c 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-itemss_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-itemss_destroy_callback.c @@ -16,8 +16,8 @@ void test__f_fss_itemss_destroy_callback__fails(void **state) { f_fss_items_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_itemss_destroy_callback(0, 1, (void *) datas_array); @@ -25,8 +25,8 @@ void test__f_fss_itemss_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, true); will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); @@ -39,7 +39,7 @@ void test__f_fss_itemss_destroy_callback__fails(void **state) { void test__f_fss_itemss_destroy_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -47,13 +47,13 @@ void test__f_fss_itemss_destroy_callback__works(void **state) { f_fss_itemss_t datass = f_fss_itemss_t_initialize; { - f_status_t status = f_memory_array_adjust(length, sizeof(f_fss_items_t), (void **) &datass.array, &datass.used, &datass.size); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_items_t), (void **) &datass.array, &datass.used, &datass.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_fss_item_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + status = f_memory_array_resize(1, sizeof(f_fss_item_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_adjust(1, &datass.array[0].array[0].content); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].content.array, &datass.array[0].array[0].content.used, &datass.array[0].array[0].content.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-named_delete.c b/level_0/f_fss/tests/unit/c/test-fss-named_delete.c new file mode 100644 index 0000000..f7fb371 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-named_delete.c @@ -0,0 +1,99 @@ +#include "test-fss.h" +#include "test-fss-named_delete.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_named_delete__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_named_t data = f_fss_named_t_initialize; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_named_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + { + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_arrays_resize, true); + will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_named_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + { + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_arrays_resize, false); + will_return(__wrap_f_memory_arrays_resize, F_okay); + + will_return(__wrap_f_memory_arrays_resize, true); + will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_named_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_named_delete__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_named_delete(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_named_delete__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_named_t data = f_fss_named_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &data.objects.array, &data.objects.used, &data.objects.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &data.contents.array, &data.contents.used, &data.contents.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &data.contents.array[0].array, &data.contents.array[0].used, &data.contents.array[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &data.quotess.array, &data.quotess.used, &data.quotess.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &data.quotess.array[0].array, &data.quotess.array[0].used, &data.quotess.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_named_delete(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.objects.size, 0); + assert_int_equal(data.contents.size, 0); + assert_int_equal(data.quotess.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-named_delete.h b/level_0/f_fss/tests/unit/c/test-fss-named_delete.h new file mode 100644 index 0000000..7c4dedf --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-named_delete.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__named_delete +#define _TEST__F_fss__named_delete + +/** + * Test that the function fails. + * + * @see f_fss_named_delete() + */ +extern void test__f_fss_named_delete__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_named_delete() + */ +extern void test__f_fss_named_delete__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_named_delete() + */ +extern void test__f_fss_named_delete__works(void **state); + +#endif // _TEST__F_fss__named_delete diff --git a/level_0/f_fss/tests/unit/c/test-fss-named_destroy.c b/level_0/f_fss/tests/unit/c/test-fss-named_destroy.c new file mode 100644 index 0000000..acf4482 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-named_destroy.c @@ -0,0 +1,99 @@ +#include "test-fss.h" +#include "test-fss-named_destroy.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_named_destroy__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_named_t data = f_fss_named_t_initialize; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_named_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + { + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_arrays_adjust, true); + will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_named_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + { + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_arrays_adjust, false); + will_return(__wrap_f_memory_arrays_adjust, F_okay); + + will_return(__wrap_f_memory_arrays_adjust, true); + will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_named_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_named_destroy__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_named_destroy(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_named_destroy__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_named_t data = f_fss_named_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &data.objects.array, &data.objects.used, &data.objects.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &data.contents.array, &data.contents.used, &data.contents.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &data.contents.array[0].array, &data.contents.array[0].used, &data.contents.array[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &data.quotess.array, &data.quotess.used, &data.quotess.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &data.quotess.array[0].array, &data.quotess.array[0].used, &data.quotess.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_named_destroy(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.objects.size, 0); + assert_int_equal(data.contents.size, 0); + assert_int_equal(data.quotess.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-named_destroy.h b/level_0/f_fss/tests/unit/c/test-fss-named_destroy.h new file mode 100644 index 0000000..d8047df --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-named_destroy.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__named_destroy +#define _TEST__F_fss__named_destroy + +/** + * Test that the function fails. + * + * @see f_fss_named_destroy() + */ +extern void test__f_fss_named_destroy__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_named_destroy() + */ +extern void test__f_fss_named_destroy__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_named_destroy() + */ +extern void test__f_fss_named_destroy__works(void **state); + +#endif // _TEST__F_fss__named_destroy diff --git a/level_0/f_fss/tests/unit/c/test-fss-nameds_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-nameds_delete_callback.c index 2e616c4..e02d1e4 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-nameds_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-nameds_delete_callback.c @@ -16,8 +16,8 @@ void test__f_fss_nameds_delete_callback__fails(void **state) { f_fss_nameds_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_nameds_delete_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_nameds_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, true); - will_return(__wrap_f_string_rangess_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_resize, true); + will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_nameds_delete_callback(0, 1, (void *) datas_array); @@ -37,11 +37,11 @@ void test__f_fss_nameds_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + will_return(__wrap_f_memory_arrays_resize, false); + will_return(__wrap_f_memory_arrays_resize, F_okay); will_return(__wrap_f_memory_arrays_resize, true); will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); @@ -55,28 +55,42 @@ void test__f_fss_nameds_delete_callback__fails(void **state) { void test__f_fss_nameds_delete_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_named_t data = f_fss_named_t_initialize; - f_fss_named_t data_array[] = { data }; - f_fss_nameds_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_fss_nameds_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_fss_nameds_t datas = f_fss_nameds_t_initialize; + { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_named_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].objects.array, &datas.array[0].objects.used, &datas.array[0].objects.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datas.array[0].contents.array, &datas.array[0].contents.used, &datas.array[0].contents.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_arrays_resize, false); - will_return(__wrap_f_memory_arrays_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].contents.array[0].array, &datas.array[0].contents.array[0].used, &datas.array[0].contents.array[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &datas.array[0].quotess.array, &datas.array[0].quotess.used, &datas.array[0].quotess.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datas.array[0].quotess.array[0].array, &datas.array[0].quotess.array[0].used, &datas.array[0].quotess.array[0].size); + assert_int_equal(status, F_okay); + } - const f_status_t status = f_fss_nameds_delete_callback(0, length, (void *) datas_array); + { + const f_status_t status = f_fss_nameds_delete_callback(0, length, (void *) datas.array); assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].objects.size, 0); + assert_int_equal(datas.array[0].contents.size, 0); + assert_int_equal(datas.array[0].quotess.size, 0); } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-nameds_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-nameds_destroy_callback.c index 1260630..850d39b 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-nameds_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-nameds_destroy_callback.c @@ -16,8 +16,8 @@ void test__f_fss_nameds_destroy_callback__fails(void **state) { f_fss_nameds_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_nameds_destroy_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_nameds_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, true); - will_return(__wrap_f_string_rangess_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_adjust, true); + will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_nameds_destroy_callback(0, 1, (void *) datas_array); @@ -37,11 +37,11 @@ void test__f_fss_nameds_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + will_return(__wrap_f_memory_arrays_adjust, false); + will_return(__wrap_f_memory_arrays_adjust, F_okay); will_return(__wrap_f_memory_arrays_adjust, true); will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); @@ -55,28 +55,42 @@ void test__f_fss_nameds_destroy_callback__fails(void **state) { void test__f_fss_nameds_destroy_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_named_t data = f_fss_named_t_initialize; - f_fss_named_t data_array[] = { data }; - f_fss_nameds_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_fss_nameds_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_fss_nameds_t datas = f_fss_nameds_t_initialize; + { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_named_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].objects.array, &datas.array[0].objects.used, &datas.array[0].objects.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datas.array[0].contents.array, &datas.array[0].contents.used, &datas.array[0].contents.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_arrays_adjust, false); - will_return(__wrap_f_memory_arrays_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].contents.array[0].array, &datas.array[0].contents.array[0].used, &datas.array[0].contents.array[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &datas.array[0].quotess.array, &datas.array[0].quotess.used, &datas.array[0].quotess.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datas.array[0].quotess.array[0].array, &datas.array[0].quotess.array[0].used, &datas.array[0].quotess.array[0].size); + assert_int_equal(status, F_okay); + } - const f_status_t status = f_fss_nameds_destroy_callback(0, length, (void *) datas_array); + { + const f_status_t status = f_fss_nameds_destroy_callback(0, length, (void *) datas.array); assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].objects.size, 0); + assert_int_equal(datas.array[0].contents.size, 0); + assert_int_equal(datas.array[0].quotess.size, 0); } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-namedss_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-namedss_delete_callback.c index dbc7e73..ae19edd 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-namedss_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-namedss_delete_callback.c @@ -16,8 +16,8 @@ void test__f_fss_namedss_delete_callback__fails(void **state) { f_fss_nameds_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_namedss_delete_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_namedss_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, true); - will_return(__wrap_f_string_rangess_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_resize, true); + will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_namedss_delete_callback(0, 1, (void *) datas_array); @@ -37,11 +37,11 @@ void test__f_fss_namedss_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + will_return(__wrap_f_memory_arrays_resize, false); + will_return(__wrap_f_memory_arrays_resize, F_okay); will_return(__wrap_f_memory_arrays_resize, true); will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); @@ -54,7 +54,7 @@ void test__f_fss_namedss_delete_callback__fails(void **state) { void test__f_fss_namedss_delete_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -68,13 +68,13 @@ void test__f_fss_namedss_delete_callback__works(void **state) { status = f_memory_array_resize(1, sizeof(f_fss_named_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_resize(1, &datass.array[0].array[0].objects); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].objects.array, &datass.array[0].array[0].objects.used, &datass.array[0].array[0].objects.size); assert_int_equal(status, F_okay); - status = f_string_rangess_resize(1, &datass.array[0].array[0].contents); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datass.array[0].array[0].contents.array, &datass.array[0].array[0].contents.used, &datass.array[0].array[0].contents.size); assert_int_equal(status, F_okay); - status = f_memory_arrays_resize(1, sizeof(f_uint8s_t), (void **) &datass.array[0].array[0].quotess.array, &datass.array[0].array[0].quotess.used, &datass.array[0].array[0].quotess.size, &f_uint8ss_delete_callback); + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &datass.array[0].array[0].quotess.array, &datass.array[0].array[0].quotess.used, &datass.array[0].array[0].quotess.size); assert_int_equal(status, F_okay); status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datass.array[0].array[0].quotess.array[0].array, &datass.array[0].array[0].quotess.array[0].used, &datass.array[0].array[0].quotess.array[0].size); diff --git a/level_0/f_fss/tests/unit/c/test-fss-namedss_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-namedss_destroy_callback.c index 97bc9e2..2cdfe6e 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-namedss_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-namedss_destroy_callback.c @@ -16,8 +16,8 @@ void test__f_fss_namedss_destroy_callback__fails(void **state) { f_fss_nameds_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_namedss_destroy_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_namedss_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, true); - will_return(__wrap_f_string_rangess_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_adjust, true); + will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_namedss_destroy_callback(0, 1, (void *) datas_array); @@ -37,11 +37,11 @@ void test__f_fss_namedss_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + will_return(__wrap_f_memory_arrays_adjust, false); + will_return(__wrap_f_memory_arrays_adjust, F_okay); will_return(__wrap_f_memory_arrays_adjust, true); will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); @@ -54,7 +54,7 @@ void test__f_fss_namedss_destroy_callback__fails(void **state) { void test__f_fss_namedss_destroy_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -62,22 +62,22 @@ void test__f_fss_namedss_destroy_callback__works(void **state) { f_fss_namedss_t datass = f_fss_namedss_t_initialize; { - f_status_t status = f_memory_array_adjust(length, sizeof(f_fss_nameds_t), (void **) &datass.array, &datass.used, &datass.size); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_nameds_t), (void **) &datass.array, &datass.used, &datass.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_fss_named_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + status = f_memory_array_resize(1, sizeof(f_fss_named_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_adjust(1, &datass.array[0].array[0].objects); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].objects.array, &datass.array[0].array[0].objects.used, &datass.array[0].array[0].objects.size); assert_int_equal(status, F_okay); - status = f_string_rangess_adjust(1, &datass.array[0].array[0].contents); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datass.array[0].array[0].contents.array, &datass.array[0].array[0].contents.used, &datass.array[0].array[0].contents.size); assert_int_equal(status, F_okay); - status = f_memory_arrays_adjust(1, sizeof(f_uint8s_t), (void **) &datass.array[0].array[0].quotess.array, &datass.array[0].array[0].quotess.used, &datass.array[0].array[0].quotess.size, &f_uint8ss_delete_callback); + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &datass.array[0].array[0].quotess.array, &datass.array[0].array[0].quotess.used, &datass.array[0].array[0].quotess.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(uint8_t), (void **) &datass.array[0].array[0].quotess.array[0].array, &datass.array[0].array[0].quotess.array[0].used, &datass.array[0].array[0].quotess.array[0].size); + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datass.array[0].array[0].quotess.array[0].array, &datass.array[0].array[0].quotess.array[0].used, &datass.array[0].array[0].quotess.array[0].size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-nest_delete.c b/level_0/f_fss/tests/unit/c/test-fss-nest_delete.c new file mode 100644 index 0000000..7b9c9f6 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-nest_delete.c @@ -0,0 +1,80 @@ +#include "test-fss.h" +#include "test-fss-nest_delete.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_nest_delete__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_item_t item = f_fss_item_t_initialize; + f_fss_item_t item_array[] = { item }; + f_fss_items_t items = { .array = item_array, .used = 0, .size = 1 }; + f_fss_items_t items_array[] = { items }; + f_fss_nest_t data = { .depth = items_array, .used = 0, .size = 1 }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_nest_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + { + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_nest_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_nest_delete__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_nest_delete(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_nest_delete__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_nest_t data = f_fss_nest_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_items_t), (void **) &data.depth, &data.used, &data.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_fss_item_t), (void **) &data.depth[0].array, &data.depth[0].used, &data.depth[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &data.depth[0].array[0].content.array, &data.depth[0].array[0].content.used, &data.depth[0].array[0].content.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_nest_delete(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-nest_delete.h b/level_0/f_fss/tests/unit/c/test-fss-nest_delete.h new file mode 100644 index 0000000..818c1c8 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-nest_delete.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__nest_delete +#define _TEST__F_fss__nest_delete + +/** + * Test that the function fails. + * + * @see f_fss_nest_delete() + */ +extern void test__f_fss_nest_delete__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_nest_delete() + */ +extern void test__f_fss_nest_delete__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_nest_delete() + */ +extern void test__f_fss_nest_delete__works(void **state); + +#endif // _TEST__F_fss__nest_delete diff --git a/level_0/f_fss/tests/unit/c/test-fss-nest_destroy.c b/level_0/f_fss/tests/unit/c/test-fss-nest_destroy.c new file mode 100644 index 0000000..7546dac --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-nest_destroy.c @@ -0,0 +1,80 @@ +#include "test-fss.h" +#include "test-fss-nest_destroy.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_nest_destroy__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_item_t item = f_fss_item_t_initialize; + f_fss_item_t item_array[] = { item }; + f_fss_items_t items = { .array = item_array, .used = 0, .size = 1 }; + f_fss_items_t items_array[] = { items }; + f_fss_nest_t data = { .depth = items_array, .used = 0, .size = 1 }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_nest_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + { + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_nest_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_nest_destroy__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_nest_destroy(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_nest_destroy__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_nest_t data = f_fss_nest_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_items_t), (void **) &data.depth, &data.used, &data.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_fss_item_t), (void **) &data.depth[0].array, &data.depth[0].used, &data.depth[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &data.depth[0].array[0].content.array, &data.depth[0].array[0].content.used, &data.depth[0].array[0].content.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_nest_destroy(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-nest_destroy.h b/level_0/f_fss/tests/unit/c/test-fss-nest_destroy.h new file mode 100644 index 0000000..5e19caa --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-nest_destroy.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__nest_destroy +#define _TEST__F_fss__nest_destroy + +/** + * Test that the function fails. + * + * @see f_fss_nest_destroy() + */ +extern void test__f_fss_nest_destroy__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_nest_destroy() + */ +extern void test__f_fss_nest_destroy__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_nest_destroy() + */ +extern void test__f_fss_nest_destroy__works(void **state); + +#endif // _TEST__F_fss__nest_destroy diff --git a/level_0/f_fss/tests/unit/c/test-fss-nests_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-nests_delete_callback.c index f4fdbb1..e607e09 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-nests_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-nests_delete_callback.c @@ -18,8 +18,8 @@ void test__f_fss_nests_delete_callback__fails(void **state) { f_fss_nest_t data_array[] = { data }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_nests_delete_callback(0, 1, (void *) data_array); @@ -27,8 +27,8 @@ void test__f_fss_nests_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, true); will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); @@ -39,8 +39,8 @@ void test__f_fss_nests_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, false); will_return(__wrap_f_memory_array_resize, F_okay); @@ -57,30 +57,34 @@ void test__f_fss_nests_delete_callback__fails(void **state) { void test__f_fss_nests_delete_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_item_t item = f_fss_item_t_initialize; - f_fss_item_t item_array[] = { item }; - f_fss_items_t items = { .array = item_array, .used = 1, .size = 1 }; - f_fss_items_t items_array[] = { items }; - f_fss_nest_t data = { .depth = items_array, .used = 1, .size = 1 }; - f_fss_nest_t data_array[] = { data }; const f_number_unsigned_t length = 1; + f_fss_nests_t datas = f_fss_nests_t_initialize; + { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_nest_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_array_resize, false); - will_return(__wrap_f_memory_array_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_fss_items_t), (void **) &datas.array[0].depth, &datas.array[0].used, &datas.array[0].size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_array_resize, false); - will_return(__wrap_f_memory_array_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_fss_item_t), (void **) &datas.array[0].depth[0].array, &datas.array[0].depth[0].used, &datas.array[0].depth[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].depth[0].array[0].content.array, &datas.array[0].depth[0].array[0].content.used, &datas.array[0].depth[0].array[0].content.size); + assert_int_equal(status, F_okay); + } - const f_status_t status = f_fss_nests_delete_callback(0, length, (void *) data_array); + { + const f_status_t status = f_fss_nests_delete_callback(0, length, (void *) datas.array); assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].size, 0); } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-nests_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-nests_destroy_callback.c index 2680bf3..abb2a20 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-nests_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-nests_destroy_callback.c @@ -18,8 +18,8 @@ void test__f_fss_nests_destroy_callback__fails(void **state) { f_fss_nest_t data_array[] = { data }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_nests_destroy_callback(0, 1, (void *) data_array); @@ -27,8 +27,8 @@ void test__f_fss_nests_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, true); will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); @@ -39,8 +39,8 @@ void test__f_fss_nests_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, false); will_return(__wrap_f_memory_array_adjust, F_okay); @@ -57,30 +57,34 @@ void test__f_fss_nests_destroy_callback__fails(void **state) { void test__f_fss_nests_destroy_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_item_t item = f_fss_item_t_initialize; - f_fss_item_t item_array[] = { item }; - f_fss_items_t items = { .array = item_array, .used = 1, .size = 1 }; - f_fss_items_t items_array[] = { items }; - f_fss_nest_t data = { .depth = items_array, .used = 1, .size = 1 }; - f_fss_nest_t data_array[] = { data }; const f_number_unsigned_t length = 1; + f_fss_nests_t datas = f_fss_nests_t_initialize; + { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_nest_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_array_adjust, false); - will_return(__wrap_f_memory_array_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_fss_items_t), (void **) &datas.array[0].depth, &datas.array[0].used, &datas.array[0].size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_array_adjust, false); - will_return(__wrap_f_memory_array_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_fss_item_t), (void **) &datas.array[0].depth[0].array, &datas.array[0].depth[0].used, &datas.array[0].depth[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].depth[0].array[0].content.array, &datas.array[0].depth[0].array[0].content.used, &datas.array[0].depth[0].array[0].content.size); + assert_int_equal(status, F_okay); + } - const f_status_t status = f_fss_nests_destroy_callback(0, length, (void *) data_array); + { + const f_status_t status = f_fss_nests_destroy_callback(0, length, (void *) datas.array); assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].size, 0); } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-nestss_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-nestss_delete_callback.c index 5afadb3..00cc2c8 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-nestss_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-nestss_delete_callback.c @@ -20,8 +20,8 @@ void test__f_fss_nestss_delete_callback__fails(void **state) { f_fss_nests_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_nestss_delete_callback(0, 1, (void *) datas_array); @@ -29,8 +29,8 @@ void test__f_fss_nestss_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, true); will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); @@ -43,7 +43,7 @@ void test__f_fss_nestss_delete_callback__fails(void **state) { void test__f_fss_nestss_delete_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -63,7 +63,7 @@ void test__f_fss_nestss_delete_callback__works(void **state) { status = f_memory_array_resize(1, sizeof(f_fss_item_t), (void **) &datass.array[0].array[0].depth[0].array, &datass.array[0].array[0].depth[0].used, &datass.array[0].array[0].depth[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_resize(1, &datass.array[0].array[0].depth[0].array[0].content); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].depth[0].array[0].content.array, &datass.array[0].array[0].depth[0].array[0].content.used, &datass.array[0].array[0].depth[0].array[0].content.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-nestss_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-nestss_destroy_callback.c index c15faa1..a697364 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-nestss_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-nestss_destroy_callback.c @@ -20,8 +20,8 @@ void test__f_fss_nestss_destroy_callback__fails(void **state) { f_fss_nests_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_nestss_destroy_callback(0, 1, (void *) datas_array); @@ -29,8 +29,8 @@ void test__f_fss_nestss_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, true); will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); @@ -43,7 +43,7 @@ void test__f_fss_nestss_destroy_callback__fails(void **state) { void test__f_fss_nestss_destroy_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -51,19 +51,19 @@ void test__f_fss_nestss_destroy_callback__works(void **state) { f_fss_nestss_t datass = f_fss_nestss_t_initialize; { - f_status_t status = f_memory_array_adjust(length, sizeof(f_fss_nests_t), (void **) &datass.array, &datass.used, &datass.size); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_nests_t), (void **) &datass.array, &datass.used, &datass.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_fss_nest_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + status = f_memory_array_resize(1, sizeof(f_fss_nest_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_fss_items_t), (void **) &datass.array[0].array[0].depth, &datass.array[0].array[0].used, &datass.array[0].array[0].size); + status = f_memory_array_resize(1, sizeof(f_fss_items_t), (void **) &datass.array[0].array[0].depth, &datass.array[0].array[0].used, &datass.array[0].array[0].size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_fss_item_t), (void **) &datass.array[0].array[0].depth[0].array, &datass.array[0].array[0].depth[0].used, &datass.array[0].array[0].depth[0].size); + status = f_memory_array_resize(1, sizeof(f_fss_item_t), (void **) &datass.array[0].array[0].depth[0].array, &datass.array[0].array[0].depth[0].used, &datass.array[0].array[0].depth[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_adjust(1, &datass.array[0].array[0].depth[0].array[0].content); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].depth[0].array[0].content.array, &datass.array[0].array[0].depth[0].array[0].content.used, &datass.array[0].array[0].depth[0].array[0].content.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_delete.c b/level_0/f_fss/tests/unit/c/test-fss-set_delete.c new file mode 100644 index 0000000..4551fb9 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-set_delete.c @@ -0,0 +1,65 @@ +#include "test-fss.h" +#include "test-fss-set_delete.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_set_delete__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_set_t data = f_fss_set_t_initialize; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_set_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_set_delete__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_set_delete(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_set_delete__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_set_t data = f_fss_set_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &data.objects.array, &data.objects.used, &data.objects.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &data.contents.array, &data.contents.used, &data.contents.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &data.contents.array[0].array, &data.contents.array[0].used, &data.contents.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_set_delete(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.objects.size, 0); + assert_int_equal(data.contents.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_delete.h b/level_0/f_fss/tests/unit/c/test-fss-set_delete.h new file mode 100644 index 0000000..cf28f2a --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-set_delete.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__set_delete +#define _TEST__F_fss__set_delete + +/** + * Test that the function fails. + * + * @see f_fss_set_delete() + */ +extern void test__f_fss_set_delete__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_set_delete() + */ +extern void test__f_fss_set_delete__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_set_delete() + */ +extern void test__f_fss_set_delete__works(void **state); + +#endif // _TEST__F_fss__set_delete diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_destroy.c b/level_0/f_fss/tests/unit/c/test-fss-set_destroy.c new file mode 100644 index 0000000..ac81e29 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-set_destroy.c @@ -0,0 +1,65 @@ +#include "test-fss.h" +#include "test-fss-set_destroy.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_set_destroy__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_set_t data = f_fss_set_t_initialize; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_set_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_set_destroy__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_set_destroy(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_set_destroy__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_set_t data = f_fss_set_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &data.objects.array, &data.objects.used, &data.objects.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &data.contents.array, &data.contents.used, &data.contents.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &data.contents.array[0].array, &data.contents.array[0].used, &data.contents.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_set_destroy(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.objects.size, 0); + assert_int_equal(data.contents.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_destroy.h b/level_0/f_fss/tests/unit/c/test-fss-set_destroy.h new file mode 100644 index 0000000..7d1018c --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-set_destroy.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__set_destroy +#define _TEST__F_fss__set_destroy + +/** + * Test that the function fails. + * + * @see f_fss_set_destroy() + */ +extern void test__f_fss_set_destroy__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_set_destroy() + */ +extern void test__f_fss_set_destroy__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_set_destroy() + */ +extern void test__f_fss_set_destroy__works(void **state); + +#endif // _TEST__F_fss__set_destroy diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_quote_delete.c b/level_0/f_fss/tests/unit/c/test-fss-set_quote_delete.c new file mode 100644 index 0000000..6499923 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-set_quote_delete.c @@ -0,0 +1,76 @@ +#include "test-fss.h" +#include "test-fss-set_quote_delete.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_set_quote_delete__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_set_quote_t data = f_fss_set_quote_t_initialize; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_set_quote_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_set_quote_delete__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_set_quote_delete(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_set_quote_delete__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_set_quote_t data = f_fss_set_quote_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &data.objects.array, &data.objects.used, &data.objects.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &data.contents.array, &data.contents.used, &data.contents.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &data.contents.array[0].array, &data.contents.array[0].used, &data.contents.array[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &data.objects_quote.array, &data.objects_quote.used, &data.objects_quote.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &data.contents_quote.array, &data.contents_quote.used, &data.contents_quote.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &data.contents_quote.array[0].array, &data.contents_quote.array[0].used, &data.contents_quote.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_set_quote_delete(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.objects.size, 0); + assert_int_equal(data.contents.size, 0); + assert_int_equal(data.objects_quote.size, 0); + assert_int_equal(data.contents_quote.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_quote_delete.h b/level_0/f_fss/tests/unit/c/test-fss-set_quote_delete.h new file mode 100644 index 0000000..7debcd8 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-set_quote_delete.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__set_quote_delete +#define _TEST__F_fss__set_quote_delete + +/** + * Test that the function fails. + * + * @see f_fss_set_quote_delete() + */ +extern void test__f_fss_set_quote_delete__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_set_quote_delete() + */ +extern void test__f_fss_set_quote_delete__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_set_quote_delete() + */ +extern void test__f_fss_set_quote_delete__works(void **state); + +#endif // _TEST__F_fss__set_quote_delete diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_quote_destroy.c b/level_0/f_fss/tests/unit/c/test-fss-set_quote_destroy.c new file mode 100644 index 0000000..837833e --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-set_quote_destroy.c @@ -0,0 +1,76 @@ +#include "test-fss.h" +#include "test-fss-set_quote_destroy.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_set_quote_destroy__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_set_quote_t data = f_fss_set_quote_t_initialize; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_set_quote_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_set_quote_destroy__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_set_quote_destroy(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_set_quote_destroy__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_set_quote_t data = f_fss_set_quote_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &data.objects.array, &data.objects.used, &data.objects.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &data.contents.array, &data.contents.used, &data.contents.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &data.contents.array[0].array, &data.contents.array[0].used, &data.contents.array[0].size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &data.objects_quote.array, &data.objects_quote.used, &data.objects_quote.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &data.contents_quote.array, &data.contents_quote.used, &data.contents_quote.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &data.contents_quote.array[0].array, &data.contents_quote.array[0].used, &data.contents_quote.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_set_quote_delete(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.objects.size, 0); + assert_int_equal(data.contents.size, 0); + assert_int_equal(data.objects_quote.size, 0); + assert_int_equal(data.contents_quote.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_quote_destroy.h b/level_0/f_fss/tests/unit/c/test-fss-set_quote_destroy.h new file mode 100644 index 0000000..b04ceac --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-set_quote_destroy.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__set_quote_destroy +#define _TEST__F_fss__set_quote_destroy + +/** + * Test that the function fails. + * + * @see f_fss_set_quote_destroy() + */ +extern void test__f_fss_set_quote_destroy__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_set_quote_destroy() + */ +extern void test__f_fss_set_quote_destroy__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_set_quote_destroy() + */ +extern void test__f_fss_set_quote_destroy__works(void **state); + +#endif // _TEST__F_fss__set_quote_destroy diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_quotes_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-set_quotes_delete_callback.c index e163617..270952d 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-set_quotes_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-set_quotes_delete_callback.c @@ -16,8 +16,8 @@ void test__f_fss_set_quotes_delete_callback__fails(void **state) { f_fss_set_quotes_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_set_quotes_delete_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_set_quotes_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, true); - will_return(__wrap_f_string_rangess_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_resize, true); + will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_set_quotes_delete_callback(0, 1, (void *) datas_array); @@ -37,11 +37,11 @@ void test__f_fss_set_quotes_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + will_return(__wrap_f_memory_arrays_resize, false); + will_return(__wrap_f_memory_arrays_resize, F_okay); will_return(__wrap_f_memory_array_resize, true); will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); @@ -52,11 +52,11 @@ void test__f_fss_set_quotes_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + will_return(__wrap_f_memory_arrays_resize, false); + will_return(__wrap_f_memory_arrays_resize, F_okay); will_return(__wrap_f_memory_array_resize, false); will_return(__wrap_f_memory_array_resize, F_okay); @@ -73,31 +73,46 @@ void test__f_fss_set_quotes_delete_callback__fails(void **state) { void test__f_fss_set_quotes_delete_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_set_quote_t data = f_fss_set_quote_t_initialize; - f_fss_set_quote_t data_array[] = { data }; - f_fss_set_quotes_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_fss_set_quotes_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_fss_set_quotes_t datas = f_fss_set_quotes_t_initialize; + { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_set_quote_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].objects.array, &datas.array[0].objects.used, &datas.array[0].objects.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_array_resize, false); - will_return(__wrap_f_memory_array_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datas.array[0].contents.array, &datas.array[0].contents.used, &datas.array[0].contents.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_arrays_resize, false); - will_return(__wrap_f_memory_arrays_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].contents.array[0].array, &datas.array[0].contents.array[0].used, &datas.array[0].contents.array[0].size); + assert_int_equal(status, F_okay); - const f_status_t status = f_fss_set_quotes_delete_callback(0, length, (void *) datas_array); + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datas.array[0].objects_quote.array, &datas.array[0].objects_quote.used, &datas.array[0].objects_quote.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &datas.array[0].contents_quote.array, &datas.array[0].contents_quote.used, &datas.array[0].contents_quote.size); + assert_int_equal(status, F_okay); + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datas.array[0].contents_quote.array[0].array, &datas.array[0].contents_quote.array[0].used, &datas.array[0].contents_quote.array[0].size); assert_int_equal(status, F_okay); } + + { + const f_status_t status = f_fss_set_quotes_delete_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].objects.size, 0); + assert_int_equal(datas.array[0].contents.size, 0); + assert_int_equal(datas.array[0].objects_quote.size, 0); + assert_int_equal(datas.array[0].contents_quote.size, 0); + } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_quotes_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-set_quotes_destroy_callback.c index ebc11f2..2ebf3af 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-set_quotes_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-set_quotes_destroy_callback.c @@ -16,8 +16,8 @@ void test__f_fss_set_quotes_destroy_callback__fails(void **state) { f_fss_set_quotes_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_set_quotes_destroy_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_set_quotes_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, true); - will_return(__wrap_f_string_rangess_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_adjust, true); + will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_set_quotes_destroy_callback(0, 1, (void *) datas_array); @@ -37,11 +37,11 @@ void test__f_fss_set_quotes_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + will_return(__wrap_f_memory_arrays_adjust, false); + will_return(__wrap_f_memory_arrays_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, true); will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); @@ -52,11 +52,11 @@ void test__f_fss_set_quotes_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + will_return(__wrap_f_memory_arrays_adjust, false); + will_return(__wrap_f_memory_arrays_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, false); will_return(__wrap_f_memory_array_adjust, F_okay); @@ -73,31 +73,46 @@ void test__f_fss_set_quotes_destroy_callback__fails(void **state) { void test__f_fss_set_quotes_destroy_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_set_quote_t data = f_fss_set_quote_t_initialize; - f_fss_set_quote_t data_array[] = { data }; - f_fss_set_quotes_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_fss_set_quotes_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_fss_set_quotes_t datas = f_fss_set_quotes_t_initialize; + { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_set_quote_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].objects.array, &datas.array[0].objects.used, &datas.array[0].objects.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_array_adjust, false); - will_return(__wrap_f_memory_array_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datas.array[0].contents.array, &datas.array[0].contents.used, &datas.array[0].contents.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_arrays_adjust, false); - will_return(__wrap_f_memory_arrays_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].contents.array[0].array, &datas.array[0].contents.array[0].used, &datas.array[0].contents.array[0].size); + assert_int_equal(status, F_okay); - const f_status_t status = f_fss_set_quotes_destroy_callback(0, length, (void *) datas_array); + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datas.array[0].objects_quote.array, &datas.array[0].objects_quote.used, &datas.array[0].objects_quote.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &datas.array[0].contents_quote.array, &datas.array[0].contents_quote.used, &datas.array[0].contents_quote.size); + assert_int_equal(status, F_okay); + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datas.array[0].contents_quote.array[0].array, &datas.array[0].contents_quote.array[0].used, &datas.array[0].contents_quote.array[0].size); assert_int_equal(status, F_okay); } + + { + const f_status_t status = f_fss_set_quotes_destroy_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].objects.size, 0); + assert_int_equal(datas.array[0].contents.size, 0); + assert_int_equal(datas.array[0].objects_quote.size, 0); + assert_int_equal(datas.array[0].contents_quote.size, 0); + } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_quotess_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-set_quotess_delete_callback.c index ba70a12..6458115 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-set_quotess_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-set_quotess_delete_callback.c @@ -16,8 +16,8 @@ void test__f_fss_set_quotess_delete_callback__fails(void **state) { f_fss_set_quotes_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_set_quotess_delete_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_set_quotess_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, true); - will_return(__wrap_f_string_rangess_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_resize, true); + will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_set_quotess_delete_callback(0, 1, (void *) datas_array); @@ -37,11 +37,11 @@ void test__f_fss_set_quotess_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + will_return(__wrap_f_memory_arrays_resize, false); + will_return(__wrap_f_memory_arrays_resize, F_okay); will_return(__wrap_f_memory_array_resize, true); will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); @@ -52,11 +52,11 @@ void test__f_fss_set_quotess_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + will_return(__wrap_f_memory_arrays_resize, false); + will_return(__wrap_f_memory_arrays_resize, F_okay); will_return(__wrap_f_memory_array_resize, false); will_return(__wrap_f_memory_array_resize, F_okay); @@ -72,7 +72,7 @@ void test__f_fss_set_quotess_delete_callback__fails(void **state) { void test__f_fss_set_quotess_delete_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -86,16 +86,16 @@ void test__f_fss_set_quotess_delete_callback__works(void **state) { status = f_memory_array_resize(1, sizeof(f_fss_set_quote_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_resize(1, &datass.array[0].array[0].objects); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].objects.array, &datass.array[0].array[0].objects.used, &datass.array[0].array[0].objects.size); assert_int_equal(status, F_okay); - status = f_string_rangess_resize(1, &datass.array[0].array[0].contents); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].contents.array, &datass.array[0].array[0].contents.used, &datass.array[0].array[0].contents.size); assert_int_equal(status, F_okay); status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datass.array[0].array[0].objects_quote.array, &datass.array[0].array[0].objects_quote.used, &datass.array[0].array[0].objects_quote.size); assert_int_equal(status, F_okay); - status = f_memory_arrays_adjust(1, sizeof(f_uint8s_t), (void **) &datass.array[0].array[0].contents_quote.array, &datass.array[0].array[0].contents_quote.used, &datass.array[0].array[0].contents_quote.size, &f_uint8ss_destroy_callback); + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &datass.array[0].array[0].contents_quote.array, &datass.array[0].array[0].contents_quote.used, &datass.array[0].array[0].contents_quote.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-set_quotess_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-set_quotess_destroy_callback.c index 2a92f1e..c41c208 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-set_quotess_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-set_quotess_destroy_callback.c @@ -16,8 +16,8 @@ void test__f_fss_set_quotess_destroy_callback__fails(void **state) { f_fss_set_quotes_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_set_quotess_destroy_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_set_quotess_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, true); - will_return(__wrap_f_string_rangess_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_adjust, true); + will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_set_quotess_destroy_callback(0, 1, (void *) datas_array); @@ -37,11 +37,11 @@ void test__f_fss_set_quotess_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + will_return(__wrap_f_memory_arrays_adjust, false); + will_return(__wrap_f_memory_arrays_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, true); will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); @@ -52,11 +52,11 @@ void test__f_fss_set_quotess_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + will_return(__wrap_f_memory_arrays_adjust, false); + will_return(__wrap_f_memory_arrays_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, false); will_return(__wrap_f_memory_array_adjust, F_okay); @@ -72,7 +72,7 @@ void test__f_fss_set_quotess_destroy_callback__fails(void **state) { void test__f_fss_set_quotess_destroy_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -80,22 +80,22 @@ void test__f_fss_set_quotess_destroy_callback__works(void **state) { f_fss_set_quotess_t datass = f_fss_set_quotess_t_initialize; { - f_status_t status = f_memory_array_adjust(length, sizeof(f_fss_set_quotes_t), (void **) &datass.array, &datass.used, &datass.size); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_set_quotes_t), (void **) &datass.array, &datass.used, &datass.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_fss_set_quote_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + status = f_memory_array_resize(1, sizeof(f_fss_set_quote_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_adjust(1, &datass.array[0].array[0].objects); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].objects.array, &datass.array[0].array[0].objects.used, &datass.array[0].array[0].objects.size); assert_int_equal(status, F_okay); - status = f_string_rangess_adjust(1, &datass.array[0].array[0].contents); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datass.array[0].array[0].contents.array, &datass.array[0].array[0].contents.used, &datass.array[0].array[0].contents.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(uint8_t), (void **) &datass.array[0].array[0].objects_quote.array, &datass.array[0].array[0].objects_quote.used, &datass.array[0].array[0].objects_quote.size); + status = f_memory_array_resize(1, sizeof(uint8_t), (void **) &datass.array[0].array[0].objects_quote.array, &datass.array[0].array[0].objects_quote.used, &datass.array[0].array[0].objects_quote.size); assert_int_equal(status, F_okay); - status = f_memory_arrays_adjust(1, sizeof(f_uint8s_t), (void **) &datass.array[0].array[0].contents_quote.array, &datass.array[0].array[0].contents_quote.used, &datass.array[0].array[0].contents_quote.size, &f_uint8ss_destroy_callback); + status = f_memory_array_resize(1, sizeof(f_uint8s_t), (void **) &datass.array[0].array[0].contents_quote.array, &datass.array[0].array[0].contents_quote.used, &datass.array[0].array[0].contents_quote.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-sets_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-sets_delete_callback.c index 444c6ec..d1e980c 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-sets_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-sets_delete_callback.c @@ -16,8 +16,8 @@ void test__f_fss_sets_delete_callback__fails(void **state) { f_fss_sets_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_sets_delete_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_sets_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, true); - will_return(__wrap_f_string_rangess_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_resize, true); + will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_sets_delete_callback(0, 1, (void *) datas_array); @@ -40,25 +40,35 @@ void test__f_fss_sets_delete_callback__fails(void **state) { void test__f_fss_sets_delete_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_set_t data = f_fss_set_t_initialize; - f_fss_set_t data_array[] = { data }; - f_fss_sets_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_fss_sets_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_fss_sets_t datas = f_fss_sets_t_initialize; + { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_set_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_rangess_resize, false); - will_return(__wrap_f_string_rangess_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].objects.array, &datas.array[0].objects.used, &datas.array[0].objects.size); + assert_int_equal(status, F_okay); - const f_status_t status = f_fss_sets_delete_callback(0, length, (void *) datas_array); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datas.array[0].contents.array, &datas.array[0].contents.used, &datas.array[0].contents.size); + assert_int_equal(status, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].contents.array[0].array, &datas.array[0].contents.array[0].used, &datas.array[0].contents.array[0].size); assert_int_equal(status, F_okay); } + + { + const f_status_t status = f_fss_sets_delete_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].objects.size, 0); + assert_int_equal(datas.array[0].contents.size, 0); + } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-sets_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-sets_destroy_callback.c index a674d54..3714d05 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-sets_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-sets_destroy_callback.c @@ -16,8 +16,8 @@ void test__f_fss_sets_destroy_callback__fails(void **state) { f_fss_sets_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_sets_destroy_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_sets_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, true); - will_return(__wrap_f_string_rangess_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_adjust, true); + will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_sets_destroy_callback(0, 1, (void *) datas_array); @@ -40,25 +40,35 @@ void test__f_fss_sets_destroy_callback__fails(void **state) { void test__f_fss_sets_destroy_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_fss_set_t data = f_fss_set_t_initialize; - f_fss_set_t data_array[] = { data }; - f_fss_sets_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_fss_sets_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_fss_sets_t datas = f_fss_sets_t_initialize; + { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_set_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_rangess_adjust, false); - will_return(__wrap_f_string_rangess_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].objects.array, &datas.array[0].objects.used, &datas.array[0].objects.size); + assert_int_equal(status, F_okay); - const f_status_t status = f_fss_sets_destroy_callback(0, length, (void *) datas_array); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datas.array[0].contents.array, &datas.array[0].contents.used, &datas.array[0].contents.size); + assert_int_equal(status, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].contents.array[0].array, &datas.array[0].contents.array[0].used, &datas.array[0].contents.array[0].size); assert_int_equal(status, F_okay); } + + { + const f_status_t status = f_fss_sets_destroy_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].objects.size, 0); + assert_int_equal(datas.array[0].contents.size, 0); + } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_fss/tests/unit/c/test-fss-setss_delete_callback.c b/level_0/f_fss/tests/unit/c/test-fss-setss_delete_callback.c index 07c81a6..d724826 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-setss_delete_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-setss_delete_callback.c @@ -16,8 +16,8 @@ void test__f_fss_setss_delete_callback__fails(void **state) { f_fss_sets_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_setss_delete_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_setss_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_rangess_resize, true); - will_return(__wrap_f_string_rangess_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_resize, true); + will_return(__wrap_f_memory_arrays_resize, F_status_set_error(F_failure)); const f_status_t status = f_fss_setss_delete_callback(0, 1, (void *) datas_array); @@ -53,10 +53,10 @@ void test__f_fss_setss_delete_callback__works(void **state) { status = f_memory_array_resize(1, sizeof(f_fss_set_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_resize(1, &datass.array[0].array[0].objects); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].objects.array, &datass.array[0].array[0].objects.used, &datass.array[0].array[0].objects.size); assert_int_equal(status, F_okay); - status = f_string_rangess_resize(1, &datass.array[0].array[0].contents); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datass.array[0].array[0].contents.array, &datass.array[0].array[0].contents.used, &datass.array[0].array[0].contents.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-setss_destroy_callback.c b/level_0/f_fss/tests/unit/c/test-fss-setss_destroy_callback.c index 1eaac54..57ec057 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-setss_destroy_callback.c +++ b/level_0/f_fss/tests/unit/c/test-fss-setss_destroy_callback.c @@ -16,8 +16,8 @@ void test__f_fss_setss_destroy_callback__fails(void **state) { f_fss_sets_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_setss_destroy_callback(0, 1, (void *) datas_array); @@ -25,11 +25,11 @@ void test__f_fss_setss_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_rangess_adjust, true); - will_return(__wrap_f_string_rangess_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_arrays_adjust, true); + will_return(__wrap_f_memory_arrays_adjust, F_status_set_error(F_failure)); const f_status_t status = f_fss_setss_destroy_callback(0, 1, (void *) datas_array); @@ -39,7 +39,7 @@ void test__f_fss_setss_destroy_callback__fails(void **state) { void test__f_fss_setss_destroy_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -47,16 +47,16 @@ void test__f_fss_setss_destroy_callback__works(void **state) { f_fss_setss_t datass = f_fss_setss_t_initialize; { - f_status_t status = f_memory_array_adjust(length, sizeof(f_fss_sets_t), (void **) &datass.array, &datass.used, &datass.size); + f_status_t status = f_memory_array_resize(length, sizeof(f_fss_sets_t), (void **) &datass.array, &datass.used, &datass.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_fss_set_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + status = f_memory_array_resize(1, sizeof(f_fss_set_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_adjust(1, &datass.array[0].array[0].objects); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].objects.array, &datass.array[0].array[0].objects.used, &datass.array[0].array[0].objects.size); assert_int_equal(status, F_okay); - status = f_string_rangess_adjust(1, &datass.array[0].array[0].contents); + status = f_memory_array_resize(1, sizeof(f_string_ranges_t), (void **) &datass.array[0].array[0].contents.array, &datass.array[0].array[0].contents.used, &datass.array[0].array[0].contents.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_fss/tests/unit/c/test-fss-simple_packet_delete.c b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_delete.c new file mode 100644 index 0000000..ce8cc93 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_delete.c @@ -0,0 +1,58 @@ +#include "test-fss.h" +#include "test-fss-simple_packet_delete.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_simple_packet_delete__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_simple_packet_t data = f_fss_simple_packet_t_initialize; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_simple_packet_delete(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_simple_packet_delete__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_simple_packet_delete(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_simple_packet_delete__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_simple_packet_t data = f_fss_simple_packet_t_initialize; + + { + const f_status_t status = f_memory_array_resize(length, sizeof(f_char_t), (void **) &data.payload, &data.payload.used, &data.payload.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_simple_packet_delete(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.payload.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-simple_packet_delete.h b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_delete.h new file mode 100644 index 0000000..638a4b1 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_delete.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__simple_packet_delete +#define _TEST__F_fss__simple_packet_delete + +/** + * Test that the function fails. + * + * @see f_fss_simple_packet_delete() + */ +extern void test__f_fss_simple_packet_delete__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_simple_packet_delete() + */ +extern void test__f_fss_simple_packet_delete__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_simple_packet_delete() + */ +extern void test__f_fss_simple_packet_delete__works(void **state); + +#endif // _TEST__F_fss__simple_packet_delete diff --git a/level_0/f_fss/tests/unit/c/test-fss-simple_packet_destroy.c b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_destroy.c new file mode 100644 index 0000000..54e39da --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_destroy.c @@ -0,0 +1,58 @@ +#include "test-fss.h" +#include "test-fss-simple_packet_destroy.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_fss_simple_packet_destroy__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_fss_simple_packet_t data = f_fss_simple_packet_t_initialize; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_fss_simple_packet_destroy(&data); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_fss_simple_packet_destroy__parameter_checking(void **state) { + + { + const f_status_t status = f_fss_simple_packet_destroy(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_fss_simple_packet_destroy__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_fss_simple_packet_t data = f_fss_simple_packet_t_initialize; + + { + const f_status_t status = f_memory_array_resize(length, sizeof(f_char_t), (void **) &data.payload, &data.payload.used, &data.payload.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_fss_simple_packet_destroy(&data); + + assert_int_equal(status, F_okay); + assert_int_equal(data.payload.size, 0); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_fss/tests/unit/c/test-fss-simple_packet_destroy.h b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_destroy.h new file mode 100644 index 0000000..65cce64 --- /dev/null +++ b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_destroy.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: FSS + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_fss__simple_packet_destroy +#define _TEST__F_fss__simple_packet_destroy + +/** + * Test that the function fails. + * + * @see f_fss_simple_packet_destroy() + */ +extern void test__f_fss_simple_packet_destroy__fails(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_fss_simple_packet_destroy() + */ +extern void test__f_fss_simple_packet_destroy__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_fss_simple_packet_destroy() + */ +extern void test__f_fss_simple_packet_destroy__works(void **state); + +#endif // _TEST__F_fss__simple_packet_destroy diff --git a/level_0/f_fss/tests/unit/c/test-fss.c b/level_0/f_fss/tests/unit/c/test-fss.c index 1af9f30..8f2de39 100644 --- a/level_0/f_fss/tests/unit/c/test-fss.c +++ b/level_0/f_fss/tests/unit/c/test-fss.c @@ -45,61 +45,85 @@ int main(void) { cmocka_unit_test(test__f_fss_fail_utf__works_for_no_error), cmocka_unit_test(test__f_fss_fail_utf_to_false__works_for_no_error), + cmocka_unit_test(test__f_fss_item_delete__fails), + cmocka_unit_test(test__f_fss_item_destroy__fails), cmocka_unit_test(test__f_fss_items_delete_callback__fails), cmocka_unit_test(test__f_fss_items_destroy_callback__fails), cmocka_unit_test(test__f_fss_itemss_delete_callback__fails), cmocka_unit_test(test__f_fss_itemss_destroy_callback__fails), + cmocka_unit_test(test__f_fss_item_delete__works), + cmocka_unit_test(test__f_fss_item_destroy__works), cmocka_unit_test(test__f_fss_items_delete_callback__works), cmocka_unit_test(test__f_fss_items_destroy_callback__works), cmocka_unit_test(test__f_fss_itemss_delete_callback__works), cmocka_unit_test(test__f_fss_itemss_destroy_callback__works), + cmocka_unit_test(test__f_fss_named_delete__fails), + cmocka_unit_test(test__f_fss_named_destroy__fails), cmocka_unit_test(test__f_fss_nameds_delete_callback__fails), cmocka_unit_test(test__f_fss_nameds_destroy_callback__fails), cmocka_unit_test(test__f_fss_namedss_delete_callback__fails), cmocka_unit_test(test__f_fss_namedss_destroy_callback__fails), + cmocka_unit_test(test__f_fss_named_delete__works), + cmocka_unit_test(test__f_fss_named_destroy__works), cmocka_unit_test(test__f_fss_nameds_delete_callback__works), cmocka_unit_test(test__f_fss_nameds_destroy_callback__works), cmocka_unit_test(test__f_fss_namedss_delete_callback__works), cmocka_unit_test(test__f_fss_namedss_destroy_callback__works), + cmocka_unit_test(test__f_fss_nest_delete__fails), + cmocka_unit_test(test__f_fss_nest_destroy__fails), cmocka_unit_test(test__f_fss_nests_delete_callback__fails), cmocka_unit_test(test__f_fss_nests_destroy_callback__fails), cmocka_unit_test(test__f_fss_nestss_delete_callback__fails), cmocka_unit_test(test__f_fss_nestss_destroy_callback__fails), + cmocka_unit_test(test__f_fss_nest_delete__works), + cmocka_unit_test(test__f_fss_nest_destroy__works), cmocka_unit_test(test__f_fss_nests_delete_callback__works), cmocka_unit_test(test__f_fss_nests_destroy_callback__works), cmocka_unit_test(test__f_fss_nestss_delete_callback__works), cmocka_unit_test(test__f_fss_nestss_destroy_callback__works), - cmocka_unit_test(test__f_fss_set_quotes_delete_callback__fails), - cmocka_unit_test(test__f_fss_set_quotes_destroy_callback__fails), - cmocka_unit_test(test__f_fss_set_quotess_delete_callback__fails), - cmocka_unit_test(test__f_fss_set_quotess_destroy_callback__fails), - - cmocka_unit_test(test__f_fss_set_quotes_delete_callback__works), - cmocka_unit_test(test__f_fss_set_quotes_destroy_callback__works), - cmocka_unit_test(test__f_fss_set_quotess_delete_callback__works), - cmocka_unit_test(test__f_fss_set_quotess_destroy_callback__works), - + cmocka_unit_test(test__f_fss_set_delete__fails), + cmocka_unit_test(test__f_fss_set_destroy__fails), cmocka_unit_test(test__f_fss_sets_delete_callback__fails), cmocka_unit_test(test__f_fss_sets_destroy_callback__fails), cmocka_unit_test(test__f_fss_setss_delete_callback__fails), cmocka_unit_test(test__f_fss_setss_destroy_callback__fails), + cmocka_unit_test(test__f_fss_set_delete__works), + cmocka_unit_test(test__f_fss_set_destroy__works), cmocka_unit_test(test__f_fss_sets_delete_callback__works), cmocka_unit_test(test__f_fss_sets_destroy_callback__works), cmocka_unit_test(test__f_fss_setss_delete_callback__works), cmocka_unit_test(test__f_fss_setss_destroy_callback__works), + cmocka_unit_test(test__f_fss_set_quote_delete__fails), + cmocka_unit_test(test__f_fss_set_quote_destroy__fails), + cmocka_unit_test(test__f_fss_set_quotes_delete_callback__fails), + cmocka_unit_test(test__f_fss_set_quotes_destroy_callback__fails), + cmocka_unit_test(test__f_fss_set_quotess_delete_callback__fails), + cmocka_unit_test(test__f_fss_set_quotess_destroy_callback__fails), + + cmocka_unit_test(test__f_fss_set_quote_delete__works), + cmocka_unit_test(test__f_fss_set_quote_destroy__works), + cmocka_unit_test(test__f_fss_set_quotes_delete_callback__works), + cmocka_unit_test(test__f_fss_set_quotes_destroy_callback__works), + cmocka_unit_test(test__f_fss_set_quotess_delete_callback__works), + cmocka_unit_test(test__f_fss_set_quotess_destroy_callback__works), + + cmocka_unit_test(test__f_fss_simple_packet_delete__fails), + cmocka_unit_test(test__f_fss_simple_packet_destroy__fails), cmocka_unit_test(test__f_fss_simple_packets_delete_callback__fails), cmocka_unit_test(test__f_fss_simple_packets_destroy_callback__fails), cmocka_unit_test(test__f_fss_simple_packetss_delete_callback__fails), cmocka_unit_test(test__f_fss_simple_packetss_destroy_callback__fails), + cmocka_unit_test(test__f_fss_simple_packet_delete__works), + cmocka_unit_test(test__f_fss_simple_packet_destroy__works), cmocka_unit_test(test__f_fss_simple_packets_delete_callback__works), cmocka_unit_test(test__f_fss_simple_packets_destroy_callback__works), cmocka_unit_test(test__f_fss_simple_packetss_delete_callback__works), @@ -120,6 +144,24 @@ int main(void) { cmocka_unit_test(test__f_fss_skip_past_delimit__parameter_checking), cmocka_unit_test(test__f_fss_skip_past_space__parameter_checking), + cmocka_unit_test(test__f_fss_item_delete__parameter_checking), + cmocka_unit_test(test__f_fss_item_destroy__parameter_checking), + + cmocka_unit_test(test__f_fss_named_delete__parameter_checking), + cmocka_unit_test(test__f_fss_named_destroy__parameter_checking), + + cmocka_unit_test(test__f_fss_named_delete__parameter_checking), + cmocka_unit_test(test__f_fss_named_destroy__parameter_checking), + + cmocka_unit_test(test__f_fss_set_delete__parameter_checking), + cmocka_unit_test(test__f_fss_set_destroy__parameter_checking), + + cmocka_unit_test(test__f_fss_set_quote_delete__parameter_checking), + cmocka_unit_test(test__f_fss_set_quote_destroy__parameter_checking), + + cmocka_unit_test(test__f_fss_simple_packet_delete__parameter_checking), + cmocka_unit_test(test__f_fss_simple_packet_destroy__parameter_checking), + // f_fss_items_delete_callback() doesn't use parameter checking. // f_fss_items_destroy_callback() doesn't use parameter checking. // f_fss_itemss_delete_callback() doesn't use parameter checking. @@ -132,14 +174,14 @@ int main(void) { // f_fss_nests_destroy_callback() doesn't use parameter checking. // f_fss_nestss_delete_callback() doesn't use parameter checking. // f_fss_nestss_destroy_callback() doesn't use parameter checking. - // f_fss_set_quotes_delete_callback() doesn't use parameter checking. - // f_fss_set_quotes_destroy_callback() doesn't use parameter checking. - // f_fss_set_quotess_delete_callback() doesn't use parameter checking. - // f_fss_set_quotess_destroy_callback() doesn't use parameter checking. // f_fss_sets_delete_callback() doesn't use parameter checking. // f_fss_sets_destroy_callback() doesn't use parameter checking. // f_fss_setss_delete_callback() doesn't use parameter checking. // f_fss_setss_destroy_callback() doesn't use parameter checking. + // f_fss_set_quotes_delete_callback() doesn't use parameter checking. + // f_fss_set_quotes_destroy_callback() doesn't use parameter checking. + // f_fss_set_quotess_delete_callback() doesn't use parameter checking. + // f_fss_set_quotess_destroy_callback() doesn't use parameter checking. // f_fss_simple_packets_delete_callback() doesn't use parameter checking. // f_fss_simple_packets_destroy_callback() doesn't use parameter checking. // f_fss_simple_packetss_delete_callback() doesn't use parameter checking. diff --git a/level_0/f_fss/tests/unit/c/test-fss.h b/level_0/f_fss/tests/unit/c/test-fss.h index 4e9eceb..304183c 100644 --- a/level_0/f_fss/tests/unit/c/test-fss.h +++ b/level_0/f_fss/tests/unit/c/test-fss.h @@ -36,31 +36,43 @@ #include "test-fss-is_graph.h" #include "test-fss-is_space.h" #include "test-fss-is_zero_width.h" -#include "test-fss-items_destroy_callback.h" +#include "test-fss-item_delete.h" +#include "test-fss-item_destroy.h" #include "test-fss-items_delete_callback.h" -#include "test-fss-itemss_destroy_callback.h" +#include "test-fss-items_destroy_callback.h" #include "test-fss-itemss_delete_callback.h" -#include "test-fss-nameds_destroy_callback.h" +#include "test-fss-itemss_destroy_callback.h" +#include "test-fss-named_delete.h" +#include "test-fss-named_destroy.h" #include "test-fss-nameds_delete_callback.h" -#include "test-fss-namedss_destroy_callback.h" +#include "test-fss-nameds_destroy_callback.h" #include "test-fss-namedss_delete_callback.h" -#include "test-fss-nests_destroy_callback.h" +#include "test-fss-namedss_destroy_callback.h" +#include "test-fss-nest_delete.h" +#include "test-fss-nest_destroy.h" #include "test-fss-nests_delete_callback.h" -#include "test-fss-nestss_destroy_callback.h" +#include "test-fss-nests_destroy_callback.h" #include "test-fss-nestss_delete_callback.h" +#include "test-fss-nestss_destroy_callback.h" #include "test-fss-seek_to_eol.h" -#include "test-fss-set_quotes_destroy_callback.h" -#include "test-fss-set_quotes_delete_callback.h" -#include "test-fss-set_quotess_destroy_callback.h" -#include "test-fss-set_quotess_delete_callback.h" -#include "test-fss-sets_destroy_callback.h" +#include "test-fss-set_delete.h" +#include "test-fss-set_destroy.h" #include "test-fss-sets_delete_callback.h" -#include "test-fss-setss_destroy_callback.h" +#include "test-fss-sets_destroy_callback.h" #include "test-fss-setss_delete_callback.h" -#include "test-fss-simple_packets_destroy_callback.h" +#include "test-fss-setss_destroy_callback.h" +#include "test-fss-set_quote_delete.h" +#include "test-fss-set_quote_destroy.h" +#include "test-fss-set_quotes_delete_callback.h" +#include "test-fss-set_quotes_destroy_callback.h" +#include "test-fss-set_quotess_delete_callback.h" +#include "test-fss-set_quotess_destroy_callback.h" +#include "test-fss-simple_packet_delete.h" +#include "test-fss-simple_packet_destroy.h" #include "test-fss-simple_packets_delete_callback.h" -#include "test-fss-simple_packetss_destroy_callback.h" +#include "test-fss-simple_packets_destroy_callback.h" #include "test-fss-simple_packetss_delete_callback.h" +#include "test-fss-simple_packetss_destroy_callback.h" #include "test-fss-skip_past_delimit.h" #include "test-fss-skip_past_space.h" diff --git a/level_0/f_iki/c/iki.c b/level_0/f_iki/c/iki.c index af54c74..811847e 100644 --- a/level_0/f_iki/c/iki.c +++ b/level_0/f_iki/c/iki.c @@ -322,13 +322,13 @@ extern "C" { } if (buffer->string[range->start] == quote) { - state->status = f_string_ranges_increase(state->step_small, &data->variable); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &data->variable.array, &data->variable.used, &data->variable.size); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, &data->vocabulary); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &data->vocabulary.array, &data->vocabulary.used, &data->vocabulary.size); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, &data->content); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &data->content.array, &data->content.used, &data->content.size); if (F_status_is_error(state->status)) break; data->variable.array[data->variable.used].start = found_vocabulary.start; @@ -395,13 +395,13 @@ extern "C" { // Valid content's ending quote is not delimited, save and return. if (content_slash_total % 2 == 0) { - state->status = f_string_ranges_increase(state->step_small, &data->variable); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &data->variable.array, &data->variable.used, &data->variable.size); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, &data->vocabulary); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &data->vocabulary.array, &data->vocabulary.used, &data->vocabulary.size); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, &data->content); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &data->content.array, &data->content.used, &data->content.size); if (F_status_is_error(state->status)) break; data->variable.array[data->variable.used].start = found_vocabulary.start; diff --git a/level_0/f_iki/c/iki/data.c b/level_0/f_iki/c/iki/data.c index 4f6d7cc..41af639 100644 --- a/level_0/f_iki/c/iki/data.c +++ b/level_0/f_iki/c/iki/data.c @@ -13,16 +13,16 @@ extern "C" { #endif // _di_level_0_parameter_checking_ { - f_status_t status = f_string_ranges_resize(0, &data->content); + f_status_t status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &data->content.array, &data->content.used, &data->content.size); if (F_status_is_error(status)) return status; status = f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &data->delimits.array, &data->delimits.used, &data->delimits.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_resize(0, &data->variable); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &data->variable.array, &data->variable.used, &data->variable.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_resize(0, &data->vocabulary); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &data->vocabulary.array, &data->vocabulary.used, &data->vocabulary.size); if (F_status_is_error(status)) return status; } @@ -37,16 +37,16 @@ extern "C" { #endif // _di_level_0_parameter_checking_ { - f_status_t status = f_string_ranges_adjust(0, &data->content); + f_status_t status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &data->content.array, &data->content.used, &data->content.size); if (F_status_is_error(status)) return status; status = f_memory_array_adjust(0, sizeof(f_number_unsigned_t), (void **) &data->delimits.array, &data->delimits.used, &data->delimits.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_adjust(0, &data->variable); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &data->variable.array, &data->variable.used, &data->variable.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_adjust(0, &data->vocabulary); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &data->vocabulary.array, &data->vocabulary.used, &data->vocabulary.size); if (F_status_is_error(status)) return status; } @@ -118,16 +118,16 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_resize(0, &array[i].content); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].content.array, &array[i].content.used, &array[i].content.size); if (F_status_is_error(status)) return status; status = f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &array[i].delimits.array, &array[i].delimits.used, &array[i].delimits.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_resize(0, &array[i].variable); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].variable.array, &array[i].variable.used, &array[i].variable.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_resize(0, &array[i].vocabulary); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].vocabulary.array, &array[i].vocabulary.used, &array[i].vocabulary.size); if (F_status_is_error(status)) return status; } // for } @@ -145,16 +145,16 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - status = f_string_ranges_adjust(0, &array[i].content); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].content.array, &array[i].content.used, &array[i].content.size); if (F_status_is_error(status)) return status; status = f_memory_array_adjust(0, sizeof(f_number_unsigned_t), (void **) &array[i].delimits.array, &array[i].delimits.used, &array[i].delimits.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_adjust(0, &array[i].variable); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].variable.array, &array[i].variable.used, &array[i].variable.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_adjust(0, &array[i].vocabulary); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].vocabulary.array, &array[i].vocabulary.used, &array[i].vocabulary.size); if (F_status_is_error(status)) return status; } // for } @@ -171,11 +171,13 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_iki_datas_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_iki_datas_t), (void **) &destination->array, &destination->used, &destination->size); + 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; + status = private_f_iki_datas_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } ++destination->used; @@ -191,18 +193,20 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_iki_datas_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_iki_datas_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used].used = 0; + 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 + 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_okay; } @@ -220,16 +224,16 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_resize(0, &array[i].array[j].content); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array[j].content.array, &array[i].array[j].content.used, &array[i].array[j].content.size); if (F_status_is_error(status)) return status; status = f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &array[i].array[j].delimits.array, &array[i].array[j].delimits.used, &array[i].array[j].delimits.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_resize(0, &array[i].array[j].variable); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array[j].variable.array, &array[i].array[j].variable.used, &array[i].array[j].variable.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_resize(0, &array[i].array[j].vocabulary); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array[j].vocabulary.array, &array[i].array[j].vocabulary.used, &array[i].array[j].vocabulary.size); if (F_status_is_error(status)) return status; } // for @@ -256,16 +260,16 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - status = f_string_ranges_adjust(0, &array[i].array[j].content); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array[j].content.array, &array[i].array[j].content.used, &array[i].array[j].content.size); if (F_status_is_error(status)) return status; status = f_memory_array_adjust(0, sizeof(f_number_unsigned_t), (void **) &array[i].array[j].delimits.array, &array[i].array[j].delimits.used, &array[i].array[j].delimits.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_adjust(0, &array[i].array[j].variable); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array[j].variable.array, &array[i].array[j].variable.used, &array[i].array[j].variable.size); if (F_status_is_error(status)) return status; - status = f_string_ranges_adjust(0, &array[i].array[j].vocabulary); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array[j].vocabulary.array, &array[i].array[j].vocabulary.used, &array[i].array[j].vocabulary.size); if (F_status_is_error(status)) return status; } // for diff --git a/level_0/f_iki/c/iki/data.h b/level_0/f_iki/c/iki/data.h index 1234792..51de838 100644 --- a/level_0/f_iki/c/iki/data.h +++ b/level_0/f_iki/c/iki/data.h @@ -28,10 +28,8 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). * * @see f_memory_array_resize() - * @see f_string_ranges_resize() */ #ifndef _di_f_iki_data_delete_ extern f_status_t f_iki_data_delete(f_iki_data_t * const data); @@ -49,10 +47,8 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_adjust(). - * Errors (with error bit) from: f_string_ranges_adjust(). * * @see f_memory_array_adjust() - * @see f_string_ranges_adjust() */ #ifndef _di_f_iki_data_destroy_ extern f_status_t f_iki_data_destroy(f_iki_data_t * const data); @@ -184,11 +180,9 @@ extern "C" { * * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). * * @see f_memory_array_increase() * @see f_memory_array_resize() - * @see f_string_ranges_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 * const destination); @@ -210,11 +204,9 @@ extern "C" { * * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). * * @see f_memory_array_increase_by() * @see f_memory_array_resize() - * @see f_string_ranges_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 * const destination); @@ -243,7 +235,6 @@ extern "C" { * Errors (with error bit) from: f_memory_array_resize(). * * @see f_memory_array_resize() - * @see f_memory_arrays_resize() */ #ifndef _di_f_iki_datass_delete_callback_ extern f_status_t f_iki_datass_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); @@ -272,7 +263,6 @@ extern "C" { * Errors (with error bit) from: f_memory_array_adjust(). * * @see f_memory_array_adjust() - * @see f_memory_arrays_adjust() */ #ifndef _di_f_iki_datass_destroy_callback_ extern f_status_t f_iki_datass_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); diff --git a/level_0/f_iki/data/build/settings-mocks b/level_0/f_iki/data/build/settings-mocks index c6241fb..779a827 100644 --- a/level_0/f_iki/data/build/settings-mocks +++ b/level_0/f_iki/data/build/settings-mocks @@ -67,5 +67,3 @@ flags_library -fPIC # Inject mocks. flags -Wl,--wrap=f_memory_array_adjust flags -Wl,--wrap=f_memory_array_resize -flags -Wl,--wrap=f_string_ranges_adjust -flags -Wl,--wrap=f_string_ranges_resize diff --git a/level_0/f_iki/tests/unit/c/mock-iki.c b/level_0/f_iki/tests/unit/c/mock-iki.c index 4ea9c7b..f524333 100644 --- a/level_0/f_iki/tests/unit/c/mock-iki.c +++ b/level_0/f_iki/tests/unit/c/mock-iki.c @@ -41,40 +41,6 @@ f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const return mock_type(f_status_t); } -f_status_t __wrap_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure) { - - if (mock_unwrap) { - return __real_f_string_ranges_adjust(length, structure); - } - - if (!structure) return F_status_set_error(F_parameter_not); - - const bool failure = mock_type(bool); - - if (failure) return mock_type(f_status_t); - - structure->size = length; - - return mock_type(f_status_t); -} - -f_status_t __wrap_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure) { - - if (mock_unwrap) { - return __real_f_string_ranges_resize(length, structure); - } - - if (!structure) return F_status_set_error(F_parameter_not); - - const bool failure = mock_type(bool); - - if (failure) return mock_type(f_status_t); - - structure->size = length; - - return mock_type(f_status_t); -} - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_iki/tests/unit/c/mock-iki.h b/level_0/f_iki/tests/unit/c/mock-iki.h index 51dcaa7..9946ea2 100644 --- a/level_0/f_iki/tests/unit/c/mock-iki.h +++ b/level_0/f_iki/tests/unit/c/mock-iki.h @@ -35,15 +35,9 @@ extern int mock_unwrap_f_memory; extern f_status_t __real_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); extern f_status_t __real_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); -extern f_status_t __real_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure); -extern f_status_t __real_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure); - extern f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); extern f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); -extern f_status_t __wrap_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure); -extern f_status_t __wrap_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure); - #ifdef __cplusplus } // extern "C" #endif 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 index 106d2b5..7d39944 100644 --- 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 @@ -14,7 +14,7 @@ void test__f_iki_datas_append__works(void **state) { { f_number_unsigned_t i = 1; - f_status_t status = f_string_ranges_resize(length, &source.content); + f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.content.array, &source.content.used, &source.content.size); assert_int_equal(status, F_okay); assert_int_equal(source.content.size, length); @@ -24,12 +24,12 @@ void test__f_iki_datas_append__works(void **state) { assert_int_equal(status, F_okay); assert_int_equal(source.delimits.size, length); - status = f_string_ranges_resize(length, &source.variable); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.variable.array, &source.variable.used, &source.variable.size); assert_int_equal(status, F_okay); assert_int_equal(source.variable.size, length); - status = f_string_ranges_resize(length, &source.vocabulary); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.vocabulary.array, &source.vocabulary.used, &source.vocabulary.size); assert_int_equal(status, F_okay); assert_int_equal(source.vocabulary.size, length); 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 index d8952f6..3866f4c 100644 --- 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 @@ -22,7 +22,7 @@ void test__f_iki_datas_append_all__works(void **state) { for (; j < 2; ++j) { - status = f_string_ranges_resize(length, &source.array[j].content); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[j].content.array, &source.array[j].content.used, &source.array[j].content.size); assert_int_equal(status, F_okay); assert_int_equal(source.array[j].content.size, length); @@ -32,12 +32,12 @@ void test__f_iki_datas_append_all__works(void **state) { assert_int_equal(status, F_okay); assert_int_equal(source.array[j].delimits.size, length); - status = f_string_ranges_resize(length, &source.array[j].variable); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[j].variable.array, &source.array[j].variable.used, &source.array[j].variable.size); assert_int_equal(status, F_okay); assert_int_equal(source.array[j].variable.size, length); - status = f_string_ranges_resize(length, &source.array[j].vocabulary); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[j].vocabulary.array, &source.array[j].vocabulary.used, &source.array[j].vocabulary.size); assert_int_equal(status, F_okay); assert_int_equal(source.array[j].vocabulary.size, length); diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_delete_callback.c b/level_0/f_iki/tests/unit/c/test-iki-datas_delete_callback.c index 3701bcc..89ba1fc 100644 --- a/level_0/f_iki/tests/unit/c/test-iki-datas_delete_callback.c +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_delete_callback.c @@ -20,8 +20,8 @@ void test__f_iki_datas_delete_callback__fails(void **state) { f_iki_datas_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_iki_datas_delete_callback(0, 1, (void *) datas_array); @@ -29,8 +29,8 @@ void test__f_iki_datas_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, true); will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); @@ -41,14 +41,14 @@ void test__f_iki_datas_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, false); will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_iki_datas_delete_callback(0, 1, (void *) datas_array); @@ -56,17 +56,17 @@ void test__f_iki_datas_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, false); will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_iki_datas_delete_callback(0, 1, (void *) datas_array); @@ -77,35 +77,40 @@ void test__f_iki_datas_delete_callback__fails(void **state) { void test__f_iki_datas_delete_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_string_ranges_t content = f_string_ranges_t_initialize; - f_number_unsigneds_t delimits = f_number_unsigneds_t_initialize; - f_string_ranges_t variable = f_string_ranges_t_initialize; - f_string_ranges_t vocabulary = f_string_ranges_t_initialize; - f_iki_data_t data = { .content = content, .delimits = delimits, .variable = variable, .vocabulary = vocabulary }; - f_iki_data_t data_array[] = { data }; - f_iki_datas_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_iki_datas_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_iki_datas_t datas = f_iki_datas_t_initialize; + { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + f_status_t status = f_memory_array_resize(1, sizeof(f_iki_data_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_array_resize, false); - will_return(__wrap_f_memory_array_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].content.array, &datas.array[0].content.used, &datas.array[0].content.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_number_unsigned_t), (void **) &datas.array[0].delimits.array, &datas.array[0].delimits.used, &datas.array[0].delimits.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].variable.array, &datas.array[0].variable.used, &datas.array[0].variable.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].vocabulary.array, &datas.array[0].vocabulary.used, &datas.array[0].vocabulary.size); + assert_int_equal(status, F_okay); + } - const f_status_t status = f_iki_datas_delete_callback(0, length, (void *) datas_array); + { + const f_status_t status = f_iki_datas_delete_callback(0, length, (void *) datas.array); assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].content.size, 0); + assert_int_equal(datas.array[0].delimits.size, 0); + assert_int_equal(datas.array[0].variable.size, 0); + assert_int_equal(datas.array[0].vocabulary.size, 0); } + + free((void *) datas.array); } #ifdef __cplusplus diff --git a/level_0/f_iki/tests/unit/c/test-iki-datas_destroy_callback.c b/level_0/f_iki/tests/unit/c/test-iki-datas_destroy_callback.c index 485984f..fc7c467 100644 --- a/level_0/f_iki/tests/unit/c/test-iki-datas_destroy_callback.c +++ b/level_0/f_iki/tests/unit/c/test-iki-datas_destroy_callback.c @@ -20,8 +20,8 @@ void test__f_iki_datas_destroy_callback__fails(void **state) { f_iki_datas_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_iki_datas_destroy_callback(0, 1, (void *) datas_array); @@ -29,8 +29,8 @@ void test__f_iki_datas_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, true); will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); @@ -41,14 +41,14 @@ void test__f_iki_datas_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, false); will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_iki_datas_destroy_callback(0, 1, (void *) datas_array); @@ -56,17 +56,17 @@ void test__f_iki_datas_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, false); will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_iki_datas_destroy_callback(0, 1, (void *) datas_array); @@ -77,35 +77,40 @@ void test__f_iki_datas_destroy_callback__fails(void **state) { void test__f_iki_datas_destroy_callback__works(void **state) { mock_unwrap = 0; - mock_unwrap_f_memory = 0; + mock_unwrap_f_memory = 1; - f_string_ranges_t content = f_string_ranges_t_initialize; - f_number_unsigneds_t delimits = f_number_unsigneds_t_initialize; - f_string_ranges_t variable = f_string_ranges_t_initialize; - f_string_ranges_t vocabulary = f_string_ranges_t_initialize; - f_iki_data_t data = { .content = content, .delimits = delimits, .variable = variable, .vocabulary = vocabulary }; - f_iki_data_t data_array[] = { data }; - f_iki_datas_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_iki_datas_t datas_array[] = { datas }; const f_number_unsigned_t length = 1; + f_iki_datas_t datas = f_iki_datas_t_initialize; + { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + f_status_t status = f_memory_array_resize(1, sizeof(f_iki_data_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_memory_array_adjust, false); - will_return(__wrap_f_memory_array_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].content.array, &datas.array[0].content.used, &datas.array[0].content.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_number_unsigned_t), (void **) &datas.array[0].delimits.array, &datas.array[0].delimits.used, &datas.array[0].delimits.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].variable.array, &datas.array[0].variable.used, &datas.array[0].variable.size); + assert_int_equal(status, F_okay); - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datas.array[0].vocabulary.array, &datas.array[0].vocabulary.used, &datas.array[0].vocabulary.size); + assert_int_equal(status, F_okay); + } - const f_status_t status = f_iki_datas_destroy_callback(0, length, (void *) datas_array); + { + const f_status_t status = f_iki_datas_destroy_callback(0, length, (void *) datas.array); assert_int_equal(status, F_okay); + assert_int_equal(datas.array[0].content.size, 0); + assert_int_equal(datas.array[0].delimits.size, 0); + assert_int_equal(datas.array[0].variable.size, 0); + assert_int_equal(datas.array[0].vocabulary.size, 0); } + + free((void *) datas.array); } #ifdef __cplusplus 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 index e864736..f9ab654 100644 --- 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 @@ -22,7 +22,7 @@ void test__f_iki_datass_append__works(void **state) { for (f_number_unsigned_t j = 0; j < length_outer; ++j) { - status = f_string_ranges_resize(length, &source.array[j].content); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[j].content.array, &source.array[j].content.used, &source.array[j].content.size); assert_int_equal(status, F_okay); assert_int_equal(source.array[j].content.size, length); @@ -32,12 +32,12 @@ void test__f_iki_datass_append__works(void **state) { assert_int_equal(status, F_okay); assert_int_equal(source.array[j].delimits.size, length); - status = f_string_ranges_resize(length, &source.array[j].variable); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[j].variable.array, &source.array[j].variable.used, &source.array[j].variable.size); assert_int_equal(status, F_okay); assert_int_equal(source.array[j].variable.size, length); - status = f_string_ranges_resize(length, &source.array[j].vocabulary); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[j].vocabulary.array, &source.array[j].vocabulary.used, &source.array[j].vocabulary.size); assert_int_equal(status, F_okay); assert_int_equal(source.array[j].vocabulary.size, length); 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 index dab365a..7281c40 100644 --- 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 @@ -31,7 +31,7 @@ void test__f_iki_datass_append_all__works(void **state) { for (j = 0; j < length_inner; ++j) { - status = f_string_ranges_resize(length, &source.array[source.used].array[j].content); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[source.used].array[j].content.array, &source.array[source.used].array[j].content.used, &source.array[source.used].array[j].content.size); assert_int_equal(status, F_okay); assert_int_equal(source.array[source.used].array[j].content.size, length); @@ -41,12 +41,12 @@ void test__f_iki_datass_append_all__works(void **state) { assert_int_equal(status, F_okay); 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); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[source.used].array[j].variable.array, &source.array[source.used].array[j].variable.used, &source.array[source.used].array[j].variable.size); assert_int_equal(status, F_okay); 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); + status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array[source.used].array[j].vocabulary.array, &source.array[source.used].array[j].vocabulary.used, &source.array[source.used].array[j].vocabulary.size); assert_int_equal(status, F_okay); assert_int_equal(source.array[source.used].array[j].vocabulary.size, length); diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_delete_callback.c b/level_0/f_iki/tests/unit/c/test-iki-datass_delete_callback.c index 69accc7..742631a 100644 --- a/level_0/f_iki/tests/unit/c/test-iki-datass_delete_callback.c +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_delete_callback.c @@ -20,8 +20,8 @@ void test__f_iki_datass_delete_callback__fails(void **state) { f_iki_datas_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_iki_datass_delete_callback(0, 1, (void *) datas_array); @@ -29,8 +29,8 @@ void test__f_iki_datass_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, true); will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); @@ -41,14 +41,14 @@ void test__f_iki_datass_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, false); will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_iki_datass_delete_callback(0, 1, (void *) datas_array); @@ -56,17 +56,17 @@ void test__f_iki_datass_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, false); will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_ranges_resize, true); - will_return(__wrap_f_string_ranges_resize, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); const f_status_t status = f_iki_datass_delete_callback(0, 1, (void *) datas_array); @@ -74,17 +74,17 @@ void test__f_iki_datass_delete_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, false); will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); - will_return(__wrap_f_string_ranges_resize, false); - will_return(__wrap_f_string_ranges_resize, F_okay); + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); will_return(__wrap_f_memory_array_resize, true); will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); @@ -97,7 +97,7 @@ void test__f_iki_datass_delete_callback__fails(void **state) { void test__f_iki_datass_delete_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -111,16 +111,16 @@ void test__f_iki_datass_delete_callback__works(void **state) { status = f_memory_array_resize(1, sizeof(f_iki_data_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_resize(1, &datass.array[0].array[0].content); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].content.array, &datass.array[0].array[0].content.used, &datass.array[0].array[0].content.size); assert_int_equal(status, F_okay); status = f_memory_array_resize(1, sizeof(f_number_unsigned_t), (void **) &datass.array[0].array[0].delimits.array, &datass.array[0].array[0].delimits.used, &datass.array[0].array[0].delimits.size); assert_int_equal(status, F_okay); - status = f_string_ranges_resize(1, &datass.array[0].array[0].variable); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].variable.array, &datass.array[0].array[0].variable.used, &datass.array[0].array[0].variable.size); assert_int_equal(status, F_okay); - status = f_string_ranges_resize(1, &datass.array[0].array[0].vocabulary); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].vocabulary.array, &datass.array[0].array[0].vocabulary.used, &datass.array[0].array[0].vocabulary.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_iki/tests/unit/c/test-iki-datass_destroy_callback.c b/level_0/f_iki/tests/unit/c/test-iki-datass_destroy_callback.c index a89d619..9e705ab 100644 --- a/level_0/f_iki/tests/unit/c/test-iki-datass_destroy_callback.c +++ b/level_0/f_iki/tests/unit/c/test-iki-datass_destroy_callback.c @@ -20,8 +20,8 @@ void test__f_iki_datass_destroy_callback__fails(void **state) { f_iki_datas_t datas_array[] = { datas }; { - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_iki_datass_destroy_callback(0, 1, (void *) datas_array); @@ -29,8 +29,8 @@ void test__f_iki_datass_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, true); will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); @@ -41,14 +41,14 @@ void test__f_iki_datass_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, false); will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_iki_datass_destroy_callback(0, 1, (void *) datas_array); @@ -56,17 +56,17 @@ void test__f_iki_datass_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, false); will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_ranges_adjust, true); - will_return(__wrap_f_string_ranges_adjust, F_status_set_error(F_failure)); + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); const f_status_t status = f_iki_datass_destroy_callback(0, 1, (void *) datas_array); @@ -74,17 +74,17 @@ void test__f_iki_datass_destroy_callback__fails(void **state) { } { - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, false); will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); - will_return(__wrap_f_string_ranges_adjust, false); - will_return(__wrap_f_string_ranges_adjust, F_okay); + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); will_return(__wrap_f_memory_array_adjust, true); will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); @@ -97,7 +97,7 @@ void test__f_iki_datass_destroy_callback__fails(void **state) { void test__f_iki_datass_destroy_callback__works(void **state) { - mock_unwrap = 1; + mock_unwrap = 0; mock_unwrap_f_memory = 1; const f_number_unsigned_t length = 1; @@ -105,22 +105,22 @@ void test__f_iki_datass_destroy_callback__works(void **state) { f_iki_datass_t datass = f_iki_datass_t_initialize; { - f_status_t status = f_memory_array_adjust(length, sizeof(f_iki_datas_t), (void **) &datass.array, &datass.used, &datass.size); + f_status_t status = f_memory_array_resize(length, sizeof(f_iki_datas_t), (void **) &datass.array, &datass.used, &datass.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_iki_data_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + status = f_memory_array_resize(1, sizeof(f_iki_data_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); assert_int_equal(status, F_okay); - status = f_string_ranges_adjust(1, &datass.array[0].array[0].content); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].content.array, &datass.array[0].array[0].content.used, &datass.array[0].array[0].content.size); assert_int_equal(status, F_okay); - status = f_memory_array_adjust(1, sizeof(f_number_unsigned_t), (void **) &datass.array[0].array[0].delimits.array, &datass.array[0].array[0].delimits.used, &datass.array[0].array[0].delimits.size); + status = f_memory_array_resize(1, sizeof(f_number_unsigned_t), (void **) &datass.array[0].array[0].delimits.array, &datass.array[0].array[0].delimits.used, &datass.array[0].array[0].delimits.size); assert_int_equal(status, F_okay); - status = f_string_ranges_adjust(1, &datass.array[0].array[0].variable); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].variable.array, &datass.array[0].array[0].variable.used, &datass.array[0].array[0].variable.size); assert_int_equal(status, F_okay); - status = f_string_ranges_adjust(1, &datass.array[0].array[0].vocabulary); + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array[0].vocabulary.array, &datass.array[0].array[0].vocabulary.used, &datass.array[0].array[0].vocabulary.size); assert_int_equal(status, F_okay); } diff --git a/level_0/f_limit/tests/unit/c/test-limit.c b/level_0/f_limit/tests/unit/c/test-limit.c index 133613b..d51b731 100644 --- a/level_0/f_limit/tests/unit/c/test-limit.c +++ b/level_0/f_limit/tests/unit/c/test-limit.c @@ -22,14 +22,14 @@ int main(void) { cmocka_unit_test(test__f_limit_process__fails), cmocka_unit_test(test__f_limit_process__works), - cmocka_unit_test(test__f_limit_setss_destroy_callback__fails), cmocka_unit_test(test__f_limit_setss_delete_callback__fails), + cmocka_unit_test(test__f_limit_setss_destroy_callback__fails), cmocka_unit_test(test__f_limit_setss_delete_callback__works), cmocka_unit_test(test__f_limit_setss_destroy_callback__works), - cmocka_unit_test(test__f_limit_valuess_destroy_callback__fails), cmocka_unit_test(test__f_limit_valuess_delete_callback__fails), + cmocka_unit_test(test__f_limit_valuess_destroy_callback__fails), cmocka_unit_test(test__f_limit_valuess_delete_callback__works), cmocka_unit_test(test__f_limit_valuess_destroy_callback__works), @@ -37,11 +37,11 @@ int main(void) { #ifndef _di_level_0_parameter_checking_ cmocka_unit_test(test__f_limit_process__parameter_checking), - // f_limit_setss_destroy_callback() doesn't use parameter checking. // f_limit_setss_delete_callback() doesn't use parameter checking. + // f_limit_setss_destroy_callback() doesn't use parameter checking. - // f_limit_valuess_destroy_callback() doesn't use parameter checking. // f_limit_valuess_delete_callback() doesn't use parameter checking. + // f_limit_valuess_destroy_callback() doesn't use parameter checking. #endif // _di_level_0_parameter_checking_ }; diff --git a/level_0/f_path/tests/unit/c/test-path.c b/level_0/f_path/tests/unit/c/test-path.c index d3d3540..14e1d1b 100644 --- a/level_0/f_path/tests/unit/c/test-path.c +++ b/level_0/f_path/tests/unit/c/test-path.c @@ -25,7 +25,6 @@ int main(void) { cmocka_unit_test(test__f_path_change_at__fails), cmocka_unit_test(test__f_path_change_at__works), - // test__f_path_directory_cleanup__fails test isn't needed yet as f_string_dynamic_increase_by() aren't tested at this time. cmocka_unit_test(test__f_path_directory_cleanup__works), cmocka_unit_test(test__f_path_is__returns_false), diff --git a/level_0/f_serialize/c/serialize.c b/level_0/f_serialize/c/serialize.c index 5259f62..c2cb699 100644 --- a/level_0/f_serialize/c/serialize.c +++ b/level_0/f_serialize/c/serialize.c @@ -131,7 +131,7 @@ extern "C" { if (i + width > source.used) { total = i - start; - status = f_string_ranges_increase(F_memory_default_allocation_small_d, ranges); + status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); if (F_status_is_error(status)) return status; if (total) { @@ -149,7 +149,7 @@ extern "C" { if (source.string[i] == f_serialize_to_simple_splitter_s.string[0]) { total = i - start; - status = f_string_ranges_increase(F_memory_default_allocation_small_d, ranges); + status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); if (F_status_is_error(status)) return status; if (total) { @@ -165,7 +165,7 @@ extern "C" { // Handle case when splitter as at the end of the string, creating a new empty string. if (start == source.used) { - status = f_string_ranges_increase(F_memory_default_allocation_small_d, ranges); + status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); if (F_status_is_error(status)) return status; ranges->array[ranges->used].start = 1; @@ -180,7 +180,7 @@ extern "C" { if (start < source.used) { total = source.used - start; - status = f_string_ranges_increase(F_memory_default_allocation_small_d, ranges); + status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); if (F_status_is_error(status)) return status; if (total) { diff --git a/level_0/f_serialize/c/serialize.h b/level_0/f_serialize/c/serialize.h index 75f418a..71989c3 100644 --- a/level_0/f_serialize/c/serialize.h +++ b/level_0/f_serialize/c/serialize.h @@ -121,9 +121,9 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_ranges_increase() + * Errors (with error bit) from: f_memory_array_increase() * - * @see f_string_ranges_increase() + * @see f_memory_array_increase() */ #ifndef _di_f_serialize_from_simple_range_ extern f_status_t f_serialize_from_simple_range(const f_string_static_t source, f_string_ranges_t * const ranges); diff --git a/level_0/f_serialize/tests/unit/c/test-serialize-from_simple_range.c b/level_0/f_serialize/tests/unit/c/test-serialize-from_simple_range.c index 04315d7..125a8b3 100644 --- a/level_0/f_serialize/tests/unit/c/test-serialize-from_simple_range.c +++ b/level_0/f_serialize/tests/unit/c/test-serialize-from_simple_range.c @@ -28,7 +28,7 @@ void test__f_serialize_from_simple_range__returns_data_not(void **state) { assert_int_equal(status, F_data_not); } - f_string_ranges_resize(0, &ranges); + free((void *) ranges.array); } void test__f_serialize_from_simple_range__works(void **state) { @@ -98,7 +98,7 @@ void test__f_serialize_from_simple_range__works(void **state) { } // for } - f_string_ranges_resize(0, &ranges); + free((void *) ranges.array); } #ifdef __cplusplus diff --git a/level_0/f_string/c/private-string.c b/level_0/f_string/c/private-string.c index d2fef9e..e1953b8 100644 --- a/level_0/f_string/c/private-string.c +++ b/level_0/f_string/c/private-string.c @@ -26,45 +26,47 @@ extern "C" { if (destination->used >= F_string_t_size_d) return F_status_set_error(F_string_too_large); - f_status_t status = F_okay; - f_number_unsigned_t i = 0; - f_number_unsigned_t size = 0; + { + f_status_t status = F_okay; + f_number_unsigned_t i = 0; + f_number_unsigned_t size = 0; - // Count all of the NULLs and subtract them from the total size. - for (; i < length; ++i) { - if (source[i]) ++size; - } // for + // Count all of the NULLs and subtract them from the total size. + for (; i < length; ++i) { + if (source[i]) ++size; + } // for - if (size + 1 > F_string_t_size_d) return F_status_set_error(F_string_too_large); + if (size + 1 > F_string_t_size_d) return F_status_set_error(F_string_too_large); - status = f_memory_array_increase_by(size + 1, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; + status = f_memory_array_increase_by(size + 1, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; - f_number_unsigned_t first = 0; + f_number_unsigned_t first = 0; - for (i = 0, size = 0; i < length; ++i) { + for (i = 0, size = 0; i < length; ++i) { - if (source[i]) continue; + if (source[i]) continue; - if (i && i > first) { - size = i - first; + if (i && i > first) { + size = i - first; - memcpy(destination->string + destination->used, source + first, sizeof(f_char_t) * size); - destination->used += size; - } + memcpy(destination->string + destination->used, source + first, sizeof(f_char_t) * size); + destination->used += size; + } - while (i + 1 < length && !source[i + 1]) { - ++i; - } // while + while (i + 1 < length && !source[i + 1]) { + ++i; + } // while - first = i + 1; - } // for + first = i + 1; + } // for - if (i > first) { - size = i - first; + if (i > first) { + size = i - first; - memcpy(destination->string + destination->used, source + first, sizeof(f_char_t) * size); - destination->used += size; + memcpy(destination->string + destination->used, source + first, sizeof(f_char_t) * size); + destination->used += size; + } } destination->string[destination->used] = 0; diff --git a/level_0/f_string/c/string/dynamics.c b/level_0/f_string/c/string/dynamics.c index 6bcb579..ddc20dc 100644 --- a/level_0/f_string/c/string/dynamics.c +++ b/level_0/f_string/c/string/dynamics.c @@ -1,6 +1,5 @@ #include "../string.h" #include "../private-string.h" -#include "private-dynamics.h" #ifdef __cplusplus extern "C" { @@ -14,7 +13,21 @@ extern "C" { if (!source.used) return F_data_not; - return private_f_string_dynamics_append(source, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &destination->array, &destination->used, &destination->size); + 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_okay; } #endif // _di_f_string_dynamics_append_ @@ -26,7 +39,22 @@ extern "C" { if (!source.used) return F_data_not; - return private_f_string_dynamics_append_all(source, destination); + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_dynamic_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; + + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + + 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_okay; } #endif // _di_f_string_dynamics_append_all_ diff --git a/level_0/f_string/c/string/dynamicss.c b/level_0/f_string/c/string/dynamicss.c index 870872b..0879d1a 100644 --- a/level_0/f_string/c/string/dynamicss.c +++ b/level_0/f_string/c/string/dynamicss.c @@ -1,6 +1,5 @@ #include "../string.h" #include "../private-string.h" -#include "private-dynamics.h" #ifdef __cplusplus extern "C" { @@ -18,11 +17,22 @@ extern "C" { f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_dynamics_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - destination->array[destination->used].used = 0; + f_string_dynamics_t * const destination_inner = &destination->array[destination->used]; + destination_inner->used = 0; if (source.used) { - status = private_f_string_dynamics_append_all(source, &destination->array[destination->used]); + status = f_memory_array_increase_by(source.used, sizeof(f_string_dynamic_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); if (F_status_is_error(status)) return status; + + for (f_number_unsigned_t j = 0; j < source.used; ++j, ++destination_inner->used) { + + destination_inner->array[destination_inner->used].used = 0; + + if (source.array[j].used) { + status = private_f_string_append(source.array[j].string, source.array[j].used, &destination_inner->array[destination_inner->used]); + if (F_status_is_error(status)) return status; + } + } // for } } @@ -49,8 +59,18 @@ extern "C" { 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]); + status = f_memory_array_increase_by(source.array[i].used, sizeof(f_string_dynamic_t), (void **) &destination->array[destination->used].array, &destination->array[destination->used].used, &destination->array[destination->used].size); if (F_status_is_error(status)) return status; + + for (f_number_unsigned_t j = 0; j < source.array[i].used; ++j, ++destination->array[destination->used].used) { + + destination->array[destination->used].array[destination->array[destination->used].used].used = 0; + + if (source.array[i].array[j].used) { + status = private_f_string_append(source.array[i].array[j].string, source.array[i].array[j].used, &destination->array[destination->used].array[destination->array[destination->used].used]); + if (F_status_is_error(status)) return status; + } + } // for } } // for } diff --git a/level_0/f_string/c/string/map_multis.c b/level_0/f_string/c/string/map_multis.c index 37412a1..375faea 100644 --- a/level_0/f_string/c/string/map_multis.c +++ b/level_0/f_string/c/string/map_multis.c @@ -1,46 +1,44 @@ #include "../string.h" #include "../private-string.h" -#include "private-dynamics.h" -#include "private-map_multis.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_map_multis_adjust_ - f_status_t f_string_map_multis_adjust(const f_number_unsigned_t length, f_string_map_multis_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_map_multis_adjust(length, structure); - } -#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_okay; - - if (destination->used + 1 > destination->size) { - status = private_f_string_map_multis_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_map_multi_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; + f_string_map_multi_t * const destination_inner = &destination->array[destination->used]; - 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; - } + destination_inner->name.used = 0; + destination_inner->value.used = 0; - 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; + if (source.name.used) { + status = private_f_string_append(source.name.string, source.name.used, &destination_inner->name); + if (F_status_is_error(status)) return status; + } + + if (source.value.used) { + status = f_memory_array_increase_by(source.value.used, sizeof(f_string_dynamic_t), (void **) &destination_inner->value.array, &destination_inner->value.used, &destination_inner->value.size); + if (F_status_is_error(status)) return status; + + for (f_number_unsigned_t j = 0; j < source.value.used; ++j, ++destination_inner->value.used) { + + destination_inner->value.array[destination_inner->value.used].used = 0; + + if (source.value.array[j].used) { + status = private_f_string_append(source.value.array[j].string, source.value.array[j].used, &destination_inner->value.array[destination_inner->value.used]); + if (F_status_is_error(status)) return status; + } + } // for + } } ++destination->used; @@ -57,87 +55,108 @@ extern "C" { 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_ + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_map_multi_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; -#ifndef _di_f_string_map_multis_decimate_by_ - f_status_t f_string_map_multis_decimate_by(const f_number_unsigned_t amount, f_string_map_multis_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + f_string_map_multi_t * destination_inner = 0; + f_number_unsigned_t j = 0; - if (!amount) return F_data_not; + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - return private_f_string_map_multis_adjust((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_map_multis_decimate_by_ + destination_inner = &destination->array[destination->used]; + destination_inner->name.used = 0; + destination_inner->value.used = 0; -#ifndef _di_f_string_map_multis_decrease_by_ - f_status_t f_string_map_multis_decrease_by(const f_number_unsigned_t amount, f_string_map_multis_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (source.array[i].name.used) { + status = private_f_string_append(source.array[i].name.string, source.array[i].name.used, &destination_inner->name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].value.used) { + status = f_memory_array_increase_by(source.array[i].value.used, sizeof(f_string_dynamic_t), (void **) &destination_inner->value.array, &destination_inner->value.used, &destination_inner->value.size); + if (F_status_is_error(status)) return status; + + for (j = 0; j < source.array[i].value.used; ++j, ++destination_inner->value.used) { - if (!amount) return F_data_not; + destination_inner->value.array[destination_inner->value.used].used = 0; - return private_f_string_map_multis_resize((structure->size > amount) ? structure->size - amount : 0, structure); + if (source.array[i].value.array[j].used) { + status = private_f_string_append(source.array[i].value.array[j].string, source.array[i].value.array[j].used, &destination_inner->value.array[destination_inner->value.used]); + if (F_status_is_error(status)) return status; + } + } // for + } + } // for + } + + return F_okay; } -#endif // _di_f_string_map_multis_decrease_by_ +#endif // _di_f_string_map_multis_append_all_ -#ifndef _di_f_string_map_multis_increase_ - f_status_t f_string_map_multis_increase(const f_number_unsigned_t step, f_string_map_multis_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_map_multis_delete_callback_ + f_status_t f_string_map_multis_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; + { + f_string_map_multi_t * const array = (f_string_map_multi_t *) void_array; + f_status_t status = F_okay; + f_number_unsigned_t j = 0; - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + for (f_number_unsigned_t i = start; i < stop; ++i) { - length = F_number_t_size_unsigned_d; - } + if (array[i].name.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].name.string, &array[i].name.used, &array[i].name.size); + if (F_status_is_error(status)) return status; + } + + if (array[i].value.size) { + for (j = 0; j < array[i].value.size; ++j) { - return private_f_string_map_multis_resize(length, structure); + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].value.array[j].string, &array[i].value.array[j].used, &array[i].value.array[j].size); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_array_resize(0, sizeof(f_string_dynamic_t), (void **) &array[i].value.array, &array[i].value.used, &array[i].value.size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; + return F_okay; } -#endif // _di_f_string_map_multis_increase_ +#endif // _di_f_string_map_multis_delete_callback_ -#ifndef _di_f_string_map_multis_increase_by_ - f_status_t f_string_map_multis_increase_by(const f_number_unsigned_t amount, f_string_map_multis_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_map_multis_destroy_callback_ + f_status_t f_string_map_multis_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_string_map_multi_t * const array = (f_string_map_multi_t *) void_array; + f_status_t status = F_okay; + f_number_unsigned_t j = 0; - const f_number_unsigned_t length = structure->used + amount; + for (f_number_unsigned_t i = start; i < stop; ++i) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (array[i].name.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].name.string, &array[i].name.used, &array[i].name.size); + if (F_status_is_error(status)) return status; + } - return private_f_string_map_multis_resize(length, structure); - } - } + if (array[i].value.size) { + for (j = 0; j < array[i].value.size; ++j) { - return F_data_not; - } -#endif // _di_f_string_map_multis_increase_by_ + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].value.array[j].string, &array[i].value.array[j].used, &array[i].value.array[j].size); + if (F_status_is_error(status)) return status; + } // for -#ifndef _di_f_string_map_multis_resize_ - f_status_t f_string_map_multis_resize(const f_number_unsigned_t length, f_string_map_multis_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + status = f_memory_array_adjust(0, sizeof(f_string_dynamic_t), (void **) &array[i].value.array, &array[i].value.used, &array[i].value.size); + if (F_status_is_error(status)) return status; + } + } // for + } - return private_f_string_map_multis_resize(length, structure); + return F_okay; } -#endif // _di_f_string_map_multis_resize_ +#endif // _di_f_string_map_multis_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/map_multis.h b/level_0/f_string/c/string/map_multis.h index 5aafdb4..09c6c84 100644 --- a/level_0/f_string/c/string/map_multis.h +++ b/level_0/f_string/c/string/map_multis.h @@ -44,25 +44,6 @@ extern "C" { #endif // _di_f_string_map_multis_t_ /** - * Resize the map_multis array. - * - * @param length - * The new size to use. - * @param structure - * The map_multis array to resize. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_map_multis_t * const structure); -#endif // _di_f_string_map_multis_adjust_ - -/** * Append a single source map_multi onto the destination. * * @param source @@ -104,120 +85,60 @@ extern "C" { #endif // _di_f_string_map_multis_append_all_ /** - * Resize the map_multis array to a smaller size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_string_map_multis_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The map_multis array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_number_unsigned_t amount, f_string_map_multis_t * const structure); -#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 structure - * The map_multis array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay 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_number_unsigned_t amount, f_string_map_multis_t * const structure); -#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_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The map_multis array to resize. - * - * @return - * F_okay on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_array_resize(). * - * Errors (with error bit) from: f_memory_resize(). + * @see f_memory_array_resize() */ -#ifndef _di_f_string_map_multis_increase_ - extern f_status_t f_string_map_multis_increase(const f_number_unsigned_t step, f_string_map_multis_t * const structure); -#endif // _di_f_string_map_multis_increase_ +#ifndef _di_f_string_map_multis_delete_callback_ + extern f_status_t f_string_map_multis_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_map_multis_delete_callback_ /** - * Resize the map_multis array to a larger size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_string_map_multis_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The map_multis array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_number_unsigned_t amount, f_string_map_multis_t * const structure); -#endif // _di_f_string_map_multis_increase_by_ - -/** - * Resize the map_multis array. - * - * @param length - * The new size to use. - * @param structure - * The map_multis array to adjust. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ -#ifndef _di_f_string_map_multis_resize_ - extern f_status_t f_string_map_multis_resize(const f_number_unsigned_t length, f_string_map_multis_t * const structure); -#endif // _di_f_string_map_multis_resize_ +#ifndef _di_f_string_map_multis_destroy_callback_ + extern f_status_t f_string_map_multis_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_map_multis_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/map_multiss.c b/level_0/f_string/c/string/map_multiss.c index 3e740a8..448ceae 100644 --- a/level_0/f_string/c/string/map_multiss.c +++ b/level_0/f_string/c/string/map_multiss.c @@ -1,23 +1,10 @@ #include "../string.h" #include "../private-string.h" -#include "private-dynamics.h" -#include "private-map_multis.h" -#include "private-map_multiss.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_map_multiss_adjust_ - f_status_t f_string_map_multiss_adjust(const f_number_unsigned_t length, f_string_map_multiss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_map_multiss_adjust(length, structure); - } -#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_ @@ -26,18 +13,49 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + 1 > destination->size) { - status = private_f_string_map_multiss_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_map_multis_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - destination->array[destination->used].used = 0; + f_string_map_multis_t * const destination_inner = &destination->array[destination->used]; - 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_inner->used = 0; + + if (source.used) { + status = f_memory_array_increase_by(source.used, sizeof(f_string_map_multi_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); + if (F_status_is_error(status)) return status; + + f_string_map_multi_t * destination_inner_deep = 0; + f_number_unsigned_t j = 0; + + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination_inner->used) { + + destination_inner->array[destination_inner->used].name.used = 0; + destination_inner->array[destination_inner->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_inner->array[destination_inner->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].value.used) { + destination_inner_deep = &destination_inner->array[destination_inner->used]; + + status = f_memory_array_increase_by(source.array[i].value.used, sizeof(f_string_dynamic_t), (void **) &destination_inner_deep->value.array, &destination_inner_deep->value.used, &destination_inner_deep->value.size); + if (F_status_is_error(status)) return status; + + for (j = 0; j < source.array[i].value.used; ++j, ++destination_inner_deep->value.used) { + + destination_inner_deep->value.array[destination_inner_deep->value.used].used = 0; + + if (source.array[i].value.array[j].used) { + status = private_f_string_append(source.array[i].value.array[j].string, source.array[i].value.array[j].used, &destination_inner_deep->value.array[destination_inner_deep->value.used]); + if (F_status_is_error(status)) return status; + } + } // for + } + } // for + } } ++destination->used; @@ -54,104 +72,134 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + source.used > destination->size) { - status = private_f_string_map_multiss_resize(destination->used + source.used, destination); + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_map_multis_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + f_number_unsigned_t j = 0; + f_number_unsigned_t k = 0; + f_string_map_multis_t * destination_inner = 0; + f_string_map_multi_t * destination_inner_deep = 0; - destination->array[destination->used].used = 0; + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - 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 + destination_inner = &destination->array[destination->used]; + destination_inner->used = 0; - return F_okay; - } -#endif // _di_f_string_map_multiss_append_all_ + if (source.array[i].used) { + status = f_memory_array_increase_by(source.array[i].used, sizeof(f_string_map_multi_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); + if (F_status_is_error(status)) return status; -#ifndef _di_f_string_map_multiss_decimate_by_ - f_status_t f_string_map_multiss_decimate_by(const f_number_unsigned_t amount, f_string_map_multiss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + for (j = 0; j < source.array[i].used; ++j, ++destination_inner->used) { - if (!amount) return F_data_not; + destination_inner_deep = &destination_inner->array[destination_inner->used]; - return private_f_string_map_multiss_adjust((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_map_multiss_decimate_by_ + destination_inner_deep->name.used = 0; + destination_inner_deep->value.used = 0; -#ifndef _di_f_string_map_multiss_decrease_by_ - f_status_t f_string_map_multiss_decrease_by(const f_number_unsigned_t amount, f_string_map_multiss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (source.array[i].array[j].name.used) { + status = private_f_string_append(source.array[i].array[j].name.string, source.array[i].array[j].name.used, &destination_inner_deep->name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].array[j].value.used) { + status = f_memory_array_increase_by(source.array[i].array[j].value.used, sizeof(f_string_dynamic_t), (void **) &destination_inner_deep->value.array, &destination_inner_deep->value.used, &destination_inner_deep->value.size); + if (F_status_is_error(status)) return status; + + for (k = 0; k < source.array[i].array[j].value.used; ++k, ++destination_inner_deep->value.used) { + + destination_inner_deep->value.array[destination_inner_deep->value.used].used = 0; - if (!amount) return F_data_not; + if (source.array[i].array[j].value.array[k].used) { + status = private_f_string_append(source.array[i].array[j].value.array[k].string, source.array[i].array[j].value.array[k].used, &destination_inner_deep->value.array[destination_inner_deep->value.used]); + if (F_status_is_error(status)) return status; + } + } // for + } + } // for + } + } // for + } - return private_f_string_map_multiss_resize((structure->size > amount) ? structure->size - amount : 0, structure); + return F_okay; } -#endif // _di_f_string_map_multiss_decrease_by_ +#endif // _di_f_string_map_multiss_append_all_ -#ifndef _di_f_string_map_multiss_increase_ - f_status_t f_string_map_multiss_increase(const f_number_unsigned_t step, f_string_map_multiss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_map_multiss_delete_callback_ + f_status_t f_string_map_multiss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; + { + f_string_map_multis_t * const array = (f_string_map_multis_t *) void_array; + f_status_t status = F_okay; + f_number_unsigned_t j = 0; + f_number_unsigned_t k = 0; - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + for (f_number_unsigned_t i = start; i < stop; ++i) { - length = F_number_t_size_unsigned_d; - } + if (array[i].size) { + if (array[i].array[j].name.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].array[j].name.string, &array[i].array[j].name.used, &array[i].array[j].name.size); + if (F_status_is_error(status)) return status; + } + + if (array[i].array[j].value.size) { + for (k = 0; k < array[i].array[j].value.size; ++k) { - return private_f_string_map_multiss_resize(length, structure); + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].array[j].value.array[k].string, &array[i].array[j].value.array[k].used, &array[i].array[j].value.array[k].size); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_array_resize(0, sizeof(f_string_dynamic_t), (void **) &array[i].array[j].value.array, &array[i].array[j].value.used, &array[i].array[j].value.size); + if (F_status_is_error(status)) return status; + } + + status = f_memory_array_resize(0, sizeof(f_string_map_multi_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; + return F_okay; } -#endif // _di_f_string_map_multiss_increase_ +#endif // _di_f_string_map_multiss_delete_callback_ -#ifndef _di_f_string_map_multiss_increase_by_ - f_status_t f_string_map_multiss_increase_by(const f_number_unsigned_t amount, f_string_map_multiss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_map_multiss_destroy_callback_ + f_status_t f_string_map_multiss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_string_map_multis_t * const array = (f_string_map_multis_t *) void_array; + f_status_t status = F_okay; + f_number_unsigned_t j = 0; + f_number_unsigned_t k = 0; - const f_number_unsigned_t length = structure->used + amount; + for (f_number_unsigned_t i = start; i < stop; ++i) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (array[i].size) { + if (array[i].array[j].name.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].array[j].name.string, &array[i].array[j].name.used, &array[i].array[j].name.size); + if (F_status_is_error(status)) return status; + } - return private_f_string_map_multiss_resize(length, structure); - } - } + if (array[i].array[j].value.size) { + for (k = 0; k < array[i].array[j].value.size; ++k) { - return F_data_not; - } -#endif // _di_f_string_map_multiss_increase_by_ + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].array[j].value.array[k].string, &array[i].array[j].value.array[k].used, &array[i].array[j].value.array[k].size); + if (F_status_is_error(status)) return status; + } // for -#ifndef _di_f_string_map_multiss_resize_ - f_status_t f_string_map_multiss_resize(const f_number_unsigned_t length, f_string_map_multiss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + status = f_memory_array_adjust(0, sizeof(f_string_dynamic_t), (void **) &array[i].array[j].value.array, &array[i].array[j].value.used, &array[i].array[j].value.size); + if (F_status_is_error(status)) return status; + } - return private_f_string_map_multiss_resize(length, structure); + status = f_memory_array_adjust(0, sizeof(f_string_map_multi_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for + } + + return F_okay; } -#endif // _di_f_string_map_multiss_resize_ +#endif // _di_f_string_map_multiss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/map_multiss.h b/level_0/f_string/c/string/map_multiss.h index 58194c5..85ea400 100644 --- a/level_0/f_string/c/string/map_multiss.h +++ b/level_0/f_string/c/string/map_multiss.h @@ -44,25 +44,6 @@ extern "C" { #endif // _di_f_string_map_multiss_t_ /** - * Resize the map_multiss array. - * - * @param length - * The new size to use. - * @param structure - * The map_multiss array to resize. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_map_multiss_t * const structure); -#endif // _di_f_string_map_multiss_adjust_ - -/** * Append a single source map_multis onto the destination. * * @param source @@ -104,120 +85,60 @@ extern "C" { #endif // _di_f_string_map_multiss_append_all_ /** - * Resize the map_multiss array to a smaller size. + * A callback intended to be passed to f_memory_arrayss_resize() for an f_string_map_multiss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The map_multiss array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_number_unsigned_t amount, f_string_map_multiss_t * const structure); -#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 structure - * The map_multiss array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay 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_number_unsigned_t amount, f_string_map_multiss_t * const structure); -#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_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The map_multiss array to resize. - * - * @return - * F_okay on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_array_resize(). * - * Errors (with error bit) from: f_memory_resize(). + * @see f_memory_array_resize() */ -#ifndef _di_f_string_map_multiss_increase_ - extern f_status_t f_string_map_multiss_increase(const f_number_unsigned_t step, f_string_map_multiss_t * const structure); -#endif // _di_f_string_map_multiss_increase_ +#ifndef _di_f_string_map_multiss_delete_callback_ + extern f_status_t f_string_map_multiss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_map_multiss_delete_callback_ /** - * Resize the map_multiss array to a larger size. + * A callback intended to be passed to f_memory_arrayss_adjust() for an f_string_map_multiss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The map_multiss array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_number_unsigned_t amount, f_string_map_multiss_t * const structure); -#endif // _di_f_string_map_multiss_increase_by_ - -/** - * Resize the map_multiss array. - * - * @param length - * The new size to use. - * @param structure - * The map_multiss array to adjust. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ -#ifndef _di_f_string_map_multiss_resize_ - extern f_status_t f_string_map_multiss_resize(const f_number_unsigned_t length, f_string_map_multiss_t * const structure); -#endif // _di_f_string_map_multiss_resize_ +#ifndef _di_f_string_map_multiss_destroy_callback_ + extern f_status_t f_string_map_multiss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_map_multiss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/maps.c b/level_0/f_string/c/string/maps.c index edb9737..1f6faac 100644 --- a/level_0/f_string/c/string/maps.c +++ b/level_0/f_string/c/string/maps.c @@ -1,45 +1,32 @@ #include "../string.h" #include "../private-string.h" -#include "private-maps.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_maps_adjust_ - f_status_t f_string_maps_adjust(const f_number_unsigned_t length, f_string_maps_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_maps_adjust(length, structure); - } -#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_ - f_status_t status = F_okay; - - if (destination->used + 1 > destination->size) { - status = private_f_string_maps_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_map_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; + 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.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; + 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; @@ -56,87 +43,80 @@ extern "C" { if (!source.used) return F_data_not; - return private_f_string_maps_append_all(source, destination); - } -#endif // _di_f_string_maps_append_all_ + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_map_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; -#ifndef _di_f_string_maps_decimate_by_ - f_status_t f_string_maps_decimate_by(const f_number_unsigned_t amount, f_string_maps_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - if (!amount) return F_data_not; + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; - return private_f_string_maps_adjust((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_maps_decimate_by_ + 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; + } -#ifndef _di_f_string_maps_decrease_by_ - f_status_t f_string_maps_decrease_by(const f_number_unsigned_t amount, f_string_maps_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; + 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 private_f_string_maps_resize((structure->size > amount) ? structure->size - amount : 0, structure); + return F_okay; } -#endif // _di_f_string_maps_decrease_by_ +#endif // _di_f_string_maps_append_all_ -#ifndef _di_f_string_maps_increase_ - f_status_t f_string_maps_increase(const f_number_unsigned_t step, f_string_maps_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_maps_delete_callback_ + f_status_t f_string_maps_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; + { + f_string_map_t * const array = (f_string_map_t *) void_array; + f_status_t status = F_okay; - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + for (f_number_unsigned_t i = start; i < stop; ++i) { - length = F_number_t_size_unsigned_d; - } + if (array[i].name.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].name.string, &array[i].name.used, &array[i].name.size); + if (F_status_is_error(status)) return status; + } - return private_f_string_maps_resize(length, structure); + if (array[i].value.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].value.string, &array[i].value.used, &array[i].value.size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; + return F_okay; } -#endif // _di_f_string_maps_increase_ +#endif // _di_f_string_maps_delete_callback_ -#ifndef _di_f_string_maps_increase_by_ - f_status_t f_string_maps_increase_by(const f_number_unsigned_t amount, f_string_maps_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_maps_destroy_callback_ + f_status_t f_string_maps_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_string_map_t * const array = (f_string_map_t *) void_array; + f_status_t status = F_okay; - const f_number_unsigned_t length = structure->used + amount; + for (f_number_unsigned_t i = start; i < stop; ++i) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (array[i].name.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].name.string, &array[i].name.used, &array[i].name.size); + if (F_status_is_error(status)) return status; + } - return private_f_string_maps_resize(length, structure); - } + if (array[i].value.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].value.string, &array[i].value.used, &array[i].value.size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; - } -#endif // _di_f_string_maps_increase_by_ - -#ifndef _di_f_string_maps_resize_ - f_status_t f_string_maps_resize(const f_number_unsigned_t length, f_string_maps_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_maps_resize(length, structure); + return F_okay; } -#endif // _di_f_string_maps_resize_ +#endif // _di_f_string_maps_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/maps.h b/level_0/f_string/c/string/maps.h index 850c1c6..eb238a6 100644 --- a/level_0/f_string/c/string/maps.h +++ b/level_0/f_string/c/string/maps.h @@ -44,25 +44,6 @@ extern "C" { #endif // _di_f_string_maps_t_ /** - * Resize the string maps array. - * - * @param length - * The new size to use. - * @param structure - * The string maps array to resize. - * - * @return - * F_okay on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_maps_adjust_ - extern f_status_t f_string_maps_adjust(const f_number_unsigned_t length, f_string_maps_t * const structure); -#endif // _di_f_string_maps_adjust_ - -/** * Append a single source map onto the destination. * * @param source @@ -104,120 +85,60 @@ extern "C" { #endif // _di_f_string_maps_append_all_ /** - * Resize the string maps array to a smaller size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_string_maps_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The string maps array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_maps_decimate_by_ - extern f_status_t f_string_maps_decimate_by(const f_number_unsigned_t amount, f_string_maps_t * const structure); -#endif // _di_f_string_maps_decimate_by_ - -/** - * Resize the string maps 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 structure - * The string maps array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_maps_decrease_by_ - extern f_status_t f_string_maps_decrease_by(const f_number_unsigned_t amount, f_string_maps_t * const structure); -#endif // _di_f_string_maps_decrease_by_ - -/** - * Increase the size of the string maps array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The string maps array to resize. - * - * @return - * F_okay on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_array_resize(). * - * Errors (with error bit) from: f_memory_resize(). + * @see f_memory_array_resize() */ -#ifndef _di_f_string_maps_increase_ - extern f_status_t f_string_maps_increase(const f_number_unsigned_t step, f_string_maps_t * const structure); -#endif // _di_f_string_maps_increase_ +#ifndef _di_f_string_maps_delete_callback_ + extern f_status_t f_string_maps_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_maps_delete_callback_ /** - * Resize the string maps array to a larger size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_string_maps_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The string maps array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_maps_increase_by_ - extern f_status_t f_string_maps_increase_by(const f_number_unsigned_t amount, f_string_maps_t * const structure); -#endif // _di_f_string_maps_increase_by_ - -/** - * Resize the string maps array. - * - * @param length - * The new size to use. - * @param structure - * The string maps array to adjust. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ -#ifndef _di_f_string_maps_resize_ - extern f_status_t f_string_maps_resize(const f_number_unsigned_t length, f_string_maps_t * const structure); -#endif // _di_f_string_maps_resize_ +#ifndef _di_f_string_maps_destroy_callback_ + extern f_status_t f_string_maps_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_maps_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/mapss.c b/level_0/f_string/c/string/mapss.c index 0b84da3..7454a90 100644 --- a/level_0/f_string/c/string/mapss.c +++ b/level_0/f_string/c/string/mapss.c @@ -1,22 +1,10 @@ #include "../string.h" #include "../private-string.h" -#include "private-maps.h" -#include "private-mapss.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_mapss_adjust_ - f_status_t f_string_mapss_adjust(const f_number_unsigned_t length, f_string_mapss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_mapss_adjust(length, structure); - } -#endif // _di_f_string_mapss_adjust_ - #ifndef _di_f_string_mapss_append_ f_status_t f_string_mapss_append(const f_string_maps_t source, f_string_mapss_t * const destination) { #ifndef _di_level_0_parameter_checking_ @@ -25,18 +13,34 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + 1 > destination->size) { - status = private_f_string_mapss_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_maps_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - destination->array[destination->used].used = 0; + f_string_maps_t * const destination_inner = &destination->array[destination->used]; - if (source.used) { - status = private_f_string_maps_append_all(source, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; + destination_inner->used = 0; + + if (source.used) { + status = f_memory_array_increase_by(source.used, sizeof(f_string_map_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); + if (F_status_is_error(status)) return status; + + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination_inner->used) { + + destination_inner->array[destination_inner->used].name.used = 0; + destination_inner->array[destination_inner->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_inner->array[destination_inner->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_inner->array[destination_inner->used].value); + if (F_status_is_error(status)) return status; + } + } // for + } } ++destination->used; @@ -53,104 +57,112 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + source.used > destination->size) { - status = private_f_string_mapss_resize(destination->used + source.used, destination); + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_maps_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + f_number_unsigned_t j = 0; + f_string_maps_t * destination_inner = 0; - destination->array[destination->used].used = 0; + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - if (source.array[i].used) { - status = private_f_string_maps_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_okay; - } -#endif // _di_f_string_mapss_append_all_ + destination_inner = &destination->array[destination->used]; + destination_inner->used = 0; -#ifndef _di_f_string_mapss_decimate_by_ - f_status_t f_string_mapss_decimate_by(const f_number_unsigned_t amount, f_string_mapss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (source.array[i].used) { + status = f_memory_array_increase_by(source.array[i].used, sizeof(f_string_map_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); + if (F_status_is_error(status)) return status; - if (!amount) return F_data_not; + for (j = 0; j < source.array[i].used; ++j, ++destination_inner->used) { - return private_f_string_mapss_adjust((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_mapss_decimate_by_ + destination_inner->array[destination_inner->used].name.used = 0; + destination_inner->array[destination_inner->used].value.used = 0; -#ifndef _di_f_string_mapss_decrease_by_ - f_status_t f_string_mapss_decrease_by(const f_number_unsigned_t amount, f_string_mapss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (source.array[i].array[j].name.used) { + status = private_f_string_append(source.array[i].array[j].name.string, source.array[i].array[j].name.used, &destination_inner->array[destination_inner->used].name); + if (F_status_is_error(status)) return status; + } - if (!amount) return F_data_not; + if (source.array[i].array[j].value.used) { + status = private_f_string_append(source.array[i].array[j].value.string, source.array[i].array[j].value.used, &destination_inner->array[destination_inner->used].value); + if (F_status_is_error(status)) return status; + } + } // for + } + } // for + } - return private_f_string_mapss_resize((structure->size > amount) ? structure->size - amount : 0, structure); + return F_okay; } -#endif // _di_f_string_mapss_decrease_by_ +#endif // _di_f_string_mapss_append_all_ -#ifndef _di_f_string_mapss_increase_ - f_status_t f_string_mapss_increase(const f_number_unsigned_t step, f_string_mapss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_mapss_delete_callback_ + f_status_t f_string_mapss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; + { + f_string_maps_t * const array = (f_string_maps_t *) void_array; + f_status_t status = F_okay; + f_number_unsigned_t j = 0; - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + for (f_number_unsigned_t i = start; i < stop; ++i) { - length = F_number_t_size_unsigned_d; - } + if (array[i].size) { + for (j = 0; j < array[i].size; ++j) { + + if (array[i].array[j].name.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].array[j].name.string, &array[i].array[j].name.used, &array[i].array[j].name.size); + if (F_status_is_error(status)) return status; + } - return private_f_string_mapss_resize(length, structure); + if (array[i].array[j].value.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].array[j].value.string, &array[i].array[j].value.used, &array[i].array[j].value.size); + if (F_status_is_error(status)) return status; + } + } // for + + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; + return F_okay; } -#endif // _di_f_string_mapss_increase_ +#endif // _di_f_string_mapss_delete_callback_ -#ifndef _di_f_string_mapss_increase_by_ - f_status_t f_string_mapss_increase_by(const f_number_unsigned_t amount, f_string_mapss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_mapss_destroy_callback_ + f_status_t f_string_mapss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_string_maps_t * const array = (f_string_maps_t *) void_array; + f_status_t status = F_okay; + f_number_unsigned_t j = 0; - const f_number_unsigned_t length = structure->used + amount; + for (f_number_unsigned_t i = start; i < stop; ++i) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (array[i].size) { + for (j = 0; j < array[i].size; ++j) { - return private_f_string_mapss_resize(length, structure); - } - } + if (array[i].array[j].name.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].array[j].name.string, &array[i].array[j].name.used, &array[i].array[j].name.size); + if (F_status_is_error(status)) return status; + } - return F_data_not; - } -#endif // _di_f_string_mapss_increase_by_ + if (array[i].array[j].value.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].array[j].value.string, &array[i].array[j].value.used, &array[i].array[j].value.size); + if (F_status_is_error(status)) return status; + } + } // for -#ifndef _di_f_string_mapss_resize_ - f_status_t f_string_mapss_resize(const f_number_unsigned_t length, f_string_mapss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for + } - return private_f_string_mapss_resize(length, structure); + return F_okay; } -#endif // _di_f_string_mapss_resize_ +#endif // _di_f_string_mapss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/mapss.h b/level_0/f_string/c/string/mapss.h index 0da2ff3..b30f5d1 100644 --- a/level_0/f_string/c/string/mapss.h +++ b/level_0/f_string/c/string/mapss.h @@ -44,25 +44,6 @@ extern "C" { #endif // _di_f_string_mapss_t_ /** - * Resize the string mapss array. - * - * @param length - * The new size to use. - * @param structure - * The string mapss array to resize. - * - * @return - * F_okay on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_mapss_adjust_ - extern f_status_t f_string_mapss_adjust(const f_number_unsigned_t length, f_string_mapss_t * const structure); -#endif // _di_f_string_mapss_adjust_ - -/** * Append a single source maps onto the destination. * * @param source @@ -104,121 +85,60 @@ extern "C" { #endif // _di_f_string_mapss_append_all_ /** - * Resize the string mapss array to a smaller size. + * A callback intended to be passed to f_memory_arrayss_resize() for an f_string_mapss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The string mapss array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_mapss_decimate_by_ - extern f_status_t f_string_mapss_decimate_by(const f_number_unsigned_t amount, f_string_mapss_t * const structure); -#endif // _di_f_string_mapss_decimate_by_ - -/** - * Resize the string mapss 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 structure - * The string mapss array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay 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_mapss_decrease_by_ - extern f_status_t f_string_mapss_decrease_by(const f_number_unsigned_t amount, f_string_mapss_t * const structure); -#endif // _di_f_string_mapss_decrease_by_ - -/** - * Increase the size of the string mapss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The string mapss array to resize. - * - * @return - * F_okay on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size) (or step is 0). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_array_resize(). * - * Errors (with error bit) from: f_memory_resize(). + * @see f_memory_array_resize() */ -#ifndef _di_f_string_mapss_increase_ - extern f_status_t f_string_mapss_increase(const f_number_unsigned_t step, f_string_mapss_t * const structure); -#endif // _di_f_string_mapss_increase_ +#ifndef _di_f_string_mapss_delete_callback_ + extern f_status_t f_string_mapss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_mapss_delete_callback_ /** - * Resize the string mapss array to a larger size. + * A callback intended to be passed to f_memory_arrayss_adjust() for an f_string_mapss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The string mapss array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_mapss_increase_by_ - extern f_status_t f_string_mapss_increase_by(const f_number_unsigned_t amount, f_string_mapss_t * const structure); -#endif // _di_f_string_mapss_increase_by_ - -/** - * Resize the string mapss array. - * - * @param length - * The new size to use. - * @param structure - * The string mapss array to adjust. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ -#ifndef _di_f_string_mapss_resize_ - extern f_status_t f_string_mapss_resize(const f_number_unsigned_t length, f_string_mapss_t * const structure); -#endif // _di_f_string_mapss_resize_ +#ifndef _di_f_string_mapss_destroy_callback_ + extern f_status_t f_string_mapss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_mapss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/private-dynamics.c b/level_0/f_string/c/string/private-dynamics.c deleted file mode 100644 index 32a601c..0000000 --- a/level_0/f_string/c/string/private-dynamics.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-dynamics.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#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_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &destination->array, &destination->used, &destination->size); - 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_okay; - } -#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_memory_array_increase_by(source.used, sizeof(f_string_dynamic_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - - 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_okay; - } -#endif // !defined(_di_f_string_dynamics_append_all_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-dynamics.h b/level_0/f_string/c/string/private-dynamics.h deleted file mode 100644 index 0897a7a..0000000 --- a/level_0/f_string/c/string/private-dynamics.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_dynamics_h -#define _PRIVATE_F_string_dynamics_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * 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 dynamics the source is appended onto. - * - * @return - * F_okay 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 dynamics the source is appended onto. - * - * @return - * F_okay 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_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_dynamics_h diff --git a/level_0/f_string/c/string/private-map_multis.c b/level_0/f_string/c/string/private-map_multis.c deleted file mode 100644 index 4b62478..0000000 --- a/level_0/f_string/c/string/private-map_multis.c +++ /dev/null @@ -1,96 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-dynamics.h" -#include "private-map_multis.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_number_unsigned_t length, f_string_map_multis_t * const structure) { - - { - f_status_t status = F_okay; - f_number_unsigned_t j = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &structure->array[i].name.string, &structure->array[i].name.used, &structure->array[i].name.size); - if (F_status_is_error(status)) return status; - - for (j = 0; j < structure->array[i].value.size; ++j) { - - status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &structure->array[i].value.array[j].string, &structure->array[i].value.array[j].used, &structure->array[i].value.array[j].size); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_arrays_adjust(0, sizeof(f_string_dynamic_t), (void **) &structure->array[i].value.array, &structure->array[i].value.used, &structure->array[i].value.size, &f_string_dynamics_destroy_callback); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_adjust(length, sizeof(f_string_map_multi_t), (void **) &structure->array, &structure->used, &structure->size); - } -#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_okay; - - 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_number_unsigned_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_okay; - } -#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_append_) || !defined(_di_f_string_map_multis_append_all_) || !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_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) - f_status_t private_f_string_map_multis_resize(const f_number_unsigned_t length, f_string_map_multis_t * const structure) { - - { - f_status_t status = F_okay; - f_number_unsigned_t j = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &structure->array[i].name.string, &structure->array[i].name.used, &structure->array[i].name.size); - if (F_status_is_error(status)) return status; - - for (j = 0; j < structure->array[i].value.size; ++j) { - - status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &structure->array[i].value.array[j].string, &structure->array[i].value.array[j].used, &structure->array[i].value.array[j].size); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &structure->array[i].value.array, &structure->array[i].value.used, &structure->array[i].value.size, &f_string_dynamics_delete_callback); - if (F_status_is_error(status)) return status; - } // for - } - - return f_memory_array_resize(length, sizeof(f_string_map_multi_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) || !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_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-map_multis.h b/level_0/f_string/c/string/private-map_multis.h deleted file mode 100644 index fea1b7c..0000000 --- a/level_0/f_string/c/string/private-map_multis.h +++ /dev/null @@ -1,109 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_multis_h -#define _PRIVATE_F_string_map_multis_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_okay 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_number_unsigned_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 destination to append. - * @param destination - * The destination map_multis the source is appended onto. - * - * @return - * F_okay 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_okay 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() - * @see f_string_map_multis_append_all() - * @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_resize() - * @see f_string_map_multiss_append() - * @see f_string_map_multiss_append_all() - * @see f_string_map_multiss_decrease_by() - * @see f_string_map_multiss_increase() - * @see f_string_map_multiss_increase_by() - */ -#if !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) || !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_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) - extern f_status_t private_f_string_map_multis_resize(const f_number_unsigned_t length, f_string_map_multis_t * const map_multis) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) || !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_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_map_multis_h diff --git a/level_0/f_string/c/string/private-map_multiss.c b/level_0/f_string/c/string/private-map_multiss.c deleted file mode 100644 index 0526453..0000000 --- a/level_0/f_string/c/string/private-map_multiss.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-dynamics.h" -#include "private-map_multis.h" -#include "private-map_multiss.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#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_number_unsigned_t length, f_string_map_multiss_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = private_f_string_map_multis_adjust(0, &structure->array[i]); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_string_map_multis_t), (void **) &structure->array, &structure->used, &structure->size); - } -#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_) - f_status_t private_f_string_map_multiss_resize(const f_number_unsigned_t length, f_string_map_multiss_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = private_f_string_map_multis_resize(0, &structure->array[i]); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_string_map_multis_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-map_multiss.h b/level_0/f_string/c/string/private-map_multiss.h deleted file mode 100644 index 02756ac..0000000 --- a/level_0/f_string/c/string/private-map_multiss.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_multiss_h -#define _PRIVATE_F_string_map_multiss_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 structure - * The map_multiss to adjust. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_map_multiss_t * const structure) 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 structure - * The map_multiss to resize. - * - * @return - * F_okay 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_multiss_decrease_by() - * @see f_string_map_multiss_increase() - * @see f_string_map_multiss_increase_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_) - extern f_status_t private_f_string_map_multiss_resize(const f_number_unsigned_t length, f_string_map_multiss_t * const structure) 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_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_map_multiss_h diff --git a/level_0/f_string/c/string/private-maps.c b/level_0/f_string/c/string/private-maps.c deleted file mode 100644 index 5e1fb3d..0000000 --- a/level_0/f_string/c/string/private-maps.c +++ /dev/null @@ -1,77 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-maps.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_number_unsigned_t length, f_string_maps_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &structure->array[i].name.string, &structure->array[i].name.used, &structure->array[i].name.size); - if (F_status_is_error(status)) return status; - - status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &structure->array[i].value.string, &structure->array[i].value.used, &structure->array[i].value.size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_string_map_t), (void **) &structure->array, &structure->used, &structure->size); - } -#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_okay; - - 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_number_unsigned_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_okay; - } -#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_append_) || !defined(_di_f_string_maps_append_all_) || !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_resize_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) - f_status_t private_f_string_maps_resize(const f_number_unsigned_t length, f_string_maps_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &structure->array[i].name.string, &structure->array[i].name.used, &structure->array[i].name.size); - if (F_status_is_error(status)) return status; - - status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &structure->array[i].value.string, &structure->array[i].value.used, &structure->array[i].value.size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_string_map_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_maps_append_) || !defined(_di_f_string_maps_append_all_) || !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_resize_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-maps.h b/level_0/f_string/c/string/private-maps.h deleted file mode 100644 index af64c7f..0000000 --- a/level_0/f_string/c/string/private-maps.h +++ /dev/null @@ -1,108 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_maps_h -#define _PRIVATE_F_string_maps_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 structure - * The maps to adjust. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_maps_t * const structure) 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 destination to append. - * @param destination - * The destination maps the source is appended onto. - * - * @return - * F_okay 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 structure - * The maps to resize. - * - * @return - * F_okay 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_maps_append_all() - * @see f_string_maps_decrease_by() - * @see f_string_maps_increase() - * @see f_string_maps_increase_by() - * @see f_string_maps_resize() - * @see f_string_mapss_append() - * @see f_string_mapss_append_all() - * @see f_string_mapss_decrease_by() - * @see f_string_mapss_increase() - * @see f_string_mapss_increase_by() - */ -#if !defined(_di_f_string_maps_append_) || !defined(_di_f_string_maps_append_all_) || !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_resize_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) - extern f_status_t private_f_string_maps_resize(const f_number_unsigned_t length, f_string_maps_t * const structure) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_maps_append_) || !defined(_di_f_string_maps_append_all_) || !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_resize_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_maps_h diff --git a/level_0/f_string/c/string/private-mapss.c b/level_0/f_string/c/string/private-mapss.c deleted file mode 100644 index aee11fd..0000000 --- a/level_0/f_string/c/string/private-mapss.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-maps.h" -#include "private-mapss.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) - f_status_t private_f_string_mapss_adjust(const f_number_unsigned_t length, f_string_mapss_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = private_f_string_maps_adjust(0, &structure->array[i]); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_string_maps_t), (void **) &structure->array, &structure->used, &structure->size); - } -#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_) - f_status_t private_f_string_mapss_resize(const f_number_unsigned_t length, f_string_mapss_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = private_f_string_maps_resize(0, &structure->array[i]); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_string_maps_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-mapss.h b/level_0/f_string/c/string/private-mapss.h deleted file mode 100644 index 7e6618d..0000000 --- a/level_0/f_string/c/string/private-mapss.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_mapss_h -#define _PRIVATE_F_string_mapss_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 structure - * The structure to adjust. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_mapss_t * const structure) 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 structure - * The structure to resize. - * - * @return - * F_okay 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_mapss_decrease_by() - * @see f_string_mapss_increase() - * @see f_string_mapss_increase_by() - */ -#if !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) - extern f_status_t private_f_string_mapss_resize(const f_number_unsigned_t length, f_string_mapss_t * const structure) 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_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_mapss_h diff --git a/level_0/f_string/c/string/private-quantityss.c b/level_0/f_string/c/string/private-quantityss.c deleted file mode 100644 index 7e29f4b..0000000 --- a/level_0/f_string/c/string/private-quantityss.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-quantitys.h" -#include "private-quantityss.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) - f_status_t private_f_string_quantityss_adjust(const f_number_unsigned_t length, f_string_quantityss_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_adjust(length, sizeof(f_string_quantitys_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_string_quantitys_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) - -#if !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) - f_status_t private_f_string_quantityss_resize(const f_number_unsigned_t length, f_string_quantityss_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_string_quantity_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_string_quantitys_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-quantityss.h b/level_0/f_string/c/string/private-quantityss.h deleted file mode 100644 index db2b5c8..0000000 --- a/level_0/f_string/c/string/private-quantityss.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_quantityss_h -#define _PRIVATE_F_string_quantityss_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 structure - * The structure to adjust. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_quantityss_t * const structure) 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 structure - * The structure to resize. - * - * @return - * F_okay 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() - */ -#if !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) - extern f_status_t private_f_string_quantityss_resize(const f_number_unsigned_t length, f_string_quantityss_t * const structure) 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_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_quantityss_h diff --git a/level_0/f_string/c/string/private-ranges.c b/level_0/f_string/c/string/private-ranges.c deleted file mode 100644 index bd0dc34..0000000 --- a/level_0/f_string/c/string/private-ranges.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-ranges.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#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 = f_memory_array_increase_by(source.used, sizeof(f_string_range_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - } - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - - destination->array[destination->used].start = source.array[i].start; - destination->array[destination->used++].stop = source.array[i].stop; - } // for - - return F_okay; - } -#endif // !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-ranges.h b/level_0/f_string/c/string/private-ranges.h deleted file mode 100644 index 998c344..0000000 --- a/level_0/f_string/c/string/private-ranges.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_ranges_h -#define _PRIVATE_F_string_ranges_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * 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_okay 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_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_ranges_h diff --git a/level_0/f_string/c/string/private-rangess.c b/level_0/f_string/c/string/private-rangess.c deleted file mode 100644 index f066079..0000000 --- a/level_0/f_string/c/string/private-rangess.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-ranges.h" -#include "private-rangess.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) - f_status_t private_f_string_rangess_adjust(const f_number_unsigned_t length, f_string_rangess_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_string_ranges_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) - -#if !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !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_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) - f_status_t private_f_string_rangess_resize(const f_number_unsigned_t length, f_string_rangess_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &structure->array[i].array, &structure->array[i].used, &structure->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_string_ranges_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !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_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-rangess.h b/level_0/f_string/c/string/private-rangess.h deleted file mode 100644 index 212dedd..0000000 --- a/level_0/f_string/c/string/private-rangess.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_rangess_h -#define _PRIVATE_F_string_rangess_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 structure - * The structure to adjust. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_rangess_t * const structure) 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 structure - * The structure to resize. - * - * @return - * F_okay 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_append() - * @see f_string_rangess_append_all() - * @see f_string_rangess_decrease_by() - * @see f_string_rangess_increase() - * @see f_string_rangess_increase_by() - */ -#if !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !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_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) - extern f_status_t private_f_string_rangess_resize(const f_number_unsigned_t length, f_string_rangess_t * const structure) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !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_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_rangess_h diff --git a/level_0/f_string/c/string/private-triples.c b/level_0/f_string/c/string/private-triples.c deleted file mode 100644 index 4abf778..0000000 --- a/level_0/f_string/c/string/private-triples.c +++ /dev/null @@ -1,89 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-triples.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_number_unsigned_t length, f_string_triples_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_string_triple_t), (void **) &structure->array[i].a.string, &structure->array[i].a.used, &structure->array[i].a.size); - if (F_status_is_error(status)) return status; - - status = f_memory_array_adjust(0, sizeof(f_string_triple_t), (void **) &structure->array[i].b.string, &structure->array[i].b.used, &structure->array[i].b.size); - if (F_status_is_error(status)) return status; - - status = f_memory_array_adjust(0, sizeof(f_string_triple_t), (void **) &structure->array[i].c.string, &structure->array[i].c.used, &structure->array[i].c.size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_string_triple_t), (void **) &structure->array, &structure->used, &structure->size); - } -#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_okay; - - 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_number_unsigned_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_okay; - } -#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_) - f_status_t private_f_string_triples_resize(const f_number_unsigned_t length, f_string_triples_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_string_triple_t), (void **) &structure->array[i].a.string, &structure->array[i].a.used, &structure->array[i].a.size); - if (F_status_is_error(status)) return status; - - status = f_memory_array_resize(0, sizeof(f_string_triple_t), (void **) &structure->array[i].b.string, &structure->array[i].b.used, &structure->array[i].b.size); - if (F_status_is_error(status)) return status; - - status = f_memory_array_resize(0, sizeof(f_string_triple_t), (void **) &structure->array[i].c.string, &structure->array[i].c.used, &structure->array[i].c.size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_string_triple_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-triples.h b/level_0/f_string/c/string/private-triples.h deleted file mode 100644 index ba3d24b..0000000 --- a/level_0/f_string/c/string/private-triples.h +++ /dev/null @@ -1,148 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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 structure - * The triples to adjust. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_triples_t * const structure) 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 destination to append. - * @param destination - * The destination triples the source is appended onto. - * - * @return - * F_okay 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 structure - * The triples to resize. - * - * @return - * F_okay 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() - */ -#if !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) - extern f_status_t private_f_string_triples_resize(const f_number_unsigned_t length, f_string_triples_t * const structure) 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_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param structure - * The tripless to adjust. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_tripless_t * const structure) 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 structure - * The tripless to resize. - * - * @return - * F_okay 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() - */ -#if !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) - extern f_status_t private_f_string_tripless_resize(const f_number_unsigned_t length, f_string_tripless_t * const structure) 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_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_triple_h diff --git a/level_0/f_string/c/string/private-tripless.c b/level_0/f_string/c/string/private-tripless.c deleted file mode 100644 index f000ac2..0000000 --- a/level_0/f_string/c/string/private-tripless.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "../string.h" -#include "../private-string.h" -#include "private-triples.h" -#include "private-tripless.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) - f_status_t private_f_string_tripless_adjust(const f_number_unsigned_t length, f_string_tripless_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = private_f_string_triples_adjust(0, &structure->array[i]); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_string_triples_t), (void **) &structure->array, &structure->used, &structure->size); - } -#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_) - f_status_t private_f_string_tripless_resize(const f_number_unsigned_t length, f_string_tripless_t * const structure) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - status = private_f_string_triples_resize(0, &structure->array[i]); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_string_triples_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_string/c/string/private-tripless.h b/level_0/f_string/c/string/private-tripless.h deleted file mode 100644 index 11c16cd..0000000 --- a/level_0/f_string/c/string/private-tripless.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.7 - * 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_tripless_h -#define _PRIVATE_F_string_tripless_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 structure - * The tripless to adjust. - * - * @return - * F_okay 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_number_unsigned_t length, f_string_tripless_t * const structure) 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 structure - * The tripless to resize. - * - * @return - * F_okay 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() - */ -#if !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) - extern f_status_t private_f_string_tripless_resize(const f_number_unsigned_t length, f_string_tripless_t * const structure) 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_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_string_tripless_h diff --git a/level_0/f_string/c/string/quantitys.c b/level_0/f_string/c/string/quantitys.c index 5848842..134e102 100644 --- a/level_0/f_string/c/string/quantitys.c +++ b/level_0/f_string/c/string/quantitys.c @@ -1,28 +1,17 @@ #include "../string.h" #include "../private-string.h" -#include "private-quantitys.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_quantitys_adjust_ - f_status_t f_string_quantitys_adjust(const f_number_unsigned_t length, f_string_quantitys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_adjust(length, sizeof(f_string_quantity_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_quantitys_adjust_ - #ifndef _di_f_string_quantitys_append_ 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 (destination->used + 1 > destination->size) { + { const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_quantity_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -42,60 +31,20 @@ extern "C" { 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_number_unsigned_t amount, f_string_quantitys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decimate_by(amount, sizeof(f_string_quantity_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_quantitys_decimate_by_ - -#ifndef _di_f_string_quantitys_decrease_by_ - f_status_t f_string_quantitys_decrease_by(const f_number_unsigned_t amount, f_string_quantitys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - - return f_memory_array_decrease_by(amount, sizeof(f_string_quantity_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_quantitys_decrease_by_ - -#ifndef _di_f_string_quantitys_increase_ - f_status_t f_string_quantitys_increase(const f_number_unsigned_t step, f_string_quantitys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_string_quantity_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_quantitys_increase_ - -#ifndef _di_f_string_quantitys_increase_by_ - f_status_t f_string_quantitys_increase_by(const f_number_unsigned_t amount, f_string_quantitys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_quantity_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; + } - return f_memory_array_increase_by(amount, sizeof(f_string_quantity_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_quantitys_increase_by_ + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { -#ifndef _di_f_string_quantitys_resize_ - f_status_t f_string_quantitys_resize(const f_number_unsigned_t length, f_string_quantitys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + destination->array[destination->used].start = source.array[i].start; + destination->array[destination->used].total = source.array[i].total; + } // for - return f_memory_array_resize(length, sizeof(f_string_quantity_t), (void **) &structure->array, &structure->used, &structure->size); + return F_okay; } -#endif // _di_f_string_quantitys_resize_ +#endif // _di_f_string_quantitys_append_all_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/quantitys.h b/level_0/f_string/c/string/quantitys.h index 88744af..74ed1f6 100644 --- a/level_0/f_string/c/string/quantitys.h +++ b/level_0/f_string/c/string/quantitys.h @@ -44,25 +44,6 @@ extern "C" { #endif // _di_f_string_quantitys_t_ /** - * Resize the string quantitys array. - * - * @param length - * The new size to use. - * @param structure - * The string quantitys array to resize. - * - * @return - * F_okay on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_quantitys_adjust_ - extern f_status_t f_string_quantitys_adjust(const f_number_unsigned_t length, f_string_quantitys_t * const structure); -#endif // _di_f_string_quantitys_adjust_ - -/** * Append the single source quantity onto the destination. * * @param source @@ -102,120 +83,6 @@ extern "C" { 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). - * 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 structure - * The string quantitys array to resize. - * - * @return - * F_okay 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_quantitys_decimate_by_ - extern f_status_t f_string_quantitys_decimate_by(const f_number_unsigned_t amount, f_string_quantitys_t * const structure); -#endif // _di_f_string_quantitys_decimate_by_ - -/** - * Resize the string quantitys 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 structure - * The string quantitys array to resize. - * - * @return - * F_okay on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_quantitys_decrease_by_ - extern f_status_t f_string_quantitys_decrease_by(const f_number_unsigned_t amount, f_string_quantitys_t * const structure); -#endif // _di_f_string_quantitys_decrease_by_ - -/** - * Increase the size of the string quantitys array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The string quantitys array to resize. - * - * @return - * F_okay on success. - * - * 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_quantitys_increase_ - extern f_status_t f_string_quantitys_increase(const f_number_unsigned_t step, f_string_quantitys_t * const structure); -#endif // _di_f_string_quantitys_increase_ - -/** - * Resize the string quantitys array to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The string quantitys array to resize. - * - * @return - * F_okay on success. - * - * 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_quantitys_increase_by_ - extern f_status_t f_string_quantitys_increase_by(const f_number_unsigned_t amount, f_string_quantitys_t * const structure); -#endif // _di_f_string_quantitys_increase_by_ - -/** - * Resize the string quantitys array. - * - * @param length - * The new size to use. - * @param structure - * The string quantitys array to adjust. - * - * @return - * F_okay on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_quantitys_resize_ - extern f_status_t f_string_quantitys_resize(const f_number_unsigned_t length, f_string_quantitys_t * const structure); -#endif // _di_f_string_quantitys_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/quantityss.c b/level_0/f_string/c/string/quantityss.c index 3761a27..3346cdf 100644 --- a/level_0/f_string/c/string/quantityss.c +++ b/level_0/f_string/c/string/quantityss.c @@ -1,22 +1,10 @@ #include "../string.h" #include "../private-string.h" -#include "private-quantitys.h" -#include "private-quantityss.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_quantityss_adjust_ - f_status_t f_string_quantityss_adjust(const f_number_unsigned_t length, f_string_quantityss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_quantityss_adjust(length, structure); - } -#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_ @@ -25,18 +13,23 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + 1 > destination->size) { - status = private_f_string_quantityss_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_quantitys_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - destination->array[destination->used].used = 0; + f_string_quantitys_t * const destination_inner = &destination->array[destination->used]; + destination_inner->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; + if (source.used) { + status = f_memory_array_increase_by(source.used, sizeof(f_string_quantity_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); + if (F_status_is_error(status)) return status; + + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination_inner->used) { + + destination_inner->array[destination_inner->used].start = source.array[i].start; + destination_inner->array[destination_inner->used].total = source.array[i].total; + } // for + } } ++destination->used; @@ -53,105 +46,74 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + source.used > destination->size) { - status = private_f_string_quantityss_resize(destination->used + source.used, destination); + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_quantitys_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - 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 + f_string_quantitys_t * destination_inner = 0; + f_number_unsigned_t j = 0; - return F_okay; - } -#endif // _di_f_string_quantityss_append_all_ - -#ifndef _di_f_string_quantityss_decimate_by_ - f_status_t f_string_quantityss_decimate_by(const f_number_unsigned_t amount, f_string_quantityss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - if (!amount) return F_data_not; + destination_inner = &destination->array[destination->used]; + destination_inner->used = 0; - return private_f_string_quantityss_adjust((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_quantityss_decimate_by_ + if (source.array[i].used) { + status = f_memory_array_increase_by(source.array[i].used, sizeof(f_string_quantity_t), (void **) &destination->array[destination->used].array, &destination->array[destination->used].used, &destination->array[destination->used].size); + if (F_status_is_error(status)) return status; -#ifndef _di_f_string_quantityss_decrease_by_ - f_status_t f_string_quantityss_decrease_by(const f_number_unsigned_t amount, f_string_quantityss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + for (j = 0; j < source.array[i].used; ++j, ++destination_inner->used) { - if (!amount) return F_data_not; + destination_inner->array[destination_inner->used].start = source.array[i].array[j].start; + destination_inner->array[destination_inner->used].total = source.array[i].array[j].total; + } // for + } + } // for + } - return private_f_string_quantityss_resize((structure->size > amount) ? structure->size - amount : 0, structure); + return F_okay; } -#endif // _di_f_string_quantityss_decrease_by_ - -#ifndef _di_f_string_quantityss_increase_ - f_status_t f_string_quantityss_increase(const f_number_unsigned_t step, f_string_quantityss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#endif // _di_f_string_quantityss_append_all_ - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; +#ifndef _di_f_string_quantityss_delete_callback_ + f_status_t f_string_quantityss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_string_quantitys_t * const array = (f_string_quantitys_t *) void_array; + f_status_t status = F_okay; - length = F_number_t_size_unsigned_d; - } + for (f_number_unsigned_t i = start; i < stop; ++i) { - return private_f_string_quantityss_resize(length, structure); + if (array[i].size) { + status = f_memory_array_resize(0, sizeof(f_string_quantity_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; + return F_okay; } -#endif // _di_f_string_quantityss_increase_ +#endif // _di_f_string_quantityss_delete_callback_ -#ifndef _di_f_string_quantityss_increase_by_ - f_status_t f_string_quantityss_increase_by(const f_number_unsigned_t amount, f_string_quantityss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); +#ifndef _di_f_string_quantityss_destroy_callback_ + f_status_t f_string_quantityss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - const f_number_unsigned_t length = structure->used + amount; + { + f_string_quantitys_t * const array = (f_string_quantitys_t *) void_array; + f_status_t status = F_okay; - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + for (f_number_unsigned_t i = start; i < stop; ++i) { - return private_f_string_quantityss_resize(length, structure); - } + if (array[i].size) { + status = f_memory_array_adjust(0, sizeof(f_string_quantity_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; - } -#endif // _di_f_string_quantityss_increase_by_ - -#ifndef _di_f_string_quantityss_resize_ - f_status_t f_string_quantityss_resize(const f_number_unsigned_t length, f_string_quantityss_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_quantityss_resize(length, structure); + return F_okay; } -#endif // _di_f_string_quantityss_resize_ - +#endif // _di_f_string_quantityss_destroy_callback_ #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/quantityss.h b/level_0/f_string/c/string/quantityss.h index 55f574c..7e3810c 100644 --- a/level_0/f_string/c/string/quantityss.h +++ b/level_0/f_string/c/string/quantityss.h @@ -44,25 +44,6 @@ extern "C" { #endif // _di_f_string_quantityss_t_ /** - * Resize the string quantityss array. - * - * @param length - * The new size to use. - * @param structure - * The string quantityss array to resize. - * - * @return - * F_okay on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_quantityss_adjust_ - extern f_status_t f_string_quantityss_adjust(const f_number_unsigned_t length, f_string_quantityss_t * const structure); -#endif // _di_f_string_quantityss_adjust_ - -/** * Append the single source quantitys onto the destination. * * @param source @@ -103,120 +84,60 @@ extern "C" { #endif // _di_f_string_quantityss_append_all_ /** - * Resize the string quantityss array to a smaller size. + * A callback intended to be passed to f_memory_arrayss_resize() for an f_string_quantityss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The string quantityss array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_quantityss_decimate_by_ - extern f_status_t f_string_quantityss_decimate_by(const f_number_unsigned_t amount, f_string_quantityss_t * const structure); -#endif // _di_f_string_quantityss_decimate_by_ - -/** - * Resize the string quantityss 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 structure - * The string quantityss array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_quantityss_decrease_by_ - extern f_status_t f_string_quantityss_decrease_by(const f_number_unsigned_t amount, f_string_quantityss_t * const structure); -#endif // _di_f_string_quantityss_decrease_by_ - -/** - * Increase the size of the string quantityss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The string quantityss array to resize. - * - * @return - * F_okay on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_array_resize(). * - * Errors (with error bit) from: f_memory_resize(). + * @see f_memory_array_resize() */ -#ifndef _di_f_string_quantityss_increase_ - extern f_status_t f_string_quantityss_increase(const f_number_unsigned_t step, f_string_quantityss_t * const structure); -#endif // _di_f_string_quantityss_increase_ +#ifndef _di_f_string_quantityss_delete_callback_ + extern f_status_t f_string_quantityss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_quantityss_delete_callback_ /** - * Resize the string quantityss array to a larger size. + * A callback intended to be passed to f_memory_arrayss_adjust() for an f_string_quantityss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The string quantityss array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_quantityss_increase_by_ - extern f_status_t f_string_quantityss_increase_by(const f_number_unsigned_t amount, f_string_quantityss_t * const structure); -#endif // _di_f_string_quantityss_increase_by_ - -/** - * Resize the string quantityss array. - * - * @param length - * The new size to use. - * @param structure - * The string quantityss array to adjust. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ -#ifndef _di_f_string_quantityss_resize_ - extern f_status_t f_string_quantityss_resize(const f_number_unsigned_t length, f_string_quantityss_t * const structure); -#endif // _di_f_string_quantityss_resize_ +#ifndef _di_f_string_quantityss_destroy_callback_ + extern f_status_t f_string_quantityss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_quantityss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/range.c b/level_0/f_string/c/string/range.c index 9763e26..37d48a1 100644 --- a/level_0/f_string/c/string/range.c +++ b/level_0/f_string/c/string/range.c @@ -1,6 +1,5 @@ #include "../string.h" #include "../private-string.h" -#include "private-ranges.h" #ifdef __cplusplus extern "C" { diff --git a/level_0/f_string/c/string/ranges.c b/level_0/f_string/c/string/ranges.c index 875740e..38f9fef 100644 --- a/level_0/f_string/c/string/ranges.c +++ b/level_0/f_string/c/string/ranges.c @@ -1,21 +1,10 @@ #include "../string.h" #include "../private-string.h" -#include "private-ranges.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_ranges_adjust_ - f_status_t f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_adjust(length, sizeof(f_string_range_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_ranges_adjust_ - #ifndef _di_f_string_ranges_append_ 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_ @@ -57,58 +46,6 @@ extern "C" { } #endif // _di_f_string_ranges_append_all_ -#ifndef _di_f_string_ranges_decimate_by_ - f_status_t f_string_ranges_decimate_by(const f_number_unsigned_t amount, f_string_ranges_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - return f_memory_array_decimate_by(amount, sizeof(f_string_range_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_ranges_decimate_by_ - -#ifndef _di_f_string_ranges_decrease_by_ - f_status_t f_string_ranges_decrease_by(const f_number_unsigned_t amount, f_string_ranges_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decrease_by(amount, sizeof(f_string_range_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_ranges_decrease_by_ - -#ifndef _di_f_string_ranges_increase_ - f_status_t f_string_ranges_increase(const f_number_unsigned_t step, f_string_ranges_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_string_range_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_ranges_increase_ - -#ifndef _di_f_string_ranges_increase_by_ - f_status_t f_string_ranges_increase_by(const f_number_unsigned_t amount, f_string_ranges_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase_by(amount, sizeof(f_string_range_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_ranges_increase_by_ - -#ifndef _di_f_string_ranges_resize_ - f_status_t f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_string_ranges_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/ranges.h b/level_0/f_string/c/string/ranges.h index 31aec5f..65ccfcc 100644 --- a/level_0/f_string/c/string/ranges.h +++ b/level_0/f_string/c/string/ranges.h @@ -44,24 +44,6 @@ extern "C" { #endif // _di_f_string_ranges_t_ /** - * Resize the string ranges array. - * - * @param length - * The new size to use. - * @param structure - * The string ranges array to resize. - * - * @return - * F_okay on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_string_ranges_adjust_ - extern f_status_t f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const structure); -#endif // _di_f_string_ranges_adjust_ - -/** * Append the single source range onto the destination. * * @param source @@ -101,123 +83,6 @@ extern "C" { 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). - * 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 structure - * The string ranges array to resize. - * - * @return - * F_okay 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_ranges_decimate_by_ - extern f_status_t f_string_ranges_decimate_by(const f_number_unsigned_t amount, f_string_ranges_t * const structure); -#endif // _di_f_string_ranges_decimate_by_ - -/** - * Resize the string ranges 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 structure - * The string ranges array to resize. - * - * @return - * F_okay 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_ranges_decrease_by_ - extern f_status_t f_string_ranges_decrease_by(const f_number_unsigned_t amount, f_string_ranges_t * const structure); -#endif // _di_f_string_ranges_decrease_by_ - -/** - * Increase the size of the string ranges array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The string ranges array to resize. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * @return - * F_okay on success. - * 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_ranges_increase_ - extern f_status_t f_string_ranges_increase(const f_number_unsigned_t step, f_string_ranges_t * const structure); -#endif // _di_f_string_ranges_increase_ - -/** - * Resize the string ranges array to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The string ranges array to resize. - * - * @return - * F_okay 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_ranges_increase_by_ - extern f_status_t f_string_ranges_increase_by(const f_number_unsigned_t amount, f_string_ranges_t * const structure); -#endif // _di_f_string_ranges_increase_by_ - -/** - * Resize the string ranges array. - * - * @param length - * The new size to use. - * @param structure - * The string ranges array to adjust. - * - * @return - * F_okay on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_ranges_resize_ - extern f_status_t f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const structure); -#endif // _di_f_string_ranges_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/rangess.c b/level_0/f_string/c/string/rangess.c index 7f0a8fe..0f1ff8f 100644 --- a/level_0/f_string/c/string/rangess.c +++ b/level_0/f_string/c/string/rangess.c @@ -1,22 +1,10 @@ #include "../string.h" #include "../private-string.h" -#include "private-ranges.h" -#include "private-rangess.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_rangess_adjust_ - f_status_t f_string_rangess_adjust(const f_number_unsigned_t length, f_string_rangess_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_rangess_adjust(length, structure); - } -#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_ @@ -25,18 +13,23 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + 1 > destination->size) { - status = private_f_string_rangess_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_ranges_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - destination->array[destination->used].used = 0; + f_string_ranges_t * const destination_inner = &destination->array[destination->used]; + destination_inner->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; + if (source.used) { + status = f_memory_array_increase_by(source.used, sizeof(f_string_range_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); + if (F_status_is_error(status)) return status; + + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination_inner->used) { + + destination_inner->array[destination_inner->used].start = source.array[i].start; + destination_inner->array[destination_inner->used].stop = source.array[i].stop; + } // for + } } ++destination->used; @@ -53,104 +46,74 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + source.used > destination->size) { - status = private_f_string_rangess_resize(destination->used + source.used, destination); + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_ranges_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + f_string_ranges_t * destination_inner = 0; + f_number_unsigned_t j = 0; - destination->array[destination->used].used = 0; + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - 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 + destination_inner = &destination->array[destination->used]; + destination_inner->used = 0; - return F_okay; - } -#endif // _di_f_string_rangess_append_all_ + if (source.array[i].used) { + status = f_memory_array_increase_by(source.array[i].used, sizeof(f_string_range_t), (void **) &destination->array[destination->used].array, &destination->array[destination->used].used, &destination->array[destination->used].size); + if (F_status_is_error(status)) return status; -#ifndef _di_f_string_rangess_decimate_by_ - f_status_t f_string_rangess_decimate_by(const f_number_unsigned_t amount, f_string_rangess_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + for (j = 0; j < source.array[i].used; ++j, ++destination_inner->used) { - if (!amount) return F_data_not; - - return private_f_string_rangess_adjust((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_rangess_decimate_by_ - -#ifndef _di_f_string_rangess_decrease_by_ - f_status_t f_string_rangess_decrease_by(const f_number_unsigned_t amount, f_string_rangess_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; + destination_inner->array[destination_inner->used].start = source.array[i].array[j].start; + destination_inner->array[destination_inner->used].stop = source.array[i].array[j].stop; + } // for + } + } // for + } - return private_f_string_rangess_resize((structure->size > amount) ? structure->size - amount : 0, structure); + return F_okay; } -#endif // _di_f_string_rangess_decrease_by_ - -#ifndef _di_f_string_rangess_increase_ - f_status_t f_string_rangess_increase(const f_number_unsigned_t step, f_string_rangess_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#endif // _di_f_string_rangess_append_all_ - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; +#ifndef _di_f_string_rangess_delete_callback_ + f_status_t f_string_rangess_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_string_ranges_t * const array = (f_string_ranges_t *) void_array; + f_status_t status = F_okay; - length = F_number_t_size_unsigned_d; - } + for (f_number_unsigned_t i = start; i < stop; ++i) { - return private_f_string_rangess_resize(length, structure); + if (array[i].size) { + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; + return F_okay; } -#endif // _di_f_string_rangess_increase_ - -#ifndef _di_f_string_rangess_increase_by_ - f_status_t f_string_rangess_increase_by(const f_number_unsigned_t amount, f_string_rangess_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#endif // _di_f_string_rangess_delete_callback_ - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); +#ifndef _di_f_string_rangess_destroy_callback_ + f_status_t f_string_rangess_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - const f_number_unsigned_t length = structure->used + amount; + { + f_string_ranges_t * const array = (f_string_ranges_t *) void_array; + f_status_t status = F_okay; - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + for (f_number_unsigned_t i = start; i < stop; ++i) { - return private_f_string_rangess_resize(length, structure); - } + if (array[i].size) { + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; - } -#endif // _di_f_string_rangess_increase_by_ - -#ifndef _di_f_string_rangess_resize_ - f_status_t f_string_rangess_resize(const f_number_unsigned_t length, f_string_rangess_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_rangess_resize(length, structure); + return F_okay; } -#endif // _di_f_string_rangess_resize_ +#endif // _di_f_string_rangess_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/rangess.h b/level_0/f_string/c/string/rangess.h index 5c30bf9..5de97e1 100644 --- a/level_0/f_string/c/string/rangess.h +++ b/level_0/f_string/c/string/rangess.h @@ -44,25 +44,6 @@ extern "C" { #endif // _di_f_string_rangess_t_ /** - * Resize the string rangess array. - * - * @param length - * The new size to use. - * @param structure - * The string rangess array to resize. - * - * @return - * F_okay on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_rangess_adjust_ - extern f_status_t f_string_rangess_adjust(const f_number_unsigned_t length, f_string_rangess_t * const structure); -#endif // _di_f_string_rangess_adjust_ - -/** * Append the single source ranges onto the destination. * * @param source @@ -103,121 +84,60 @@ extern "C" { #endif // _di_f_string_rangess_append_all_ /** - * Resize the string rangess array to a smaller size. + * A callback intended to be passed to f_memory_arrayss_resize() for an f_string_rangess_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The string rangess array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_rangess_decimate_by_ - extern f_status_t f_string_rangess_decimate_by(const f_number_unsigned_t amount, f_string_rangess_t * const structure); -#endif // _di_f_string_rangess_decimate_by_ - -/** - * Resize the string rangess 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 structure - * The string rangess array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay 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_rangess_decrease_by_ - extern f_status_t f_string_rangess_decrease_by(const f_number_unsigned_t amount, f_string_rangess_t * const structure); -#endif // _di_f_string_rangess_decrease_by_ - -/** - * Increase the size of the string rangess array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The string rangess array to resize. - * - * @return - * F_okay on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. + * Errors (with error bit) from: f_memory_array_resize(). * - * Errors (with error bit) from: f_memory_resize(). + * @see f_memory_array_resize() */ -#ifndef _di_f_string_rangess_increase_ - extern f_status_t f_string_rangess_increase(const f_number_unsigned_t step, f_string_rangess_t * const structure); -#endif // _di_f_string_rangess_increase_ +#ifndef _di_f_string_rangess_delete_callback_ + extern f_status_t f_string_rangess_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_rangess_delete_callback_ /** - * Resize the string rangess array to a larger size. + * A callback intended to be passed to f_memory_arrayss_adjust() for an f_string_rangess_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This is only called when shrinking the array and generally should perform deallocations. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The string rangess array to resize. + * This does not do parameter checking. * - * @return - * F_okay 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_rangess_increase_by_ - extern f_status_t f_string_rangess_increase_by(const f_number_unsigned_t amount, f_string_rangess_t * const structure); -#endif // _di_f_string_rangess_increase_by_ - -/** - * Resize the string rangess array. - * - * @param length - * The new size to use. - * @param structure - * The string rangess array to adjust. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ -#ifndef _di_f_string_rangess_resize_ - extern f_status_t f_string_rangess_resize(const f_number_unsigned_t length, f_string_rangess_t * const structure); -#endif // _di_f_string_rangess_resize_ +#ifndef _di_f_string_rangess_destroy_callback_ + extern f_status_t f_string_rangess_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_rangess_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/triples.c b/level_0/f_string/c/string/triples.c index 9159d31..3b17dbc 100644 --- a/level_0/f_string/c/string/triples.c +++ b/level_0/f_string/c/string/triples.c @@ -1,51 +1,38 @@ #include "../string.h" #include "../private-string.h" -#include "private-triples.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_string_triples_adjust_ - f_status_t f_string_triples_adjust(const f_number_unsigned_t length, f_string_triples_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_string_triples_adjust(length, structure); - } -#endif // _di_f_string_triples_adjust_ - #ifndef _di_f_string_triples_append_ 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_ - f_status_t status = F_okay; - - if (destination->used + 1 > destination->size) { - status = private_f_string_triples_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_triple_t), (void **) &destination->array, &destination->used, &destination->size); 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; + 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.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.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; + 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; @@ -62,116 +49,96 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + source.used > destination->size) { - status = private_f_string_triples_resize(destination->used + source.used, destination); + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_triple_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + for (f_number_unsigned_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; + 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].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].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 + 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_okay; } #endif // _di_f_string_triples_append_all_ -#ifndef _di_f_string_triples_decimate_by_ - f_status_t f_string_triples_decimate_by(const f_number_unsigned_t amount, f_string_triples_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_triples_delete_callback_ + f_status_t f_string_triples_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (!amount) return F_data_not; + { + f_string_triple_t * const array = (f_string_triple_t *) void_array; + f_status_t status = F_okay; - return private_f_string_triples_adjust((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_triples_decimate_by_ + for (f_number_unsigned_t i = start; i < stop; ++i) { -#ifndef _di_f_string_triples_decrease_by_ - f_status_t f_string_triples_decrease_by(const f_number_unsigned_t amount, f_string_triples_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - return private_f_string_triples_resize((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_triples_decrease_by_ - -#ifndef _di_f_string_triples_increase_ - f_status_t f_string_triples_increase(const f_number_unsigned_t step, f_string_triples_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (array[i].a.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].a.string, &array[i].a.used, &array[i].a.size); + if (F_status_is_error(status)) return status; + } - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + F_memory_default_allocation_small_d; + if (array[i].b.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].b.string, &array[i].b.used, &array[i].b.size); + if (F_status_is_error(status)) return status; + } - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - return private_f_string_triples_resize(length, structure); + if (array[i].c.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].c.string, &array[i].c.used, &array[i].c.size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; + return F_okay; } -#endif // _di_f_string_triples_increase_ - -#ifndef _di_f_string_triples_increase_by_ - f_status_t f_string_triples_increase_by(const f_number_unsigned_t amount, f_string_triples_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#endif // _di_f_string_triples_delete_callback_ - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); +#ifndef _di_f_string_triples_destroy_callback_ + f_status_t f_string_triples_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - const f_number_unsigned_t length = structure->used + amount; + { + f_string_triple_t * const array = (f_string_triple_t *) void_array; + f_status_t status = F_okay; - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + for (f_number_unsigned_t i = start; i < stop; ++i) { - return private_f_string_triples_resize(length, structure); - } - } + if (array[i].a.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].a.string, &array[i].a.used, &array[i].a.size); + if (F_status_is_error(status)) return status; + } - return F_data_not; - } -#endif // _di_f_string_triples_increase_by_ + if (array[i].b.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].b.string, &array[i].b.used, &array[i].b.size); + if (F_status_is_error(status)) return status; + } -#ifndef _di_f_string_triples_resize_ - f_status_t f_string_triples_resize(const f_number_unsigned_t length, f_string_triples_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (array[i].c.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].c.string, &array[i].c.used, &array[i].c.size); + if (F_status_is_error(status)) return status; + } + } // for + } - return private_f_string_triples_resize(length, structure); + return F_okay; } -#endif // _di_f_string_triples_resize_ +#endif // _di_f_string_triples_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/triples.h b/level_0/f_string/c/string/triples.h index 5ec7e2c..e3948c2 100644 --- a/level_0/f_string/c/string/triples.h +++ b/level_0/f_string/c/string/triples.h @@ -44,24 +44,6 @@ extern "C" { #endif // _di_f_string_triples_t_ /** - * Resize the string triples array. - * - * @param length - * The new size to use. - * @param structure - * The string triples array to resize. - * - * @return - * F_okay on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_string_triples_adjust_ - extern f_status_t f_string_triples_adjust(const f_number_unsigned_t length, f_string_triples_t * const structure); -#endif // _di_f_string_triples_adjust_ - -/** * Append the single source triples onto the destination. * * @param source @@ -104,121 +86,60 @@ extern "C" { #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). - * 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 structure - * The string triples array to resize. + * A callback intended to be passed to f_memory_arrays_resize() for an f_string_triples_t structure. * - * @return - * F_okay on success. - * F_data_not if amount is 0. + * This is only called when shrinking the array and generally should perform deallocations. * - * F_parameter (with error bit) if a parameter is invalid. + * This does not do parameter checking. * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_triples_decimate_by_ - extern f_status_t f_string_triples_decimate_by(const f_number_unsigned_t amount, f_string_triples_t * const structure); -#endif // _di_f_string_triples_decimate_by_ - -/** - * Resize the string triples 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 structure - * The string triples array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay 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_triples_decrease_by_ - extern f_status_t f_string_triples_decrease_by(const f_number_unsigned_t amount, f_string_triples_t * const structure); -#endif // _di_f_string_triples_decrease_by_ - -/** - * Increase the size of the string triples array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * Errors (with error bit) from: f_memory_array_resize(). * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The string triples array to resize. - * - * @return - * F_okay 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(). + * @see f_memory_array_resize() */ -#ifndef _di_f_string_triples_increase_ - extern f_status_t f_string_triples_increase(const f_number_unsigned_t step, f_string_triples_t * const structure); -#endif // _di_f_string_triples_increase_ +#ifndef _di_f_string_triples_delete_callback_ + extern f_status_t f_string_triples_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_triples_delete_callback_ /** - * Resize the string triples array to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_string_triples_t structure. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The string triples array to resize. + * This is only called when shrinking the array and generally should perform deallocations. * - * @return - * F_okay on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * This does not do parameter checking. * - * 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_triples_increase_by_ - extern f_status_t f_string_triples_increase_by(const f_number_unsigned_t amount, f_string_triples_t * const structure); -#endif // _di_f_string_triples_increase_by_ - -/** - * Resize the string triples array. - * - * @param length - * The new size to use. - * @param structure - * The string triples array to adjust. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ -#ifndef _di_f_string_triples_resize_ - extern f_status_t f_string_triples_resize(const f_number_unsigned_t length, f_string_triples_t * const structure); -#endif // _di_f_string_triples_resize_ +#ifndef _di_f_string_triples_destroy_callback_ + extern f_status_t f_string_triples_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_triples_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/tripless.c b/level_0/f_string/c/string/tripless.c index 8f2c9b5..e46d130 100644 --- a/level_0/f_string/c/string/tripless.c +++ b/level_0/f_string/c/string/tripless.c @@ -1,7 +1,5 @@ #include "../string.h" #include "../private-string.h" -#include "private-triples.h" -#include "private-tripless.h" #ifdef __cplusplus extern "C" { @@ -15,18 +13,39 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + 1 > destination->size) { - status = private_f_string_tripless_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_ranges_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - destination->array[destination->used].used = 0; + f_string_triples_t * const destination_inner = &destination->array[destination->used]; + destination_inner->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; + if (source.used) { + status = f_memory_array_increase_by(source.used, sizeof(f_string_triple_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); + if (F_status_is_error(status)) return status; + + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination_inner->used) { + + destination_inner->array[destination_inner->used].a.used = 0; + destination_inner->array[destination_inner->used].b.used = 0; + destination_inner->array[destination_inner->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_inner->array[destination_inner->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_inner->array[destination_inner->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_inner->array[destination_inner->used].c); + if (F_status_is_error(status)) return status; + } + } // for + } } ++destination->used; @@ -43,114 +62,128 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = F_okay; - - if (destination->used + source.used > destination->size) { - status = private_f_string_tripless_resize(destination->used + source.used, destination); + { + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_triples_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; - } - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + f_string_triples_t * destination_inner = 0; + f_number_unsigned_t j = 0; - destination->array[destination->used].used = 0; + for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { - 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 + destination_inner = &destination->array[destination->used]; + destination_inner->used = 0; - return F_okay; - } -#endif // _di_f_string_tripless_append_all_ + if (source.array[i].used) { + status = f_memory_array_increase_by(source.array[i].used, sizeof(f_string_triple_t), (void **) &destination_inner->array, &destination_inner->used, &destination_inner->size); + if (F_status_is_error(status)) return status; -#ifndef _di_f_string_tripless_adjust_ - f_status_t f_string_tripless_adjust(const f_number_unsigned_t length, f_string_tripless_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + for (j = 0; j < source.array[i].used; ++j, ++destination_inner->used) { - return private_f_string_tripless_adjust(length, structure); - } -#endif // _di_f_string_tripless_adjust_ + destination_inner->array[destination_inner->used].a.used = 0; + destination_inner->array[destination_inner->used].b.used = 0; + destination_inner->array[destination_inner->used].c.used = 0; -#ifndef _di_f_string_tripless_decimate_by_ - f_status_t f_string_tripless_decimate_by(const f_number_unsigned_t amount, f_string_tripless_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (source.array[i].array[j].a.used) { + status = private_f_string_append(source.array[i].array[j].a.string, source.array[i].array[j].a.used, &destination_inner->array[destination_inner->used].a); + if (F_status_is_error(status)) return status; + } - if (!amount) return F_data_not; + if (source.array[i].array[j].b.used) { + status = private_f_string_append(source.array[i].array[j].b.string, source.array[i].array[j].b.used, &destination_inner->array[destination_inner->used].b); + if (F_status_is_error(status)) return status; + } - return private_f_string_tripless_adjust((structure->size > amount) ? structure->size - amount : 0, structure); + if (source.array[i].array[j].c.used) { + status = private_f_string_append(source.array[i].array[j].c.string, source.array[i].array[j].c.used, &destination_inner->array[destination_inner->used].c); + if (F_status_is_error(status)) return status; + } + } // for + } + } // for + } + + return F_okay; } -#endif // _di_f_string_tripless_decimate_by_ +#endif // _di_f_string_tripless_append_all_ -#ifndef _di_f_string_tripless_decrease_by_ - f_status_t f_string_tripless_decrease_by(const f_number_unsigned_t amount, f_string_tripless_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_tripless_delete_callback_ + f_status_t f_string_tripless_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (!amount) return F_data_not; + { + f_string_triples_t * const array = (f_string_triples_t *) void_array; + f_status_t status = F_okay; + f_number_unsigned_t j = 0; - return private_f_string_tripless_resize((structure->size > amount) ? structure->size - amount : 0, structure); - } -#endif // _di_f_string_tripless_decrease_by_ + for (f_number_unsigned_t i = start; i < stop; ++i) { -#ifndef _di_f_string_tripless_increase_ - f_status_t f_string_tripless_increase(const f_number_unsigned_t step, f_string_tripless_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (array[i].size) { + for (j = 0; j < array[i].size; ++j) { - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; + if (array[i].array[j].a.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].array[j].a.string, &array[i].array[j].a.used, &array[i].array[j].a.size); + if (F_status_is_error(status)) return status; + } - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (array[i].array[j].b.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].array[j].b.string, &array[i].array[j].b.used, &array[i].array[j].b.size); + if (F_status_is_error(status)) return status; + } - length = F_number_t_size_unsigned_d; - } + if (array[i].array[j].c.size) { + status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &array[i].array[j].c.string, &array[i].array[j].c.used, &array[i].array[j].c.size); + if (F_status_is_error(status)) return status; + } + } // for - return private_f_string_tripless_resize(length, structure); + status = f_memory_array_resize(0, sizeof(f_string_triple_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for } - return F_data_not; + return F_okay; } -#endif // _di_f_string_tripless_increase_ +#endif // _di_f_string_tripless_delete_callback_ -#ifndef _di_f_string_tripless_increase_by_ - f_status_t f_string_tripless_increase_by(const f_number_unsigned_t amount, f_string_tripless_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_string_tripless_destroy_callback_ + f_status_t f_string_tripless_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_string_triples_t * const array = (f_string_triples_t *) void_array; + f_status_t status = F_okay; + f_number_unsigned_t j = 0; - const f_number_unsigned_t length = structure->used + amount; + for (f_number_unsigned_t i = start; i < stop; ++i) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + if (array[i].size) { + for (j = 0; j < array[i].size; ++j) { - return private_f_string_tripless_resize(length, structure); - } - } + if (array[i].array[j].a.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].array[j].a.string, &array[i].array[j].a.used, &array[i].array[j].a.size); + if (F_status_is_error(status)) return status; + } - return F_data_not; - } -#endif // _di_f_string_tripless_increase_by_ + if (array[i].array[j].b.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].array[j].b.string, &array[i].array[j].b.used, &array[i].array[j].b.size); + if (F_status_is_error(status)) return status; + } -#ifndef _di_f_string_tripless_resize_ - f_status_t f_string_tripless_resize(const f_number_unsigned_t length, f_string_tripless_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (array[i].array[j].c.size) { + status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &array[i].array[j].c.string, &array[i].array[j].c.used, &array[i].array[j].c.size); + if (F_status_is_error(status)) return status; + } + } // for - return private_f_string_tripless_resize(length, structure); + status = f_memory_array_adjust(0, sizeof(f_string_triple_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for + } + + return F_okay; } -#endif // _di_f_string_tripless_resize_ +#endif // _di_f_string_tripless_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/c/string/tripless.h b/level_0/f_string/c/string/tripless.h index d4f4ae1..0d7c5aa 100644 --- a/level_0/f_string/c/string/tripless.h +++ b/level_0/f_string/c/string/tripless.h @@ -44,24 +44,6 @@ extern "C" { #endif // _di_f_string_tripless_t_ /** - * Resize the string tripless array. - * - * @param length - * The new size to use. - * @param structure - * The string tripless array to resize. - * - * @return - * F_okay on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_string_tripless_adjust_ - extern f_status_t f_string_tripless_adjust(const f_number_unsigned_t length, f_string_tripless_t * const structure); -#endif // _di_f_string_tripless_adjust_ - -/** * Append the single source triples onto the destination. * * @param source @@ -104,121 +86,60 @@ extern "C" { #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). - * 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 structure - * The string tripless array to resize. + * A callback intended to be passed to f_memory_arrayss_resize() for an f_string_tripless_t structure. * - * @return - * F_okay on success. - * F_data_not if amount is 0. + * This is only called when shrinking the array and generally should perform deallocations. * - * F_parameter (with error bit) if a parameter is invalid. + * This does not do parameter checking. * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_string_tripless_decimate_by_ - extern f_status_t f_string_tripless_decimate_by(const f_number_unsigned_t amount, f_string_tripless_t * const structure); -#endif // _di_f_string_tripless_decimate_by_ - -/** - * Resize the string tripless 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 structure - * The string tripless array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay 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_tripless_decrease_by_ - extern f_status_t f_string_tripless_decrease_by(const f_number_unsigned_t amount, f_string_tripless_t * const structure); -#endif // _di_f_string_tripless_decrease_by_ - -/** - * Increase the size of the string tripless array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * Errors (with error bit) from: f_memory_array_resize(). * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The string tripless array to resize. - * - * @return - * F_okay 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(). + * @see f_memory_array_resize() */ -#ifndef _di_f_string_tripless_increase_ - extern f_status_t f_string_tripless_increase(const f_number_unsigned_t step, f_string_tripless_t * const structure); -#endif // _di_f_string_tripless_increase_ +#ifndef _di_f_string_tripless_delete_callback_ + extern f_status_t f_string_tripless_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_tripless_delete_callback_ /** - * Resize the string tripless array to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * A callback intended to be passed to f_memory_arrayss_adjust() for an f_string_tripless_t structure. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The string tripless array to resize. + * This is only called when shrinking the array and generally should perform deallocations. * - * @return - * F_okay on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * This does not do parameter checking. * - * 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_tripless_increase_by_ - extern f_status_t f_string_tripless_increase_by(const f_number_unsigned_t amount, f_string_tripless_t * const structure); -#endif // _di_f_string_tripless_increase_by_ - -/** - * Resize the string tripless array. - * - * @param length - * The new size to use. - * @param structure - * The string tripless array to adjust. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() */ -#ifndef _di_f_string_tripless_resize_ - extern f_status_t f_string_tripless_resize(const f_number_unsigned_t length, f_string_tripless_t * const structure); -#endif // _di_f_string_tripless_resize_ +#ifndef _di_f_string_tripless_destroy_callback_ + extern f_status_t f_string_tripless_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_string_tripless_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_string/data/build/settings b/level_0/f_string/data/build/settings index e80e4a7..e7c69c1 100644 --- a/level_0/f_string/data/build/settings +++ b/level_0/f_string/data/build/settings @@ -34,12 +34,6 @@ build_libraries-individual -lf_memory build_sources_library string.c build_sources_library private-string.c string/common.c -build_sources_library string/private-dynamics.c -build_sources_library string/private-maps.c string/private-mapss.c -build_sources_library string/private-map_multis.c string/private-map_multiss.c -build_sources_library string/private-quantitys.c string/private-quantityss.c -build_sources_library string/private-ranges.c string/private-rangess.c -build_sources_library string/private-triples.c string/private-tripless.c build_sources_library string/dynamic.c string/dynamics.c string/dynamicss.c build_sources_library string/map.c string/maps.c string/mapss.c build_sources_library string/map_multi.c string/map_multis.c string/map_multiss.c diff --git a/level_0/f_string/data/build/settings-mocks b/level_0/f_string/data/build/settings-mocks new file mode 100644 index 0000000..9f7f236 --- /dev/null +++ b/level_0/f_string/data/build/settings-mocks @@ -0,0 +1,71 @@ +# fss-0001 + +build_name f_string + +version_major 0 +version_minor 7 +version_micro 0 +version_file micro +version_target minor + +modes individual clang test coverage +modes_default individual test + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -lc +build_libraries-individual -lf_memory + +build_sources_library string.c +build_sources_library private-string.c string/common.c +build_sources_library string/dynamic.c string/dynamics.c string/dynamicss.c +build_sources_library string/map.c string/maps.c string/mapss.c +build_sources_library string/map_multi.c string/map_multis.c string/map_multiss.c +build_sources_library string/quantity.c string/quantitys.c string/quantityss.c +build_sources_library string/range.c string/ranges.c string/rangess.c +build_sources_library string/static.c string/statics.c string/staticss.c +build_sources_library string/triple.c string/triples.c string/tripless.c +build_sources_library ../../tests/unit/c/mock-string.c + +build_sources_headers string.h string/common.h +build_sources_headers string/dynamic.h string/dynamics.h string/dynamicss.h +build_sources_headers string/map.h string/maps.h string/mapss.h +build_sources_headers string/map_multi.h string/map_multis.h string/map_multiss.h +build_sources_headers string/quantity.h string/quantitys.h string/quantityss.h +build_sources_headers string/range.h string/ranges.h string/rangess.h +build_sources_headers string/static.h string/statics.h string/staticss.h +build_sources_headers string/triple.h string/triples.h string/tripless.h + +build_script yes +build_shared yes +build_static no + +path_headers fll/level_0 +path_library_script script +path_library_shared shared +path_library_static static + +has_path_standard yes +preserve_path_headers yes + +search_exclusive yes +search_shared yes +search_static yes + +environment PATH LD_LIBRARY_PATH +environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH + +flags -O0 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses +flags-clang -Wno-logical-op-parentheses +flags-test -fstack-protector -Wall +flags-coverage --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ + +flags_library -fPIC + +# Inject mocks. +flags -Wl,--wrap=f_memory_array_adjust +flags -Wl,--wrap=f_memory_array_resize diff --git a/level_0/f_string/data/build/settings-tests b/level_0/f_string/data/build/settings-tests index 3d6574f..13885d5 100644 --- a/level_0/f_string/data/build/settings-tests +++ b/level_0/f_string/data/build/settings-tests @@ -37,15 +37,24 @@ build_sources_program test-string-dynamic_prepend.c test-string-dynamic_prepend_ build_sources_program test-string-dynamic_seek_line.c test-string-dynamic_seek_line_to.c test-string-dynamic_seek_to.c build_sources_program test-string-dynamic_terminate.c test-string-dynamic_terminate_after.c build_sources_program test-string-dynamics_append.c test-string-dynamics_append_all.c test-string-dynamicss_append.c test-string-dynamicss_append_all.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-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-dynamicss_delete_callback.c test-string-dynamicss_destroy_callback.c +build_sources_program test-string-map_multis_append.c test-string-map_multis_append_all.c test-string-map_multiss_append.c test-string-map_multiss_append_all.c +build_sources_program test-string-map_multis_delete_callback.c test-string-map_multis_destroy_callback.c +build_sources_program test-string-map_multiss_delete_callback.c test-string-map_multiss_destroy_callback.c +build_sources_program test-string-maps_append.c test-string-maps_append_all.c test-string-mapss_append.c test-string-mapss_append_all.c +build_sources_program test-string-maps_delete_callback.c test-string-maps_destroy_callback.c +build_sources_program test-string-mapss_delete_callback.c test-string-mapss_destroy_callback.c build_sources_program test-string-mash.c test-string-mash_nulless.c build_sources_program test-string-mish.c test-string-mish_nulless.c build_sources_program test-string-prepend.c test-string-prepend_assure.c test-string-prepend_assure_nulless.c test-string-prepend_nulless.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-quantitys_append.c test-string-quantitys_append_all.c test-string-quantityss_append.c test-string-quantityss_append_all.c +build_sources_program test-string-quantityss_delete_callback.c test-string-quantityss_destroy_callback.c +build_sources_program test-string-ranges_append.c test-string-ranges_append_all.c test-string-rangess_append.c test-string-rangess_append_all.c +build_sources_program test-string-rangess_delete_callback.c test-string-rangess_destroy_callback.c build_sources_program test-string-seek_line.c test-string-seek_line_to.c test-string-seek_to.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-triples_append.c test-string-triples_append_all.c test-string-tripless_append.c test-string-tripless_append_all.c +build_sources_program test-string-triples_delete_callback.c test-string-triples_destroy_callback.c +build_sources_program test-string-tripless_delete_callback.c test-string-tripless_destroy_callback.c build_sources_program test-string.c build_script no diff --git a/level_0/f_string/data/build/testfile b/level_0/f_string/data/build/testfile index 6b6a307..a8d0238 100644 --- a/level_0/f_string/data/build/testfile +++ b/level_0/f_string/data/build/testfile @@ -18,7 +18,7 @@ settings: #define CMOCKA_XML_FILE ./out.xml main: - build settings individual test + build settings-mocks individual test build settings-tests individual test operate build_path diff --git a/level_0/f_string/tests/unit/c/mock-string.c b/level_0/f_string/tests/unit/c/mock-string.c new file mode 100644 index 0000000..288785d --- /dev/null +++ b/level_0/f_string/tests/unit/c/mock-string.c @@ -0,0 +1,46 @@ +#include "mock-string.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int mock_unwrap = 0; +int mock_unwrap_f_memory = 1; + +f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { + + if (mock_unwrap_f_memory) { + return __real_f_memory_array_adjust(length, width, array, used, size); + } + + if (!array || !used || !size) return F_status_set_error(F_parameter_not); + + const bool failure = mock_type(bool); + + if (failure) return mock_type(f_status_t); + + *size = length; + + return mock_type(f_status_t); +} + +f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** const array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { + + if (mock_unwrap_f_memory) { + return __real_f_memory_array_resize(length, width, array, used, size); + } + + if (!array || !used || !size) return F_status_set_error(F_parameter_not); + + const bool failure = mock_type(bool); + + if (failure) return mock_type(f_status_t); + + *size = length; + + return mock_type(f_status_t); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/mock-string.h b/level_0/f_string/tests/unit/c/mock-string.h new file mode 100644 index 0000000..cb748dc --- /dev/null +++ b/level_0/f_string/tests/unit/c/mock-string.h @@ -0,0 +1,44 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the string project. + */ +#ifndef _MOCK__string_h +#define _MOCK__string_h + +// Libc includes. +#include +#include +#include +#include + +// cmocka includes. +#include + +// FLL-0 includes. +#include + +#ifdef __cplusplus +extern "C" { +#endif + +const static int mock_errno_generic = 32767; + +extern int mock_unwrap; +extern int mock_unwrap_f_memory; + +extern f_status_t __real_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); +extern f_status_t __real_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); + +extern f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); +extern f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _MOCK__string_h diff --git a/level_0/f_string/tests/unit/c/test-string-append.h b/level_0/f_string/tests/unit/c/test-string-append.h index 7ddefeb..2ee97dc 100644 --- a/level_0/f_string/tests/unit/c/test-string-append.h +++ b/level_0/f_string/tests/unit/c/test-string-append.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-append_assure.h b/level_0/f_string/tests/unit/c/test-string-append_assure.h index 59f7ba2..02d75af 100644 --- a/level_0/f_string/tests/unit/c/test-string-append_assure.h +++ b/level_0/f_string/tests/unit/c/test-string-append_assure.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-append_assure_nulless.h b/level_0/f_string/tests/unit/c/test-string-append_assure_nulless.h index f67ec6d..8c72b30 100644 --- a/level_0/f_string/tests/unit/c/test-string-append_assure_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-append_assure_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-append_nulless.h b/level_0/f_string/tests/unit/c/test-string-append_nulless.h index f508d0f..7d1bf20 100644 --- a/level_0/f_string/tests/unit/c/test-string-append_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-append_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_append.h b/level_0/f_string/tests/unit/c/test-string-dynamic_append.h index a47e899..a89a35e 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_append.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_append.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_append_assure.h b/level_0/f_string/tests/unit/c/test-string-dynamic_append_assure.h index a108200..72d9457 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_append_assure.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_append_assure.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_append_assure_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_append_assure_nulless.h index 393fe46..83a7097 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_append_assure_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_append_assure_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_append_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_append_nulless.h index 537726d..5942a5f 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_append_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_append_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_mash.h b/level_0/f_string/tests/unit/c/test-string-dynamic_mash.h index 74c543f..c92487d 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_mash.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_mash.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_mash_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_mash_nulless.h index 7801b02..4744097 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_mash_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_mash_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_mish.h b/level_0/f_string/tests/unit/c/test-string-dynamic_mish.h index 00c58ae..ba3ebde 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_mish.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_mish.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_mish_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_mish_nulless.h index baf83db..f3745b0 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_mish_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_mish_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append.h index 80219f1..8bb8cdc 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_assure.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_assure.h index fc7708b..e8e6bf4 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_assure.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_assure.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_assure_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_assure_nulless.h index 337e005..c46708c 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_assure_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_assure_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_nulless.h index 9a0e290..ddd85fc 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_append_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mash.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mash.h index 63cea12..0629f3d 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mash.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mash.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mash_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mash_nulless.h index 5d50f22..838fd05 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mash_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mash_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mish.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mish.h index 8ff6455..5e27957 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mish.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mish.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mish_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mish_nulless.h index 5b81dec..29b02ec 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mish_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_mish_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend.h index f5800d8..891ac07 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_assure.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_assure.h index 4e7f623..032c3b2 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_assure.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_assure.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_assure_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_assure_nulless.h index 8940232..9139e1d 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_assure_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_assure_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_nulless.h index abd6f1d..f857f4e 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_partial_prepend_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_prepend.h b/level_0/f_string/tests/unit/c/test-string-dynamic_prepend.h index 39ed3f2..a27fc2a 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_prepend.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_prepend.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_assure.h b/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_assure.h index e12c646..5014d37 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_assure.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_assure.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_assure_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_assure_nulless.h index 893e656..62d99d0 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_assure_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_assure_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_nulless.h b/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_nulless.h index 13d2c12..f1f7d3a 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_prepend_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_seek_line.h b/level_0/f_string/tests/unit/c/test-string-dynamic_seek_line.h index 2ca646f..aaaf36a 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_seek_line.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_seek_line.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_seek_line_to.h b/level_0/f_string/tests/unit/c/test-string-dynamic_seek_line_to.h index 2f08dda..a235831 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_seek_line_to.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_seek_line_to.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_seek_to.h b/level_0/f_string/tests/unit/c/test-string-dynamic_seek_to.h index 88687fd..042d64e 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_seek_to.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_seek_to.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_terminate.h b/level_0/f_string/tests/unit/c/test-string-dynamic_terminate.h index ee35528..b4d9a8c 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_terminate.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_terminate.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamic_terminate_after.h b/level_0/f_string/tests/unit/c/test-string-dynamic_terminate_after.h index e72e264..c421660 100644 --- a/level_0/f_string/tests/unit/c/test-string-dynamic_terminate_after.h +++ b/level_0/f_string/tests/unit/c/test-string-dynamic_terminate_after.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index d8b5bb1..e4d6f3f 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index 70b4e9f..22d0f5f 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-dynamics_delete_callback.c new file mode 100644 index 0000000..a3c44e4 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_delete_callback.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-dynamics_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t data = f_string_dynamic_t_initialize; + f_string_dynamic_t data_array[] = { data }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_dynamics_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_dynamics_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_dynamics_t datas = f_string_dynamics_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_dynamic_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_dynamics_delete_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.size, 0); + } + + free((void *) datas.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-dynamics_delete_callback.h new file mode 100644 index 0000000..400f5f8 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__dynamics_delete_callback +#define _TEST__F_string__dynamics_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_dynamics_delete_callback() + */ +extern void test__f_string_dynamics_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_dynamics_delete_callback() + */ +extern void test__f_string_dynamics_delete_callback__works(void **state); + +#endif // _TEST__F_string__dynamics_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-dynamics_destroy_callback.c new file mode 100644 index 0000000..7b98038 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_destroy_callback.c @@ -0,0 +1,52 @@ +#include "test-string.h" +#include "test-string-dynamics_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamics_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t data = f_string_dynamic_t_initialize; + f_string_dynamic_t data_array[] = { data }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_dynamics_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_dynamics_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_dynamics_t datas = f_string_dynamics_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_dynamic_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_dynamics_destroy_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.size, 0); + } + + free((void *) datas.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-dynamics_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-dynamics_destroy_callback.h new file mode 100644 index 0000000..5449891 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamics_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__dynamicss_destroy_callback +#define _TEST__F_string__dynamicss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_dynamicss_destroy_callback() + */ +extern void test__f_string_dynamicss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_dynamicss_destroy_callback() + */ +extern void test__f_string_dynamicss_destroy_callback__works(void **state); + +#endif // _TEST__F_string__dynamicss_destroy_callback 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 index d02b27a..f5a2bb4 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index f7d8334..eca0be5 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_delete_callback.c new file mode 100644 index 0000000..ad10ea3 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-dynamicss_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t data = f_string_dynamic_t_initialize; + f_string_dynamic_t data_array[] = { data }; + f_string_dynamics_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_dynamics_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_dynamicss_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_dynamicss_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_dynamicss_t datass = f_string_dynamicss_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_dynamics_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_dynamic_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_dynamicss_delete_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_delete_callback.h new file mode 100644 index 0000000..cd45ef9 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__dynamicss_delete_callback +#define _TEST__F_string__dynamicss_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_dynamicss_delete_callback() + */ +extern void test__f_string_dynamicss_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_dynamicss_delete_callback() + */ +extern void test__f_string_dynamicss_delete_callback__works(void **state); + +#endif // _TEST__F_string__dynamicss_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-dynamicss_destroy_callback.c new file mode 100644 index 0000000..c1de611 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-dynamicss_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_dynamicss_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t data = f_string_dynamic_t_initialize; + f_string_dynamic_t data_array[] = { data }; + f_string_dynamics_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_dynamics_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_dynamicss_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_dynamicss_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_dynamicss_t datass = f_string_dynamicss_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_string_dynamics_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_string_dynamic_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_dynamicss_destroy_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-dynamicss_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-dynamicss_destroy_callback.h new file mode 100644 index 0000000..5449891 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-dynamicss_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__dynamicss_destroy_callback +#define _TEST__F_string__dynamicss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_dynamicss_destroy_callback() + */ +extern void test__f_string_dynamicss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_dynamicss_destroy_callback() + */ +extern void test__f_string_dynamicss_destroy_callback__works(void **state); + +#endif // _TEST__F_string__dynamicss_destroy_callback 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 deleted file mode 100644 index 019f242..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index d06e7c5..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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.h b/level_0/f_string/tests/unit/c/test-string-map_multis_append.h index 87b287f..84441f3 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index e9c446b..c841371 100644 --- 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 @@ -21,7 +21,7 @@ void test__f_string_map_multis_append_all__works(void **state) { const f_string_statics_t test_value = macro_f_string_statics_t_initialize_1(test_value_array, 0, length_values); { - f_status_t status = f_string_map_multis_resize(length_inner, &source); + f_status_t status = f_memory_arrays_resize(length_inner, sizeof(f_string_map_multi_t), (void **) &source.array, &source.used, &source.size, &f_string_map_multis_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.size, length_inner); @@ -91,7 +91,7 @@ void test__f_string_map_multis_append_all__returns_data_not(void **state) { f_string_map_multis_t destination = f_string_map_multis_t_initialize; { - const f_status_t status = f_string_map_multis_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_map_multi_t), (void **) &source.array, &source.used, &source.size, &f_string_map_multis_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index 1ecaf9e..858a94f 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index da3d83a..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index faa8988..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index b1f085e..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 36fa7b9..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-map_multis_delete_callback.c new file mode 100644 index 0000000..0a42c92 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_delete_callback.c @@ -0,0 +1,103 @@ +#include "test-string.h" +#include "test-string-map_multis_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t name = { .string = "name", .used = 0, .size = 1 }; + f_string_dynamic_t value = { .string = "value", .used = 0, .size = 1 }; + f_string_dynamic_t value_array[] = { value }; + f_string_dynamics_t values = { .array = value_array, .used = 0, .size = 1 }; + f_string_map_multi_t data = { .name = name, .value = values }; + f_string_map_multi_t data_array[] = { data }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_map_multis_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].name.size = 1; + data_array[0].value.size = 1; + data_array[0].value.array[0].size = 1; + + { + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_map_multis_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].name.size = 1; + data_array[0].value.size = 1; + data_array[0].value.array[0].size = 1; + + { + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_map_multis_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_map_multis_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_map_multis_t datas = f_string_map_multis_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_map_multi_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].name.string, &datas.array[0].name.used, &datas.array[0].name.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_dynamic_t), (void **) &datas.array[0].value.array, &datas.array[0].value.used, &datas.array[0].value.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].value.array[0].string, &datas.array[0].value.array[0].used, &datas.array[0].value.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_map_multis_delete_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.size, 0); + } + + free((void *) datas.array[0].name.string); + free((void *) datas.array[0].value.array[0].string); + free((void *) datas.array[0].value.array); + free((void *) datas.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-map_multis_delete_callback.h new file mode 100644 index 0000000..91a15b0 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__map_multis_delete_callback +#define _TEST__F_string__map_multis_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_map_multis_delete_callback() + */ +extern void test__f_string_map_multis_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_map_multis_delete_callback() + */ +extern void test__f_string_map_multis_delete_callback__works(void **state); + +#endif // _TEST__F_string__map_multis_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-map_multis_destroy_callback.c new file mode 100644 index 0000000..ba5959e --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_destroy_callback.c @@ -0,0 +1,103 @@ +#include "test-string.h" +#include "test-string-map_multis_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multis_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t name = { .string = "name", .used = 0, .size = 1 }; + f_string_dynamic_t value = { .string = "value", .used = 0, .size = 1 }; + f_string_dynamic_t value_array[] = { value }; + f_string_dynamics_t values = { .array = value_array, .used = 0, .size = 1 }; + f_string_map_multi_t data = { .name = name, .value = values }; + f_string_map_multi_t data_array[] = { data }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_map_multis_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].name.size = 1; + data_array[0].value.size = 1; + data_array[0].value.array[0].size = 1; + + { + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_map_multis_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].name.size = 1; + data_array[0].value.size = 1; + data_array[0].value.array[0].size = 1; + + { + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_map_multis_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_map_multis_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_map_multis_t datas = f_string_map_multis_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_map_multi_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].name.string, &datas.array[0].name.used, &datas.array[0].name.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_dynamic_t), (void **) &datas.array[0].value.array, &datas.array[0].value.used, &datas.array[0].value.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].value.array[0].string, &datas.array[0].value.array[0].used, &datas.array[0].value.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_map_multis_destroy_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.size, 0); + } + + free((void *) datas.array[0].name.string); + free((void *) datas.array[0].value.array[0].string); + free((void *) datas.array[0].value.array); + free((void *) datas.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-map_multis_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-map_multis_destroy_callback.h new file mode 100644 index 0000000..6874bda --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multis_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__map_multis_destroy_callback +#define _TEST__F_string__map_multis_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_map_multis_destroy_callback() + */ +extern void test__f_string_map_multis_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_map_multis_destroy_callback() + */ +extern void test__f_string_map_multis_destroy_callback__works(void **state); + +#endif // _TEST__F_string__map_multis_destroy_callback 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 deleted file mode 100644 index e62cab8..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index e61a517..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index edd3149..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index eb3b1ad..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 4ed8a6e..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 4d891ff..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multis_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 31f43b9..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index bea9999..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 index 776b0d4..ed5ce88 100644 --- 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 @@ -33,7 +33,7 @@ void test__f_string_map_multiss_append__works(void **state) { }; { - f_status_t status = f_string_map_multis_resize(length_inner, &source); + f_status_t status = f_memory_arrays_resize(length_inner, sizeof(f_string_map_multi_t), (void **) &source.array, &source.used, &source.size, &f_string_map_multis_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.size, length_inner); @@ -106,7 +106,7 @@ void test__f_string_map_multiss_append__returns_data_not(void **state) { f_string_map_multiss_t destination = f_string_map_multiss_t_initialize; { - const f_status_t status = f_string_map_multis_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_map_multi_t), (void **) &source.array, &source.used, &source.size, &f_string_map_multis_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index 974fcfd..5c7dbbc 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index b9ece24..f2352e5 100644 --- 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 @@ -34,7 +34,7 @@ void test__f_string_map_multiss_append_all__works(void **state) { }; { - f_status_t status = f_string_map_multiss_resize(length_outer, &source); + f_status_t status = f_memory_arrays_resize(length_outer, sizeof(f_string_map_multis_t), (void **) &source.array, &source.used, &source.size, &f_string_map_multiss_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); @@ -44,7 +44,7 @@ void test__f_string_map_multiss_append_all__works(void **state) { for (; source.used < length_outer; ++source.used) { - status = f_string_map_multis_resize(length_inner, &source.array[source.used]); + status = f_memory_arrays_resize(length_inner, sizeof(f_string_map_multi_t), (void **) &source.array[source.used].array, &source.array[source.used].used, &source.array[source.used].size, &f_string_map_multis_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.array[source.used].used, 0); @@ -132,7 +132,7 @@ void test__f_string_map_multiss_append_all__returns_data_not(void **state) { f_string_map_multiss_t destination = f_string_map_multiss_t_initialize; { - const f_status_t status = f_string_map_multiss_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_map_multis_t), (void **) &source.array, &source.used, &source.size, &f_string_map_multiss_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index ae4841e..da35a9e 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index 458297f..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 9a600e9..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 04ff341..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 1a0b66f..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_delete_callback.c new file mode 100644 index 0000000..0f09df5 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-map_multiss_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_map_multi_t data = f_string_map_multi_t_initialize; + f_string_map_multi_t data_array[] = { data }; + f_string_map_multis_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_map_multis_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_map_multiss_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_map_multiss_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_map_multiss_t datass = f_string_map_multiss_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_map_multis_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_map_multi_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_map_multiss_delete_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_delete_callback.h new file mode 100644 index 0000000..3407570 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__map_multiss_delete_callback +#define _TEST__F_string__map_multiss_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_map_multiss_delete_callback() + */ +extern void test__f_string_map_multiss_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_map_multiss_delete_callback() + */ +extern void test__f_string_map_multiss_delete_callback__works(void **state); + +#endif // _TEST__F_string__map_multiss_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-map_multiss_destroy_callback.c new file mode 100644 index 0000000..b24e0cd --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-map_multiss_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_map_multiss_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_map_multi_t data = f_string_map_multi_t_initialize; + f_string_map_multi_t data_array[] = { data }; + f_string_map_multis_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_map_multis_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_map_multiss_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_map_multiss_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_map_multiss_t datass = f_string_map_multiss_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_string_map_multis_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_string_map_multi_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_map_multiss_destroy_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-map_multiss_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-map_multiss_destroy_callback.h new file mode 100644 index 0000000..8e12442 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-map_multiss_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__map_multiss_destroy_callback +#define _TEST__F_string__map_multiss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_map_multiss_destroy_callback() + */ +extern void test__f_string_map_multiss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_map_multiss_destroy_callback() + */ +extern void test__f_string_map_multiss_destroy_callback__works(void **state); + +#endif // _TEST__F_string__map_multiss_destroy_callback 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 deleted file mode 100644 index d13a6f6..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index 4e5f78e..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 2d93fc0..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 823fad7..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index a152b03..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index f7cb290..0000000 --- a/level_0/f_string/tests/unit/c/test-string-map_multiss_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 4ed7edd..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index f25f52c..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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.h b/level_0/f_string/tests/unit/c/test-string-maps_append.h index 4a8056c..0a04a3c 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index 8b8fce5..a73053b 100644 --- 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 @@ -15,7 +15,7 @@ void test__f_string_maps_append_all__works(void **state) { const f_string_static_t test_value = macro_f_string_static_t_initialize_1("test_value", 0, 10); { - f_status_t status = f_string_maps_resize(length_inner, &source); + f_status_t status = f_memory_arrays_resize(length_inner, sizeof(f_string_map_t), (void **) &source.array, &source.used, &source.size, &f_string_maps_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.size, length_inner); @@ -76,7 +76,7 @@ void test__f_string_maps_append_all__returns_data_not(void **state) { f_string_maps_t destination = f_string_maps_t_initialize; { - const f_status_t status = f_string_maps_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_map_t), (void **) &source.array, &source.used, &source.size, &f_string_maps_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index c946317..9975c9e 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index fcb4d47..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 611748a..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index ab81270..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index ed704c0..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-maps_delete_callback.c new file mode 100644 index 0000000..ed56012 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_delete_callback.c @@ -0,0 +1,77 @@ +#include "test-string.h" +#include "test-string-maps_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t name = { .string = "name", .used = 0, .size = 1 }; + f_string_dynamic_t value = { .string = "value", .used = 0, .size = 1 }; + f_string_map_t data = { .name = name, .value = value }; + f_string_map_t data_array[] = { data }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_maps_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].name.size = 1; + data_array[0].value.size = 1; + + { + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_maps_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_maps_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_maps_t datas = f_string_maps_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_map_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].name.string, &datas.array[0].name.used, &datas.array[0].name.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].value.string, &datas.array[0].value.used, &datas.array[0].value.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_maps_delete_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.size, 0); + } + + free((void *) datas.array[0].name.string); + free((void *) datas.array[0].value.string); + free((void *) datas.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-maps_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-maps_delete_callback.h new file mode 100644 index 0000000..125cc01 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__map_delete_callback +#define _TEST__F_string__map_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_maps_delete_callback() + */ +extern void test__f_string_maps_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_maps_delete_callback() + */ +extern void test__f_string_maps_delete_callback__works(void **state); + +#endif // _TEST__F_string__map_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-maps_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-maps_destroy_callback.c new file mode 100644 index 0000000..c1ccc1d --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_destroy_callback.c @@ -0,0 +1,77 @@ +#include "test-string.h" +#include "test-string-maps_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_maps_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t name = { .string = "name", .used = 0, .size = 1 }; + f_string_dynamic_t value = { .string = "value", .used = 0, .size = 1 }; + f_string_map_t data = { .name = name, .value = value }; + f_string_map_t data_array[] = { data }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_maps_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].name.size = 1; + data_array[0].value.size = 1; + + { + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_maps_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_maps_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_maps_t datas = f_string_maps_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_map_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].name.string, &datas.array[0].name.used, &datas.array[0].name.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].value.string, &datas.array[0].value.used, &datas.array[0].value.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_maps_destroy_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.size, 0); + } + + free((void *) datas.array[0].name.string); + free((void *) datas.array[0].value.string); + free((void *) datas.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-maps_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-maps_destroy_callback.h new file mode 100644 index 0000000..0fe0e61 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-maps_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__map_destroy_callback +#define _TEST__F_string__map_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_maps_destroy_callback() + */ +extern void test__f_string_maps_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_maps_destroy_callback() + */ +extern void test__f_string_maps_destroy_callback__works(void **state); + +#endif // _TEST__F_string__map_destroy_callback 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 deleted file mode 100644 index 46bed9f..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index ff4ca74..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index f7d860a..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index f903f76..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index c6550b3..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 2d4167f..0000000 --- a/level_0/f_string/tests/unit/c/test-string-maps_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 6fdbbb1..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 70db7f4..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 index 381700d..b86a5c4 100644 --- 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 @@ -22,7 +22,7 @@ void test__f_string_mapss_append__works(void **state) { }; { - f_status_t status = f_string_maps_resize(length_inner, &source); + f_status_t status = f_memory_arrays_resize(length_inner, sizeof(f_string_map_t), (void **) &source.array, &source.used, &source.size, &f_string_maps_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.size, length_inner); @@ -85,7 +85,7 @@ void test__f_string_mapss_append__returns_data_not(void **state) { f_string_mapss_t destination = f_string_mapss_t_initialize; { - const f_status_t status = f_string_maps_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_map_t), (void **) &source.array, &source.used, &source.size, &f_string_maps_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index ac77163..0a9369f 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index 369732a..76ed80c 100644 --- 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 @@ -23,7 +23,7 @@ void test__f_string_mapss_append_all__works(void **state) { }; { - f_status_t status = f_string_mapss_resize(length_outer, &source); + f_status_t status = f_memory_arrays_resize(length_outer, sizeof(f_string_maps_t), (void **) &source.array, &source.used, &source.size, &f_string_mapss_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); @@ -33,7 +33,7 @@ void test__f_string_mapss_append_all__works(void **state) { for (; source.used < length_outer; ++source.used) { - status = f_string_maps_resize(length_inner, &source.array[source.used]); + status = f_memory_arrays_resize(length_inner, sizeof(f_string_map_t), (void **) &source.array[source.used].array, &source.array[source.used].used, &source.array[source.used].size, &f_string_maps_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.array[source.used].used, 0); @@ -110,7 +110,7 @@ void test__f_string_mapss_append_all__returns_data_not(void **state) { f_string_mapss_t destination = f_string_mapss_t_initialize; { - const f_status_t status = f_string_mapss_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_maps_t), (void **) &source.array, &source.used, &source.size, &f_string_mapss_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index ce9426b..caa1629 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index 281d947..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index abe0d40..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index b7c3961..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 289acbd..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-mapss_delete_callback.c new file mode 100644 index 0000000..101e7ab --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-mapss_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_map_t data = f_string_map_t_initialize; + f_string_map_t data_array[] = { data }; + f_string_maps_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_maps_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_mapss_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_mapss_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_mapss_t datass = f_string_mapss_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_maps_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_map_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_mapss_delete_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-mapss_delete_callback.h new file mode 100644 index 0000000..a0fea92 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__mapss_delete_callback +#define _TEST__F_string__mapss_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_mapss_delete_callback() + */ +extern void test__f_string_mapss_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_mapss_delete_callback() + */ +extern void test__f_string_mapss_delete_callback__works(void **state); + +#endif // _TEST__F_string__mapss_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-mapss_destroy_callback.c new file mode 100644 index 0000000..e553fb4 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-mapss_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_mapss_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_map_t data = f_string_map_t_initialize; + f_string_map_t data_array[] = { data }; + f_string_maps_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_maps_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_mapss_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_mapss_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_mapss_t datass = f_string_mapss_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_string_maps_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_string_map_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_mapss_destroy_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-mapss_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-mapss_destroy_callback.h new file mode 100644 index 0000000..77db641 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-mapss_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__mapss_destroy_callback +#define _TEST__F_string__mapss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_mapss_destroy_callback() + */ +extern void test__f_string_mapss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_mapss_destroy_callback() + */ +extern void test__f_string_mapss_destroy_callback__works(void **state); + +#endif // _TEST__F_string__mapss_destroy_callback 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 deleted file mode 100644 index a5bb79e..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index 028a849..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 99b63f0..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 3765b11..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 38e9093..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index d7a6295..0000000 --- a/level_0/f_string/tests/unit/c/test-string-mapss_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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-mash.h b/level_0/f_string/tests/unit/c/test-string-mash.h index 3318511..8120d7b 100644 --- a/level_0/f_string/tests/unit/c/test-string-mash.h +++ b/level_0/f_string/tests/unit/c/test-string-mash.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-mash_nulless.h b/level_0/f_string/tests/unit/c/test-string-mash_nulless.h index 7bfa92b..ed9e38c 100644 --- a/level_0/f_string/tests/unit/c/test-string-mash_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-mash_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-mish.h b/level_0/f_string/tests/unit/c/test-string-mish.h index fc3a25a..d15bad7 100644 --- a/level_0/f_string/tests/unit/c/test-string-mish.h +++ b/level_0/f_string/tests/unit/c/test-string-mish.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-mish_nulless.h b/level_0/f_string/tests/unit/c/test-string-mish_nulless.h index 49aa986..a9fc863 100644 --- a/level_0/f_string/tests/unit/c/test-string-mish_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-mish_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-prepend.h b/level_0/f_string/tests/unit/c/test-string-prepend.h index f75bbd7..8617a30 100644 --- a/level_0/f_string/tests/unit/c/test-string-prepend.h +++ b/level_0/f_string/tests/unit/c/test-string-prepend.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-prepend_assure.h b/level_0/f_string/tests/unit/c/test-string-prepend_assure.h index 4edc8d8..1dd7582 100644 --- a/level_0/f_string/tests/unit/c/test-string-prepend_assure.h +++ b/level_0/f_string/tests/unit/c/test-string-prepend_assure.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-prepend_assure_nulless.h b/level_0/f_string/tests/unit/c/test-string-prepend_assure_nulless.h index d31c1e3..ae967af 100644 --- a/level_0/f_string/tests/unit/c/test-string-prepend_assure_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-prepend_assure_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-prepend_nulless.h b/level_0/f_string/tests/unit/c/test-string-prepend_nulless.h index e129717..17fdcd0 100644 --- a/level_0/f_string/tests/unit/c/test-string-prepend_nulless.h +++ b/level_0/f_string/tests/unit/c/test-string-prepend_nulless.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index 2cc7f11..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index fc7c807..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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.h b/level_0/f_string/tests/unit/c/test-string-quantitys_append.h index dcb6a3a..8f023bd 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index c21fd48..e872384 100644 --- 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 @@ -41,7 +41,7 @@ void test__f_string_quantitys_append_all__returns_data_not(void **state) { f_string_quantitys_t destination = f_string_quantitys_t_initialize; { - const f_status_t status = f_string_quantitys_resize(length, &source); + const f_status_t status = f_memory_array_resize(length, sizeof(f_string_quantity_t), (void **) &source.array, &source.used, &source.size); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index 5bc4529..0c22220 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index cb45b3d..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 9baefd2..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 765e7d8..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index f245982..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 1add3fa..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index 8ccb0c4..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 8fa0546..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 1d52555..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 67e4ebd..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index f29fefd..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantitys_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 9b4c8b7..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 75f4e4d..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 index 04f5016..801fbf7 100644 --- 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 @@ -41,7 +41,7 @@ void test__f_string_quantityss_append__returns_data_not(void **state) { f_string_quantityss_t destination = f_string_quantityss_t_initialize; { - const f_status_t status = f_string_quantitys_resize(length, &source); + const f_status_t status = f_memory_array_resize(length, sizeof(f_string_quantity_t), (void **) &source.array, &source.used, &source.size); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index 5ee4f33..7ef50a9 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index 8321f0c..73a9a7b 100644 --- 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 @@ -58,7 +58,7 @@ void test__f_string_quantityss_append_all__returns_data_not(void **state) { f_string_quantityss_t destination = f_string_quantityss_t_initialize; { - const f_status_t status = f_string_quantityss_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_quantitys_t), (void **) &source.array, &source.used, &source.size, &f_string_quantityss_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index dd97727..28f45bc 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index c6c8b1d..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 0500166..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index b042e13..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 1cacca3..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-quantityss_delete_callback.c new file mode 100644 index 0000000..061a069 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-quantityss_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_quantity_t data = f_string_quantity_t_initialize; + f_string_quantity_t data_array[] = { data }; + f_string_quantitys_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_quantitys_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_quantityss_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_quantityss_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_quantityss_t datass = f_string_quantityss_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_quantitys_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_quantity_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_quantityss_delete_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-quantityss_delete_callback.h new file mode 100644 index 0000000..4f3ec97 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__quantityss_delete_callback +#define _TEST__F_string__quantityss_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_quantityss_delete_callback() + */ +extern void test__f_string_quantityss_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_quantityss_delete_callback() + */ +extern void test__f_string_quantityss_delete_callback__works(void **state); + +#endif // _TEST__F_string__quantityss_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-quantityss_destroy_callback.c new file mode 100644 index 0000000..35fe553 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-quantityss_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_quantityss_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_quantity_t data = f_string_quantity_t_initialize; + f_string_quantity_t data_array[] = { data }; + f_string_quantitys_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_quantitys_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_quantityss_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_quantityss_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_quantityss_t datass = f_string_quantityss_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_string_quantitys_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_string_quantity_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_quantityss_destroy_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-quantityss_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-quantityss_destroy_callback.h new file mode 100644 index 0000000..f88891b --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-quantityss_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__quantityss_destroy_callback +#define _TEST__F_string__quantityss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_quantityss_destroy_callback() + */ +extern void test__f_string_quantityss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_quantityss_destroy_callback() + */ +extern void test__f_string_quantityss_destroy_callback__works(void **state); + +#endif // _TEST__F_string__quantityss_destroy_callback 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 deleted file mode 100644 index 5cd7902..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index 51a95d2..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 66c04d0..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index ccbf50c..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index f170ef0..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 77c4a07..0000000 --- a/level_0/f_string/tests/unit/c/test-string-quantityss_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index cdfba97..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 4e016f6..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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.h b/level_0/f_string/tests/unit/c/test-string-ranges_append.h index 75764a9..d6f9e15 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index 386b6a5..a1df06a 100644 --- 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 @@ -41,7 +41,7 @@ void test__f_string_ranges_append_all__returns_data_not(void **state) { f_string_ranges_t destination = f_string_ranges_t_initialize; { - const f_status_t status = f_string_ranges_resize(length, &source); + const f_status_t status = f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &source.array, &source.used, &source.size); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index 2f75492..fc9a66c 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index 3bce006..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 4217158..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 387d3b1..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index f291b11..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index c25e332..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index 0c6d13a..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index af1b0ec..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 450434b..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 9870b8b..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index f6f56b3..0000000 --- a/level_0/f_string/tests/unit/c/test-string-ranges_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index cabfb46..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index a12fa45..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 index dab482d..bdb2624 100644 --- 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 @@ -41,7 +41,7 @@ void test__f_string_rangess_append__returns_data_not(void **state) { f_string_rangess_t destination = f_string_rangess_t_initialize; { - const f_status_t status = f_string_ranges_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_ranges_t), (void **) &source.array, &source.used, &source.size, &f_string_rangess_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index 096721f..7b07263 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index 15f73b3..9773ce6 100644 --- 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 @@ -58,7 +58,7 @@ void test__f_string_rangess_append_all__returns_data_not(void **state) { f_string_rangess_t destination = f_string_rangess_t_initialize; { - const f_status_t status = f_string_rangess_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_ranges_t), (void **) &source.array, &source.used, &source.size, &f_string_rangess_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index 985b030..0ee22c0 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index 055e2c8..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 6fbf9d5..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 47eb21a..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 492d203..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-rangess_delete_callback.c new file mode 100644 index 0000000..d0be50c --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-rangess_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_range_t data = f_string_range_t_initialize; + f_string_range_t data_array[] = { data }; + f_string_ranges_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_ranges_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_rangess_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_rangess_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_rangess_t datass = f_string_rangess_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_ranges_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_rangess_delete_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-rangess_delete_callback.h new file mode 100644 index 0000000..678b767 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__rangess_delete_callback +#define _TEST__F_string__rangess_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_rangess_delete_callback() + */ +extern void test__f_string_rangess_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_rangess_delete_callback() + */ +extern void test__f_string_rangess_delete_callback__works(void **state); + +#endif // _TEST__F_string__rangess_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-rangess_destroy_callback.c new file mode 100644 index 0000000..c339fd2 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-rangess_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_rangess_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_range_t data = f_string_range_t_initialize; + f_string_range_t data_array[] = { data }; + f_string_ranges_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_ranges_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_rangess_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_rangess_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_rangess_t datass = f_string_rangess_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_string_ranges_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_string_range_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_rangess_destroy_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-rangess_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-rangess_destroy_callback.h new file mode 100644 index 0000000..5c423ff --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-rangess_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__rangess_destroy_callback +#define _TEST__F_string__rangess_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_rangess_destroy_callback() + */ +extern void test__f_string_rangess_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_rangess_destroy_callback() + */ +extern void test__f_string_rangess_destroy_callback__works(void **state); + +#endif // _TEST__F_string__rangess_destroy_callback 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 deleted file mode 100644 index 24caa5a..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index 2090ba6..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 8df2167..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index c377d7c..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index cc8a2c1..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 7c02cd5..0000000 --- a/level_0/f_string/tests/unit/c/test-string-rangess_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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-seek_line.h b/level_0/f_string/tests/unit/c/test-string-seek_line.h index 5819d71..71769af 100644 --- a/level_0/f_string/tests/unit/c/test-string-seek_line.h +++ b/level_0/f_string/tests/unit/c/test-string-seek_line.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-seek_line_to.h b/level_0/f_string/tests/unit/c/test-string-seek_line_to.h index 94a7854..616433c 100644 --- a/level_0/f_string/tests/unit/c/test-string-seek_line_to.h +++ b/level_0/f_string/tests/unit/c/test-string-seek_line_to.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * diff --git a/level_0/f_string/tests/unit/c/test-string-seek_to.h b/level_0/f_string/tests/unit/c/test-string-seek_to.h index fd1b6ac..ece924a 100644 --- a/level_0/f_string/tests/unit/c/test-string-seek_to.h +++ b/level_0/f_string/tests/unit/c/test-string-seek_to.h @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index 3035920..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 413d272..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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.h b/level_0/f_string/tests/unit/c/test-string-triples_append.h index 16b4fe7..af1bb66 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index c03ccb4..279491b 100644 --- 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 @@ -61,7 +61,7 @@ void test__f_string_triples_append_all__returns_data_not(void **state) { f_string_triples_t destination = f_string_triples_t_initialize; { - const f_status_t status = f_string_triples_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_triple_t), (void **) &source.array, &source.used, &source.size, &f_string_triples_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index f472467..ceb8950 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index 92b2a22..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 776aa2c..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 22d61db..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index a2b27d1..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-triples_delete_callback.c new file mode 100644 index 0000000..9b2362e --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_delete_callback.c @@ -0,0 +1,102 @@ +#include "test-string.h" +#include "test-string-triples_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t a = { .string = "a", .used = 0, .size = 1 }; + f_string_dynamic_t b = { .string = "b", .used = 0, .size = 1 }; + f_string_dynamic_t c = { .string = "c", .used = 0, .size = 1 }; + f_string_triple_t data = { .a = a, .b = b, .c = c }; + f_string_triple_t data_array[] = { data }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_triples_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].a.size = 1; + data_array[0].b.size = 1; + data_array[0].c.size = 1; + + { + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_triples_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].a.size = 1; + data_array[0].b.size = 1; + data_array[0].c.size = 1; + + { + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_array_resize, false); + will_return(__wrap_f_memory_array_resize, F_okay); + + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_triples_delete_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_triples_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_triples_t datas = f_string_triples_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_triple_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].a.string, &datas.array[0].a.used, &datas.array[0].a.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].b.string, &datas.array[0].b.used, &datas.array[0].b.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].c.string, &datas.array[0].c.used, &datas.array[0].c.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_triples_delete_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.size, 0); + } + + free((void *) datas.array[0].a.string); + free((void *) datas.array[0].b.string); + free((void *) datas.array[0].c.string); + free((void *) datas.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-triples_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-triples_delete_callback.h new file mode 100644 index 0000000..cacc87d --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__triples_delete_callback +#define _TEST__F_string__triples_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_triples_delete_callback() + */ +extern void test__f_string_triples_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_triples_delete_callback() + */ +extern void test__f_string_triples_delete_callback__works(void **state); + +#endif // _TEST__F_string__triples_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-triples_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-triples_destroy_callback.c new file mode 100644 index 0000000..a3804ae --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_destroy_callback.c @@ -0,0 +1,102 @@ +#include "test-string.h" +#include "test-string-triples_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_triples_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_dynamic_t a = { .string = "a", .used = 0, .size = 1 }; + f_string_dynamic_t b = { .string = "b", .used = 0, .size = 1 }; + f_string_dynamic_t c = { .string = "c", .used = 0, .size = 1 }; + f_string_triple_t data = { .a = a, .b = b, .c = c }; + f_string_triple_t data_array[] = { data }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_triples_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].a.size = 1; + data_array[0].b.size = 1; + data_array[0].c.size = 1; + + { + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_triples_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } + + data_array[0].a.size = 1; + data_array[0].b.size = 1; + data_array[0].c.size = 1; + + { + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_array_adjust, false); + will_return(__wrap_f_memory_array_adjust, F_okay); + + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_triples_destroy_callback(0, 1, (void *) data_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_triples_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_triples_t datas = f_string_triples_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_triple_t), (void **) &datas.array, &datas.used, &datas.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].a.string, &datas.array[0].a.used, &datas.array[0].a.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].b.string, &datas.array[0].b.used, &datas.array[0].b.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_char_t), (void **) &datas.array[0].c.string, &datas.array[0].c.used, &datas.array[0].c.size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_triples_destroy_callback(0, length, (void *) datas.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datas.size, 0); + } + + free((void *) datas.array[0].a.string); + free((void *) datas.array[0].b.string); + free((void *) datas.array[0].c.string); + free((void *) datas.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-triples_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-triples_destroy_callback.h new file mode 100644 index 0000000..c37bfdf --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-triples_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__triples_destroy_callback +#define _TEST__F_string__triples_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_triples_destroy_callback() + */ +extern void test__f_string_triples_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_triples_destroy_callback() + */ +extern void test__f_string_triples_destroy_callback__works(void **state); + +#endif // _TEST__F_string__triples_destroy_callback 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 deleted file mode 100644 index 5249d73..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index ea68b53..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 8785980..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 45b7127..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 422808a..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index 2e35b05..0000000 --- a/level_0/f_string/tests/unit/c/test-string-triples_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 9c3024e..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index e20b796..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 index b1f294d..e455a0a 100644 --- 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 @@ -61,7 +61,7 @@ void test__f_string_tripless_append__returns_data_not(void **state) { f_string_tripless_t destination = f_string_tripless_t_initialize; { - const f_status_t status = f_string_triples_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_triple_t), (void **) &source.array, &source.used, &source.size, &f_string_triples_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index a93519b..7efb569 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 index d6e9cc9..0202f61 100644 --- 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 @@ -87,7 +87,7 @@ void test__f_string_tripless_append_all__returns_data_not(void **state) { f_string_tripless_t destination = f_string_tripless_t_initialize; { - const f_status_t status = f_string_tripless_resize(length, &source); + const f_status_t status = f_memory_arrays_resize(length, sizeof(f_string_triples_t), (void **) &source.array, &source.used, &source.size, &f_string_tripless_delete_callback); assert_int_equal(status, F_okay); assert_int_equal(source.used, 0); 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 index dda4401..5970131 100644 --- 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 @@ -1,7 +1,7 @@ /** * FLL - Level 0 * - * Project: Type + * Project: String * API Version: 0.7 * Licenses: lgpl-2.1-or-later * 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 deleted file mode 100644 index 10a407a..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index edef6d1..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index f4d78d9..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index a4f2670..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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_delete_callback.c b/level_0/f_string/tests/unit/c/test-string-tripless_delete_callback.c new file mode 100644 index 0000000..6db2e3d --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-tripless_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_triple_t data = f_string_triple_t_initialize; + f_string_triple_t data_array[] = { data }; + f_string_triples_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_triples_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_string_tripless_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_tripless_delete_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_tripless_t datass = f_string_tripless_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_string_triples_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_string_triple_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_tripless_delete_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_delete_callback.h b/level_0/f_string/tests/unit/c/test-string-tripless_delete_callback.h new file mode 100644 index 0000000..dbd76bc --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__tripless_delete_callback +#define _TEST__F_string__tripless_delete_callback + +/** + * Test that the function fails. + * + * @see f_string_tripless_delete_callback() + */ +extern void test__f_string_tripless_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_tripless_delete_callback() + */ +extern void test__f_string_tripless_delete_callback__works(void **state); + +#endif // _TEST__F_string__tripless_delete_callback diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_destroy_callback.c b/level_0/f_string/tests/unit/c/test-string-tripless_destroy_callback.c new file mode 100644 index 0000000..c5dec11 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-string.h" +#include "test-string-tripless_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_string_tripless_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_string_triple_t data = f_string_triple_t_initialize; + f_string_triple_t data_array[] = { data }; + f_string_triples_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_string_triples_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_string_tripless_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_string_tripless_destroy_callback__works(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_string_tripless_t datass = f_string_tripless_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_string_triples_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_string_triple_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_string_tripless_destroy_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_string/tests/unit/c/test-string-tripless_destroy_callback.h b/level_0/f_string/tests/unit/c/test-string-tripless_destroy_callback.h new file mode 100644 index 0000000..29e4602 --- /dev/null +++ b/level_0/f_string/tests/unit/c/test-string-tripless_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_string__tripless_destroy_callback +#define _TEST__F_string__tripless_destroy_callback + +/** + * Test that the function fails. + * + * @see f_string_tripless_destroy_callback() + */ +extern void test__f_string_tripless_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_string_tripless_destroy_callback() + */ +extern void test__f_string_tripless_destroy_callback__works(void **state); + +#endif // _TEST__F_string__tripless_destroy_callback 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 deleted file mode 100644 index ea5b57e..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#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_okay); - 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_okay); - 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_okay); - 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 deleted file mode 100644 index caec0af..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 213be1e..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#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_okay); - 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_okay); - 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 deleted file mode 100644 index 6dc83b8..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 deleted file mode 100644 index 8da8956..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#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_okay); - 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 deleted file mode 100644 index d405ea2..0000000 --- a/level_0/f_string/tests/unit/c/test-string-tripless_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Type - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_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 index c42bca2..1d889ce 100644 --- a/level_0/f_string/tests/unit/c/test-string.c +++ b/level_0/f_string/tests/unit/c/test-string.c @@ -87,51 +87,23 @@ int main(void) { 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_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_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_mash__works), cmocka_unit_test(test__f_string_mash_nulless__works), @@ -144,74 +116,32 @@ int main(void) { cmocka_unit_test(test__f_string_prepend_assure_nulless__works), cmocka_unit_test(test__f_string_prepend_nulless__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), cmocka_unit_test(test__f_string_seek_line__returns_data_not_stop), cmocka_unit_test(test__f_string_seek_line__returns_none_stop), @@ -226,6 +156,33 @@ int main(void) { cmocka_unit_test(test__f_string_seek_to__returns_none_stop), cmocka_unit_test(test__f_string_seek_to__works), + cmocka_unit_test(test__f_string_dynamicss_delete_callback__fails), + cmocka_unit_test(test__f_string_dynamicss_destroy_callback__fails), + + cmocka_unit_test(test__f_string_map_multis_delete_callback__fails), + cmocka_unit_test(test__f_string_map_multis_destroy_callback__fails), + + cmocka_unit_test(test__f_string_map_multiss_delete_callback__fails), + cmocka_unit_test(test__f_string_map_multiss_destroy_callback__fails), + + cmocka_unit_test(test__f_string_maps_delete_callback__fails), + cmocka_unit_test(test__f_string_maps_destroy_callback__fails), + + cmocka_unit_test(test__f_string_mapss_delete_callback__fails), + cmocka_unit_test(test__f_string_mapss_destroy_callback__fails), + + cmocka_unit_test(test__f_string_quantityss_delete_callback__fails), + cmocka_unit_test(test__f_string_quantityss_destroy_callback__fails), + + cmocka_unit_test(test__f_string_rangess_delete_callback__fails), + cmocka_unit_test(test__f_string_rangess_destroy_callback__fails), + + cmocka_unit_test(test__f_string_triples_delete_callback__fails), + cmocka_unit_test(test__f_string_triples_destroy_callback__fails), + + cmocka_unit_test(test__f_string_tripless_delete_callback__fails), + cmocka_unit_test(test__f_string_tripless_destroy_callback__fails), + #ifndef _di_level_0_parameter_checking_ cmocka_unit_test(test__f_string_append__parameter_checking), cmocka_unit_test(test__f_string_append_assure__parameter_checking), @@ -273,45 +230,18 @@ int main(void) { 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_dynamicss_append__parameter_checking), cmocka_unit_test(test__f_string_dynamicss_append_all__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_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_mash__parameter_checking), cmocka_unit_test(test__f_string_mash_nulless__parameter_checking), @@ -324,65 +254,53 @@ int main(void) { cmocka_unit_test(test__f_string_prepend_assure_nulless__parameter_checking), cmocka_unit_test(test__f_string_prepend_nulless__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), cmocka_unit_test(test__f_string_seek_line__parameter_checking), cmocka_unit_test(test__f_string_seek_line_to__parameter_checking), cmocka_unit_test(test__f_string_seek_to__parameter_checking), + + // f_string_dynamicss_delete_callback() doesn't use parameter checking. + // f_string_dynamicss_destroy_callback() doesn't use parameter checking. + + // f_string_map_multis_delete_callback() doesn't use parameter checking. + // f_string_map_multis_destroy_callback() doesn't use parameter checking. + + // f_string_map_multiss_delete_callback() doesn't use parameter checking. + // f_string_map_multiss_destroy_callback() doesn't use parameter checking. + + // f_string_maps_delete_callback() doesn't use parameter checking. + // f_string_maps_destroy_callback() doesn't use parameter checking. + + // f_string_mapss_delete_callback() doesn't use parameter checking. + // f_string_mapss_destroy_callback() doesn't use parameter checking. + + // f_string_quantityss_delete_callback() doesn't use parameter checking. + // f_string_quantityss_destroy_callback() doesn't use parameter checking. + + // f_string_rangess_delete_callback() doesn't use parameter checking. + // f_string_rangess_destroy_callback() doesn't use parameter checking. + + // f_string_triples_delete_callback() doesn't use parameter checking. + // f_string_triples_destroy_callback() doesn't use parameter checking. + + // f_string_tripless_delete_callback() doesn't use parameter checking. + // f_string_tripless_destroy_callback() doesn't use parameter checking. #endif // _di_level_0_parameter_checking_ }; diff --git a/level_0/f_string/tests/unit/c/test-string.h b/level_0/f_string/tests/unit/c/test-string.h index 6b7f904..c34ebd7 100644 --- a/level_0/f_string/tests/unit/c/test-string.h +++ b/level_0/f_string/tests/unit/c/test-string.h @@ -23,7 +23,7 @@ #include // Mock includes. -//#include "mock-string.h" +#include "mock-string.h" // Test includes. #include "test-string-append.h" @@ -63,38 +63,24 @@ #include "test-string-dynamics_append_all.h" #include "test-string-dynamicss_append.h" #include "test-string-dynamicss_append_all.h" -#include "test-string-map_multis_adjust.h" +#include "test-string-dynamicss_delete_callback.h" +#include "test-string-dynamicss_destroy_callback.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_multis_delete_callback.h" +#include "test-string-map_multis_destroy_callback.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-maps_adjust.h" +#include "test-string-map_multiss_delete_callback.h" +#include "test-string-map_multiss_destroy_callback.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-maps_delete_callback.h" +#include "test-string-maps_destroy_callback.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-mapss_delete_callback.h" +#include "test-string-mapss_destroy_callback.h" #include "test-string-mash.h" #include "test-string-mash_nulless.h" #include "test-string-mish.h" @@ -103,57 +89,29 @@ #include "test-string-prepend_assure.h" #include "test-string-prepend_assure_nulless.h" #include "test-string-prepend_nulless.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-quantityss_delete_callback.h" +#include "test-string-quantityss_destroy_callback.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-rangess_delete_callback.h" +#include "test-string-rangess_destroy_callback.h" #include "test-string-seek_line.h" #include "test-string-seek_line_to.h" #include "test-string-seek_to.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-triples_delete_callback.h" +#include "test-string-triples_destroy_callback.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" +#include "test-string-tripless_delete_callback.h" +#include "test-string-tripless_destroy_callback.h" #ifdef __cplusplus extern "C" { diff --git a/level_1/fl_environment/c/environment.c b/level_1/fl_environment/c/environment.c index d11fad3..6dfcf23 100644 --- a/level_1/fl_environment/c/environment.c +++ b/level_1/fl_environment/c/environment.c @@ -10,27 +10,27 @@ extern "C" { if (!environment) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!name.used) { - return F_data_not; - } + if (!name.used) return F_data_not; - f_status_t status = f_string_maps_increase(F_memory_default_allocation_small_d, environment); - if (F_status_is_error(status)) return status; + { + f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_map_t), (void **) &environment->array, &environment->used, &environment->size); + if (F_status_is_error(status)) return status; - environment->array[environment->used].name.used = 0; - environment->array[environment->used].value.used = 0; + environment->array[environment->used].name.used = 0; + environment->array[environment->used].value.used = 0; - status = f_string_dynamic_append_nulless(name, &environment->array[environment->used].name); + status = f_string_dynamic_append_nulless(name, &environment->array[environment->used].name); - if (F_status_is_error_not(status)) { - status = f_environment_get(name, &environment->array[environment->used].value); - } + if (F_status_is_error_not(status)) { + status = f_environment_get(name, &environment->array[environment->used].value); + } - if (F_status_is_error(status) || status == F_data_not || status == F_exist_not) { - environment->array[environment->used].name.used = 0; - environment->array[environment->used].value.used = 0; + if (F_status_is_error(status) || status == F_data_not || status == F_exist_not) { + environment->array[environment->used].name.used = 0; + environment->array[environment->used].value.used = 0; - return status; + return status; + } } ++environment->used; @@ -49,7 +49,7 @@ extern "C" { return F_data_not; } - f_status_t status = f_string_maps_increase_by(names.used, environment); + f_status_t status = f_memory_array_increase_by(names.used, sizeof(f_string_map_t), (void **) &environment->array, &environment->used, &environment->size); if (F_status_is_error(status)) return status; for (f_number_unsigned_t i = 0; i < names.used; ++i) { diff --git a/level_1/fl_environment/c/environment.h b/level_1/fl_environment/c/environment.h index 63aa40e..5ce4c4d 100644 --- a/level_1/fl_environment/c/environment.h +++ b/level_1/fl_environment/c/environment.h @@ -47,12 +47,12 @@ extern "C" { * F_exist_not if name does not exist. * * Errors (with error bit) from: f_environment_get(). + * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_string_dynamic_append_nulless(). - * Errors (with error bit) from: f_string_maps_increase_by(). * * @see f_environment_get() + * @see f_memory_array_increase_by() * @see f_string_dynamic_append_nulless() - * @see f_string_maps_increase_by() */ #ifndef _di_fl_environment_load_name_ extern f_status_t fl_environment_load_name(const f_string_static_t name, f_string_maps_t * const environment); @@ -80,12 +80,12 @@ extern "C" { * F_data_not if names.used is 0. * * Errors (with error bit) from: f_environment_get(). + * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_string_dynamic_append_nulless(). - * Errors (with error bit) from: f_string_maps_increase_by(). * * @see f_environment_get() + * @see f_memory_array_increase_by() * @see f_string_dynamic_append_nulless() - * @see f_string_maps_increase_by() */ #ifndef _di_fl_environment_load_names_ extern f_status_t fl_environment_load_names(const f_string_statics_t names, f_string_maps_t * const environment); diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index ce0e6eb..a674842 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -40,7 +40,7 @@ extern "C" { return; } - state->status = f_string_ranges_increase(state->step_small, found); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &found->array, &found->used, &found->size); if (F_status_is_error(state->status)) return; found->array[found->used].start = range->start; diff --git a/level_1/fl_fss/c/fss/basic.h b/level_1/fl_fss/c/fss/basic.h index 4682ead..fced4c0 100644 --- a/level_1/fl_fss/c/fss/basic.h +++ b/level_1/fl_fss/c/fss/basic.h @@ -71,12 +71,12 @@ extern "C" { * * Errors (with error bit) from: f_fss_skip_past_delimit(). * Errors (with error bit) from: f_fss_skip_past_space(). - * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_utf_buffer_increment(). * * @see f_fss_skip_past_delimit() * @see f_fss_skip_past_space() - * @see f_string_ranges_increase() + * @see f_memory_array_increase() * @see f_utf_buffer_increment() */ #ifndef _di_fl_fss_basic_content_read_ diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index 5a82cf4..f41c7a2 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -40,7 +40,7 @@ extern "C" { return; } - state->status = f_string_ranges_increase(state->step_small, found); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &found->array, &found->used, &found->size); if (F_status_is_error(state->status)) return; found->array[found->used].start = range->start; @@ -236,7 +236,7 @@ extern "C" { f_fss_seek_to_eol(buffer, range, state); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, comments); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &comments->array, &comments->used, &comments->size); if (F_status_is_error(state->status)) break; if (range->start > range->stop || range->start >= buffer.used) { diff --git a/level_1/fl_fss/c/fss/basic_list.h b/level_1/fl_fss/c/fss/basic_list.h index 8a77dd2..02fdf2a 100644 --- a/level_1/fl_fss/c/fss/basic_list.h +++ b/level_1/fl_fss/c/fss/basic_list.h @@ -74,20 +74,18 @@ extern "C" { * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_fss_is_space(). * Errors (with error bit) from: f_fss_seek_to_eol(). * Errors (with error bit) from: f_fss_skip_past_delimit(). - * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_memory_array_increase(). + * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_utf_buffer_increment(). * - * @see f_memory_array_increase() - * @see f_memory_array_increase_by() * @see f_fss_is_space() * @see f_fss_seek_to_eol() * @see f_fss_skip_past_delimit() - * @see f_string_ranges_increase() + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() * @see f_utf_buffer_increment() */ #ifndef _di_fl_fss_basic_list_content_read_ diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index acf68d8..2de0279 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -32,7 +32,7 @@ extern "C" { f_string_ranges_t objects = f_string_ranges_t_initialize; - state->status = f_string_ranges_increase(state->step_small, &objects); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); if (F_status_is_error(state->status)) { f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); @@ -46,7 +46,7 @@ extern "C" { if (F_status_is_error(state->status)) { f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); return; } @@ -105,7 +105,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop; @@ -116,7 +116,7 @@ extern "C" { else { if (range->start >= buffer.used || range->start > range->stop) { f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_okay_eos : F_okay_stop; @@ -164,7 +164,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop; @@ -178,7 +178,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop; @@ -260,7 +260,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop; @@ -274,7 +274,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop; @@ -324,7 +324,7 @@ extern "C" { state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, &objects); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); if (F_status_is_error(state->status)) break; state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); @@ -401,7 +401,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop; @@ -415,7 +415,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop; @@ -431,7 +431,7 @@ extern "C" { state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, &objects); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); if (F_status_is_error(state->status)) break; state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); @@ -506,7 +506,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop; @@ -520,7 +520,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop; @@ -564,7 +564,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop; @@ -578,7 +578,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop; @@ -599,7 +599,7 @@ extern "C" { position = found->depth[depth].used; if (found->depth[depth].array[position].content.size != 1) { - state->status = f_string_ranges_resize(1, &found->depth[depth].array[position].content); + state->status = f_memory_array_resize(1, sizeof(f_string_range_t), (void **) &found->depth[depth].array[position].content.array, &found->depth[depth].array[position].content.used, &found->depth[depth].array[position].content.size); if (F_status_is_error(state->status)) break; } @@ -639,7 +639,7 @@ extern "C" { if (F_status_is_error(state->status)) break; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); if (range->start >= buffer.used) { @@ -695,7 +695,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_end_not_nest_eos : F_end_not_nest_stop; @@ -709,7 +709,7 @@ extern "C" { comments->used = comments_used; f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); state->status = (range->start >= buffer.used) ? F_data_not_eos : F_data_not_stop; @@ -725,7 +725,7 @@ extern "C" { f_fss_seek_to_eol(buffer, range, state); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, comments); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &comments->array, &comments->used, &comments->size); if (F_status_is_error(state->status)) break; if (range->start > range->stop || range->start >= buffer.used) { @@ -774,7 +774,7 @@ extern "C" { } // while f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &positions_start.array, &positions_start.used, &positions_start.size); - f_string_ranges_resize(0, &objects); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &slashes.array, &slashes.used, &slashes.size); delimits->used = delimits_used; diff --git a/level_1/fl_fss/c/fss/embedded_list.h b/level_1/fl_fss/c/fss/embedded_list.h index 6170e65..b229ae3 100644 --- a/level_1/fl_fss/c/fss/embedded_list.h +++ b/level_1/fl_fss/c/fss/embedded_list.h @@ -78,20 +78,18 @@ extern "C" { * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_fss_is_space(). * Errors (with error bit) from: f_fss_seek_to_eol(). * Errors (with error bit) from: f_fss_skip_past_delimit(). - * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_memory_array_increase(). + * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_utf_buffer_increment(). * - * @see f_memory_array_increase() - * @see f_memory_array_increase_by() * @see f_fss_is_space() * @see f_fss_seek_to_eol() * @see f_fss_skip_past_delimit() - * @see f_string_ranges_increase() + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() * @see f_utf_buffer_increment() */ #ifndef _di_fl_fss_embedded_list_content_read_ diff --git a/level_1/fl_fss/c/fss/extended.c b/level_1/fl_fss/c/fss/extended.c index e3e1254..745706e 100644 --- a/level_1/fl_fss/c/fss/extended.c +++ b/level_1/fl_fss/c/fss/extended.c @@ -55,7 +55,7 @@ extern "C" { private_fl_fss_basic_read(buffer, F_false, range, &content_partial, "e, delimits, state); if (state->status == F_fss_found_object || F_status_set_fine(state->status) == F_fss_found_object_content_not) { - status = f_string_ranges_increase(state->step_small, found); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &found->array, &found->used, &found->size); // The private function sets the error bit on unterminated quoted Object. if (state->status == F_status_set_error(F_fss_found_object_content_not)) { diff --git a/level_1/fl_fss/c/fss/extended.h b/level_1/fl_fss/c/fss/extended.h index 5bceb80..70563b5 100644 --- a/level_1/fl_fss/c/fss/extended.h +++ b/level_1/fl_fss/c/fss/extended.h @@ -203,22 +203,20 @@ extern "C" { * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_fss_is_graph(). * Errors (with error bit) from: f_fss_is_space(). * Errors (with error bit) from: f_fss_is_zero_width(). * Errors (with error bit) from: f_fss_skip_past_delimit(). * Errors (with error bit) from: f_fss_skip_past_space(). - * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_utf_buffer_increment(). * - * @see f_memory_array_increase() * @see f_fss_is_graph() * @see f_fss_is_space() * @see f_fss_is_zero_width() * @see f_fss_skip_past_delimit() * @see f_fss_skip_past_space() - * @see f_string_ranges_increase() + * @see f_memory_array_increase() * @see f_utf_buffer_increment() * @see fl_fss_basic_object_read() * @see fl_fss_extended_object_read() diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 214bd3c..7d03037 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -40,7 +40,7 @@ extern "C" { return; } - state->status = f_string_ranges_increase(state->step_small, found); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &found->array, &found->used, &found->size); if (F_status_is_error(state->status)) return; found->array[found->used].start = range->start; @@ -192,7 +192,7 @@ extern "C" { f_fss_seek_to_eol(buffer, range, state); if (F_status_is_error(state->status)) break; - state->status = f_string_ranges_increase(state->step_small, comments); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &comments->array, &comments->used, &comments->size); if (F_status_is_error(state->status)) break; if (range->start > range->stop || range->start >= buffer.used) { diff --git a/level_1/fl_fss/c/fss/extended_list.h b/level_1/fl_fss/c/fss/extended_list.h index ad908b6..5b656b5 100644 --- a/level_1/fl_fss/c/fss/extended_list.h +++ b/level_1/fl_fss/c/fss/extended_list.h @@ -76,20 +76,18 @@ extern "C" { * F_interrupt (with error bit) if stopping due to an interrupt. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_fss_is_space(). * Errors (with error bit) from: f_fss_seek_to_eol(). * Errors (with error bit) from: f_fss_skip_past_delimit(). - * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_memory_array_increase(). + * Errors (with error bit) from: f_memory_array_increase_by(). * Errors (with error bit) from: f_utf_buffer_increment(). * - * @see f_memory_array_increase() - * @see f_memory_array_increase_by() * @see f_fss_is_space() * @see f_fss_seek_to_eol() * @see f_fss_skip_past_delimit() - * @see f_string_ranges_increase() + * @see f_memory_array_increase() + * @see f_memory_array_increase_by() * @see f_utf_buffer_increment() */ #ifndef _di_fl_fss_extended_list_content_read_ diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index 4fa4bed..d22ebfd 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -438,7 +438,7 @@ extern "C" { matches[j] = F_true; } - status = f_string_map_multis_increase(F_fss_default_allocation_step_small_d, values[j]); + status = f_memory_array_increase(F_fss_default_allocation_step_small_d, sizeof(f_string_map_multi_t), (void **) &values[j]->array, &values[j]->used, &values[j]->size); if (F_status_is_error(status)) return status; if (indexs) { @@ -512,7 +512,7 @@ extern "C" { matches[j] = F_true; } - status = f_string_maps_increase(F_fss_default_allocation_step_small_d, values[j]); + status = f_memory_array_increase(F_fss_default_allocation_step_small_d, sizeof(f_string_map_t), (void **) &values[j]->array, &values[j]->used, &values[j]->size); if (F_status_is_error(status)) return status; if (indexs) { @@ -619,7 +619,7 @@ extern "C" { map_multi = &values[j]->array[k]; } else { - status = f_string_map_multis_increase(F_fss_default_allocation_step_small_d, values[j]); + status = f_memory_array_increase(F_fss_default_allocation_step_small_d, sizeof(f_string_map_multi_t), (void **) &values[j]->array, &values[j]->used, &values[j]->size); if (F_status_is_error(status)) return status; if (indexs) { @@ -735,7 +735,7 @@ extern "C" { map = &values[j]->array[k]; } else { - status = f_string_maps_increase(F_fss_default_allocation_step_small_d, values[j]); + status = f_memory_array_increase(F_fss_default_allocation_step_small_d, sizeof(f_string_map_t), (void **) &values[j]->array, &values[j]->used, &values[j]->size); if (F_status_is_error(status)) return status; if (indexs) { diff --git a/level_2/fll_fss/c/fss/basic.c b/level_2/fll_fss/c/fss/basic.c index e1893e3..1503d60 100644 --- a/level_2/fll_fss/c/fss/basic.c +++ b/level_2/fll_fss/c/fss/basic.c @@ -24,10 +24,10 @@ extern "C" { uint8_t *quoted_object = 0; do { - state->status = f_string_ranges_increase(state->step_small, objects); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &objects->array, &objects->used, &objects->size); if (F_status_is_error(state->status)) return; - state->status = f_string_rangess_increase(state->step_small, contents); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_ranges_t), (void **) &contents->array, &contents->used, &contents->size); if (F_status_is_error(state->status)) return; contents->array[contents->used].used = 0; @@ -53,7 +53,8 @@ extern "C" { ++objects_quoted->used; } - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); + if (F_status_is_error(status)) { state->status = status; @@ -92,7 +93,7 @@ extern "C" { if (state->status == F_fss_found_object_content_not) { found_data = F_true; - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); if (F_status_is_error(status)) { state->status = status; diff --git a/level_2/fll_fss/c/fss/basic.h b/level_2/fll_fss/c/fss/basic.h index 1f3506c..68ed193 100644 --- a/level_2/fll_fss/c/fss/basic.h +++ b/level_2/fll_fss/c/fss/basic.h @@ -70,14 +70,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_string_ranges_increase(). - * Errors (with error bit) from: f_string_rangess_increase(). * Errors (with error bit) from: fl_fss_basic_content_read(). * Errors (with error bit) from: fl_fss_basic_object_read(). * * @see f_memory_array_increase() - * @see f_string_ranges_increase() - * @see f_string_rangess_increase() * @see fl_fss_basic_content_read() * @see fl_fss_basic_object_read() */ diff --git a/level_2/fll_fss/c/fss/basic_list.c b/level_2/fll_fss/c/fss/basic_list.c index 67d54ef..5dd539d 100644 --- a/level_2/fll_fss/c/fss/basic_list.c +++ b/level_2/fll_fss/c/fss/basic_list.c @@ -22,10 +22,10 @@ extern "C" { bool found_data = F_false; do { - state->status = f_string_ranges_increase(state->step_small, objects); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &objects->array, &objects->used, &objects->size); if (F_status_is_error(state->status)) return; - state->status = f_string_rangess_increase(state->step_small, contents); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_ranges_t), (void **) &contents->array, &contents->used, &contents->size); if (F_status_is_error(state->status)) return; contents->array[contents->used].used = 0; @@ -38,7 +38,7 @@ extern "C" { if (state->status == F_fss_found_object || state->status == F_fss_found_object_content_not) { ++objects->used; - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); if (F_status_is_error(status)) { state->status = status; @@ -78,7 +78,7 @@ extern "C" { if (state->status == F_fss_found_object_content_not) { found_data = F_true; - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); if (F_status_is_error(status)) { state->status = status; diff --git a/level_2/fll_fss/c/fss/basic_list.h b/level_2/fll_fss/c/fss/basic_list.h index 328c741..85ef1af 100644 --- a/level_2/fll_fss/c/fss/basic_list.h +++ b/level_2/fll_fss/c/fss/basic_list.h @@ -69,14 +69,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_string_ranges_increase(). - * Errors (with error bit) from: f_string_rangess_increase(). * Errors (with error bit) from: fl_fss_basic_list_content_read(). * Errors (with error bit) from: fl_fss_basic_list_object_read(). * * @see f_memory_array_increase() - * @see f_string_ranges_increase() - * @see f_string_rangess_increase() * @see fl_fss_basic_list_content_read() * @see fl_fss_basic_list_object_read() */ diff --git a/level_2/fll_fss/c/fss/embedded_list.h b/level_2/fll_fss/c/fss/embedded_list.h index 6864e7b..647cbf5 100644 --- a/level_2/fll_fss/c/fss/embedded_list.h +++ b/level_2/fll_fss/c/fss/embedded_list.h @@ -69,14 +69,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_string_ranges_increase(). - * Errors (with error bit) from: f_string_rangess_increase(). * Errors (with error bit) from: fl_fss_embedded_list_content_read(). * Errors (with error bit) from: fl_fss_embedded_list_object_read(). * * @see f_memory_array_increase() - * @see f_string_ranges_increase() - * @see f_string_rangess_increase() * @see fl_fss_embedded_list_content_read() * @see fl_fss_embedded_list_object_read() */ diff --git a/level_2/fll_fss/c/fss/extended.c b/level_2/fll_fss/c/fss/extended.c index 3900515..3f1b685 100644 --- a/level_2/fll_fss/c/fss/extended.c +++ b/level_2/fll_fss/c/fss/extended.c @@ -25,10 +25,10 @@ extern "C" { f_uint8s_t *quoted_content = 0; do { - state->status = f_string_ranges_increase(state->step_small, objects); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &objects->array, &objects->used, &objects->size); if (F_status_is_error(state->status)) return; - state->status = f_string_rangess_increase(state->step_small, contents); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_ranges_t), (void **) &contents->array, &contents->used, &contents->size); if (F_status_is_error(state->status)) return; contents->array[contents->used].used = 0; @@ -61,7 +61,7 @@ extern "C" { ++objects_quoted->used; } - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); if (F_status_is_error(status)) return; contents->array[contents->used++].used = 0; diff --git a/level_2/fll_fss/c/fss/extended.h b/level_2/fll_fss/c/fss/extended.h index 2bf678f..556af07 100644 --- a/level_2/fll_fss/c/fss/extended.h +++ b/level_2/fll_fss/c/fss/extended.h @@ -73,14 +73,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_string_ranges_increase(). - * Errors (with error bit) from: f_string_rangess_increase(). * Errors (with error bit) from: fl_fss_extended_content_read(). * Errors (with error bit) from: fl_fss_extended_object_read(). * * @see f_memory_array_increase() - * @see f_string_ranges_increase() - * @see f_string_rangess_increase() * @see fl_fss_extended_content_read() * @see fl_fss_extended_object_read() */ diff --git a/level_2/fll_fss/c/fss/extended_list.c b/level_2/fll_fss/c/fss/extended_list.c index cbc037b..dc20d4b 100644 --- a/level_2/fll_fss/c/fss/extended_list.c +++ b/level_2/fll_fss/c/fss/extended_list.c @@ -22,10 +22,10 @@ extern "C" { bool found_data = F_false; do { - state->status = f_string_ranges_increase(state->step_small, objects); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &objects->array, &objects->used, &objects->size); if (F_status_is_error(state->status)) return; - state->status = f_string_rangess_increase(state->step_small, contents); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_ranges_t), (void **) &contents->array, &contents->used, &contents->size); if (F_status_is_error(state->status)) return; contents->array[contents->used].used = 0; @@ -38,7 +38,8 @@ extern "C" { if (state->status == F_fss_found_object || state->status == F_fss_found_object_content_not) { ++objects->used; - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); + if (F_status_is_error(state->status)) { state->status = status; @@ -76,7 +77,7 @@ extern "C" { if (state->status == F_fss_found_object_content_not) { found_data = F_true; - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); if (F_status_is_error(status)) { state->status = status; diff --git a/level_2/fll_fss/c/fss/extended_list.h b/level_2/fll_fss/c/fss/extended_list.h index 619a546..2fb17e2 100644 --- a/level_2/fll_fss/c/fss/extended_list.h +++ b/level_2/fll_fss/c/fss/extended_list.h @@ -73,14 +73,10 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_string_ranges_increase(). - * Errors (with error bit) from: f_string_rangess_increase(). * Errors (with error bit) from: fl_fss_extended_list_content_read(). * Errors (with error bit) from: fl_fss_extended_list_object_read(). * * @see f_memory_array_increase() - * @see f_string_ranges_increase() - * @see f_string_rangess_increase() * @see fl_fss_extended_list_content_read() * @see fl_fss_extended_list_object_read() */ diff --git a/level_2/fll_fss/c/fss/payload.c b/level_2/fll_fss/c/fss/payload.c index 9e20a12..b354c75 100644 --- a/level_2/fll_fss/c/fss/payload.c +++ b/level_2/fll_fss/c/fss/payload.c @@ -22,10 +22,10 @@ extern "C" { bool found_data = F_false; do { - state->status = f_string_ranges_increase(state->step_small, objects); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &objects->array, &objects->used, &objects->size); if (F_status_is_error(state->status)) return; - state->status = f_string_rangess_increase(state->step_small, contents); + state->status = f_memory_array_increase(state->step_small, sizeof(f_string_ranges_t), (void **) &contents->array, &contents->used, &contents->size); if (F_status_is_error(state->status)) return; contents->array[contents->used].used = 0; @@ -47,7 +47,8 @@ extern "C" { ++objects->used; - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); + if (F_status_is_error(status)) { state->status = status; @@ -82,7 +83,7 @@ extern "C" { contents->array[contents->used].used = 0; if (f_compare_dynamic_partial_string(f_fss_payload_s.string, buffer, f_fss_payload_s.used, objects->array[objects->used]) == F_equal_to) { - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); if (F_status_is_error(status)) { state->status = status; @@ -119,7 +120,7 @@ extern "C" { if (state->status == F_fss_found_object_content_not) { found_data = F_true; - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); if (F_status_is_error(status)) { state->status = status; @@ -132,7 +133,7 @@ extern "C" { if (f_compare_dynamic_partial_string(f_fss_payload_s.string, buffer, f_fss_payload_s.used, objects->array[objects->used]) == F_equal_to) { ++objects->used; - status = f_string_ranges_increase(state->step_small, &contents->array[contents->used]); + status = f_memory_array_increase(state->step_small, sizeof(f_string_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); if (F_status_is_error(status)) { state->status = status; diff --git a/level_2/fll_fss/c/fss/payload.h b/level_2/fll_fss/c/fss/payload.h index 772fa61..54eb791 100644 --- a/level_2/fll_fss/c/fss/payload.h +++ b/level_2/fll_fss/c/fss/payload.h @@ -86,14 +86,10 @@ extern "C" { * F_number_overflow (with error bit) if the maximum buffer size is reached. * * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_string_ranges_increase(). - * Errors (with error bit) from: f_string_rangess_increase(). * Errors (with error bit) from: fl_fss_basic_list_content_read(). * Errors (with error bit) from: fl_fss_basic_list_object_read(). * * @see f_memory_array_increase() - * @see f_string_ranges_increase() - * @see f_string_rangess_increase() * @see fl_fss_basic_list_content_read() * @see fl_fss_basic_list_object_read() */ diff --git a/level_3/control/c/main/common.c b/level_3/control/c/main/common.c index a29e3f9..7ea8540 100644 --- a/level_3/control/c/main/common.c +++ b/level_3/control/c/main/common.c @@ -385,8 +385,8 @@ extern "C" { return; } - f_string_ranges_resize(0, &main->cache.objects); - f_string_rangess_resize(0, &main->cache.contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &main->cache.objects.array, &main->cache.objects.used, &main->cache.objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &main->cache.contents.array, &main->cache.contents.used, &main->cache.contents.size, &f_string_rangess_delete_callback); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &main->cache.delimits.array, &main->cache.delimits.used, &main->cache.delimits.size); { diff --git a/level_3/control/c/main/common/type.c b/level_3/control/c/main/common/type.c index ec6ca68..4d36fd4 100644 --- a/level_3/control/c/main/common/type.c +++ b/level_3/control/c/main/common/type.c @@ -16,14 +16,14 @@ extern "C" { f_memory_array_resize(0, sizeof(f_char_t), (void **) &main->cache.small.string, &main->cache.small.used, &main->cache.small.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &main->cache.packet.string, &main->cache.packet.used, &main->cache.packet.size); - f_string_ranges_resize(0, &main->cache.objects); - f_string_rangess_resize(0, &main->cache.contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &main->cache.objects.array, &main->cache.objects.used, &main->cache.objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &main->cache.contents.array, &main->cache.contents.used, &main->cache.contents.size, &f_string_rangess_delete_callback); - f_string_ranges_resize(0, &main->cache.packet_objects); - f_string_rangess_resize(0, &main->cache.packet_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &main->cache.packet_objects.array, &main->cache.packet_objects.used, &main->cache.packet_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &main->cache.packet_contents.array, &main->cache.packet_contents.used, &main->cache.packet_contents.size, &f_string_rangess_delete_callback); - f_string_ranges_resize(0, &main->cache.header_objects); - f_string_rangess_resize(0, &main->cache.header_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &main->cache.header_objects.array, &main->cache.header_objects.used, &main->cache.header_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &main->cache.header_contents.array, &main->cache.header_contents.used, &main->cache.header_contents.size, &f_string_rangess_delete_callback); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &main->cache.delimits.array, &main->cache.delimits.used, &main->cache.delimits.size); } diff --git a/level_3/control/c/main/common/type.h b/level_3/control/c/main/common/type.h index 599ee38..7e24f8e 100644 --- a/level_3/control/c/main/common/type.h +++ b/level_3/control/c/main/common/type.h @@ -182,8 +182,7 @@ extern "C" { * This does not alter main.setting.state.status. * * @see f_memory_array_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() + * @see f_memory_arrays_resize() * @see fll_program_data_delete() */ #ifndef _di_control_main_delete_ diff --git a/level_3/controller/c/common/private-cache.c b/level_3/controller/c/common/private-cache.c index f2692c4..1fb1c21 100644 --- a/level_3/controller/c/common/private-cache.c +++ b/level_3/controller/c/common/private-cache.c @@ -28,13 +28,13 @@ extern "C" { f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &cache->stack.array, &cache->stack.used, &cache->stack.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &cache->delimits.array, &cache->delimits.used, &cache->delimits.size); - f_string_ranges_resize(0, &cache->comments); - f_string_ranges_resize(0, &cache->content_action); - f_string_ranges_resize(0, &cache->object_actions); - f_string_ranges_resize(0, &cache->object_items); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &cache->comments.array, &cache->comments.used, &cache->comments.size); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &cache->content_action.array, &cache->content_action.used, &cache->content_action.size); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &cache->object_actions.array, &cache->object_actions.used, &cache->object_actions.size); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &cache->object_items.array, &cache->object_items.used, &cache->object_items.size); - f_string_rangess_resize(0, &cache->content_actions); - f_string_rangess_resize(0, &cache->content_items); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &cache->content_actions.array, &cache->content_actions.used, &cache->content_actions.size, &f_string_rangess_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &cache->content_items.array, &cache->content_items.used, &cache->content_items.size, &f_string_rangess_delete_callback); controller_cache_action_delete_simple(&cache->action); } diff --git a/level_3/controller/c/common/private-cache.h b/level_3/controller/c/common/private-cache.h index 95f0a7f..9382503 100644 --- a/level_3/controller/c/common/private-cache.h +++ b/level_3/controller/c/common/private-cache.h @@ -140,8 +140,7 @@ extern "C" { * @see controller_cache_action_delete_simple() * * @see f_memory_array_resize() - * @see f_string_ranges_resize() - * @see f_string_rangess_resize() + * @see f_memory_arrays_resize() */ #ifndef _di_controller_cache_delete_simple_ extern void controller_cache_delete_simple(controller_cache_t * const cache) F_attribute_visibility_internal_d; diff --git a/level_3/controller/c/common/private-rule.c b/level_3/controller/c/common/private-rule.c index c27eb90..c8b6431 100644 --- a/level_3/controller/c/common/private-rule.c +++ b/level_3/controller/c/common/private-rule.c @@ -63,8 +63,8 @@ extern "C" { f_memory_array_resize(0, sizeof(f_char_t), (void **) &rule->name.string, &rule->name.used, &rule->name.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &rule->path.string, &rule->path.used, &rule->path.size); - f_string_maps_resize(0, &rule->define); - f_string_maps_resize(0, &rule->parameter); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &rule->define.array, &rule->define.used, &rule->define.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &rule->parameter.array, &rule->parameter.used, &rule->parameter.size, &f_string_maps_delete_callback); f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &rule->engine_arguments.array, &rule->engine_arguments.used, &rule->engine_arguments.size, &f_string_dynamics_delete_callback); f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &rule->environment.array, &rule->environment.used, &rule->environment.size, &f_string_dynamics_delete_callback); diff --git a/level_3/controller/c/common/private-setting.c b/level_3/controller/c/common/private-setting.c index 8e4affe..94165b3 100644 --- a/level_3/controller/c/common/private-setting.c +++ b/level_3/controller/c/common/private-setting.c @@ -18,11 +18,11 @@ extern "C" { controller_control_delete_simple(&setting->control); - f_string_maps_resize(0, &setting->entry.define); - f_string_maps_resize(0, &setting->entry.parameter); + status = f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &setting->entry.define.array, &setting->entry.define.used, &setting->entry.define.size, &f_string_maps_delete_callback); + status = f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &setting->entry.parameter.array, &setting->entry.parameter.used, &setting->entry.parameter.size, &f_string_maps_delete_callback); - f_string_maps_resize(0, &setting->exit.define); - f_string_maps_resize(0, &setting->exit.parameter); + status = f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &setting->exit.define.array, &setting->exit.define.used, &setting->exit.define.size, &f_string_maps_delete_callback); + status = f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &setting->exit.parameter.array, &setting->exit.parameter.used, &setting->exit.parameter.size, &f_string_maps_delete_callback); controller_entry_items_delete_simple(&setting->entry.items); controller_entry_items_delete_simple(&setting->exit.items); diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index 266d1f4..0989cf8 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -2327,17 +2327,19 @@ extern "C" { #ifndef _di_controller_entry_settings_read_map_ f_status_t controller_entry_settings_read_map(const f_string_static_t buffer, const f_string_ranges_t ranges, f_string_maps_t *setting_maps) { - f_status_t status = f_string_maps_increase(controller_common_allocation_small_d, setting_maps); - if (F_status_is_error(status)) return status; + { + f_status_t status = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_string_map_t), (void **) &setting_maps->array, &setting_maps->used, &setting_maps->size); + if (F_status_is_error(status)) return status; - setting_maps->array[setting_maps->used].name.used = 0; - setting_maps->array[setting_maps->used].value.used = 0; + setting_maps->array[setting_maps->used].name.used = 0; + setting_maps->array[setting_maps->used].value.used = 0; - status = f_string_dynamic_partial_append_nulless(buffer, ranges.array[0], &setting_maps->array[setting_maps->used].name); - if (F_status_is_error(status)) return status; + status = f_string_dynamic_partial_append_nulless(buffer, ranges.array[0], &setting_maps->array[setting_maps->used].name); + if (F_status_is_error(status)) return status; - status = f_string_dynamic_partial_append_nulless(buffer, ranges.array[1], &setting_maps->array[setting_maps->used].value); - if (F_status_is_error(status)) return status; + status = f_string_dynamic_partial_append_nulless(buffer, ranges.array[1], &setting_maps->array[setting_maps->used].value); + if (F_status_is_error(status)) return status; + } ++setting_maps->used; diff --git a/level_3/controller/c/entry/private-entry.h b/level_3/controller/c/entry/private-entry.h index ba799df..f2e18c5 100644 --- a/level_3/controller/c/entry/private-entry.h +++ b/level_3/controller/c/entry/private-entry.h @@ -224,11 +224,11 @@ extern "C" { * The map to load the settings into. * * @return + * Errors (with error bit) from: f_memory_aray_increase(). * Errors (with error bit) from: f_string_dynamic_partial_append_nulless(). - * Errors (with error bit) from: f_string_maps_increase(). * + * @see f_memory_aray_increase() * @see f_string_dynamic_partial_append_nulless() - * @see f_string_maps_increase() */ #ifndef _di_controller_entry_settings_read_map_ f_status_t controller_entry_settings_read_map(const f_string_static_t buffer, const f_string_ranges_t ranges, f_string_maps_t *setting_maps) F_attribute_visibility_internal_d; diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 1c9e930..5d8e23f 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -4240,10 +4240,10 @@ extern "C" { setting_maps = &rule->parameter; } - status = f_string_maps_increase(controller_common_allocation_small_d, setting_maps); + status = f_memory_array_increase(controller_common_allocation_small_d, sizeof(f_string_map_t), (void **) &setting_maps->array, &setting_maps->used, &setting_maps->size); if (F_status_is_error(status)) { - controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_string_maps_increase", F_true, F_false); + controller_rule_print_error(global.thread, global.main->error, cache->action, F_status_set_fine(status), "f_memory_array_increase", F_true, F_false); if (F_status_set_fine(status) == F_memory_not) { status_return = status; diff --git a/level_3/controller/c/rule/private-rule.h b/level_3/controller/c/rule/private-rule.h index 9fb2d97..e52a96b 100644 --- a/level_3/controller/c/rule/private-rule.h +++ b/level_3/controller/c/rule/private-rule.h @@ -706,7 +706,6 @@ extern "C" { * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_rip_dynamic_partial_nulless(). * Errors (with error bit) from: f_string_dynamic_partial_append_nulless(). - * Errors (with error bit) from: f_string_maps_increase(). * Errors (with error bit) from: fll_fss_extended_read(). * * Errors (with error bit) from: controller_path_canonical_relative(). @@ -714,7 +713,6 @@ extern "C" { * @see f_memory_array_increase() * @see f_rip_dynamic_partial_nulless() * @see f_string_dynamic_partial_append_nulless() - * @see f_string_maps_increase() * @see fll_fss_extended_read() * * @see controller_path_canonical_relative() diff --git a/level_3/fake/c/main/build/load.c b/level_3/fake/c/main/build/load.c index 9fb2ba9..babffd3 100644 --- a/level_3/fake/c/main/build/load.c +++ b/level_3/fake/c/main/build/load.c @@ -174,8 +174,8 @@ extern "C" { f_memory_array_resize(0, sizeof(f_char_t), (void **) &buffer.string, &buffer.used, &buffer.size); - f_string_ranges_resize(0, &objects); - f_string_rangess_resize(0, &contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &objects.array, &objects.used, &objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_rangess_delete_callback); } // Error when required settings are not specified. diff --git a/level_3/fake/c/main/common.c b/level_3/fake/c/main/common.c index 189077f..05f0d3e 100644 --- a/level_3/fake/c/main/common.c +++ b/level_3/fake/c/main/common.c @@ -555,7 +555,7 @@ extern "C" { // Shrink an overly long array. if (iki_data->content.used > fake_max_over_array_d) { - f_string_ranges_resize(fake_allocation_large_d, &iki_data->content); + f_memory_array_resize(fake_allocation_large_d, sizeof(f_string_range_t), (void **) &iki_data->content.array, &iki_data->content.used, &iki_data->content.size); } if (iki_data->delimits.used > fake_max_over_array_d) { @@ -563,11 +563,11 @@ extern "C" { } if (iki_data->variable.used > fake_max_over_array_d) { - f_string_ranges_resize(fake_allocation_large_d, &iki_data->variable); + f_memory_array_resize(fake_allocation_large_d, sizeof(f_string_range_t), (void **) &iki_data->variable.array, &iki_data->variable.used, &iki_data->variable.size); } if (iki_data->vocabulary.used > fake_max_over_array_d) { - f_string_ranges_resize(fake_allocation_large_d, &iki_data->vocabulary); + f_memory_array_resize(fake_allocation_large_d, sizeof(f_string_range_t), (void **) &iki_data->vocabulary.array, &iki_data->vocabulary.used, &iki_data->vocabulary.size); } while (iki_data->content.used) { diff --git a/level_3/fake/c/main/common.h b/level_3/fake/c/main/common.h index dc243b2..a8683ee 100644 --- a/level_3/fake/c/main/common.h +++ b/level_3/fake/c/main/common.h @@ -118,7 +118,6 @@ extern "C" { * The iki data to shrink. * * @see f_memory_array_resize() - * @see f_string_ranges_resize() */ #ifndef _di_fake_iki_data_reset_ extern void fake_iki_data_reset(f_iki_data_t * const iki_data); diff --git a/level_3/fake/c/main/common/print.c b/level_3/fake/c/main/common/print.c index 003077e..5b5d3ec 100644 --- a/level_3/fake/c/main/common/print.c +++ b/level_3/fake/c/main/common/print.c @@ -62,7 +62,6 @@ extern "C" { "f_string_dynamic_partial_append", "f_string_dynamic_partial_append_nulless", "f_string_dynamic_prepend", - "f_string_map_multis_resize", "f_thread_create", "f_utf_is_word_dash_plus", "fl_conversion_dynamic_to_unsigned_detect", diff --git a/level_3/fake/c/main/common/print.h b/level_3/fake/c/main/common/print.h index fc147d7..b0dc249 100644 --- a/level_3/fake/c/main/common/print.h +++ b/level_3/fake/c/main/common/print.h @@ -95,7 +95,6 @@ extern "C" { fake_f_f_string_dynamic_partial_append_e, fake_f_f_string_dynamic_partial_append_nulless_e, fake_f_f_string_dynamic_prepend_e, - fake_f_f_string_map_multis_resize_e, fake_f_f_thread_create_e, fake_f_f_utf_is_word_dash_plus_e, fake_f_fl_conversion_dynamic_to_unsigned_detect_e, diff --git a/level_3/fake/c/main/common/type.c b/level_3/fake/c/main/common/type.c index 5ef2803..554f96d 100644 --- a/level_3/fake/c/main/common/type.c +++ b/level_3/fake/c/main/common/type.c @@ -10,7 +10,8 @@ extern "C" { if (!build_data) return; fake_build_setting_delete(&build_data->setting); - f_string_maps_resize(0, &build_data->environment); + + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &build_data->environment.array, &build_data->environment.used, &build_data->environment.size, &f_string_maps_delete_callback); } #endif // _di_fake_build_data_delete_ @@ -36,6 +37,7 @@ extern "C" { f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_setting->path_program_script.string, &build_setting->path_program_script.used, &build_setting->path_program_script.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_setting->path_program_shared.string, &build_setting->path_program_shared.used, &build_setting->path_program_shared.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_setting->path_program_static.string, &build_setting->path_program_static.used, &build_setting->path_program_static.size); + f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_setting->path_sources.string, &build_setting->path_sources.used, &build_setting->path_sources.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_setting->path_sources_object.string, &build_setting->path_sources_object.used, &build_setting->path_sources_object.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_setting->process_post.string, &build_setting->process_post.used, &build_setting->process_post.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_setting->process_pre.string, &build_setting->process_pre.used, &build_setting->process_pre.size); @@ -109,6 +111,7 @@ extern "C" { f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_stage->file_library_shared.string, &build_stage->file_library_shared.used, &build_stage->file_library_shared.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_stage->file_library_static.string, &build_stage->file_library_static.used, &build_stage->file_library_static.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_stage->file_object_script.string, &build_stage->file_object_script.used, &build_stage->file_object_script.size); + f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_stage->file_object_shared.string, &build_stage->file_object_shared.used, &build_stage->file_object_shared.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_stage->file_object_static.string, &build_stage->file_object_static.used, &build_stage->file_object_static.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_stage->file_objects_static.string, &build_stage->file_objects_static.used, &build_stage->file_objects_static.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &build_stage->file_process_post.string, &build_stage->file_process_post.used, &build_stage->file_process_post.size); @@ -137,6 +140,7 @@ extern "C" { f_memory_array_resize(0, sizeof(f_char_t), (void **) &data->path_build_libraries_script.string, &data->path_build_libraries_script.used, &data->path_build_libraries_script.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &data->path_build_libraries_shared.string, &data->path_build_libraries_shared.used, &data->path_build_libraries_shared.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &data->path_build_libraries_static.string, &data->path_build_libraries_static.used, &data->path_build_libraries_static.size); + f_memory_array_resize(0, sizeof(f_char_t), (void **) &data->path_build_objects.string, &data->path_build_objects.used, &data->path_build_objects.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &data->path_build_objects_script.string, &data->path_build_objects_script.used, &data->path_build_objects_script.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &data->path_build_objects_shared.string, &data->path_build_objects_shared.used, &data->path_build_objects_shared.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &data->path_build_objects_static.string, &data->path_build_objects_static.used, &data->path_build_objects_static.size); @@ -208,7 +212,7 @@ extern "C" { fake_build_setting_delete(&data_make->setting_build); fake_make_setting_delete(&data_make->setting_make); - f_string_maps_resize(0, &data_make->environment); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &data_make->environment.array, &data_make->environment.used, &data_make->environment.size, &f_string_maps_delete_callback); f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &data_make->parameter.build.array, &data_make->parameter.build.used, &data_make->parameter.build.size, &f_string_dynamics_delete_callback); f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &data_make->parameter.color.array, &data_make->parameter.color.used, &data_make->parameter.color.size, &f_string_dynamics_delete_callback); @@ -261,7 +265,7 @@ extern "C" { #ifndef _di_fake_make_setting_delete_ void fake_make_setting_delete(fake_make_setting_t * const setting_make) { - f_string_map_multis_resize(0, &setting_make->parameter); + f_memory_arrays_resize(0, sizeof(f_string_map_multi_t), (void **) &setting_make->parameter.array, &setting_make->parameter.used, &setting_make->parameter.size, &f_string_map_multis_delete_callback); } #endif // _di_fake_make_setting_delete_ diff --git a/level_3/fake/c/main/make/load_fakefile.c b/level_3/fake/c/main/make/load_fakefile.c index 0b4c22d..3ba7d02 100644 --- a/level_3/fake/c/main/make/load_fakefile.c +++ b/level_3/fake/c/main/make/load_fakefile.c @@ -59,11 +59,11 @@ extern "C" { delimits.used = 0; } - f_string_ranges_resize(0, &comments); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &comments.array, &comments.used, &comments.size); if (F_status_is_error(data_make->main->setting.state.status)) { - f_string_ranges_resize(0, &list_objects); - f_string_rangess_resize(0, &list_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &list_objects.array, &list_objects.used, &list_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &list_contents.array, &list_contents.used, &list_contents.size, &f_string_rangess_delete_callback); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &delimits.array, &delimits.used, &delimits.size); return; @@ -84,8 +84,8 @@ extern "C" { fake_print_error(&data_make->main->program.error, macro_fake_f(f_memory_array_resize)); f_fss_set_delete(&settings); - f_string_ranges_resize(0, &list_objects); - f_string_rangess_resize(0, &list_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &list_objects.array, &list_objects.used, &list_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &list_contents.array, &list_contents.used, &list_contents.size, &f_string_rangess_delete_callback); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &delimits.array, &delimits.used, &delimits.size); return; @@ -170,8 +170,8 @@ extern "C" { } // for } - f_string_ranges_resize(0, &list_objects); - f_string_rangess_resize(0, &list_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &list_objects.array, &list_objects.used, &list_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &list_contents.array, &list_contents.used, &list_contents.size, &f_string_rangess_delete_callback); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &delimits.array, &delimits.used, &delimits.size); if (F_status_is_error(data_make->main->setting.state.status)) { @@ -189,7 +189,7 @@ extern "C" { { f_string_t function_name = macro_fake_f(macro_f_string_map_multis_t_resize); - data_make->main->setting.state.status = f_string_map_multis_resize(data_make->main->setting.state.step_small, &data_make->setting_make.parameter); + data_make->main->setting.state.status = f_memory_arrays_resize(data_make->main->setting.state.step_small, sizeof(f_string_map_multi_t), (void **) &data_make->setting_make.parameter.array, &data_make->setting_make.parameter.used, &data_make->setting_make.parameter.size, &f_string_map_multis_delete_callback); if (F_status_is_error_not(data_make->main->setting.state.status)) { data_make->setting_make.parameter.used = 1; @@ -368,7 +368,7 @@ extern "C" { if (F_status_is_error(data_make->main->setting.state.status)) { fake_print_error(&data_make->main->program.error, macro_fake_f(fll_fss_snatch_map_apart)); - f_string_map_multis_resize(0, &define); + f_memory_arrays_resize(0, sizeof(f_string_map_multi_t), (void **) &define.array, &define.used, &define.size, &f_string_map_multis_delete_callback); return; } @@ -418,7 +418,7 @@ extern "C" { f_memory_array_resize(0, sizeof(f_char_t), (void **) &combined.string, &combined.used, &combined.size); } - f_string_map_multis_resize(0, &define); + f_memory_arrays_resize(0, sizeof(f_string_map_multi_t), (void **) &define.array, &define.used, &define.size, &f_string_map_multis_delete_callback); if (F_status_is_error(data_make->main->setting.state.status)) return; diff --git a/level_3/fake/c/main/make/load_fakefile.h b/level_3/fake/c/main/make/load_fakefile.h index 5e82261..dfa4f54 100644 --- a/level_3/fake/c/main/make/load_fakefile.h +++ b/level_3/fake/c/main/make/load_fakefile.h @@ -30,9 +30,9 @@ extern "C" { * F_interrupt (with error bit) on interrupt signal received. * * Errors (with error bit) from: f_fss_apply_delimit(). + * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_string_dynamic_append(). * Errors (with error bit) from: f_string_dynamic_partial_append(). - * Errors (with error bit) from: f_string_map_multis_resize(). * Errors (with error bit) from: fll_fss_basic_list_read(). * Errors (with error bit) from: fll_fss_extended_read(). * Errors (with error bit) from: fll_program_standard_signal_received(). @@ -52,9 +52,9 @@ extern "C" { * If FALSE, then ignore the program input pipe. * * @see f_fss_apply_delimit() + * @see f_memory_array_resize() * @see f_string_dynamic_append() * @see f_string_dynamic_partial_append() - * @see f_string_map_multis_resize() * @see fll_fss_basic_list_read() * @see fll_fss_extended_read() * @see fll_program_standard_signal_received() diff --git a/level_3/fake/c/main/make/operate_process_type.c b/level_3/fake/c/main/make/operate_process_type.c index c3c9674..a8e6925 100644 --- a/level_3/fake/c/main/make/operate_process_type.c +++ b/level_3/fake/c/main/make/operate_process_type.c @@ -1703,10 +1703,10 @@ extern "C" { } } else { - main->setting.state.status = f_string_map_multis_resize(fake_allocation_small_d, &data_make->setting_make.parameter); + main->setting.state.status = f_memory_arrays_resize(fake_allocation_small_d, sizeof(f_string_map_multi_t), (void **) &data_make->setting_make.parameter.array, &data_make->setting_make.parameter.used, &data_make->setting_make.parameter.size, &f_string_map_multis_delete_callback); if (F_status_is_error(main->setting.state.status)) { - fake_print_error(&main->program.error, macro_fake_f(f_string_map_multis_resize)); + fake_print_error(&main->program.error, macro_fake_f(f_memory_arrays_resize)); main->setting.state.status = F_status_set_error(F_failure); diff --git a/level_3/fake/c/main/make/operate_process_type.h b/level_3/fake/c/main/make/operate_process_type.h index eff84a6..63b2426 100644 --- a/level_3/fake/c/main/make/operate_process_type.h +++ b/level_3/fake/c/main/make/operate_process_type.h @@ -627,10 +627,8 @@ extern "C" { * F_failure (with error bit) on any error. * * Errors (with error bit) from: f_memory_array_resize() - * Errors (with error bit) from: f_string_map_multis_resize() * * @see f_memory_array_resize() - * @see f_string_map_multis_resize() */ #ifndef _di_fake_make_operate_process_type_parameter_ extern void fake_make_operate_process_type_parameter(fake_make_data_t * const data_make); diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 56751c2..4fcab1a 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -724,8 +724,8 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca f_memory_array_resize(0, sizeof(f_char_t), (void **) &local_buffer.string, &local_buffer.used, &local_buffer.size); f_memory_array_resize(0, sizeof(f_char_t), (void **) &path_file.string, &path_file.used, &path_file.size); - f_string_ranges_resize(0, &basic_objects); - f_string_rangess_resize(0, &basic_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &basic_objects.array, &basic_objects.used, &basic_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &basic_contents.array, &basic_contents.used, &basic_contents.size, &f_string_rangess_delete_callback); if (F_status_set_fine(status) == F_failure || F_status_set_fine(status) == F_parameter) break; } @@ -1280,8 +1280,8 @@ f_status_t firewall_process_rules(firewall_data_t * const data, f_string_range_t } } - f_string_ranges_resize(0, &local->rule_objects); - f_string_rangess_resize(0, &local->rule_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &local->rule_objects.array, &local->rule_objects.used, &local->rule_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &local->rule_contents.array, &local->rule_contents.used, &local->rule_contents.size, &f_string_rangess_delete_callback); return status; } @@ -1301,11 +1301,11 @@ f_status_t firewall_delete_local_data(firewall_local_data_t * const local) { f_memory_array_resize(0, sizeof(f_char_t), (void **) &local->buffer.string, &local->buffer.used, &local->buffer.size); f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &local->chain_ids.array, &local->chain_ids.used, &local->chain_ids.size); - f_string_ranges_resize(0, &local->chain_objects); - f_string_rangess_resize(0, &local->chain_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &local->chain_objects.array, &local->chain_objects.used, &local->chain_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &local->chain_contents.array, &local->chain_contents.used, &local->chain_contents.size, &f_string_rangess_delete_callback); - f_string_ranges_resize(0, &local->rule_objects); - f_string_rangess_resize(0, &local->rule_contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &local->rule_objects.array, &local->rule_objects.used, &local->rule_objects.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &local->rule_contents.array, &local->rule_contents.used, &local->rule_contents.size, &f_string_rangess_delete_callback); return F_okay; } diff --git a/level_3/fss_read/c/main/common/print.c b/level_3/fss_read/c/main/common/print.c index 9a93719..befaa41 100644 --- a/level_3/fss_read/c/main/common/print.c +++ b/level_3/fss_read/c/main/common/print.c @@ -14,15 +14,12 @@ extern "C" { "f_file_stream_read_block", "f_file_stream_read_until", "f_fss_is_space", + "f_memory_array_increase", "f_memory_array_increase_by", "f_rip_dynamic", "f_string_dynamic_append", "f_string_dynamic_append_assure", "f_string_dynamic_append_nulless", - "f_string_ranges_increase", - "f_string_ranges_increase_by", - "f_string_rangess_increase", - "f_string_rangess_increase_by", "f_string_read_block_increase", "f_thread_create", "fl_conversion_dynamic_partial_to_unsigned_detect", diff --git a/level_3/fss_read/c/main/common/print.h b/level_3/fss_read/c/main/common/print.h index 8ab62ca..12aad9e 100644 --- a/level_3/fss_read/c/main/common/print.h +++ b/level_3/fss_read/c/main/common/print.h @@ -47,15 +47,12 @@ extern "C" { fss_read_f_f_file_stream_read_block_e, fss_read_f_f_file_stream_read_until_e, fss_read_f_f_fss_is_space_e, + fss_read_f_f_memory_array_increase_e, fss_read_f_f_memory_array_increase_by_e, fss_read_f_f_rip_dynamic_e, fss_read_f_f_string_dynamic_append_e, fss_read_f_f_string_dynamic_append_assure_e, fss_read_f_f_string_dynamic_append_nulless_e, - fss_read_f_f_string_ranges_increase_e, - fss_read_f_f_string_ranges_increase_by_e, - fss_read_f_f_string_rangess_increase_e, - fss_read_f_f_string_rangess_increase_by_e, fss_read_f_f_string_read_block_increase_e, fss_read_f_f_thread_create_e, fss_read_f_fl_conversion_dynamic_partial_to_unsigned_detect_e, diff --git a/level_3/fss_read/c/main/common/type.c b/level_3/fss_read/c/main/common/type.c index ce3508b..f4cee6c 100644 --- a/level_3/fss_read/c/main/common/type.c +++ b/level_3/fss_read/c/main/common/type.c @@ -77,9 +77,9 @@ extern "C" { f_memory_array_resize(0, sizeof(f_char_t), (void **) &setting->buffer.string, &setting->buffer.used, &setting->buffer.size); - f_string_ranges_resize(0, &setting->objects); - f_string_ranges_resize(0, &setting->comments); - f_string_rangess_resize(0, &setting->contents); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &setting->objects.array, &setting->objects.used, &setting->objects.size); + f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &setting->comments.array, &setting->comments.used, &setting->comments.size); + f_memory_arrays_resize(0, sizeof(f_string_ranges_t), (void **) &setting->contents.array, &setting->contents.used, &setting->contents.size, &f_string_rangess_delete_callback); f_fss_nest_delete(&setting->nest); diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index 1281d79..e1a88fc 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -343,10 +343,8 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_resize(). - * Errors (with error bit) from: f_string_ranges_resize(). * * @see f_memory_resize() - * @see f_string_ranges_resize() */ #ifndef _di_fss_read_files_resize_ extern f_status_t fss_read_files_resize(const f_number_unsigned_t length, fss_read_files_t * const files); diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index 6904cea..f3e73ac 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -371,14 +371,14 @@ extern "C" { main->setting.ignoress.used = 0; - main->setting.state.status = f_string_rangess_increase_by(values_data->used, &main->setting.ignoress); + main->setting.state.status = f_memory_array_increase_by(values_data->used, sizeof(f_string_ranges_t), (void **) &main->setting.ignoress.array, &main->setting.ignoress.used, &main->setting.ignoress.size); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_write_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_rangess_increase_by)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_memory_array_increase_by)); return; } @@ -405,14 +405,14 @@ extern "C" { break; } - main->setting.state.status = f_string_ranges_increase_by(total, &main->setting.ignoress.array[j]); + main->setting.state.status = f_memory_array_increase_by(total, sizeof(f_string_range_t), (void **) &main->setting.ignoress.array[j].array, &main->setting.ignoress.array[j].used, &main->setting.ignoress.array[j].size); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_write_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_ranges_increase_by)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_memory_array_increase_by)); return; } diff --git a/level_3/fss_write/c/main/common/print.c b/level_3/fss_write/c/main/common/print.c index 7da0143..9101d78 100644 --- a/level_3/fss_write/c/main/common/print.c +++ b/level_3/fss_write/c/main/common/print.c @@ -15,10 +15,6 @@ extern "C" { "f_memory_arrays_resize", "f_string_dynamic_append", "f_string_dynamic_append_nulless", - "f_string_ranges_increase", - "f_string_ranges_increase_by", - "f_string_rangess_increase", - "f_string_rangess_increase_by", "f_string_read_block_increase", "f_thread_create", "fl_fss_basic_content_write", diff --git a/level_3/fss_write/c/main/common/print.h b/level_3/fss_write/c/main/common/print.h index 840511c..39dd344 100644 --- a/level_3/fss_write/c/main/common/print.h +++ b/level_3/fss_write/c/main/common/print.h @@ -48,10 +48,6 @@ extern "C" { fss_write_f_f_memory_arrays_resize_e, fss_write_f_f_string_dynamic_append_e, fss_write_f_f_string_dynamic_append_nulless_e, - fss_write_f_f_string_ranges_increase_e, - fss_write_f_f_string_ranges_increase_by_e, - fss_write_f_f_string_rangess_increase_e, - fss_write_f_f_string_rangess_increase_by_e, fss_write_f_f_string_read_block_increase_e, fss_write_f_f_thread_create_e, fss_write_f_fl_fss_basic_content_write_e, diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index 6916677..b2a5ae2 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -190,10 +190,10 @@ extern "C" { } // This is processed in a single set, so there is only ever one Ignores added. - main->setting.state.status = f_string_rangess_increase(main->setting.state.step_small, &main->setting.ignoress); + main->setting.state.status = f_memory_array_increase(main->setting.state.step_small, sizeof(f_string_ranges_t), (void **) &main->setting.ignoress.array, &main->setting.ignoress.used, &main->setting.ignoress.size); if (F_status_is_error(main->setting.state.status)) { - fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_rangess_increase)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_memory_array_increase)); return; } @@ -377,10 +377,10 @@ extern "C" { // Ignore is enabled. if (flag & 0x2) { - main->setting.state.status = f_string_ranges_increase(main->setting.state.step_small, main->setting.ignores); + main->setting.state.status = f_memory_array_increase(main->setting.state.step_small, sizeof(f_string_range_t), (void **) &main->setting.ignores->array, &main->setting.ignores->used, &main->setting.ignores->size); if (F_status_is_error(main->setting.state.status)) { - fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_ranges_increase)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_memory_array_increase)); break; } diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index d3999de..87795f7 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -71,10 +71,10 @@ extern "C" { } // This is processed in a single set, so there is only ever one Ignores added. - main->setting.state.status = f_string_rangess_increase(main->setting.state.step_small, &main->setting.ignoress); + main->setting.state.status = f_memory_array_increase(main->setting.state.step_small, sizeof(f_string_ranges_t), (void **) &main->setting.ignoress.array, &main->setting.ignoress.used, &main->setting.ignoress.size); if (F_status_is_error(main->setting.state.status)) { - fss_write_print_error(&main->program.error, macro_fss_write_f(f_string_rangess_increase)); + fss_write_print_error(&main->program.error, macro_fss_write_f(f_memory_array_increase)); return; } diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index 6db57f3..b2b5355 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -268,14 +268,14 @@ extern "C" { main->setting.replace.used = 0; - main->setting.state.status = f_string_maps_increase_by(main->program.parameters.array[iki_read_parameter_replace_e].values.used / 2, &main->setting.replace); + main->setting.state.status = f_memory_array_increase_by(main->program.parameters.array[iki_read_parameter_replace_e].values.used / 2, sizeof(f_string_map_t), (void **) &main->setting.replace.array, &main->setting.replace.used, &main->setting.replace.size); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & iki_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_maps_increase_by)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_memory_array_increase_by)); return; } @@ -363,14 +363,14 @@ extern "C" { main->setting.wrap.used = 0; - main->setting.state.status = f_string_triples_increase_by(main->program.parameters.array[iki_read_parameter_wrap_e].values.used / 3, &main->setting.wrap); + main->setting.state.status = f_memory_array_increase_by(main->program.parameters.array[iki_read_parameter_wrap_e].values.used / 3, sizeof(f_string_triple_t), (void **) &main->setting.wrap.array, &main->setting.wrap.used, &main->setting.wrap.size); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & iki_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_triples_increase_by)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_memory_array_increase_by)); return; } @@ -614,14 +614,14 @@ extern "C" { triple->used = 0; - main->setting.state.status = f_string_triples_increase_by(parameter.values.used / 3, triple); + main->setting.state.status = f_memory_array_increase_by(parameter.values.used / 3, sizeof(f_string_triple_t), (void **) &triple->array, &triple->used, &triple->size); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & iki_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - iki_read_print_error(&main->program.error, macro_iki_read_f(f_string_triples_increase_by)); + iki_read_print_error(&main->program.error, macro_iki_read_f(f_memory_array_increase_by)); return F_false; } diff --git a/level_3/iki_read/c/main/common.h b/level_3/iki_read/c/main/common.h index 73a76b1..cbf5cac 100644 --- a/level_3/iki_read/c/main/common.h +++ b/level_3/iki_read/c/main/common.h @@ -35,8 +35,6 @@ extern "C" { * Errors (with error bit) from: f_file_exists(). * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_string_dynamic_append(). - * Errors (with error bit) from: f_string_maps_resize(). - * Errors (with error bit) from: f_string_triples_resize(). * Errors (with error bit) from: fll_program_parameter_process_context(). * Errors (with error bit) from: fll_program_parameter_process_verbosity_standard(). * @@ -44,8 +42,6 @@ extern "C" { * @see f_file_exists() * @see f_memory_array_resize() * @see f_string_dynamic_append() - * @see f_string_maps_resize() - * @see f_string_triples_resize() * @see fll_program_parameter_process_context() * @see fll_program_parameter_process_verbosity_standard() */ @@ -65,7 +61,6 @@ extern "C" { * F_okay on success. * * Errors (with error bit) from: f_memory_array_resize(). - * Errors (with error bit) from: f_string_triples_resize(). * @param name * The name of the parameter. * This is used for printing error messages. @@ -77,7 +72,6 @@ extern "C" { * F_false if not found or not processed. * * @see f_memory_array_resize() - * @see f_string_triples_resize() */ #ifndef _di_iki_read_setting_load_parameter_substitution_ extern f_status_t iki_read_setting_load_parameter_substitution(iki_read_main_t * const main, const f_console_parameter_t parameter, const f_string_static_t name, f_string_triples_t *triple); diff --git a/level_3/iki_read/c/main/common/print.c b/level_3/iki_read/c/main/common/print.c index cc5ecc2..3c8ef35 100644 --- a/level_3/iki_read/c/main/common/print.c +++ b/level_3/iki_read/c/main/common/print.c @@ -18,8 +18,6 @@ extern "C" { "f_memory_arrays_resize", "f_string_dynamic_append_nulless", "f_string_dynamics_append", - "f_string_maps_increase_by", - "f_string_triples_increase_by", "f_thread_create", "fl_iki_read", "fll_program_parameter_process_context_standard", diff --git a/level_3/iki_read/c/main/common/print.h b/level_3/iki_read/c/main/common/print.h index 4901068..529607a 100644 --- a/level_3/iki_read/c/main/common/print.h +++ b/level_3/iki_read/c/main/common/print.h @@ -53,8 +53,6 @@ extern "C" { iki_read_f_f_string_dynamics_append_e, iki_read_f_f_string_dynamics_increase_by_e, iki_read_f_f_string_dynamics_resize_e, - iki_read_f_f_string_maps_increase_by_e, - iki_read_f_f_string_triples_increase_by_e, iki_read_f_f_thread_create_e, iki_read_f_fl_iki_read_e, iki_read_f_fll_program_parameter_process_context_standard_e, diff --git a/level_3/iki_read/c/main/common/type.c b/level_3/iki_read/c/main/common/type.c index 81ed025..c298a8a 100644 --- a/level_3/iki_read/c/main/common/type.c +++ b/level_3/iki_read/c/main/common/type.c @@ -24,10 +24,11 @@ extern "C" { f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &setting->names.array, &setting->names.used, &setting->names.size, &f_string_dynamics_delete_callback); f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &setting->files.array, &setting->files.used, &setting->files.size, &f_string_dynamics_delete_callback); - f_string_maps_resize(0, &setting->replace); - f_string_triples_resize(0, &setting->reassign); - f_string_triples_resize(0, &setting->substitute); - f_string_triples_resize(0, &setting->wrap); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &setting->replace.array, &setting->replace.used, &setting->replace.size, &f_string_maps_delete_callback); + + f_memory_arrays_resize(0, sizeof(f_string_triple_t), (void **) &setting->reassign.array, &setting->reassign.used, &setting->reassign.size, &f_string_triples_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_triple_t), (void **) &setting->substitute.array, &setting->substitute.used, &setting->substitute.size, &f_string_triples_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_triple_t), (void **) &setting->wrap.array, &setting->wrap.used, &setting->wrap.size, &f_string_triples_delete_callback); f_iki_data_delete(&setting->data); -- 1.8.3.1