From 1e8eb68a8c0b2019f258028ddd99c81db5966de6 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 18 Aug 2023 23:19:37 -0500 Subject: [PATCH] Progress: Continue re-designing of the memory logic. I would note that I am leaving the append() and append_all() for the IKI structures because they are complex. In the long term I may end up adding back the append() and append_all() functions for each type. At this time it is more advantageous for me to not have that consistency for easier maintainability while the project is evolving and refactoring. I still need to look over the string and UTF string memory related functionality. This will be more delicate and given the size of these two projects will be a bit time consuming. --- build/level_0/settings | 6 +- build/monolithic/settings | 6 +- build/stand_alone/fake.config.h | 66 +-- build/stand_alone/fake.settings | 2 +- build/stand_alone/firewall.settings | 2 +- level_0/f_account/c/account/accounts.c | 3 - level_0/f_directory/c/directory/recurse_do.c | 26 - level_0/f_directory/c/directory/status.c | 6 - level_0/f_fss/c/fss/item.c | 12 - level_0/f_fss/c/fss/item.h | 8 +- level_0/f_fss/c/fss/named.c | 9 - level_0/f_fss/c/fss/named.h | 8 +- level_0/f_fss/c/fss/nest.c | 12 - level_0/f_fss/c/fss/nest.h | 8 +- level_0/f_fss/c/fss/set.h | 10 +- level_0/f_fss/c/fss/set_quote.h | 8 +- level_0/f_fss/c/fss/simple_packet.c | 9 - level_0/f_fss/c/fss/simple_packet.h | 8 +- level_0/f_iki/c/iki/data.c | 12 +- level_0/f_iki/c/iki/data.h | 12 +- level_0/f_iki/c/iki/private-data.c | 2 +- level_0/f_iki/c/iki/private-data.h | 2 +- level_0/f_limit/c/limit/private-set.c | 67 --- level_0/f_limit/c/limit/private-set.h | 131 ----- level_0/f_limit/c/limit/private-value.c | 67 --- level_0/f_limit/c/limit/private-value.h | 131 ----- level_0/f_limit/c/limit/set.c | 204 +------- level_0/f_limit/c/limit/set.h | 415 ++------------- level_0/f_limit/c/limit/value.c | 204 +------- level_0/f_limit/c/limit/value.h | 420 ++------------- level_0/f_limit/data/build/settings | 2 +- level_0/f_limit/data/build/settings-mocks | 5 +- level_0/f_limit/data/build/settings-tests | 6 +- level_0/f_limit/tests/unit/c/mock-limit.c | 37 ++ level_0/f_limit/tests/unit/c/mock-limit.h | 9 + .../f_limit/tests/unit/c/test-limit-sets_adjust.c | 42 -- .../f_limit/tests/unit/c/test-limit-sets_adjust.h | 27 - .../f_limit/tests/unit/c/test-limit-sets_append.c | 39 -- .../f_limit/tests/unit/c/test-limit-sets_append.h | 27 - .../tests/unit/c/test-limit-sets_append_all.c | 87 ---- .../tests/unit/c/test-limit-sets_append_all.h | 34 -- .../tests/unit/c/test-limit-sets_decimate_by.c | 50 -- .../tests/unit/c/test-limit-sets_decimate_by.h | 27 - .../tests/unit/c/test-limit-sets_decrease_by.c | 50 -- .../tests/unit/c/test-limit-sets_decrease_by.h | 27 - .../tests/unit/c/test-limit-sets_increase.c | 76 --- .../tests/unit/c/test-limit-sets_increase.h | 34 -- .../tests/unit/c/test-limit-sets_increase_by.c | 52 -- .../tests/unit/c/test-limit-sets_increase_by.h | 27 - .../f_limit/tests/unit/c/test-limit-sets_resize.c | 42 -- .../f_limit/tests/unit/c/test-limit-sets_resize.h | 27 - .../f_limit/tests/unit/c/test-limit-setss_adjust.c | 42 -- .../f_limit/tests/unit/c/test-limit-setss_adjust.h | 27 - .../f_limit/tests/unit/c/test-limit-setss_append.c | 92 ---- .../f_limit/tests/unit/c/test-limit-setss_append.h | 34 -- .../tests/unit/c/test-limit-setss_append_all.c | 113 ---- .../tests/unit/c/test-limit-setss_append_all.h | 34 -- .../tests/unit/c/test-limit-setss_decimate_by.c | 74 --- .../tests/unit/c/test-limit-setss_decimate_by.h | 34 -- .../tests/unit/c/test-limit-setss_decrease_by.c | 74 --- .../tests/unit/c/test-limit-setss_decrease_by.h | 34 -- .../unit/c/test-limit-setss_delete_callback.c | 57 +++ .../unit/c/test-limit-setss_delete_callback.h | 27 + .../unit/c/test-limit-setss_destroy_callback.c | 57 +++ .../unit/c/test-limit-setss_destroy_callback.h | 27 + .../tests/unit/c/test-limit-setss_increase.c | 84 --- .../tests/unit/c/test-limit-setss_increase.h | 34 -- .../tests/unit/c/test-limit-setss_increase_by.c | 84 --- .../tests/unit/c/test-limit-setss_increase_by.h | 34 -- .../f_limit/tests/unit/c/test-limit-setss_resize.c | 42 -- .../f_limit/tests/unit/c/test-limit-setss_resize.h | 27 - .../tests/unit/c/test-limit-values_adjust.c | 42 -- .../tests/unit/c/test-limit-values_adjust.h | 27 - .../tests/unit/c/test-limit-values_append.c | 38 -- .../tests/unit/c/test-limit-values_append.h | 27 - .../tests/unit/c/test-limit-values_append_all.c | 85 --- .../tests/unit/c/test-limit-values_append_all.h | 34 -- .../tests/unit/c/test-limit-values_decimate_by.c | 50 -- .../tests/unit/c/test-limit-values_decimate_by.h | 27 - .../tests/unit/c/test-limit-values_decrease_by.c | 50 -- .../tests/unit/c/test-limit-values_decrease_by.h | 27 - .../tests/unit/c/test-limit-values_increase.c | 76 --- .../tests/unit/c/test-limit-values_increase.h | 34 -- .../tests/unit/c/test-limit-values_increase_by.c | 52 -- .../tests/unit/c/test-limit-values_increase_by.h | 27 - .../tests/unit/c/test-limit-values_resize.c | 42 -- .../tests/unit/c/test-limit-values_resize.h | 27 - .../tests/unit/c/test-limit-valuess_adjust.c | 42 -- .../tests/unit/c/test-limit-valuess_adjust.h | 27 - .../tests/unit/c/test-limit-valuess_append.c | 90 ---- .../tests/unit/c/test-limit-valuess_append.h | 34 -- .../tests/unit/c/test-limit-valuess_append_all.c | 111 ---- .../tests/unit/c/test-limit-valuess_append_all.h | 34 -- .../tests/unit/c/test-limit-valuess_decimate_by.c | 74 --- .../tests/unit/c/test-limit-valuess_decimate_by.h | 34 -- .../tests/unit/c/test-limit-valuess_decrease_by.c | 74 --- .../tests/unit/c/test-limit-valuess_decrease_by.h | 34 -- .../unit/c/test-limit-valuess_delete_callback.c | 57 +++ .../unit/c/test-limit-valuess_delete_callback.h | 27 + .../unit/c/test-limit-valuess_destroy_callback.c | 57 +++ .../unit/c/test-limit-valuess_destroy_callback.h | 27 + .../tests/unit/c/test-limit-valuess_increase.c | 84 --- .../tests/unit/c/test-limit-valuess_increase.h | 34 -- .../tests/unit/c/test-limit-valuess_increase_by.c | 84 --- .../tests/unit/c/test-limit-valuess_increase_by.h | 34 -- .../tests/unit/c/test-limit-valuess_resize.c | 42 -- .../tests/unit/c/test-limit-valuess_resize.h | 27 - level_0/f_limit/tests/unit/c/test-limit.c | 100 +--- level_0/f_limit/tests/unit/c/test-limit.h | 36 +- level_0/f_memory/c/memory/arrays.h | 4 + level_0/f_socket/c/socket.h | 1 + level_0/f_socket/c/socket/address.c | 50 ++ level_0/f_socket/c/socket/address.h | 205 ++++++++ level_0/f_socket/c/socket/common.h | 253 --------- level_0/f_socket/c/socket/private-socket.c | 54 -- level_0/f_socket/c/socket/private-socket.h | 107 ---- level_0/f_socket/c/socket/socket.c | 209 +------- level_0/f_socket/c/socket/socket.h | 567 ++++++++------------- level_0/f_socket/data/build/settings | 4 +- level_0/f_socket/data/build/settings-mocks | 7 +- level_0/f_socket/data/build/settings-tests | 4 +- level_0/f_socket/tests/unit/c/mock-socket.c | 37 ++ level_0/f_socket/tests/unit/c/mock-socket.h | 45 +- .../unit/c/test-socket-addressss_delete_callback.c | 57 +++ .../unit/c/test-socket-addressss_delete_callback.h | 27 + .../c/test-socket-addressss_destroy_callback.c | 57 +++ .../c/test-socket-addressss_destroy_callback.h | 27 + .../tests/unit/c/test-socket-sockets_adjust.c | 42 -- .../tests/unit/c/test-socket-sockets_adjust.h | 27 - .../tests/unit/c/test-socket-sockets_append.c | 44 -- .../tests/unit/c/test-socket-sockets_append.h | 27 - .../tests/unit/c/test-socket-sockets_append_all.c | 101 ---- .../tests/unit/c/test-socket-sockets_append_all.h | 34 -- .../tests/unit/c/test-socket-sockets_decimate_by.c | 74 --- .../tests/unit/c/test-socket-sockets_decimate_by.h | 34 -- .../tests/unit/c/test-socket-sockets_decrease_by.c | 74 --- .../tests/unit/c/test-socket-sockets_decrease_by.h | 34 -- .../tests/unit/c/test-socket-sockets_increase.c | 76 --- .../tests/unit/c/test-socket-sockets_increase.h | 34 -- .../tests/unit/c/test-socket-sockets_increase_by.c | 76 --- .../tests/unit/c/test-socket-sockets_increase_by.h | 34 -- .../tests/unit/c/test-socket-sockets_resize.c | 42 -- .../tests/unit/c/test-socket-sockets_resize.h | 27 - .../tests/unit/c/test-socket-socketss_adjust.c | 42 -- .../tests/unit/c/test-socket-socketss_adjust.h | 34 -- .../tests/unit/c/test-socket-socketss_append.c | 110 ---- .../tests/unit/c/test-socket-socketss_append.h | 34 -- .../tests/unit/c/test-socket-socketss_append_all.c | 123 ----- .../tests/unit/c/test-socket-socketss_append_all.h | 34 -- .../unit/c/test-socket-socketss_decimate_by.c | 74 --- .../unit/c/test-socket-socketss_decimate_by.h | 34 -- .../unit/c/test-socket-socketss_decrease_by.c | 74 --- .../unit/c/test-socket-socketss_decrease_by.h | 34 -- .../tests/unit/c/test-socket-socketss_increase.c | 76 --- .../tests/unit/c/test-socket-socketss_increase.h | 34 -- .../unit/c/test-socket-socketss_increase_by.c | 84 --- .../unit/c/test-socket-socketss_increase_by.h | 34 -- .../tests/unit/c/test-socket-socketss_resize.c | 42 -- .../tests/unit/c/test-socket-socketss_resize.h | 27 - .../tests/unit/c/test-socket-ss_delete_callback.c | 57 +++ .../tests/unit/c/test-socket-ss_delete_callback.h | 27 + .../tests/unit/c/test-socket-ss_destroy_callback.c | 57 +++ .../tests/unit/c/test-socket-ss_destroy_callback.h | 27 + level_0/f_socket/tests/unit/c/test-socket.c | 63 +-- level_0/f_socket/tests/unit/c/test-socket.h | 20 +- 165 files changed, 1506 insertions(+), 7592 deletions(-) delete mode 100644 level_0/f_limit/c/limit/private-set.c delete mode 100644 level_0/f_limit/c/limit/private-set.h delete mode 100644 level_0/f_limit/c/limit/private-value.c delete mode 100644 level_0/f_limit/c/limit/private-value.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_adjust.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_adjust.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_append.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_append.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_append_all.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_append_all.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_decimate_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_decimate_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_decrease_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_decrease_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_increase.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_increase.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_increase_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_increase_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_resize.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-sets_resize.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_adjust.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_adjust.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_append.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_append.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_append_all.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_append_all.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_decimate_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_decimate_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_decrease_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_decrease_by.h create mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_delete_callback.c create mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_delete_callback.h create mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_destroy_callback.c create mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_destroy_callback.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_increase.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_increase.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_increase_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_increase_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_resize.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-setss_resize.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_adjust.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_adjust.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_append.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_append.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_append_all.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_append_all.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_decimate_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_decimate_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_decrease_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_decrease_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_increase.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_increase.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_increase_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_increase_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_resize.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-values_resize.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_adjust.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_adjust.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_append.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_append.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_append_all.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_append_all.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_decimate_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_decimate_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_decrease_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_decrease_by.h create mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_delete_callback.c create mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_delete_callback.h create mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_destroy_callback.c create mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_destroy_callback.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_increase.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_increase.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_increase_by.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_increase_by.h delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_resize.c delete mode 100644 level_0/f_limit/tests/unit/c/test-limit-valuess_resize.h create mode 100644 level_0/f_socket/c/socket/address.c create mode 100644 level_0/f_socket/c/socket/address.h delete mode 100644 level_0/f_socket/c/socket/private-socket.c delete mode 100644 level_0/f_socket/c/socket/private-socket.h create mode 100644 level_0/f_socket/tests/unit/c/test-socket-addressss_delete_callback.c create mode 100644 level_0/f_socket/tests/unit/c/test-socket-addressss_delete_callback.h create mode 100644 level_0/f_socket/tests/unit/c/test-socket-addressss_destroy_callback.c create mode 100644 level_0/f_socket/tests/unit/c/test-socket-addressss_destroy_callback.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_adjust.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_adjust.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_append.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_append.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_decimate_by.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_decimate_by.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_decrease_by.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_decrease_by.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_increase.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_increase.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_increase_by.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_increase_by.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_resize.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-sockets_resize.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_adjust.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_adjust.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_append.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_append.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_decimate_by.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_decimate_by.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_decrease_by.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_decrease_by.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_increase.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_increase.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_increase_by.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_increase_by.h delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_resize.c delete mode 100644 level_0/f_socket/tests/unit/c/test-socket-socketss_resize.h create mode 100644 level_0/f_socket/tests/unit/c/test-socket-ss_delete_callback.c create mode 100644 level_0/f_socket/tests/unit/c/test-socket-ss_delete_callback.h create mode 100644 level_0/f_socket/tests/unit/c/test-socket-ss_destroy_callback.c create mode 100644 level_0/f_socket/tests/unit/c/test-socket-ss_destroy_callback.h diff --git a/build/level_0/settings b/build/level_0/settings index 84bba37..e98ca9a 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -47,7 +47,7 @@ build_sources_library execute.c build_sources_library file.c private-file.c file/common.c file/stream.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 iki.c iki/common.c iki/data.c private-iki.c iki/private-data.c -build_sources_library limit.c limit/set.c limit/value.c limit/private-set.c limit/private-value.c +build_sources_library limit.c limit/set.c limit/value.c build_sources_library memory.c memory/array.c memory/arrays.c build_sources_library private-memory.c memory/private-array.c build_sources_library network.c @@ -58,7 +58,7 @@ build_sources_library print.c private-print.c print/common.c print/to.c print/pr build_sources_library rip.c rip/utf.c private-rip.c rip/private-utf.c build_sources_library serialize.c private-serialize.c serialize/common.c build_sources_library signal.c -build_sources_library socket.c socket/socket.c socket/private-socket.c +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 @@ -116,7 +116,7 @@ build_sources_headers print.h print/to.h print/common.h build_sources_headers rip.h rip/utf.h build_sources_headers serialize.h serialize/common.h build_sources_headers signal.h signal/common.h -build_sources_headers socket.h socket/socket.h socket/common.h +build_sources_headers socket.h socket/address.h socket/socket.h socket/common.h build_sources_headers status.h build_sources_headers status_string.h build_sources_headers string.h string/common.h diff --git a/build/monolithic/settings b/build/monolithic/settings index 769d8ec..1ae9dd8 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -47,7 +47,7 @@ build_sources_library level_0/execute.c build_sources_library level_0/file.c level_0/private-file.c level_0/file/common.c level_0/file/stream.c build_sources_library level_0/fss.c level_0/fss/common.c level_0/fss/item.c level_0/fss/named.c level_0/fss/nest.c level_0/fss/quote.c level_0/fss/set.c level_0/fss/set_quote.c level_0/fss/simple_packet.c build_sources_library level_0/iki.c level_0/iki/common.c level_0/iki/data.c level_0/private-iki.c level_0/iki/private-data.c -build_sources_library level_0/limit.c level_0/limit/set.c level_0/limit/value.c level_0/limit/private-set.c level_0/limit/private-value.c +build_sources_library level_0/limit.c level_0/limit/set.c level_0/limit/value.c build_sources_library level_0/memory.c level_0/memory/array.c level_0/memory/arrays.c build_sources_library level_0/private-memory.c level_0/memory/private-array.c build_sources_library level_0/network.c @@ -58,7 +58,7 @@ build_sources_library level_0/print.c level_0/private-print.c level_0/print/comm build_sources_library level_0/rip.c level_0/rip/utf.c level_0/private-rip.c level_0/rip/private-utf.c build_sources_library level_0/serialize.c level_0/private-serialize.c level_0/serialize/common.c build_sources_library level_0/signal.c -build_sources_library level_0/socket.c level_0/socket/socket.c level_0/socket/private-socket.c +build_sources_library level_0/socket.c level_0/socket/address.c level_0/socket/socket.c 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 @@ -137,7 +137,7 @@ build_sources_headers level_0/print.h level_0/print/to.h level_0/print/common.h build_sources_headers level_0/rip.h level_0/rip/utf.h build_sources_headers level_0/serialize.h level_0/serialize/common.h build_sources_headers level_0/signal.h level_0/signal/common.h -build_sources_headers level_0/socket.h level_0/socket/socket.h level_0/socket/common.h +build_sources_headers level_0/socket.h level_0/socket/address.h level_0/socket/socket.h level_0/socket/common.h build_sources_headers level_0/status.h build_sources_headers level_0/status_string.h build_sources_headers level_0/string.h level_0/string/common.h diff --git a/build/stand_alone/fake.config.h b/build/stand_alone/fake.config.h index 9bfeab5..1e7351e 100644 --- a/build/stand_alone/fake.config.h +++ b/build/stand_alone/fake.config.h @@ -612,7 +612,7 @@ #define _di_f_fss_sets_destroy_callback_ #define _di_f_fss_sets_resize_ #define _di_f_fss_setss_delete_callback_ -#define _di_f_fss_sets_sdestroy_callback_ +#define _di_f_fss_setss_destroy_callback_ #define _di_f_fss_setss_destroy_callback_ #define _di_f_fss_setss_t_ #define _di_f_fss_sets_t_ @@ -811,41 +811,15 @@ #define _di_fl_fss_extended_object_write_ //#define _di_fl_iki_read_ //#define _di_f_limit_process_ -#define _di_f_limit_sets_adjust_ -#define _di_f_limit_sets_append_ -#define _di_f_limit_sets_append_all_ -#define _di_f_limit_sets_decimate_by_ -#define _di_f_limit_sets_decrease_by_ -#define _di_f_limit_sets_increase_ -#define _di_f_limit_sets_increase_by_ -#define _di_f_limit_sets_resize_ -#define _di_f_limit_setss_adjust_ -#define _di_f_limit_setss_append_ -#define _di_f_limit_setss_append_all_ -#define _di_f_limit_setss_decimate_by_ -#define _di_f_limit_setss_decrease_by_ -#define _di_f_limit_setss_increase_ -#define _di_f_limit_setss_increase_by_ -#define _di_f_limit_setss_resize_ +#define _di_f_limit_setss_delete_callback_ +#define _di_f_limit_setss_destroy_callback_ +#define _di_f_limit_setss_destroy_callback_ #define _di_f_limit_setss_t_ //#define _di_f_limit_sets_t_ //#define _di_f_limit_set_t_ -#define _di_f_limit_values_adjust_ -#define _di_f_limit_values_append_ -#define _di_f_limit_values_append_all_ -#define _di_f_limit_values_decimate_by_ -#define _di_f_limit_values_decrease_by_ -#define _di_f_limit_values_increase_ -#define _di_f_limit_values_increase_by_ -#define _di_f_limit_values_resize_ -#define _di_f_limit_valuess_adjust_ -#define _di_f_limit_valuess_append_ -#define _di_f_limit_valuess_append_all_ -#define _di_f_limit_valuess_decimate_by_ -#define _di_f_limit_valuess_decrease_by_ -#define _di_f_limit_valuess_increase_ -#define _di_f_limit_valuess_increase_by_ -#define _di_f_limit_valuess_resize_ +#define _di_f_limit_valuess_delete_callback_ +#define _di_f_limit_valuess_destroy_callback_ +#define _di_f_limit_valuess_destroy_callback_ #define _di_f_limit_valuess_t_ #define _di_f_limit_values_t_ //#define _di_f_limit_value_t_ @@ -1368,6 +1342,11 @@ #define _di_f_signal_wait_until_ #define _di_f_socket_accept_ #define _di_f_socket_address_family_e_ +#define _di_f_socket_addressss_delete_callback_ +#define _di_f_socket_addressss_destroy_callback_ +#define _di_f_socket_addressss_destroy_callback_ +#define _di_f_socket_addressss_t_ +#define _di_f_socket_addresss_t_ #define _di_f_socket_address_t_ #define _di_f_socket_bind_ #define _di_f_socket_bind_inet4_ @@ -1394,22 +1373,9 @@ #define _di_f_socket_read_ #define _di_f_socket_read_message_ #define _di_f_socket_read_stream_ -#define _di_f_sockets_adjust_ -#define _di_f_sockets_append_ -#define _di_f_sockets_append_all_ -#define _di_f_sockets_decimate_by_ -#define _di_f_sockets_decrease_by_ -#define _di_f_sockets_increase_ -#define _di_f_sockets_increase_by_ -#define _di_f_sockets_resize_ -#define _di_f_socketss_adjust_ -#define _di_f_socketss_append_ -#define _di_f_socketss_append_all_ -#define _di_f_socketss_decimate_by_ -#define _di_f_socketss_decrease_by_ -#define _di_f_socketss_increase_ -#define _di_f_socketss_increase_by_ -#define _di_f_socketss_resize_ +#define _di_f_socketss_delete_callback_ +#define _di_f_socketss_destroy_callback_ +#define _di_f_socketss_destroy_callback_ #define _di_f_socketss_t_ #define _di_f_sockets_t_ #define _di_f_socket_t_ @@ -1423,12 +1389,12 @@ #define _di_f_states_t_ //#define _di_f_state_t_ //#define _di_f_status_e_ +//#define _di_f_status_mask_d_ #define _di_f_statusss_delete_callback_ #define _di_f_statusss_destroy_callback_ #define _di_f_statusss_t_ #define _di_f_statuss_t_ //#define _di_f_status_t_ -//#define _di_f_status_terminal_e_ //#define _di_f_string_append_ #define _di_f_string_append_assure_ #define _di_f_string_append_assure_nulless_ diff --git a/build/stand_alone/fake.settings b/build/stand_alone/fake.settings index 1eff6c1..271d579 100644 --- a/build/stand_alone/fake.settings +++ b/build/stand_alone/fake.settings @@ -45,7 +45,7 @@ build_sources_program fll/level_0/execute.c build_sources_program fll/level_0/file.c fll/level_0/private-file.c fll/level_0/file/common.c fll/level_0/file/stream.c build_sources_program fll/level_0/fss.c fll/level_0/fss/common.c fll/level_0/fss/item.c fll/level_0/fss/named.c fll/level_0/fss/nest.c fll/level_0/fss/quote.c fll/level_0/fss/set.c fll/level_0/fss/set_quote.c fll/level_0/fss/simple_packet.c build_sources_program fll/level_0/iki.c fll/level_0/private-iki.c fll/level_0/iki/common.c fll/level_0/iki/private-data.c fll/level_0/iki/data.c -build_sources_program fll/level_0/limit.c fll/level_0/limit/set.c fll/level_0/limit/value.c fll/level_0/limit/private-set.c fll/level_0/limit/private-value.c +build_sources_program fll/level_0/limit.c fll/level_0/limit/set.c fll/level_0/limit/value.c build_sources_program fll/level_0/memory.c fll/level_0/memory/array.c fll/level_0/memory/arrays.c build_sources_program fll/level_0/private-memory.c fll/level_0/memory/private-array.c build_sources_program fll/level_0/parse.c fll/level_0/parse/utf.c diff --git a/build/stand_alone/firewall.settings b/build/stand_alone/firewall.settings index f3d1ab2..f812271 100644 --- a/build/stand_alone/firewall.settings +++ b/build/stand_alone/firewall.settings @@ -34,7 +34,7 @@ build_sources_program fll/level_0/environment.c build_sources_program fll/level_0/execute.c build_sources_program fll/level_0/file.c fll/level_0/private-file.c fll/level_0/file/common.c build_sources_program fll/level_0/fss.c fll/level_0/private-fss.c fll/level_0/fss/common.c fll/level_0/fss/named.c fll/level_0/fss/nest.c fll/level_0/fss/set.c -build_sources_program fll/level_0/limit.c fll/level_0/limit/set.c fll/level_0/limit/value.c fll/level_0/limit/private-set.c fll/level_0/limit/private-value.c +build_sources_program fll/level_0/limit.c fll/level_0/limit/set.c fll/level_0/limit/value.c build_sources_program fll/level_0/memory.c fll/level_0/private-memory.c fll/level_0/memory/structure.c build_sources_program fll/level_0/path.c fll/level_0/private-path.c fll/level_0/path/common.c build_sources_program fll/level_0/pipe.c diff --git a/level_0/f_account/c/account/accounts.c b/level_0/f_account/c/account/accounts.c index 9ba76a3..d69757a 100644 --- a/level_0/f_account/c/account/accounts.c +++ b/level_0/f_account/c/account/accounts.c @@ -101,9 +101,6 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - array[i].id_user = 0; - array[i].id_group = 0; - status = f_string_dynamic_adjust(0, &array[i].home); if (F_status_is_error(status)) return status; diff --git a/level_0/f_directory/c/directory/recurse_do.c b/level_0/f_directory/c/directory/recurse_do.c index a07bd36..06ddac5 100644 --- a/level_0/f_directory/c/directory/recurse_do.c +++ b/level_0/f_directory/c/directory/recurse_do.c @@ -52,14 +52,6 @@ extern "C" { if (!recurse) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - recurse->depth = 0; - recurse->depth_max = 0; - recurse->flag = 0; - recurse->path_top = 0; - - macro_f_state_t_clear(recurse->state); - memset((void *) &recurse->mode, 0, sizeof(f_mode_t)); - { f_status_t status = f_string_dynamic_adjust(0, &recurse->path); if (F_status_is_error(status)) return status; @@ -150,15 +142,6 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - array[i].depth = 0; - array[i].depth_max = 0; - array[i].flag = 0; - array[i].path_top = 0; - - macro_f_state_t_clear(array[i].state); - - memset((void *) &array[i].mode, 0, sizeof(f_mode_t)); - status = f_string_dynamic_adjust(0, &array[i].path); if (F_status_is_error(status)) return status; @@ -261,15 +244,6 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - array[i].array[j].depth = 0; - array[i].array[j].depth_max = 0; - array[i].array[j].flag = 0; - array[i].array[j].path_top = 0; - - macro_f_state_t_clear(array[i].array[j].state); - - memset((void *) &array[i].array[j].mode, 0, sizeof(f_mode_t)); - status = f_string_dynamic_adjust(0, &array[i].array[j].path); if (F_status_is_error(status)) return status; diff --git a/level_0/f_directory/c/directory/status.c b/level_0/f_directory/c/directory/status.c index b73a7d6..0dd3497 100644 --- a/level_0/f_directory/c/directory/status.c +++ b/level_0/f_directory/c/directory/status.c @@ -25,8 +25,6 @@ extern "C" { if (!directory_status) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - directory_status->status = 0; - { const f_status_t status = f_string_dynamic_adjust(0, &directory_status->path); if (F_status_is_error(status)) return status; @@ -63,8 +61,6 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - array[i].status = F_okay; - status = f_string_dynamic_adjust(0, &array[i].path); if (F_status_is_error(status)) return status; } // for @@ -113,8 +109,6 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - array[i].array[j].status = F_okay; - status = f_string_dynamic_adjust(0, &array[i].array[j].path); if (F_status_is_error(status)) return status; } // for diff --git a/level_0/f_fss/c/fss/item.c b/level_0/f_fss/c/fss/item.c index 30ee93c..39acd56 100644 --- a/level_0/f_fss/c/fss/item.c +++ b/level_0/f_fss/c/fss/item.c @@ -20,10 +20,6 @@ extern "C" { if (!item) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - item->object.start = 1; - item->object.stop = 0; - item->parent = 0; - return f_string_ranges_adjust(0, &item->content); } #endif // _di_f_fss_item_destroy_ @@ -55,10 +51,6 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - array[i].object.start = 1; - array[i].object.stop = 0; - array[i].parent = 0; - status = f_string_ranges_adjust(0, &array[i].content); if (F_status_is_error(status)) return status; } // for @@ -107,10 +99,6 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - array[i].array[j].object.start = 1; - array[i].array[j].object.stop = 0; - array[i].array[j].parent = 0; - status = f_string_ranges_adjust(0, &array[i].array[j].content); 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 2ea05e3..c80cebf 100644 --- a/level_0/f_fss/c/fss/item.h +++ b/level_0/f_fss/c/fss/item.h @@ -154,7 +154,7 @@ extern "C" { #endif // _di_f_fss_item_destroy_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_items_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_items_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -182,7 +182,7 @@ extern "C" { #endif // _di_f_fss_items_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_items_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_items_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -210,7 +210,7 @@ extern "C" { #endif // _di_f_fss_items_destroy_callback_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_itemss_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_itemss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -238,7 +238,7 @@ extern "C" { #endif // _di_f_fss_itemss_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_itemss_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_itemss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * diff --git a/level_0/f_fss/c/fss/named.c b/level_0/f_fss/c/fss/named.c index ad7d185..2142914 100644 --- a/level_0/f_fss/c/fss/named.c +++ b/level_0/f_fss/c/fss/named.c @@ -31,9 +31,6 @@ extern "C" { if (!named) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - named->name.start = 1; - named->name.stop = 0; - { f_status_t status = f_string_ranges_adjust(0, &named->objects); if (F_status_is_error(status)) return status; @@ -82,9 +79,6 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - array[i].name.start = 1; - array[i].name.stop = 0; - status = f_string_ranges_adjust(0, &array[i].objects); if (F_status_is_error(status)) return status; @@ -145,9 +139,6 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - array[i].array[j].name.start = 1; - array[i].array[j].name.stop = 0; - status = f_string_ranges_adjust(0, &array[i].array[j].objects); if (F_status_is_error(status)) return status; diff --git a/level_0/f_fss/c/fss/named.h b/level_0/f_fss/c/fss/named.h index db42de8..41bab47 100644 --- a/level_0/f_fss/c/fss/named.h +++ b/level_0/f_fss/c/fss/named.h @@ -143,7 +143,7 @@ extern "C" { #endif // _di_f_fss_named_destroy_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_nameds_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_nameds_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -175,7 +175,7 @@ extern "C" { #endif // _di_f_fss_nameds_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_nameds_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_nameds_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -207,7 +207,7 @@ extern "C" { #endif // _di_f_fss_nameds_destroy_callback_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_namedss_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_namedss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -239,7 +239,7 @@ extern "C" { #endif // _di_f_fss_namedss_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_namedss_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_namedss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * diff --git a/level_0/f_fss/c/fss/nest.c b/level_0/f_fss/c/fss/nest.c index 1cbd6d7..f41ae0c 100644 --- a/level_0/f_fss/c/fss/nest.c +++ b/level_0/f_fss/c/fss/nest.c @@ -47,10 +47,6 @@ extern "C" { for (j = 0; j < nest->depth[i].size; ++j) { - nest->depth[i].array[j].object.start = 1; - nest->depth[i].array[j].object.stop = 0; - nest->depth[i].array[j].parent = 0; - status = f_string_ranges_adjust(0, &nest->depth[i].array[j].content); if (F_status_is_error(status)) return status; } // for @@ -117,10 +113,6 @@ extern "C" { for (k = 0; k < array[i].depth[j].size; ++k) { - array[i].depth[j].array[k].object.start = 1; - array[i].depth[j].array[k].object.stop = 0; - array[i].depth[j].array[k].parent = 0; - status = f_string_ranges_adjust(0, &array[i].depth[j].array[k].content); if (F_status_is_error(status)) return status; } // for @@ -205,10 +197,6 @@ extern "C" { for (l = 0; l < array[i].array[j].depth[k].size; ++l) { - array[i].array[j].depth[k].array[l].object.start = 1; - array[i].array[j].depth[k].array[l].object.stop = 0; - array[i].array[j].depth[k].array[l].parent = 0; - status = f_string_ranges_adjust(0, &array[i].array[j].depth[k].array[l].content); 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 587097a..8a6b9ea 100644 --- a/level_0/f_fss/c/fss/nest.h +++ b/level_0/f_fss/c/fss/nest.h @@ -133,7 +133,7 @@ extern "C" { #endif // _di_f_fss_nest_destroy_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_nests_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_nests_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -161,7 +161,7 @@ extern "C" { #endif // _di_f_fss_nests_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_nests_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_nests_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -189,7 +189,7 @@ extern "C" { #endif // _di_f_fss_nests_destroy_callback_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_nestss_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_nestss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -217,7 +217,7 @@ extern "C" { #endif // _di_f_fss_nestss_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_nestss_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_nestss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * diff --git a/level_0/f_fss/c/fss/set.h b/level_0/f_fss/c/fss/set.h index b91d73d..beae7bb 100644 --- a/level_0/f_fss/c/fss/set.h +++ b/level_0/f_fss/c/fss/set.h @@ -132,7 +132,7 @@ extern "C" { #endif // _di_f_fss_set_destroy_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_sets_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_sets_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -160,7 +160,7 @@ extern "C" { #endif // _di_f_fss_sets_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_sets_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_sets_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -188,7 +188,7 @@ extern "C" { #endif // _di_f_fss_sets_destroy_callback_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_setss_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_setss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -216,7 +216,7 @@ extern "C" { #endif // _di_f_fss_setss_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_setss_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_setss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -241,7 +241,7 @@ extern "C" { */ #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); -#endif // _di_f_fss_sets_sdestroy_callback_ +#endif // _di_f_fss_setss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/set_quote.h b/level_0/f_fss/c/fss/set_quote.h index 110ed9c..697a8f5 100644 --- a/level_0/f_fss/c/fss/set_quote.h +++ b/level_0/f_fss/c/fss/set_quote.h @@ -147,7 +147,7 @@ extern "C" { #endif // _di_f_fss_set_quote_destroy_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_set_quotes_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_set_quotes_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -181,7 +181,7 @@ extern "C" { #endif // _di_f_fss_set_quotes_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_set_quotes_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_set_quotes_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -215,7 +215,7 @@ extern "C" { #endif // _di_f_fss_set_quotes_destroy_callback_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_set_quotess_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_set_quotess_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -249,7 +249,7 @@ extern "C" { #endif // _di_f_fss_set_quotess_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_set_quotess_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_set_quotess_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * diff --git a/level_0/f_fss/c/fss/simple_packet.c b/level_0/f_fss/c/fss/simple_packet.c index 37e821f..bf9e103 100644 --- a/level_0/f_fss/c/fss/simple_packet.c +++ b/level_0/f_fss/c/fss/simple_packet.c @@ -20,9 +20,6 @@ extern "C" { if (!packet) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - packet->control = 0; - packet->size = 0; - return f_string_dynamic_adjust(0, &packet->payload); } #endif // _di_f_fss_simple_packet_destroy_ @@ -106,9 +103,6 @@ extern "C" { for (f_number_unsigned_t i = start; i < stop; ++i) { - array[i].control = 0; - array[i].size = 0; - status = f_string_dynamic_adjust(0, &array[i].payload); if (F_status_is_error(status)) return status; } // for @@ -157,9 +151,6 @@ extern "C" { for (j = 0; j < array[i].size; ++j) { - array[i].array[j].control = 0; - array[i].array[j].size = 0; - status = f_string_dynamic_adjust(0, &array[i].array[j].payload); if (F_status_is_error(status)) return status; } // for diff --git a/level_0/f_fss/c/fss/simple_packet.h b/level_0/f_fss/c/fss/simple_packet.h index eefaf13..9293e68 100644 --- a/level_0/f_fss/c/fss/simple_packet.h +++ b/level_0/f_fss/c/fss/simple_packet.h @@ -253,7 +253,7 @@ extern "C" { #endif // _di_f_fss_simple_packet_identify_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_simple_packets_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_simple_packets_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -281,7 +281,7 @@ extern "C" { #endif // _di_f_fss_simple_packets_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_simple_packets_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_simple_packets_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -309,7 +309,7 @@ extern "C" { #endif // _di_f_fss_simple_packets_destroy_callback_ /** - * A callback intended to be passed to f_memory_arrays_resize() for an f_simple_packetss_t structure. + * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_simple_packetss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * @@ -337,7 +337,7 @@ extern "C" { #endif // _di_f_fss_simple_packetss_delete_callback_ /** - * A callback intended to be passed to f_memory_arrays_adjust() for an f_simple_packetss_t structure. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_fss_simple_packetss_t structure. * * This is only called when shrinking the array and generally should perform deallocations. * diff --git a/level_0/f_iki/c/iki/data.c b/level_0/f_iki/c/iki/data.c index 53bb7a7..4f6d7cc 100644 --- a/level_0/f_iki/c/iki/data.c +++ b/level_0/f_iki/c/iki/data.c @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef _di_f_iki_data_delete_ - f_status_t f_iki_data_delete(f_iki_data_t *data) { + f_status_t f_iki_data_delete(f_iki_data_t * const data) { #ifndef _di_level_0_parameter_checking_ if (!data) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -31,7 +31,7 @@ extern "C" { #endif // _di_f_iki_data_delete_ #ifndef _di_f_iki_data_destroy_ - f_status_t f_iki_data_destroy(f_iki_data_t *data) { + f_status_t f_iki_data_destroy(f_iki_data_t * const data) { #ifndef _di_level_0_parameter_checking_ if (!data) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -55,7 +55,7 @@ extern "C" { #endif // _di_f_iki_data_destroy_ #ifndef _di_f_iki_datas_append_ - f_status_t f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t *destination) { + f_status_t f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -98,7 +98,7 @@ extern "C" { #endif // _di_f_iki_datas_append_ #ifndef _di_f_iki_datas_append_all_ - f_status_t f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) { + f_status_t f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -164,7 +164,7 @@ extern "C" { #endif // _di_f_iki_datas_destroy_callback_ #ifndef _di_f_iki_datass_append_ - f_status_t f_iki_datass_append(const f_iki_datas_t source, f_iki_datass_t *destination) { + f_status_t f_iki_datass_append(const f_iki_datas_t source, f_iki_datass_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -184,7 +184,7 @@ extern "C" { #endif // _di_f_iki_datass_append_ #ifndef _di_f_iki_datass_append_all_ - f_status_t f_iki_datass_append_all(const f_iki_datass_t source, f_iki_datass_t *destination) { + f_status_t f_iki_datass_append_all(const f_iki_datass_t source, f_iki_datass_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_iki/c/iki/data.h b/level_0/f_iki/c/iki/data.h index 55a6967..1234792 100644 --- a/level_0/f_iki/c/iki/data.h +++ b/level_0/f_iki/c/iki/data.h @@ -34,7 +34,7 @@ extern "C" { * @see f_string_ranges_resize() */ #ifndef _di_f_iki_data_delete_ - extern f_status_t f_iki_data_delete(f_iki_data_t *data); + extern f_status_t f_iki_data_delete(f_iki_data_t * const data); #endif // _di_f_iki_data_delete_ /** @@ -55,7 +55,7 @@ extern "C" { * @see f_string_ranges_adjust() */ #ifndef _di_f_iki_data_destroy_ - extern f_status_t f_iki_data_destroy(f_iki_data_t *data); + extern f_status_t f_iki_data_destroy(f_iki_data_t * const data); #endif // _di_f_iki_data_destroy_ /** @@ -81,7 +81,7 @@ extern "C" { * @see f_string_ranges_append_all() */ #ifndef _di_f_iki_datas_append_ - extern f_status_t f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t *destination); + extern f_status_t f_iki_datas_append(const f_iki_data_t source, f_iki_datas_t * const destination); #endif // _di_f_iki_datas_append_ /** @@ -107,7 +107,7 @@ extern "C" { * @see f_string_ranges_append_all() */ #ifndef _di_f_iki_datas_append_all_ - extern f_status_t f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination); + extern f_status_t f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t * const destination); #endif // _di_f_iki_datas_append_all_ /** @@ -191,7 +191,7 @@ extern "C" { * @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 *destination); + extern f_status_t f_iki_datass_append(const f_iki_datas_t source, f_iki_datass_t * const destination); #endif // _di_f_iki_datass_append_ /** @@ -217,7 +217,7 @@ extern "C" { * @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 *destination); + extern f_status_t f_iki_datass_append_all(const f_iki_datass_t source, f_iki_datass_t * const destination); #endif // _di_f_iki_datass_append_all_ /** diff --git a/level_0/f_iki/c/iki/private-data.c b/level_0/f_iki/c/iki/private-data.c index 36b6f35..82feac2 100644 --- a/level_0/f_iki/c/iki/private-data.c +++ b/level_0/f_iki/c/iki/private-data.c @@ -6,7 +6,7 @@ extern "C" { #endif #if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_) - extern f_status_t private_f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) { + extern f_status_t private_f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t * const destination) { f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_iki_data_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_iki/c/iki/private-data.h b/level_0/f_iki/c/iki/private-data.h index db66fec..b25adf4 100644 --- a/level_0/f_iki/c/iki/private-data.h +++ b/level_0/f_iki/c/iki/private-data.h @@ -40,7 +40,7 @@ extern "C" { * @see f_iki_datass_append_all() */ #if !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_) - extern f_status_t private_f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_iki_datas_append_all(const f_iki_datas_t source, f_iki_datas_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_iki_datas_append_) || !defined(_di_f_iki_datas_append_all_) || !defined(_di_f_iki_datass_append_all_) #ifdef __cplusplus diff --git a/level_0/f_limit/c/limit/private-set.c b/level_0/f_limit/c/limit/private-set.c deleted file mode 100644 index 46e0d5e..0000000 --- a/level_0/f_limit/c/limit/private-set.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "../limit.h" -#include "set.h" -#include "private-set.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_setss_append_) - extern f_status_t private_f_limit_sets_append(const f_limit_set_t source, f_limit_sets_t *destination) { - - const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_limit_set_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_limit_sets_append_) || !defined(_di_f_limit_setss_append_) - -#if !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_append_all_) || !defined(_di_f_limit_setss_append_all_) - extern f_status_t private_f_limit_sets_append_all(const f_limit_sets_t source, f_limit_sets_t *destination) { - - const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_limit_set_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_limit_sets_append_) || !defined(_di_f_limit_sets_append_all_) || !defined(_di_f_limit_setss_append_all_) - -#if !defined(_di_f_limit_setss_adjust_) || !defined(_di_f_limit_setss_decimate_by_) - f_status_t private_f_limit_setss_adjust(const f_number_unsigned_t length, f_limit_setss_t *setss) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < setss->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_limit_set_t), (void **) &setss->array[i].array, &setss->array[i].used, &setss->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_limit_sets_t), (void **) &setss->array, &setss->used, &setss->size); - } -#endif // !defined(_di_f_limit_setss_adjust_) || !defined(_di_f_limit_setss_decimate_by_) - -#if !defined(_di_f_limit_setss_decrease_by_) || !defined(_di_f_limit_setss_increase_) || !defined(_di_f_limit_setss_increase_by_) || !defined(_di_f_limit_setss_resize_) - f_status_t private_f_limit_setss_resize(const f_number_unsigned_t length, f_limit_setss_t *setss) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < setss->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_limit_set_t), (void **) &setss->array[i].array, &setss->array[i].used, &setss->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_limit_sets_t), (void **) &setss->array, &setss->used, &setss->size); - } -#endif // !defined(_di_f_limit_setss_decrease_by_) || !defined(_di_f_limit_setss_increase_) || !defined(_di_f_limit_setss_increase_by_) || !defined(_di_f_limit_setss_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/c/limit/private-set.h b/level_0/f_limit/c/limit/private-set.h deleted file mode 100644 index abf5846..0000000 --- a/level_0/f_limit/c/limit/private-set.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * 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_limit_set_h -#define _PRIVATE_F_limit_set_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Private implementation for appending the set array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source set to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_array_increase(). - * - * @see f_memory_array_increase() - * - * @see f_limit_sets_append() - * @see f_limit_setss_append() - */ -#if !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_setss_append_) - extern f_status_t private_f_limit_sets_append(const f_limit_set_t source, f_limit_sets_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_setss_append_) - -/** - * Private implementation for appending the set array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source sets to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_array_increase_by(). - * - * @see f_memory_array_increase_by() - * - * @see f_limit_sets_append_all() - * @see f_limit_setss_append() - * @see f_limit_setss_append_all() - */ -#if !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_append_all_) || !defined(_di_f_limit_setss_append_all_) - extern f_status_t private_f_limit_sets_append_all(const f_limit_sets_t source, f_limit_sets_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_limit_sets_append_) || !defined(_di_f_limit_sets_append_all_) || !defined(_di_f_limit_setss_append_all_) - -/** - * Private implementation for resizing the setss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param setss - * The setss array to adjust. - * - * @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 new length is larger than max array length. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * - * @see f_memory_array_adjust() - * - * @see f_limit_setss_adjust() - * @see f_limit_setss_decimate_by() - */ -#if !defined(_di_f_limit_setss_adjust_) || !defined(_di_f_limit_setss_decimate_by_) - extern f_status_t private_f_limit_setss_adjust(const f_number_unsigned_t length, f_limit_setss_t *setss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_limit_setss_adjust_) || !defined(_di_f_limit_setss_decimate_by_) - -/** - * Private implementation for resizing the setss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param setss - * The setss 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 new length is larger than max array length. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_limit_setss_decrease_by() - * @see f_limit_setss_increase() - * @see f_limit_setss_increase_by() - * @see f_limit_setss_resize() - */ -#if !defined(_di_f_limit_setss_decrease_by_) || !defined(_di_f_limit_setss_increase_) || !defined(_di_f_limit_setss_increase_by_) || !defined(_di_f_limit_setss_resize_) - extern f_status_t private_f_limit_setss_resize(const f_number_unsigned_t length, f_limit_setss_t *setss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_limit_setss_decrease_by_) || !defined(_di_f_limit_setss_increase_) || !defined(_di_f_limit_setss_increase_by_) || !defined(_di_f_limit_setss_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_limit_set_h diff --git a/level_0/f_limit/c/limit/private-value.c b/level_0/f_limit/c/limit/private-value.c deleted file mode 100644 index e715bf3..0000000 --- a/level_0/f_limit/c/limit/private-value.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "../limit.h" -#include "value.h" -#include "private-value.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_valuess_append_) - extern f_status_t private_f_limit_values_append(const f_limit_value_t source, f_limit_values_t *destination) { - - const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_limit_value_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_limit_values_append_) || !defined(_di_f_limit_valuess_append_) - -#if !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_append_all_) || !defined(_di_f_limit_valuess_append_all_) - extern f_status_t private_f_limit_values_append_all(const f_limit_values_t source, f_limit_values_t *destination) { - - const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_limit_value_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_limit_values_append_) || !defined(_di_f_limit_values_append_all_) || !defined(_di_f_limit_valuess_append_all_) - -#if !defined(_di_f_limit_valuess_adjust_) || !defined(_di_f_limit_valuess_decimate_by_) - f_status_t private_f_limit_valuess_adjust(const f_number_unsigned_t length, f_limit_valuess_t *valuess) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < valuess->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_limit_value_t), (void **) &valuess->array[i].array, &valuess->array[i].used, &valuess->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_limit_values_t), (void **) &valuess->array, &valuess->used, &valuess->size); - } -#endif // !defined(_di_f_limit_valuess_adjust_) || !defined(_di_f_limit_valuess_decimate_by_) - -#if !defined(_di_f_limit_valuess_decrease_by_) || !defined(_di_f_limit_valuess_increase_) || !defined(_di_f_limit_valuess_increase_by_) || !defined(_di_f_limit_valuess_resize_) - f_status_t private_f_limit_valuess_resize(const f_number_unsigned_t length, f_limit_valuess_t *valuess) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < valuess->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_limit_value_t), (void **) &valuess->array[i].array, &valuess->array[i].used, &valuess->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_limit_values_t), (void **) &valuess->array, &valuess->used, &valuess->size); - } -#endif // !defined(_di_f_limit_valuess_decrease_by_) || !defined(_di_f_limit_valuess_increase_) || !defined(_di_f_limit_valuess_increase_by_) || !defined(_di_f_limit_valuess_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/c/limit/private-value.h b/level_0/f_limit/c/limit/private-value.h deleted file mode 100644 index 0ea767e..0000000 --- a/level_0/f_limit/c/limit/private-value.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * 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_limit_value_h -#define _PRIVATE_F_limit_value_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Private implementation for appending the value array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source value to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_array_increase(). - * - * @see f_memory_array_increase() - * - * @see f_limit_values_append() - * @see f_limit_valuess_append() - */ -#if !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_valuess_append_) - extern f_status_t private_f_limit_values_append(const f_limit_value_t source, f_limit_values_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_valuess_append_) - -/** - * Private implementation for appending the value array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source values to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_array_increase_by(). - * - * @see f_memory_array_increase_by() - * - * @see f_limit_values_append_all() - * @see f_limit_valuess_append() - * @see f_limit_valuess_append_all() - */ -#if !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_append_all_) || !defined(_di_f_limit_valuess_append_all_) - extern f_status_t private_f_limit_values_append_all(const f_limit_values_t source, f_limit_values_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_limit_values_append_) || !defined(_di_f_limit_values_append_all_) || !defined(_di_f_limit_valuess_append_all_) - -/** - * Private implementation for resizing the valuess array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param valuess - * The valuess array to adjust. - * - * @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 new length is larger than max array length. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * - * @see f_memory_array_adjust() - * - * @see f_limit_valuess_adjust() - * @see f_limit_valuess_decimate_by() - */ -#if !defined(_di_f_limit_valuess_adjust_) || !defined(_di_f_limit_valuess_decimate_by_) - extern f_status_t private_f_limit_valuess_adjust(const f_number_unsigned_t length, f_limit_valuess_t *valuess) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_limit_valuess_adjust_) || !defined(_di_f_limit_valuess_decimate_by_) - -/** - * Private implementation for resizing the valuess array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param valuess - * The valuess 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 new length is larger than max array length. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_limit_valuess_decrease_by() - * @see f_limit_valuess_increase() - * @see f_limit_valuess_increase_by() - * @see f_limit_valuess_resize() - */ -#if !defined(_di_f_limit_valuess_decrease_by_) || !defined(_di_f_limit_valuess_increase_) || !defined(_di_f_limit_valuess_increase_by_) || !defined(_di_f_limit_valuess_resize_) - extern f_status_t private_f_limit_valuess_resize(const f_number_unsigned_t length, f_limit_valuess_t *valuess) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_limit_valuess_decrease_by_) || !defined(_di_f_limit_valuess_increase_) || !defined(_di_f_limit_valuess_increase_by_) || !defined(_di_f_limit_valuess_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_limit_value_h diff --git a/level_0/f_limit/c/limit/set.c b/level_0/f_limit/c/limit/set.c index b1f6b8b..2d49f9c 100644 --- a/level_0/f_limit/c/limit/set.c +++ b/level_0/f_limit/c/limit/set.c @@ -1,201 +1,49 @@ #include "../limit.h" #include "set.h" -#include "private-set.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_limit_sets_adjust_ - f_status_t f_limit_sets_adjust(const f_number_unsigned_t length, f_limit_sets_t *sets) { - #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_limit_setss_delete_callback_ + f_status_t f_limit_setss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - return f_memory_array_adjust(length, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size); - } -#endif // _di_f_limit_sets_adjust_ - -#ifndef _di_f_limit_sets_append_ - f_status_t f_limit_sets_append(const f_limit_set_t source, f_limit_sets_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_limit_sets_append(source, destination); - } -#endif // _di_f_limit_sets_append_ - -#ifndef _di_f_limit_sets_append_all_ - f_status_t f_limit_sets_append_all(const f_limit_sets_t source, f_limit_sets_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - return private_f_limit_sets_append_all(source, destination); - } -#endif // _di_f_limit_sets_append_all_ - -#ifndef _di_f_limit_sets_decimate_by_ - f_status_t f_limit_sets_decimate_by(const f_number_unsigned_t amount, f_limit_sets_t *sets) { - #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decimate_by(amount, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size); - } -#endif // _di_f_limit_sets_decimate_by_ - -#ifndef _di_f_limit_sets_decrease_by_ - f_status_t f_limit_sets_decrease_by(const f_number_unsigned_t amount, f_limit_sets_t *sets) { - #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decrease_by(amount, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size); - } -#endif // _di_f_limit_sets_decrease_by_ - -#ifndef _di_f_limit_sets_increase_ - f_status_t f_limit_sets_increase(const f_number_unsigned_t step, f_limit_sets_t *sets) { - #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size); - } -#endif // _di_f_limit_sets_increase_ - -#ifndef _di_f_limit_sets_increase_by_ - f_status_t f_limit_sets_increase_by(const f_number_unsigned_t amount, f_limit_sets_t *sets) { - #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase_by(amount, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size); - } -#endif // _di_f_limit_sets_increase_by_ - -#ifndef _di_f_limit_sets_resize_ - f_status_t f_limit_sets_resize(const f_number_unsigned_t length, f_limit_sets_t *sets) { - #ifndef _di_level_0_parameter_checking_ - if (!sets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_resize(length, sizeof(f_limit_set_t), (void **) &sets->array, &sets->used, &sets->size); - } -#endif // _di_f_limit_sets_resize_ - -#ifndef _di_f_limit_setss_adjust_ - f_status_t f_limit_setss_adjust(const f_number_unsigned_t length, f_limit_setss_t *setss) { - #ifndef _di_level_0_parameter_checking_ - if (!setss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + { + f_limit_sets_t * const array = (f_limit_sets_t *) void_array; + f_status_t status = F_okay; - return private_f_limit_setss_adjust(length, setss); - } -#endif // _di_f_limit_setss_adjust_ - -#ifndef _di_f_limit_setss_append_ - f_status_t f_limit_setss_append(const f_limit_sets_t source, f_limit_setss_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; + for (f_number_unsigned_t i = start; i < stop; ++i) { - f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_limit_sets_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - - status = private_f_limit_sets_append_all(source, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - - ++destination->used; + if (array[i].size) { + status = f_memory_array_resize(0, sizeof(f_limit_set_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_limit_setss_append_ - -#ifndef _di_f_limit_setss_append_all_ - f_status_t f_limit_setss_append_all(const f_limit_setss_t source, f_limit_setss_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#endif // _di_f_limit_setss_delete_callback_ - if (!source.used) return F_data_not; +#ifndef _di_f_limit_setss_destroy_callback_ + f_status_t f_limit_setss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_limit_sets_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; + { + f_limit_sets_t * const array = (f_limit_sets_t *) void_array; + f_status_t status = F_okay; - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_limit_sets_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for + if (array[i].size) { + status = f_memory_array_adjust(0, sizeof(f_limit_set_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_limit_setss_append_all_ - -#ifndef _di_f_limit_setss_decimate_by_ - f_status_t f_limit_setss_decimate_by(const f_number_unsigned_t amount, f_limit_setss_t *setss) { - #ifndef _di_level_0_parameter_checking_ - if (!setss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - return private_f_limit_setss_adjust((setss->size > amount) ? setss->size - amount : 0, setss); - } -#endif // _di_f_limit_setss_decimate_by_ - -#ifndef _di_f_limit_setss_decrease_by_ - f_status_t f_limit_setss_decrease_by(const f_number_unsigned_t amount, f_limit_setss_t *setss) { - #ifndef _di_level_0_parameter_checking_ - if (!setss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - return private_f_limit_setss_resize((setss->size > amount) ? setss->size - amount : 0, setss); - } -#endif // _di_f_limit_setss_decrease_by_ - -#ifndef _di_f_limit_setss_increase_ - f_status_t f_limit_setss_increase(const f_number_unsigned_t step, f_limit_setss_t *setss) { - #ifndef _di_level_0_parameter_checking_ - if (!setss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_limit_sets_t), (void **) &setss->array, &setss->used, &setss->size); - } -#endif // _di_f_limit_setss_increase_ - -#ifndef _di_f_limit_setss_increase_by_ - f_status_t f_limit_setss_increase_by(const f_number_unsigned_t amount, f_limit_setss_t *setss) { - #ifndef _di_level_0_parameter_checking_ - if (!setss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase_by(amount, sizeof(f_limit_sets_t), (void **) &setss->array, &setss->used, &setss->size); - } -#endif // _di_f_limit_setss_increase_by_ - -#ifndef _di_f_limit_setss_resize_ - f_status_t f_limit_setss_resize(const f_number_unsigned_t length, f_limit_setss_t *setss) { - #ifndef _di_level_0_parameter_checking_ - if (!setss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_limit_setss_resize(length, setss); - } -#endif // _di_f_limit_setss_resize_ +#endif // _di_f_limit_setss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_limit/c/limit/set.h b/level_0/f_limit/c/limit/set.h index 864fdae..2205cae 100644 --- a/level_0/f_limit/c/limit/set.h +++ b/level_0/f_limit/c/limit/set.h @@ -58,17 +58,6 @@ extern "C" { #define macro_f_limit_sets_t_initialize_1(array, size, used) { array, size, used } #define macro_f_limit_sets_t_initialize_2(array, length) { array, length, length } - - #define macro_f_limit_sets_t_resize(status, sets, length) status = f_limit_sets_resize(length, &sets); - #define macro_f_limit_sets_t_adjust(status, sets, length) status = f_limit_sets_adjust(length, &sets); - - #define macro_f_limit_sets_t_delete_simple(sets) f_limit_sets_resize(0, &sets); - #define macro_f_limit_sets_t_destroy_simple(sets) f_limit_sets_adjust(0, &sets); - - #define macro_f_limit_sets_t_increase(status, step, sets) status = f_limit_sets_increase(step, &sets); - #define macro_f_limit_sets_t_increase_by(status, sets, amount) status = f_limit_sets_increase_by(amount, &sets); - #define macro_f_limit_sets_t_decrease_by(status, sets, amount) status = f_limit_sets_decrease_by(amount, &sets); - #define macro_f_limit_sets_t_decimate_by(status, sets, amount) status = f_limit_sets_decimate_by(amount, &sets); #endif // _di_f_limit_sets_t_ /** @@ -91,407 +80,63 @@ extern "C" { #define macro_f_limit_setss_t_initialize_1(array, size, used) { array, size, used } #define macro_f_limit_setss_t_initialize_2(array, length) { array, length, length } - - #define macro_f_limit_setss_t_resize(status, setss, length) status = f_limit_setss_resize(length, &setss); - #define macro_f_limit_setss_t_adjust(status, setss, length) status = f_limit_setss_adjust(length, &setss); - - #define macro_f_limit_setss_t_delete_simple(setss) f_limit_setss_resize(0, &setss); - #define macro_f_limit_setss_t_destroy_simple(setss) f_limit_setss_adjust(0, &setss); - - #define macro_f_limit_setss_t_increase(status, step, setss) status = f_limit_setss_increase(step, &setss); - #define macro_f_limit_setss_t_increase_by(status, setss, amount) status = f_limit_setss_increase_by(amount, &setss); - #define macro_f_limit_setss_t_decrease_by(status, setss, amount) status = f_limit_setss_decrease_by(amount, &setss); - #define macro_f_limit_setss_t_decimate_by(status, setss, amount) status = f_limit_setss_decimate_by(amount, &setss); #endif // _di_f_limit_setss_t_ /** - * Resize the sets array. - * - * @param length - * The new size to use. - * @param sets - * The sets 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_adjust(). - * - * @see f_memory_array_adjust() - */ -#ifndef _di_f_limit_sets_adjust_ - extern f_status_t f_limit_sets_adjust(const f_number_unsigned_t length, f_limit_sets_t *sets); -#endif // _di_f_limit_sets_adjust_ - -/** - * Append the single source set onto the destination. - * - * @param source - * The source set to append. - * @param destination - * The destination sets the source is appended onto. - * - * @return - * F_okay on success. - * F_data_not on success, but there is nothing to append (size == 0). + * A callback intended to be passed to f_memory_arrays_resize() for an f_limit_setss_t structure. * - * Success from f_memory_array_resize(). + * This is only called when shrinking the array and generally should perform deallocations. * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase(). - * - * @see f_memory_array_increase() - */ -#ifndef _di_f_limit_sets_append_ - extern f_status_t f_limit_sets_append(const f_limit_set_t source, f_limit_sets_t *destination); -#endif // _di_f_limit_sets_append_ - -/** - * Append the source sets onto the destination. + * This does not do parameter checking. * - * @param source - * The source sets to append. - * @param destination - * The destination sets the source is appended onto. + * @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 on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). - * - * 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() - */ -#ifndef _di_f_limit_sets_append_all_ - extern f_status_t f_limit_sets_append_all(const f_limit_sets_t source, f_limit_sets_t *destination); -#endif // _di_f_limit_sets_append_all_ - -/** - * Resize the sets array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to les than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param sets - * The sets array to resize. - * - * @return - * @return - * Success from f_memory_array_decimate_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decimate_by(). - * - * @see f_memory_array_decimate_by() - */ -#ifndef _di_f_limit_sets_decimate_by_ - extern f_status_t f_limit_sets_decimate_by(const f_number_unsigned_t amount, f_limit_sets_t *sets); -#endif // _di_f_limit_sets_decimate_by_ - -/** - * Resize the sets array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to les than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param sets - * The sets array to resize. - * - * @return - * Success from f_memory_array_decrease_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decrease_by(). - * - * @see f_memory_array_decrease_by() - */ -#ifndef _di_f_limit_sets_decrease_by_ - extern f_status_t f_limit_sets_decrease_by(const f_number_unsigned_t amount, f_limit_sets_t *sets); -#endif // _di_f_limit_sets_decrease_by_ - -/** - * Increase the size of the sets array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param sets - * The sets array to resize. - * - * @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() - */ -#ifndef _di_f_limit_sets_increase_ - extern f_status_t f_limit_sets_increase(const f_number_unsigned_t step, f_limit_sets_t *sets); -#endif // _di_f_limit_sets_increase_ - -/** - * Resize the sets 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 sets - * The sets array to resize. - * - * @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(). + * Errors (with error bit) from: f_string_dynamics_resize(). * - * @see f_memory_array_increase_by() + * @see f_string_dynamics_resize() */ -#ifndef _di_f_limit_sets_increase_by_ - extern f_status_t f_limit_sets_increase_by(const f_number_unsigned_t amount, f_limit_sets_t *sets); -#endif // _di_f_limit_sets_increase_by_ +#ifndef _di_f_limit_setss_delete_callback_ + extern f_status_t f_limit_setss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_limit_setss_delete_callback_ /** - * Resize the sets array. - * - * @param length - * The new size to use. - * @param sets - * The sets array to adjust. - * - * @return - * Success from f_memory_array_resize(). + * A callback intended to be passed to f_memory_arrays_adjust() for an f_limit_setss_t structure. * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). + * This is only called when shrinking the array and generally should perform deallocations. * - * @see f_memory_array_resize() - */ -#ifndef _di_f_limit_sets_resize_ - extern f_status_t f_limit_sets_resize(const f_number_unsigned_t length, f_limit_sets_t *sets); -#endif // _di_f_limit_sets_resize_ - -/** - * Resize the setss array. + * This does not do parameter checking. * - * @param length - * The new size to use. - * @param setss - * The setss array to resize. - * - * @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() - */ -#ifndef _di_f_limit_setss_adjust_ - extern f_status_t f_limit_setss_adjust(const f_number_unsigned_t length, f_limit_setss_t *setss); -#endif // _di_f_limit_setss_adjust_ - -/** - * Append the single source sets onto the destination. - * - * @param source - * The source sets to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_okay on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). - * - * 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_resize(). - * - * @see f_memory_array_increase() - * @see f_memory_array_resize() - */ -#ifndef _di_f_limit_setss_append_ - extern f_status_t f_limit_setss_append(const f_limit_sets_t source, f_limit_setss_t *destination); -#endif // _di_f_limit_setss_append_ - -/** - * Append the source setss onto the destination. - * - * @param source - * The source setss to append. - * @param destination - * The destination ranges the source is appended onto. + * @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 on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase_by(). - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_increase_by() - * @see f_memory_array_resize() - */ -#ifndef _di_f_limit_setss_append_all_ - extern f_status_t f_limit_setss_append_all(const f_limit_setss_t source, f_limit_setss_t *destination); -#endif // _di_f_limit_setss_append_all_ - -/** - * Resize the setss 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 setss - * The setss array to resize. - * - * @return - * F_data_not on success, but the amount to decrease by is 0. - * - * Success from f_memory_array_decimate_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decimate_by(). - * - * @see f_memory_array_decimate_by() - */ -#ifndef _di_f_limit_setss_decimate_by_ - extern f_status_t f_limit_setss_decimate_by(const f_number_unsigned_t amount, f_limit_setss_t *setss); -#endif // _di_f_limit_setss_decimate_by_ - -/** - * Resize the setss 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 setss - * The setss array to resize. - * - * @return - * F_data_not on success, but the amount to decrease by is 0. - * - * Success from f_memory_array_decrease_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decrease_by(). - * - * @see f_memory_array_decrease_by() - */ -#ifndef _di_f_limit_setss_decrease_by_ - extern f_status_t f_limit_setss_decrease_by(const f_number_unsigned_t amount, f_limit_setss_t *setss); -#endif // _di_f_limit_setss_decrease_by_ - -/** - * Increase the size of the setss 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 setss - * The setss array to resize. - * - * @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() - */ -#ifndef _di_f_limit_setss_increase_ - extern f_status_t f_limit_setss_increase(const f_number_unsigned_t step, f_limit_setss_t *setss); -#endif // _di_f_limit_setss_increase_ - -/** - * Resize the setss 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 setss - * The setss array to resize. - * - * @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() - */ -#ifndef _di_f_limit_setss_increase_by_ - extern f_status_t f_limit_setss_increase_by(const f_number_unsigned_t amount, f_limit_setss_t *setss); -#endif // _di_f_limit_setss_increase_by_ - -/** - * Resize the setss array. - * - * @param length - * The new size to use. - * @param setss - * The setss array to adjust. - * - * @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_dynamics_adjust(). * - * @see f_memory_array_resize() + * @see f_string_dynamics_adjust() */ -#ifndef _di_f_limit_setss_resize_ - extern f_status_t f_limit_setss_resize(const f_number_unsigned_t length, f_limit_setss_t *setss); -#endif // _di_f_limit_setss_resize_ +#ifndef _di_f_limit_setss_destroy_callback_ + extern f_status_t f_limit_setss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_limit_setss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_limit/c/limit/value.c b/level_0/f_limit/c/limit/value.c index 846c856d..f96094f 100644 --- a/level_0/f_limit/c/limit/value.c +++ b/level_0/f_limit/c/limit/value.c @@ -1,201 +1,49 @@ #include "../limit.h" #include "value.h" -#include "private-value.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_limit_values_adjust_ - f_status_t f_limit_values_adjust(const f_number_unsigned_t length, f_limit_values_t *values) { - #ifndef _di_level_0_parameter_checking_ - if (!values) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_limit_valuess_delete_callback_ + f_status_t f_limit_valuess_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - return f_memory_array_adjust(length, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size); - } -#endif // _di_f_limit_values_adjust_ - -#ifndef _di_f_limit_values_append_ - f_status_t f_limit_values_append(const f_limit_value_t source, f_limit_values_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_limit_values_append(source, destination); - } -#endif // _di_f_limit_values_append_ - -#ifndef _di_f_limit_values_append_all_ - f_status_t f_limit_values_append_all(const f_limit_values_t source, f_limit_values_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - return private_f_limit_values_append_all(source, destination); - } -#endif // _di_f_limit_values_append_all_ - -#ifndef _di_f_limit_values_decimate_by_ - f_status_t f_limit_values_decimate_by(const f_number_unsigned_t amount, f_limit_values_t *values) { - #ifndef _di_level_0_parameter_checking_ - if (!values) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decimate_by(amount, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size); - } -#endif // _di_f_limit_values_decimate_by_ - -#ifndef _di_f_limit_values_decrease_by_ - f_status_t f_limit_values_decrease_by(const f_number_unsigned_t amount, f_limit_values_t *values) { - #ifndef _di_level_0_parameter_checking_ - if (!values) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decrease_by(amount, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size); - } -#endif // _di_f_limit_values_decrease_by_ - -#ifndef _di_f_limit_values_increase_ - f_status_t f_limit_values_increase(const f_number_unsigned_t step, f_limit_values_t *values) { - #ifndef _di_level_0_parameter_checking_ - if (!values) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size); - } -#endif // _di_f_limit_values_increase_ - -#ifndef _di_f_limit_values_increase_by_ - f_status_t f_limit_values_increase_by(const f_number_unsigned_t amount, f_limit_values_t *values) { - #ifndef _di_level_0_parameter_checking_ - if (!values) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase_by(amount, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size); - } -#endif // _di_f_limit_values_increase_by_ - -#ifndef _di_f_limit_values_resize_ - f_status_t f_limit_values_resize(const f_number_unsigned_t length, f_limit_values_t *values) { - #ifndef _di_level_0_parameter_checking_ - if (!values) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_resize(length, sizeof(f_limit_value_t), (void **) &values->array, &values->used, &values->size); - } -#endif // _di_f_limit_values_resize_ - -#ifndef _di_f_limit_valuess_adjust_ - f_status_t f_limit_valuess_adjust(const f_number_unsigned_t length, f_limit_valuess_t *valuess) { - #ifndef _di_level_0_parameter_checking_ - if (!valuess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + { + f_limit_values_t * const array = (f_limit_values_t *) void_array; + f_status_t status = F_okay; - return private_f_limit_valuess_adjust(length, valuess); - } -#endif // _di_f_limit_valuess_adjust_ - -#ifndef _di_f_limit_valuess_append_ - f_status_t f_limit_valuess_append(const f_limit_values_t source, f_limit_valuess_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; + for (f_number_unsigned_t i = start; i < stop; ++i) { - f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_limit_values_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - - status = private_f_limit_values_append_all(source, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - - ++destination->used; + if (array[i].size) { + status = f_memory_array_resize(0, sizeof(f_limit_value_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_limit_valuess_append_ - -#ifndef _di_f_limit_valuess_append_all_ - f_status_t f_limit_valuess_append_all(const f_limit_valuess_t source, f_limit_valuess_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#endif // _di_f_limit_valuess_delete_callback_ - if (!source.used) return F_data_not; +#ifndef _di_f_limit_valuess_destroy_callback_ + f_status_t f_limit_valuess_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_limit_values_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; + { + f_limit_values_t * const array = (f_limit_values_t *) void_array; + f_status_t status = F_okay; - for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_limit_values_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for + if (array[i].size) { + status = f_memory_array_adjust(0, sizeof(f_limit_value_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_limit_valuess_append_all_ - -#ifndef _di_f_limit_valuess_decimate_by_ - f_status_t f_limit_valuess_decimate_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess) { - #ifndef _di_level_0_parameter_checking_ - if (!valuess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - return private_f_limit_valuess_adjust((valuess->size > amount) ? valuess->size - amount : 0, valuess); - } -#endif // _di_f_limit_valuess_decimate_by_ - -#ifndef _di_f_limit_valuess_decrease_by_ - f_status_t f_limit_valuess_decrease_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess) { - #ifndef _di_level_0_parameter_checking_ - if (!valuess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - return private_f_limit_valuess_resize((valuess->size > amount) ? valuess->size - amount : 0, valuess); - } -#endif // _di_f_limit_valuess_decrease_by_ - -#ifndef _di_f_limit_valuess_increase_ - f_status_t f_limit_valuess_increase(const f_number_unsigned_t step, f_limit_valuess_t *valuess) { - #ifndef _di_level_0_parameter_checking_ - if (!valuess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_limit_values_t), (void **) &valuess->array, &valuess->used, &valuess->size); - } -#endif // _di_f_limit_valuess_increase_ - -#ifndef _di_f_limit_valuess_increase_by_ - f_status_t f_limit_valuess_increase_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess) { - #ifndef _di_level_0_parameter_checking_ - if (!valuess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase_by(amount, sizeof(f_limit_values_t), (void **) &valuess->array, &valuess->used, &valuess->size); - } -#endif // _di_f_limit_valuess_increase_by_ - -#ifndef _di_f_limit_valuess_resize_ - f_status_t f_limit_valuess_resize(const f_number_unsigned_t length, f_limit_valuess_t *valuess) { - #ifndef _di_level_0_parameter_checking_ - if (!valuess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_limit_valuess_resize(length, valuess); - } -#endif // _di_f_limit_valuess_resize_ +#endif // _di_f_limit_valuess_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_limit/c/limit/value.h b/level_0/f_limit/c/limit/value.h index 4ff79ec..afa0628 100644 --- a/level_0/f_limit/c/limit/value.h +++ b/level_0/f_limit/c/limit/value.h @@ -54,24 +54,13 @@ extern "C" { #define macro_f_limit_values_t_initialize_1(content, size, used) { array, size, used } #define macro_f_limit_values_t_initialize_2(array, length) { array, length, length } - - #define macro_f_limit_values_t_resize(status, values, length) status = f_limit_values_resize(length, &values); - #define macro_f_limit_values_t_adjust(status, values, length) status = f_limit_values_adjust(length, &values); - - #define macro_f_limit_values_t_delete_simple(values) f_limit_values_resize(0, &values); - #define macro_f_limit_values_t_destroy_simple(values) f_limit_values_adjust(0, &values); - - #define macro_f_limit_values_t_increase(status, step, values) status = f_limit_values_increase(step, &values); - #define macro_f_limit_values_t_increase_by(status, values, amount) status = f_limit_values_increase_by(amount, &values); - #define macro_f_limit_values_t_decrease_by(status, values, amount) status = f_limit_values_decrease_by(amount, &values); - #define macro_f_limit_values_t_decimate_by(status, values, amount) status = f_limit_values_decimate_by(amount, &values); #endif // _di_f_limit_values_t_ /** - * This holds an array of f_limit_values_t. + * An array of an array of limit values. * * Properties: - * - array: An array of f_limit_values_t. + * - array: An array of an array of limit values. * - size: Total amount of allocated space. * - used: Total number of allocated spaces used. */ @@ -85,408 +74,65 @@ extern "C" { #define f_limit_valuess_t_initialize { 0, 0, 0 } - #define macro_f_limit_valuess_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_limit_valuess_t_initialize_1(content, size, used) { array, size, used } #define macro_f_limit_valuess_t_initialize_2(array, length) { array, length, length } - - #define macro_f_limit_valuess_t_resize(status, valuess, length) status = f_limit_valuess_resize(length, &valuess); - #define macro_f_limit_valuess_t_adjust(status, valuess, length) status = f_limit_valuess_adjust(length, &valuess); - - #define macro_f_limit_valuess_t_delete_simple(valuess) f_limit_valuess_resize(0, &valuess); - #define macro_f_limit_valuess_t_destroy_simple(valuess) f_limit_valuess_adjust(0, &valuess); - - #define macro_f_limit_valuess_t_increase(status, step, valuess) status = f_limit_valuess_increase(step, &valuess); - #define macro_f_limit_valuess_t_increase_by(status, valuess, amount) status = f_limit_valuess_increase_by(amount, &valuess); - #define macro_f_limit_valuess_t_decrease_by(status, valuess, amount) status = f_limit_valuess_decrease_by(amount, &valuess); - #define macro_f_limit_valuess_t_decimate_by(status, valuess, amount) status = f_limit_valuess_decimate_by(amount, &valuess); #endif // _di_f_limit_valuess_t_ /** - * Resize the values array. - * - * @param length - * The new size to use. - * @param values - * The values array to resize. - * - * @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() - */ -#ifndef _di_f_limit_values_adjust_ - extern f_status_t f_limit_values_adjust(const f_number_unsigned_t length, f_limit_values_t *values); -#endif // _di_f_limit_values_adjust_ - -/** - * Append the single source value onto the destination. - * - * @param source - * The source value to append. - * @param destination - * The destination values the source is appended onto. - * - * @return - * F_okay on success. - * F_data_not on success, but there is nothing to append (size == 0). + * A callback intended to be passed to f_memory_arrays_resize() for an f_limit_valuess_t structure. * - * Success from f_memory_array_resize(). + * This is only called when shrinking the array and generally should perform deallocations. * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase(). - * - * @see f_memory_array_increase() - */ -#ifndef _di_f_limit_values_append_ - extern f_status_t f_limit_values_append(const f_limit_value_t source, f_limit_values_t *destination); -#endif // _di_f_limit_values_append_ - -/** - * Append the source values onto the destination. + * This does not do parameter checking. * - * @param source - * The source values to append. - * @param destination - * The destination values the source is appended onto. + * @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 on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). - * - * 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() - */ -#ifndef _di_f_limit_values_append_all_ - extern f_status_t f_limit_values_append_all(const f_limit_values_t source, f_limit_values_t *destination); -#endif // _di_f_limit_values_append_all_ - -/** - * Resize the values array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to les than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param values - * The values array to resize. - * - * @return - * Success from f_memory_array_decimate_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decimate_by(). - * - * @see f_memory_array_decimate_by() - */ -#ifndef _di_f_limit_values_decimate_by_ - extern f_status_t f_limit_values_decimate_by(const f_number_unsigned_t amount, f_limit_values_t *values); -#endif // _di_f_limit_values_decimate_by_ - -/** - * Resize the values array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to les than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param values - * The values array to resize. - * - * @return - * Success from f_memory_array_decrease_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decrease_by(). - * - * @see f_memory_array_decrease_by() - */ -#ifndef _di_f_limit_values_decrease_by_ - extern f_status_t f_limit_values_decrease_by(const f_number_unsigned_t amount, f_limit_values_t *values); -#endif // _di_f_limit_values_decrease_by_ - -/** - * Increase the size of the values array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param values - * The values array to resize. - * - * @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() - */ -#ifndef _di_f_limit_values_increase_ - extern f_status_t f_limit_values_increase(const f_number_unsigned_t step, f_limit_values_t *values); -#endif // _di_f_limit_values_increase_ - -/** - * Resize the values 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 values - * The values array to resize. - * - * @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() - */ -#ifndef _di_f_limit_values_increase_by_ - extern f_status_t f_limit_values_increase_by(const f_number_unsigned_t amount, f_limit_values_t *values); -#endif // _di_f_limit_values_increase_by_ - -/** - * Resize the values array. - * - * @param length - * The new size to use. - * @param values - * The values array to adjust. - * - * @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() - */ -#ifndef _di_f_limit_values_resize_ - extern f_status_t f_limit_values_resize(const f_number_unsigned_t length, f_limit_values_t *values); -#endif // _di_f_limit_values_resize_ - -/** - * Resize the valuess array. - * - * @param length - * The new size to use. - * @param valuess - * The valuess array to resize. - * - * @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_dynamics_resize(). * - * @see f_memory_array_adjust() + * @see f_string_dynamics_resize() */ -#ifndef _di_f_limit_valuess_adjust_ - extern f_status_t f_limit_valuess_adjust(const f_number_unsigned_t length, f_limit_valuess_t *valuess); -#endif // _di_f_limit_valuess_adjust_ +#ifndef _di_f_limit_valuess_delete_callback_ + extern f_status_t f_limit_valuess_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_limit_valuess_delete_callback_ /** - * Append the single source values onto the destination. - * - * @param source - * The source values to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_okay on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). + * A callback intended to be passed to f_memory_arrays_adjust() for an f_limit_valuess_t structure. * - * F_parameter (with error bit) if a parameter is invalid. + * This is only called when shrinking the array and generally should perform deallocations. * - * Errors (with error bit) from: f_memory_array_increase(). - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_increase() - * @see f_memory_array_resize() - */ -#ifndef _di_f_limit_valuess_append_ - extern f_status_t f_limit_valuess_append(const f_limit_values_t source, f_limit_valuess_t *destination); -#endif // _di_f_limit_valuess_append_ - -/** - * Append the source valuess onto the destination. + * This does not do parameter checking. * - * @param source - * The source valuess to append. - * @param destination - * The destination ranges the source is appended onto. + * @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 on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase_by(). - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_increase_by() - * @see f_memory_array_resize() - */ -#ifndef _di_f_limit_valuess_append_all_ - extern f_status_t f_limit_valuess_append_all(const f_limit_valuess_t source, f_limit_valuess_t *destination); -#endif // _di_f_limit_valuess_append_all_ - -/** - * Resize the valuess 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 valuess - * The valuess array to resize. - * - * @return - * F_data_not on success, but the amount to decrease by is 0. - * - * Success from f_memory_array_decimate_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decimate_by(). - * - * @see f_memory_array_decimate_by() - */ -#ifndef _di_f_limit_valuess_decimate_by_ - extern f_status_t f_limit_valuess_decimate_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess); -#endif // _di_f_limit_valuess_decimate_by_ - -/** - * Resize the valuess 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 valuess - * The valuess array to resize. - * - * @return - * F_data_not on success, but the amount to decrease by is 0. - * - * Success from f_memory_array_decrease_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decrease_by(). - * - * @see f_memory_array_decrease_by() - */ -#ifndef _di_f_limit_valuess_decrease_by_ - extern f_status_t f_limit_valuess_decrease_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess); -#endif // _di_f_limit_valuess_decrease_by_ - -/** - * Increase the size of the valuess 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 valuess - * The valuess array to resize. - * - * @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() - */ -#ifndef _di_f_limit_valuess_increase_ - extern f_status_t f_limit_valuess_increase(const f_number_unsigned_t step, f_limit_valuess_t *valuess); -#endif // _di_f_limit_valuess_increase_ - -/** - * Resize the valuess 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 valuess - * The valuess array to resize. - * - * @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() - */ -#ifndef _di_f_limit_valuess_increase_by_ - extern f_status_t f_limit_valuess_increase_by(const f_number_unsigned_t amount, f_limit_valuess_t *valuess); -#endif // _di_f_limit_valuess_increase_by_ - -/** - * Resize the valuess array. - * - * @param length - * The new size to use. - * @param valuess - * The valuess array to adjust. - * - * @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_dynamics_adjust(). * - * @see f_memory_array_resize() + * @see f_string_dynamics_adjust() */ -#ifndef _di_f_limit_valuess_resize_ - extern f_status_t f_limit_valuess_resize(const f_number_unsigned_t length, f_limit_valuess_t *valuess); -#endif // _di_f_limit_valuess_resize_ +#ifndef _di_f_limit_valuess_destroy_callback_ + extern f_status_t f_limit_valuess_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_limit_valuess_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_limit/data/build/settings b/level_0/f_limit/data/build/settings index 6783b37..8321be6 100644 --- a/level_0/f_limit/data/build/settings +++ b/level_0/f_limit/data/build/settings @@ -32,7 +32,7 @@ build_language c build_libraries -lc build_libraries-individual -lf_memory -build_sources_library limit.c limit/set.c limit/value.c limit/private-set.c limit/private-value.c +build_sources_library limit.c limit/set.c limit/value.c build_sources_headers limit.h limit/set.h limit/value.h diff --git a/level_0/f_limit/data/build/settings-mocks b/level_0/f_limit/data/build/settings-mocks index d1d78cb..6c27bdc 100644 --- a/level_0/f_limit/data/build/settings-mocks +++ b/level_0/f_limit/data/build/settings-mocks @@ -20,7 +20,8 @@ build_language c build_libraries -lc build_libraries-individual -lf_memory -build_sources_library limit.c limit/set.c limit/value.c limit/private-set.c limit/private-value.c ../../tests/unit/c/mock-limit.c +build_sources_library limit.c limit/set.c limit/value.c +build_sources_library ../../tests/unit/c/mock-limit.c build_sources_headers limit.h limit/set.h limit/value.h @@ -51,4 +52,6 @@ flags-coverage --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ flags_library -fPIC # Inject mocks. +flags -Wl,--wrap=f_memory_array_adjust +flags -Wl,--wrap=f_memory_array_resize flags -Wl,--wrap=prlimit diff --git a/level_0/f_limit/data/build/settings-tests b/level_0/f_limit/data/build/settings-tests index d27b232..30b6858 100644 --- a/level_0/f_limit/data/build/settings-tests +++ b/level_0/f_limit/data/build/settings-tests @@ -26,10 +26,8 @@ build_libraries -lc -lcmocka build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_utf -lf_limit build_sources_program test-limit-process.c -build_sources_program test-limit-sets_adjust.c test-limit-sets_append.c test-limit-sets_append_all.c test-limit-sets_decimate_by.c test-limit-sets_decrease_by.c test-limit-sets_increase.c test-limit-sets_increase_by.c test-limit-sets_resize.c -build_sources_program test-limit-setss_adjust.c test-limit-setss_append.c test-limit-setss_append_all.c test-limit-setss_decimate_by.c test-limit-setss_decrease_by.c test-limit-setss_increase.c test-limit-setss_increase_by.c test-limit-setss_resize.c -build_sources_program test-limit-values_adjust.c test-limit-values_append.c test-limit-values_append_all.c test-limit-values_decimate_by.c test-limit-values_decrease_by.c test-limit-values_increase.c test-limit-values_increase_by.c test-limit-values_resize.c -build_sources_program test-limit-valuess_adjust.c test-limit-valuess_append.c test-limit-valuess_append_all.c test-limit-valuess_decimate_by.c test-limit-valuess_decrease_by.c test-limit-valuess_increase.c test-limit-valuess_increase_by.c test-limit-valuess_resize.c +build_sources_program test-limit-setss_delete_callback.c test-limit-setss_destroy_callback.c +build_sources_program test-limit-valuess_delete_callback.c test-limit-valuess_destroy_callback.c build_sources_program test-limit.c build_script no diff --git a/level_0/f_limit/tests/unit/c/mock-limit.c b/level_0/f_limit/tests/unit/c/mock-limit.c index 264a198..3ca91b6 100644 --- a/level_0/f_limit/tests/unit/c/mock-limit.c +++ b/level_0/f_limit/tests/unit/c/mock-limit.c @@ -4,6 +4,43 @@ 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); +} + int __wrap_prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit) { const bool failure = mock_type(bool); diff --git a/level_0/f_limit/tests/unit/c/mock-limit.h b/level_0/f_limit/tests/unit/c/mock-limit.h index 36e0f99..5e46182 100644 --- a/level_0/f_limit/tests/unit/c/mock-limit.h +++ b/level_0/f_limit/tests/unit/c/mock-limit.h @@ -28,6 +28,15 @@ extern "C" { 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); + extern int __wrap_prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit); #ifdef __cplusplus diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_adjust.c b/level_0/f_limit/tests/unit/c/test-limit-sets_adjust.c deleted file mode 100644 index 99cd244..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-limit.h" -#include "test-limit-sets_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_sets_adjust__parameter_checking(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_sets_adjust__works(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_adjust.h b/level_0/f_limit/tests/unit/c/test-limit-sets_adjust.h deleted file mode 100644 index 8e8ecc5..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__sets_adjust -#define _TEST__F_limit__sets_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_sets_adjust() - */ -extern void test__f_limit_sets_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_sets_adjust() - */ -extern void test__f_limit_sets_adjust__works(void **state); - -#endif // _TEST__F_limit__sets_adjust diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_append.c b/level_0/f_limit/tests/unit/c/test-limit-sets_append.c deleted file mode 100644 index 2170766..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_append.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "test-limit.h" -#include "test-limit-sets_append.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_sets_append__parameter_checking(void **state) { - - const f_limit_set_t data = f_limit_set_t_initialize; - - { - const f_status_t status = f_limit_sets_append(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_limit_sets_append__works(void **state) { - - const f_limit_set_t source = macro_f_limit_set_t_initialize_1(1, macro_f_limit_value_t_initialize_1(2, 3)); - f_limit_sets_t destination = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_append(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, 1); - assert_int_equal(destination.array[0].type, source.type); - assert_int_equal(destination.array[0].value.rlim_cur, source.value.rlim_cur); - assert_int_equal(destination.array[0].value.rlim_max, source.value.rlim_max); - } - - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_append.h b/level_0/f_limit/tests/unit/c/test-limit-sets_append.h deleted file mode 100644 index 8747a33..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_append.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__sets_append -#define _TEST__F_limit__sets_append - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_sets_append() - */ -extern void test__f_limit_sets_append__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_sets_append() - */ -extern void test__f_limit_sets_append__works(void **state); - -#endif // _TEST__F_limit__sets_append diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_append_all.c b/level_0/f_limit/tests/unit/c/test-limit-sets_append_all.c deleted file mode 100644 index 1a1a20b..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_append_all.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "test-limit.h" -#include "test-limit-sets_append_all.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_sets_append_all__parameter_checking(void **state) { - - const f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_append_all(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_limit_sets_append_all__returns_data_not(void **state) { - - const int length = 5; - f_limit_sets_t source = f_limit_sets_t_initialize; - f_limit_sets_t destination = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_limit_sets_append_all(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_limit_sets_append_all__works(void **state) { - - const int length = 5; - const int length_used = 2; - f_limit_sets_t source = f_limit_sets_t_initialize; - f_limit_sets_t destination = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - - source.array[source.used].type = source.used + 1; - source.array[source.used].value.rlim_cur = source.used + 2; - source.array[source.used].value.rlim_max = source.used + 3; - } // for - { - const f_status_t status = f_limit_sets_append_all(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - - assert_int_equal(destination.array[i].type, i + 1); - assert_int_equal(destination.array[i].value.rlim_cur, i + 2); - assert_int_equal(destination.array[i].value.rlim_max, i + 3); - } // for - } - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_append_all.h b/level_0/f_limit/tests/unit/c/test-limit-sets_append_all.h deleted file mode 100644 index e502c4a..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_append_all.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__sets_append_all -#define _TEST__F_limit__sets_append_all - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_sets_append_all() - */ -extern void test__f_limit_sets_append_all__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_sets_append_all() - */ -extern void test__f_limit_sets_append_all__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_sets_append_all() - */ -extern void test__f_limit_sets_append_all__works(void **state); - -#endif // _TEST__F_limit__sets_append_all diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_decimate_by.c b/level_0/f_limit/tests/unit/c/test-limit-sets_decimate_by.c deleted file mode 100644 index 4228684..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "test-limit.h" -#include "test-limit-sets_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_sets_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_sets_decimate_by__works(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_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_limit_sets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_decimate_by.h b/level_0/f_limit/tests/unit/c/test-limit-sets_decimate_by.h deleted file mode 100644 index a1654a7..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__sets_decimate_by -#define _TEST__F_limit__sets_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_sets_decimate_by() - */ -extern void test__f_limit_sets_decimate_by__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_sets_decimate_by() - */ -extern void test__f_limit_sets_decimate_by__works(void **state); - -#endif // _TEST__F_limit__sets_decimate_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_decrease_by.c b/level_0/f_limit/tests/unit/c/test-limit-sets_decrease_by.c deleted file mode 100644 index 8f33d85..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "test-limit.h" -#include "test-limit-sets_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_sets_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_sets_decrease_by__works(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_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_limit_sets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_decrease_by.h b/level_0/f_limit/tests/unit/c/test-limit-sets_decrease_by.h deleted file mode 100644 index 4606dc1..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__sets_decrease_by -#define _TEST__F_limit__sets_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_sets_decrease_by() - */ -extern void test__f_limit_sets_decrease_by__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_sets_decrease_by() - */ -extern void test__f_limit_sets_decrease_by__works(void **state); - -#endif // _TEST__F_limit__sets_decrease_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_increase.c b/level_0/f_limit/tests/unit/c/test-limit-sets_increase.c deleted file mode 100644 index cb5997b..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-limit.h" -#include "test-limit-sets_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_sets_increase__parameter_checking(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_limit_sets_increase__returns_data_not(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_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_limit_sets_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_limit_sets_increase__works(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_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_limit_sets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_increase.h b/level_0/f_limit/tests/unit/c/test-limit-sets_increase.h deleted file mode 100644 index 8cc898c..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__sets_increase -#define _TEST__F_limit__sets_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_sets_increase() - */ -extern void test__f_limit_sets_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_sets_increase() - */ -extern void test__f_limit_sets_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_sets_increase() - */ -extern void test__f_limit_sets_increase__works(void **state); - -#endif // _TEST__F_limit__sets_increase diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_increase_by.c b/level_0/f_limit/tests/unit/c/test-limit-sets_increase_by.c deleted file mode 100644 index 905a0ae..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "test-limit.h" -#include "test-limit-sets_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_sets_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_sets_increase_by__works(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_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_limit_sets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_increase_by.h b/level_0/f_limit/tests/unit/c/test-limit-sets_increase_by.h deleted file mode 100644 index 046ad10..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__sets_increase_by -#define _TEST__F_limit__sets_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_sets_increase_by() - */ -extern void test__f_limit_sets_increase_by__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_sets_increase_by() - */ -extern void test__f_limit_sets_increase_by__works(void **state); - -#endif // _TEST__F_limit__sets_increase_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_resize.c b/level_0/f_limit/tests/unit/c/test-limit-sets_resize.c deleted file mode 100644 index 1054845..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-limit.h" -#include "test-limit-sets_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_sets_resize__parameter_checking(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_sets_resize__works(void **state) { - - const int length = 5; - f_limit_sets_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_sets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-sets_resize.h b/level_0/f_limit/tests/unit/c/test-limit-sets_resize.h deleted file mode 100644 index dc9b14c..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-sets_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__sets_resize -#define _TEST__F_limit__sets_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_sets_resize() - */ -extern void test__f_limit_sets_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_sets_resize() - */ -extern void test__f_limit_sets_resize__works(void **state); - -#endif // _TEST__F_limit__sets_resize diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_adjust.c b/level_0/f_limit/tests/unit/c/test-limit-setss_adjust.c deleted file mode 100644 index cf8c0f4..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-limit.h" -#include "test-limit-setss_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_setss_adjust__parameter_checking(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_setss_adjust__works(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_adjust.h b/level_0/f_limit/tests/unit/c/test-limit-setss_adjust.h deleted file mode 100644 index eb52d9a..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_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_limit__setss_adjust -#define _TEST__F_limit__setss_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_setss_adjust() - */ -extern void test__f_limit_setss_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_setss_adjust() - */ -extern void test__f_limit_setss_adjust__works(void **state); - -#endif // _TEST__F_limit__setss_adjust diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_append.c b/level_0/f_limit/tests/unit/c/test-limit-setss_append.c deleted file mode 100644 index 2138099..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_append.c +++ /dev/null @@ -1,92 +0,0 @@ -#include "test-limit.h" -#include "test-limit-setss_append.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_setss_append__parameter_checking(void **state) { - - f_limit_sets_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_append(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_limit_setss_append__returns_data_not(void **state) { - - const int length = 5; - f_limit_sets_t source = f_limit_setss_t_initialize; - f_limit_setss_t destination = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_sets_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_limit_setss_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_limit_setss_append__works(void **state) { - - const int length = 5; - f_limit_sets_t source = f_limit_setss_t_initialize; - f_limit_setss_t destination = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_sets_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length; ++source.used) { - - source.array[source.used].type = source.used + 1; - source.array[source.used].value.rlim_cur = source.used + 2; - source.array[source.used].value.rlim_max = source.used + 3; - } // for - - { - const f_status_t status = f_limit_setss_append(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, 1); - assert_int_equal(destination.array[0].used, source.used); - assert_int_equal(destination.array[0].size, source.used); - - for (f_number_unsigned_t i = 0; i < destination.array[0].used; ++i) { - - assert_int_equal(destination.array[0].array[i].type, i + 1); - assert_int_equal(destination.array[0].array[i].value.rlim_cur, i + 2); - assert_int_equal(destination.array[0].array[i].value.rlim_max, i + 3); - } // for - } - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - free((void *) destination.array[i].array); - } // for - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_append.h b/level_0/f_limit/tests/unit/c/test-limit-setss_append.h deleted file mode 100644 index be3d2dc..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_append.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_limit__setss_append -#define _TEST__F_limit__setss_append - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_setss_append() - */ -extern void test__f_limit_setss_append__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_setss_append() - */ -extern void test__f_limit_setss_append__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_setss_append() - */ -extern void test__f_limit_setss_append__works(void **state); - -#endif // _TEST__F_limit__setss_append diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_append_all.c b/level_0/f_limit/tests/unit/c/test-limit-setss_append_all.c deleted file mode 100644 index ffca613..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_append_all.c +++ /dev/null @@ -1,113 +0,0 @@ -#include "test-limit.h" -#include "test-limit-setss_append_all.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_setss_append_all__parameter_checking(void **state) { - - const f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_append_all(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_limit_setss_append_all__returns_data_not(void **state) { - - const int length = 5; - f_limit_setss_t source = f_limit_setss_t_initialize; - f_limit_setss_t destination = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_limit_setss_append_all(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_limit_setss_append_all__works(void **state) { - - const int length = 5; - const int length_inner = 2; - f_limit_setss_t source = f_limit_setss_t_initialize; - f_limit_setss_t destination = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_limit_sets_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_okay); - - for (f_number_unsigned_t i = 0; i < length_inner; ++i) { - - source.array[source.used].array[i].type = i + 1; - source.array[source.used].array[i].value.rlim_cur = i + 2; - source.array[source.used].array[i].value.rlim_max = i + 3; - } // for - - source.array[source.used].used = length_inner; - } // for - } - - { - const f_status_t status = f_limit_setss_append_all(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_number_unsigned_t j = 0; j < length_inner; ++j) { - - assert_int_equal(destination.array[i].array[j].type, j + 1); - assert_int_equal(destination.array[i].array[j].value.rlim_cur, j + 2); - assert_int_equal(destination.array[i].array[j].value.rlim_max, j + 3); - } // for - } // for - } - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - free((void *) destination.array[i].array); - } // for - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_append_all.h b/level_0/f_limit/tests/unit/c/test-limit-setss_append_all.h deleted file mode 100644 index 65f2242..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_append_all.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_limit__setss_append_all -#define _TEST__F_limit__setss_append_all - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_setss_append_all() - */ -extern void test__f_limit_setss_append_all__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_setss_append_all() - */ -extern void test__f_limit_setss_append_all__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_setss_append_all() - */ -extern void test__f_limit_setss_append_all__works(void **state); - -#endif // _TEST__F_limit__setss_append_all diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_decimate_by.c b/level_0/f_limit/tests/unit/c/test-limit-setss_decimate_by.c deleted file mode 100644 index 485ba8f..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_decimate_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-limit.h" -#include "test-limit-setss_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_setss_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_setss_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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_limit_setss_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_limit_setss_decimate_by__works(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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_limit_setss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_decimate_by.h b/level_0/f_limit/tests/unit/c/test-limit-setss_decimate_by.h deleted file mode 100644 index 6cda21a..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_decimate_by.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_limit__setss_decimate_by -#define _TEST__F_limit__setss_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_setss_decimate_by() - */ -extern void test__f_limit_setss_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_setss_decimate_by() - */ -extern void test__f_limit_setss_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_setss_decimate_by() - */ -extern void test__f_limit_setss_decimate_by__works(void **state); - -#endif // _TEST__F_limit__setss_decimate_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_decrease_by.c b/level_0/f_limit/tests/unit/c/test-limit-setss_decrease_by.c deleted file mode 100644 index 2133c87..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_decrease_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-limit.h" -#include "test-limit-setss_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_setss_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_setss_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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_limit_setss_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_limit_setss_decrease_by__works(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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_limit_setss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_decrease_by.h b/level_0/f_limit/tests/unit/c/test-limit-setss_decrease_by.h deleted file mode 100644 index 2ef0871..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_decrease_by.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_limit__setss_decrease_by -#define _TEST__F_limit__setss_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_setss_decrease_by() - */ -extern void test__f_limit_setss_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_setss_decrease_by() - */ -extern void test__f_limit_setss_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_setss_decrease_by() - */ -extern void test__f_limit_setss_decrease_by__works(void **state); - -#endif // _TEST__F_limit__setss_decrease_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_delete_callback.c b/level_0/f_limit/tests/unit/c/test-limit-setss_delete_callback.c new file mode 100644 index 0000000..f9177cb --- /dev/null +++ b/level_0/f_limit/tests/unit/c/test-limit-setss_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-limit.h" +#include "test-limit-setss_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_limit_setss_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_limit_set_t data = f_limit_set_t_initialize; + f_limit_set_t data_array[] = { data }; + f_limit_sets_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_limit_sets_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_limit_setss_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_limit_setss_delete_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_limit_setss_t datass = f_limit_setss_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_limit_sets_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_limit_set_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_limit_setss_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_limit/tests/unit/c/test-limit-setss_delete_callback.h b/level_0/f_limit/tests/unit/c/test-limit-setss_delete_callback.h new file mode 100644 index 0000000..ed74b57 --- /dev/null +++ b/level_0/f_limit/tests/unit/c/test-limit-setss_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Limit + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_limit__setss_delete_callback +#define _TEST__F_limit__setss_delete_callback + +/** + * Test that the function fails. + * + * @see f_limit_setss_delete_callback() + */ +extern void test__f_limit_setss_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_limit_setss_delete_callback() + */ +extern void test__f_limit_setss_delete_callback__works(void **state); + +#endif // _TEST__F_limit__setss_delete_callback diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_destroy_callback.c b/level_0/f_limit/tests/unit/c/test-limit-setss_destroy_callback.c new file mode 100644 index 0000000..1f5883c --- /dev/null +++ b/level_0/f_limit/tests/unit/c/test-limit-setss_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-limit.h" +#include "test-limit-setss_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_limit_setss_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_limit_set_t data = f_limit_set_t_initialize; + f_limit_set_t data_array[] = { data }; + f_limit_sets_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_limit_sets_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_limit_setss_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_limit_setss_destroy_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_limit_setss_t datass = f_limit_setss_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_limit_sets_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_limit_set_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_limit_setss_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_limit/tests/unit/c/test-limit-setss_destroy_callback.h b/level_0/f_limit/tests/unit/c/test-limit-setss_destroy_callback.h new file mode 100644 index 0000000..0710309 --- /dev/null +++ b/level_0/f_limit/tests/unit/c/test-limit-setss_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Limit + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_limit__setss_destroy_callback +#define _TEST__F_limit__setss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_limit_setss_destroy_callback() + */ +extern void test__f_limit_setss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_limit_setss_destroy_callback() + */ +extern void test__f_limit_setss_destroy_callback__works(void **state); + +#endif // _TEST__F_limit__setss_destroy_callback diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_increase.c b/level_0/f_limit/tests/unit/c/test-limit-setss_increase.c deleted file mode 100644 index dfad94e..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_increase.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "test-limit.h" -#include "test-limit-setss_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_setss_increase__parameter_checking(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_limit_setss_increase__returns_data_not(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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_limit_setss_increase(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_limit_setss_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_limit_setss_increase__works(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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_limit_setss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_increase.h b/level_0/f_limit/tests/unit/c/test-limit-setss_increase.h deleted file mode 100644 index 09294df..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_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_limit__setss_increase -#define _TEST__F_limit__setss_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_setss_increase() - */ -extern void test__f_limit_setss_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_setss_increase() - */ -extern void test__f_limit_setss_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_setss_increase() - */ -extern void test__f_limit_setss_increase__works(void **state); - -#endif // _TEST__F_limit__setss_increase diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_increase_by.c b/level_0/f_limit/tests/unit/c/test-limit-setss_increase_by.c deleted file mode 100644 index 1036ec4..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_increase_by.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "test-limit.h" -#include "test-limit-setss_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_setss_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_setss_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_setss_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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_limit_setss_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_limit_setss_increase_by(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_limit_setss_increase_by__works(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_sets_t_initialize; - - { - const f_status_t status = f_limit_setss_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_limit_setss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_increase_by.h b/level_0/f_limit/tests/unit/c/test-limit-setss_increase_by.h deleted file mode 100644 index 0d12d98..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_increase_by.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_limit__setss_increase_by -#define _TEST__F_limit__setss_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_setss_increase_by() - */ -extern void test__f_limit_setss_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_setss_increase_by() - */ -extern void test__f_limit_setss_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_setss_increase_by() - */ -extern void test__f_limit_setss_increase_by__works(void **state); - -#endif // _TEST__F_limit__setss_increase_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_resize.c b/level_0/f_limit/tests/unit/c/test-limit-setss_resize.c deleted file mode 100644 index b35c136..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-limit.h" -#include "test-limit-setss_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_setss_resize__parameter_checking(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_setss_resize__works(void **state) { - - const int length = 5; - f_limit_setss_t data = f_limit_setss_t_initialize; - - { - const f_status_t status = f_limit_setss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-setss_resize.h b/level_0/f_limit/tests/unit/c/test-limit-setss_resize.h deleted file mode 100644 index e5fa43c..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-setss_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_limit__setss_resize -#define _TEST__F_limit__setss_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_setss_resize() - */ -extern void test__f_limit_setss_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_setss_resize() - */ -extern void test__f_limit_setss_resize__works(void **state); - -#endif // _TEST__F_limit__setss_resize diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_adjust.c b/level_0/f_limit/tests/unit/c/test-limit-values_adjust.c deleted file mode 100644 index 683b912..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-limit.h" -#include "test-limit-values_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_values_adjust__parameter_checking(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_values_adjust__works(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_adjust.h b/level_0/f_limit/tests/unit/c/test-limit-values_adjust.h deleted file mode 100644 index f76509c..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__values_adjust -#define _TEST__F_limit__values_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_values_adjust() - */ -extern void test__f_limit_values_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_values_adjust() - */ -extern void test__f_limit_values_adjust__works(void **state); - -#endif // _TEST__F_limit__values_adjust diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_append.c b/level_0/f_limit/tests/unit/c/test-limit-values_append.c deleted file mode 100644 index fa42230..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_append.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "test-limit.h" -#include "test-limit-values_append.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_values_append__parameter_checking(void **state) { - - const f_limit_value_t data = f_limit_value_t_initialize; - - { - const f_status_t status = f_limit_values_append(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_limit_values_append__works(void **state) { - - const f_limit_value_t source = macro_f_limit_value_t_initialize_1(1, 2); - f_limit_values_t destination = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_append(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, 1); - assert_int_equal(destination.array[0].rlim_cur, source.rlim_cur); - assert_int_equal(destination.array[0].rlim_max, source.rlim_max); - } - - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_append.h b/level_0/f_limit/tests/unit/c/test-limit-values_append.h deleted file mode 100644 index a9e5fe5..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_append.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__values_append -#define _TEST__F_limit__values_append - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_values_append() - */ -extern void test__f_limit_values_append__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_values_append() - */ -extern void test__f_limit_values_append__works(void **state); - -#endif // _TEST__F_limit__values_append diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_append_all.c b/level_0/f_limit/tests/unit/c/test-limit-values_append_all.c deleted file mode 100644 index 3905374..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_append_all.c +++ /dev/null @@ -1,85 +0,0 @@ -#include "test-limit.h" -#include "test-limit-values_append_all.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_values_append_all__parameter_checking(void **state) { - - const f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_append_all(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_limit_values_append_all__returns_data_not(void **state) { - - const int length = 5; - f_limit_values_t source = f_limit_values_t_initialize; - f_limit_values_t destination = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_limit_values_append_all(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_limit_values_append_all__works(void **state) { - - const int length = 5; - const int length_used = 2; - f_limit_values_t source = f_limit_values_t_initialize; - f_limit_values_t destination = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - - source.array[source.used].rlim_cur = source.used + 1; - source.array[source.used].rlim_max = source.used + 2; - } // for - { - const f_status_t status = f_limit_values_append_all(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - - assert_int_equal(destination.array[i].rlim_cur, i + 1); - assert_int_equal(destination.array[i].rlim_max, i + 2); - } // for - } - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_append_all.h b/level_0/f_limit/tests/unit/c/test-limit-values_append_all.h deleted file mode 100644 index 178da4a..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_append_all.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__values_append_all -#define _TEST__F_limit__values_append_all - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_values_append_all() - */ -extern void test__f_limit_values_append_all__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_values_append_all() - */ -extern void test__f_limit_values_append_all__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_values_append_all() - */ -extern void test__f_limit_values_append_all__works(void **state); - -#endif // _TEST__F_limit__values_append_all diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_decimate_by.c b/level_0/f_limit/tests/unit/c/test-limit-values_decimate_by.c deleted file mode 100644 index 0bbb5ac..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_decimate_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "test-limit.h" -#include "test-limit-values_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_values_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_values_decimate_by__works(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_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_limit_values_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_decimate_by.h b/level_0/f_limit/tests/unit/c/test-limit-values_decimate_by.h deleted file mode 100644 index dc3aa5d..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_decimate_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__values_decimate_by -#define _TEST__F_limit__values_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_values_decimate_by() - */ -extern void test__f_limit_values_decimate_by__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_values_decimate_by() - */ -extern void test__f_limit_values_decimate_by__works(void **state); - -#endif // _TEST__F_limit__values_decimate_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_decrease_by.c b/level_0/f_limit/tests/unit/c/test-limit-values_decrease_by.c deleted file mode 100644 index b29e1f1..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_decrease_by.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "test-limit.h" -#include "test-limit-values_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_values_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_values_decrease_by__works(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_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_limit_values_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_decrease_by.h b/level_0/f_limit/tests/unit/c/test-limit-values_decrease_by.h deleted file mode 100644 index 172b880..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_decrease_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__values_decrease_by -#define _TEST__F_limit__values_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_values_decrease_by() - */ -extern void test__f_limit_values_decrease_by__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_values_decrease_by() - */ -extern void test__f_limit_values_decrease_by__works(void **state); - -#endif // _TEST__F_limit__values_decrease_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_increase.c b/level_0/f_limit/tests/unit/c/test-limit-values_increase.c deleted file mode 100644 index 04ee086..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-limit.h" -#include "test-limit-values_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_values_increase__parameter_checking(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_limit_values_increase__returns_data_not(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_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_limit_values_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_limit_values_increase__works(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_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_limit_values_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_increase.h b/level_0/f_limit/tests/unit/c/test-limit-values_increase.h deleted file mode 100644 index 15143d3..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__values_increase -#define _TEST__F_limit__values_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_values_increase() - */ -extern void test__f_limit_values_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_values_increase() - */ -extern void test__f_limit_values_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_values_increase() - */ -extern void test__f_limit_values_increase__works(void **state); - -#endif // _TEST__F_limit__values_increase diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_increase_by.c b/level_0/f_limit/tests/unit/c/test-limit-values_increase_by.c deleted file mode 100644 index 360ed25..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_increase_by.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "test-limit.h" -#include "test-limit-values_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_values_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_values_increase_by__works(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_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_limit_values_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_increase_by.h b/level_0/f_limit/tests/unit/c/test-limit-values_increase_by.h deleted file mode 100644 index bf927dd..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_increase_by.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__values_increase_by -#define _TEST__F_limit__values_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_values_increase_by() - */ -extern void test__f_limit_values_increase_by__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_values_increase_by() - */ -extern void test__f_limit_values_increase_by__works(void **state); - -#endif // _TEST__F_limit__values_increase_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_resize.c b/level_0/f_limit/tests/unit/c/test-limit-values_resize.c deleted file mode 100644 index 9a62a59..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-limit.h" -#include "test-limit-values_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_values_resize__parameter_checking(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_values_resize__works(void **state) { - - const int length = 5; - f_limit_values_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_values_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-values_resize.h b/level_0/f_limit/tests/unit/c/test-limit-values_resize.h deleted file mode 100644 index 33c9b31..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-values_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Limit - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the limit project. - */ -#ifndef _TEST__F_limit__values_resize -#define _TEST__F_limit__values_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_values_resize() - */ -extern void test__f_limit_values_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_values_resize() - */ -extern void test__f_limit_values_resize__works(void **state); - -#endif // _TEST__F_limit__values_resize diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_adjust.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_adjust.c deleted file mode 100644 index 5010b70..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-limit.h" -#include "test-limit-valuess_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_valuess_adjust__parameter_checking(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_valuess_adjust__works(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_adjust.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_adjust.h deleted file mode 100644 index 1defe6e..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_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_limit__valuess_adjust -#define _TEST__F_limit__valuess_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_valuess_adjust() - */ -extern void test__f_limit_valuess_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_valuess_adjust() - */ -extern void test__f_limit_valuess_adjust__works(void **state); - -#endif // _TEST__F_limit__valuess_adjust diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_append.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_append.c deleted file mode 100644 index dbb3be2..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_append.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "test-limit.h" -#include "test-limit-valuess_append.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_valuess_append__parameter_checking(void **state) { - - f_limit_values_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_append(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_limit_valuess_append__returns_data_not(void **state) { - - const int length = 5; - f_limit_values_t source = f_limit_valuess_t_initialize; - f_limit_valuess_t destination = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_values_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_limit_valuess_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_limit_valuess_append__works(void **state) { - - const int length = 5; - f_limit_values_t source = f_limit_valuess_t_initialize; - f_limit_valuess_t destination = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_values_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length; ++source.used) { - - source.array[source.used].rlim_cur = source.used + 1; - source.array[source.used].rlim_max = source.used + 2; - } // for - - { - const f_status_t status = f_limit_valuess_append(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, 1); - assert_int_equal(destination.array[0].used, source.used); - assert_int_equal(destination.array[0].size, source.used); - - for (f_number_unsigned_t i = 0; i < destination.array[0].used; ++i) { - - assert_int_equal(destination.array[0].array[i].rlim_cur, i + 1); - assert_int_equal(destination.array[0].array[i].rlim_max, i + 2); - } // for - } - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - free((void *) destination.array[i].array); - } // for - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_append.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_append.h deleted file mode 100644 index ac7276f..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_append.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_limit__valuess_append -#define _TEST__F_limit__valuess_append - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_valuess_append() - */ -extern void test__f_limit_valuess_append__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_valuess_append() - */ -extern void test__f_limit_valuess_append__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_valuess_append() - */ -extern void test__f_limit_valuess_append__works(void **state); - -#endif // _TEST__F_limit__valuess_append diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_append_all.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_append_all.c deleted file mode 100644 index 460ded5..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_append_all.c +++ /dev/null @@ -1,111 +0,0 @@ -#include "test-limit.h" -#include "test-limit-valuess_append_all.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_valuess_append_all__parameter_checking(void **state) { - - const f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_append_all(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_limit_valuess_append_all__returns_data_not(void **state) { - - const int length = 5; - f_limit_valuess_t source = f_limit_valuess_t_initialize; - f_limit_valuess_t destination = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_limit_valuess_append_all(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_limit_valuess_append_all__works(void **state) { - - const int length = 5; - const int length_inner = 2; - f_limit_valuess_t source = f_limit_valuess_t_initialize; - f_limit_valuess_t destination = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_limit_values_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_okay); - - for (f_number_unsigned_t i = 0; i < length_inner; ++i) { - - source.array[source.used].array[i].rlim_cur = i + 1; - source.array[source.used].array[i].rlim_max = i + 2; - } // for - - source.array[source.used].used = length_inner; - } // for - } - - { - const f_status_t status = f_limit_valuess_append_all(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_number_unsigned_t j = 0; j < length_inner; ++j) { - - assert_int_equal(destination.array[i].array[j].rlim_cur, j + 1); - assert_int_equal(destination.array[i].array[j].rlim_max, j + 2); - } // for - } // for - } - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - free((void *) destination.array[i].array); - } // for - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_append_all.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_append_all.h deleted file mode 100644 index 3fd674f..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_append_all.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_limit__valuess_append_all -#define _TEST__F_limit__valuess_append_all - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_valuess_append_all() - */ -extern void test__f_limit_valuess_append_all__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_valuess_append_all() - */ -extern void test__f_limit_valuess_append_all__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_valuess_append_all() - */ -extern void test__f_limit_valuess_append_all__works(void **state); - -#endif // _TEST__F_limit__valuess_append_all diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_decimate_by.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_decimate_by.c deleted file mode 100644 index 94dcd19..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_decimate_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-limit.h" -#include "test-limit-valuess_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_valuess_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_valuess_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_limit_valuess_decimate_by__works(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_decimate_by.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_decimate_by.h deleted file mode 100644 index fcb53ab..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_decimate_by.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_limit__valuess_decimate_by -#define _TEST__F_limit__valuess_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_valuess_decimate_by() - */ -extern void test__f_limit_valuess_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_valuess_decimate_by() - */ -extern void test__f_limit_valuess_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_valuess_decimate_by() - */ -extern void test__f_limit_valuess_decimate_by__works(void **state); - -#endif // _TEST__F_limit__valuess_decimate_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_decrease_by.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_decrease_by.c deleted file mode 100644 index 6f4597a..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_decrease_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-limit.h" -#include "test-limit-valuess_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_valuess_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_valuess_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_limit_valuess_decrease_by__works(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_decrease_by.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_decrease_by.h deleted file mode 100644 index b2e4b6a..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_decrease_by.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_limit__valuess_decrease_by -#define _TEST__F_limit__valuess_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_valuess_decrease_by() - */ -extern void test__f_limit_valuess_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_valuess_decrease_by() - */ -extern void test__f_limit_valuess_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_valuess_decrease_by() - */ -extern void test__f_limit_valuess_decrease_by__works(void **state); - -#endif // _TEST__F_limit__valuess_decrease_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_delete_callback.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_delete_callback.c new file mode 100644 index 0000000..21881b5 --- /dev/null +++ b/level_0/f_limit/tests/unit/c/test-limit-valuess_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-limit.h" +#include "test-limit-valuess_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_limit_valuess_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_limit_value_t data = f_limit_value_t_initialize; + f_limit_value_t data_array[] = { data }; + f_limit_values_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_limit_values_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_limit_valuess_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_limit_valuess_delete_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_limit_valuess_t datass = f_limit_valuess_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_limit_values_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_limit_value_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_limit_valuess_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_limit/tests/unit/c/test-limit-valuess_delete_callback.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_delete_callback.h new file mode 100644 index 0000000..28221bd --- /dev/null +++ b/level_0/f_limit/tests/unit/c/test-limit-valuess_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Limit + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_limit__valuess_delete_callback +#define _TEST__F_limit__valuess_delete_callback + +/** + * Test that the function fails. + * + * @see f_limit_valuess_delete_callback() + */ +extern void test__f_limit_valuess_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_limit_valuess_delete_callback() + */ +extern void test__f_limit_valuess_delete_callback__works(void **state); + +#endif // _TEST__F_limit__valuess_delete_callback diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_destroy_callback.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_destroy_callback.c new file mode 100644 index 0000000..97052e7 --- /dev/null +++ b/level_0/f_limit/tests/unit/c/test-limit-valuess_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-limit.h" +#include "test-limit-valuess_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_limit_valuess_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_limit_value_t data = f_limit_value_t_initialize; + f_limit_value_t data_array[] = { data }; + f_limit_values_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_limit_values_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_limit_valuess_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_limit_valuess_destroy_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_limit_valuess_t datass = f_limit_valuess_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_limit_values_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_limit_value_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_limit_valuess_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_limit/tests/unit/c/test-limit-valuess_destroy_callback.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_destroy_callback.h new file mode 100644 index 0000000..be22ce7 --- /dev/null +++ b/level_0/f_limit/tests/unit/c/test-limit-valuess_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Limit + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_limit__valuess_destroy_callback +#define _TEST__F_limit__valuess_destroy_callback + +/** + * Test that the function fails. + * + * @see f_limit_valuess_destroy_callback() + */ +extern void test__f_limit_valuess_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_limit_valuess_destroy_callback() + */ +extern void test__f_limit_valuess_destroy_callback__works(void **state); + +#endif // _TEST__F_limit__valuess_destroy_callback diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_increase.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_increase.c deleted file mode 100644 index 0ff6c1c..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_increase.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "test-limit.h" -#include "test-limit-valuess_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_valuess_increase__parameter_checking(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_limit_valuess_increase__returns_data_not(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_increase(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_increase__works(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_increase.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_increase.h deleted file mode 100644 index 85be3e1..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_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_limit__valuess_increase -#define _TEST__F_limit__valuess_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_valuess_increase() - */ -extern void test__f_limit_valuess_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_valuess_increase() - */ -extern void test__f_limit_valuess_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_valuess_increase() - */ -extern void test__f_limit_valuess_increase__works(void **state); - -#endif // _TEST__F_limit__valuess_increase diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_increase_by.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_increase_by.c deleted file mode 100644 index d72faaf..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_increase_by.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "test-limit.h" -#include "test-limit-valuess_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_valuess_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_valuess_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_valuess_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_limit_valuess_increase_by(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_limit_valuess_increase_by__works(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_values_t_initialize; - - { - const f_status_t status = f_limit_valuess_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_limit_valuess_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_increase_by.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_increase_by.h deleted file mode 100644 index 695d9a8..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_increase_by.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_limit__valuess_increase_by -#define _TEST__F_limit__valuess_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_valuess_increase_by() - */ -extern void test__f_limit_valuess_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_limit_valuess_increase_by() - */ -extern void test__f_limit_valuess_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_limit_valuess_increase_by() - */ -extern void test__f_limit_valuess_increase_by__works(void **state); - -#endif // _TEST__F_limit__valuess_increase_by diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_resize.c b/level_0/f_limit/tests/unit/c/test-limit-valuess_resize.c deleted file mode 100644 index 728498d..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-limit.h" -#include "test-limit-valuess_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_limit_valuess_resize__parameter_checking(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_limit_valuess_resize__works(void **state) { - - const int length = 5; - f_limit_valuess_t data = f_limit_valuess_t_initialize; - - { - const f_status_t status = f_limit_valuess_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_limit/tests/unit/c/test-limit-valuess_resize.h b/level_0/f_limit/tests/unit/c/test-limit-valuess_resize.h deleted file mode 100644 index a39b441..0000000 --- a/level_0/f_limit/tests/unit/c/test-limit-valuess_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_limit__valuess_resize -#define _TEST__F_limit__valuess_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_limit_valuess_resize() - */ -extern void test__f_limit_valuess_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_limit_valuess_resize() - */ -extern void test__f_limit_valuess_resize__works(void **state); - -#endif // _TEST__F_limit__valuess_resize 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 0bef998..133613b 100644 --- a/level_0/f_limit/tests/unit/c/test-limit.c +++ b/level_0/f_limit/tests/unit/c/test-limit.c @@ -22,94 +22,26 @@ 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_sets_adjust__works), - cmocka_unit_test(test__f_limit_sets_append__works), - cmocka_unit_test(test__f_limit_sets_append_all__works), - cmocka_unit_test(test__f_limit_sets_decimate_by__works), - cmocka_unit_test(test__f_limit_sets_decrease_by__works), - cmocka_unit_test(test__f_limit_sets_increase__works), - cmocka_unit_test(test__f_limit_sets_increase_by__works), - cmocka_unit_test(test__f_limit_sets_resize__works), - - cmocka_unit_test(test__f_limit_setss_append__returns_data_not), - cmocka_unit_test(test__f_limit_setss_append_all__returns_data_not), - cmocka_unit_test(test__f_limit_setss_decimate_by__returns_data_not), - cmocka_unit_test(test__f_limit_setss_decrease_by__returns_data_not), - cmocka_unit_test(test__f_limit_setss_increase__returns_data_not), - cmocka_unit_test(test__f_limit_setss_increase_by__returns_data_not), - - cmocka_unit_test(test__f_limit_setss_adjust__works), - cmocka_unit_test(test__f_limit_setss_append__works), - cmocka_unit_test(test__f_limit_setss_append_all__works), - cmocka_unit_test(test__f_limit_setss_decimate_by__works), - cmocka_unit_test(test__f_limit_setss_decrease_by__works), - cmocka_unit_test(test__f_limit_setss_increase__works), - cmocka_unit_test(test__f_limit_setss_increase_by__works), - cmocka_unit_test(test__f_limit_setss_resize__works), - - cmocka_unit_test(test__f_limit_values_adjust__works), - cmocka_unit_test(test__f_limit_values_append__works), - cmocka_unit_test(test__f_limit_values_append_all__works), - cmocka_unit_test(test__f_limit_values_decimate_by__works), - cmocka_unit_test(test__f_limit_values_decrease_by__works), - cmocka_unit_test(test__f_limit_values_increase__works), - cmocka_unit_test(test__f_limit_values_increase_by__works), - cmocka_unit_test(test__f_limit_values_resize__works), - - cmocka_unit_test(test__f_limit_valuess_append__returns_data_not), - cmocka_unit_test(test__f_limit_valuess_append_all__returns_data_not), - cmocka_unit_test(test__f_limit_valuess_decimate_by__returns_data_not), - cmocka_unit_test(test__f_limit_valuess_decrease_by__returns_data_not), - cmocka_unit_test(test__f_limit_valuess_increase__returns_data_not), - cmocka_unit_test(test__f_limit_valuess_increase_by__returns_data_not), - - cmocka_unit_test(test__f_limit_valuess_adjust__works), - cmocka_unit_test(test__f_limit_valuess_append__works), - cmocka_unit_test(test__f_limit_valuess_append_all__works), - cmocka_unit_test(test__f_limit_valuess_decimate_by__works), - cmocka_unit_test(test__f_limit_valuess_decrease_by__works), - cmocka_unit_test(test__f_limit_valuess_increase__works), - cmocka_unit_test(test__f_limit_valuess_increase_by__works), - cmocka_unit_test(test__f_limit_valuess_resize__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_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_delete_callback__works), + cmocka_unit_test(test__f_limit_valuess_destroy_callback__works), #ifndef _di_level_0_parameter_checking_ cmocka_unit_test(test__f_limit_process__parameter_checking), - cmocka_unit_test(test__f_limit_sets_adjust__parameter_checking), - cmocka_unit_test(test__f_limit_sets_append__parameter_checking), - cmocka_unit_test(test__f_limit_sets_append_all__parameter_checking), - cmocka_unit_test(test__f_limit_sets_decimate_by__parameter_checking), - cmocka_unit_test(test__f_limit_sets_decrease_by__parameter_checking), - cmocka_unit_test(test__f_limit_sets_increase__parameter_checking), - cmocka_unit_test(test__f_limit_sets_increase_by__parameter_checking), - cmocka_unit_test(test__f_limit_sets_resize__parameter_checking), - - cmocka_unit_test(test__f_limit_setss_adjust__parameter_checking), - cmocka_unit_test(test__f_limit_setss_append__parameter_checking), - cmocka_unit_test(test__f_limit_setss_append_all__parameter_checking), - cmocka_unit_test(test__f_limit_setss_decimate_by__parameter_checking), - cmocka_unit_test(test__f_limit_setss_decrease_by__parameter_checking), - cmocka_unit_test(test__f_limit_setss_increase__parameter_checking), - cmocka_unit_test(test__f_limit_setss_increase_by__parameter_checking), - cmocka_unit_test(test__f_limit_setss_resize__parameter_checking), - - cmocka_unit_test(test__f_limit_values_adjust__parameter_checking), - cmocka_unit_test(test__f_limit_values_append__parameter_checking), - cmocka_unit_test(test__f_limit_values_append_all__parameter_checking), - cmocka_unit_test(test__f_limit_values_decimate_by__parameter_checking), - cmocka_unit_test(test__f_limit_values_decrease_by__parameter_checking), - cmocka_unit_test(test__f_limit_values_increase__parameter_checking), - cmocka_unit_test(test__f_limit_values_increase_by__parameter_checking), - cmocka_unit_test(test__f_limit_values_resize__parameter_checking), - - cmocka_unit_test(test__f_limit_valuess_adjust__parameter_checking), - cmocka_unit_test(test__f_limit_valuess_append__parameter_checking), - cmocka_unit_test(test__f_limit_valuess_append_all__parameter_checking), - cmocka_unit_test(test__f_limit_valuess_decimate_by__parameter_checking), - cmocka_unit_test(test__f_limit_valuess_decrease_by__parameter_checking), - cmocka_unit_test(test__f_limit_valuess_increase__parameter_checking), - cmocka_unit_test(test__f_limit_valuess_increase_by__parameter_checking), - cmocka_unit_test(test__f_limit_valuess_resize__parameter_checking), + // f_limit_setss_destroy_callback() doesn't use parameter checking. + // f_limit_setss_delete_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. #endif // _di_level_0_parameter_checking_ }; diff --git a/level_0/f_limit/tests/unit/c/test-limit.h b/level_0/f_limit/tests/unit/c/test-limit.h index d946af4..6528747 100644 --- a/level_0/f_limit/tests/unit/c/test-limit.h +++ b/level_0/f_limit/tests/unit/c/test-limit.h @@ -28,38 +28,10 @@ // Test includes. #include "test-limit-process.h" -#include "test-limit-sets_adjust.h" -#include "test-limit-sets_append.h" -#include "test-limit-sets_append_all.h" -#include "test-limit-sets_decimate_by.h" -#include "test-limit-sets_decrease_by.h" -#include "test-limit-sets_increase.h" -#include "test-limit-sets_increase_by.h" -#include "test-limit-sets_resize.h" -#include "test-limit-setss_adjust.h" -#include "test-limit-setss_append.h" -#include "test-limit-setss_append_all.h" -#include "test-limit-setss_decimate_by.h" -#include "test-limit-setss_decrease_by.h" -#include "test-limit-setss_increase.h" -#include "test-limit-setss_increase_by.h" -#include "test-limit-setss_resize.h" -#include "test-limit-values_adjust.h" -#include "test-limit-values_append.h" -#include "test-limit-values_append_all.h" -#include "test-limit-values_decimate_by.h" -#include "test-limit-values_decrease_by.h" -#include "test-limit-values_increase.h" -#include "test-limit-values_increase_by.h" -#include "test-limit-values_resize.h" -#include "test-limit-valuess_adjust.h" -#include "test-limit-valuess_append.h" -#include "test-limit-valuess_append_all.h" -#include "test-limit-valuess_decimate_by.h" -#include "test-limit-valuess_decrease_by.h" -#include "test-limit-valuess_increase.h" -#include "test-limit-valuess_increase_by.h" -#include "test-limit-valuess_resize.h" +#include "test-limit-setss_delete_callback.h" +#include "test-limit-setss_destroy_callback.h" +#include "test-limit-valuess_delete_callback.h" +#include "test-limit-valuess_destroy_callback.h" #ifdef __cplusplus extern "C" { diff --git a/level_0/f_memory/c/memory/arrays.h b/level_0/f_memory/c/memory/arrays.h index acfb583..a2460e5 100644 --- a/level_0/f_memory/c/memory/arrays.h +++ b/level_0/f_memory/c/memory/arrays.h @@ -24,6 +24,8 @@ extern "C" { * * The inner array can be a more complex structure because the callback is expected to know the type. * + * Use f_memory_array_adjust() instead if a callback is not needed. + * * @param length * The new size to use. * @param width @@ -70,6 +72,8 @@ extern "C" { * * The inner array can be a more complex structure because the callback is expected to know the type. * + * Use f_memory_array_resize() instead if a callback is not needed. + * * @param length * The new size to use. * @param width diff --git a/level_0/f_socket/c/socket.h b/level_0/f_socket/c/socket.h index 5c6d569..296697e 100644 --- a/level_0/f_socket/c/socket.h +++ b/level_0/f_socket/c/socket.h @@ -49,6 +49,7 @@ // FLL-0 socket includes. #include +#include #include #ifdef __cplusplus diff --git a/level_0/f_socket/c/socket/address.c b/level_0/f_socket/c/socket/address.c new file mode 100644 index 0000000..a61c52d --- /dev/null +++ b/level_0/f_socket/c/socket/address.c @@ -0,0 +1,50 @@ +#include "../socket.h" +#include "address.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_socket_addressss_delete_callback_ + f_status_t f_socket_addressss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { + + { + f_socket_addresss_t * const array = (f_socket_addresss_t *) void_array; + f_status_t status = F_okay; + + for (f_number_unsigned_t i = start; i < stop; ++i) { + + if (array[i].size) { + status = f_memory_array_resize(0, sizeof(f_socket_address_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_socket_addressss_delete_callback_ + +#ifndef _di_f_socket_addressss_destroy_callback_ + f_status_t f_socket_addressss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { + + { + f_socket_addresss_t * const array = (f_socket_addresss_t *) void_array; + f_status_t status = F_okay; + + for (f_number_unsigned_t i = start; i < stop; ++i) { + + if (array[i].size) { + status = f_memory_array_adjust(0, sizeof(f_socket_address_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_socket_addressss_destroy_callback_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_socket/c/socket/address.h b/level_0/f_socket/c/socket/address.h new file mode 100644 index 0000000..29215a1 --- /dev/null +++ b/level_0/f_socket/c/socket/address.h @@ -0,0 +1,205 @@ +/** + * FLL - Level 0 + * + * Project: Socket + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines socket type related functionality. + * + * This is auto-included by socket.h and should not need to be explicitly included. + */ +#ifndef _F_socket_address_h +#define _F_socket_address_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Provide a union to simplify using struct sockaddr in arrays. + * + * Managing different structures is not as practical. + * At the cost of resources, use the same space for all of these. + * This can then easily be used in a generic array that has a mixture of these. + * + * All of the properties may or may not be present, but inet4, inet6, and local are generally assumed to exist. + * + * Properties: + * - arp: Arp. + * - at: At. + * - ax25: Ax25. + * - dl: Dl. + * - eon: Eon. + * - inet4: Ipv4 internet network socket. + * - inet6: Ipv6 internet network socket.. + * - ipx: Ipx. + * - iso: Iso. + * - local: Local (aka: Unix) socket (socket file or localhost). + * - ns: Ns. + * - x25: X25. + */ +#ifndef _di_f_socket_address_t_ + typedef union { + struct sockaddr_in inet4; + struct sockaddr_in6 inet6; + struct sockaddr_un local; + + #ifdef _en_support_socket_address_arp_ + struct sockaddr_inarp arp; + #endif // _en_support_socket_address_arp_ + + #ifdef _en_support_socket_address_at_ + struct sockaddr_at at; + #endif // _en_support_socket_address_at_ + + #ifdef _en_support_socket_address_ax25_ + struct sockaddr_ax25 ax25; + #endif // _en_support_socket_address_ax25_ + + #ifdef _en_support_socket_address_dl_ + struct sockaddr_dl dl; + #endif // _en_support_socket_address_dl_ + + #ifdef _en_support_socket_address_eon_ + struct sockaddr_eon eon; + #endif // _en_support_socket_address_eon_ + + #ifdef _en_support_socket_address_ipx_ + struct sockaddr_ipx ipx; + #endif // _en_support_socket_address_ipx_ + + #ifdef _en_support_socket_address_iso_ + struct sockaddr_iso iso; + #endif // _en_support_socket_address_iso_ + + #ifdef _en_support_socket_address_ns_ + struct sockaddr_ns ns; + #endif // _en_support_socket_address_ns_ + + #ifdef _en_support_socket_address_x25_ + struct sockaddr_x25 x25; + #endif // _en_support_socket_address_x25_ + } f_socket_address_t; + + #define f_socket_address_t_initialize { 0 } + + #define f_socket_address_initialize_inet4(value_inet4) { .inet4 = value_inet4 } + #define f_socket_address_initialize_inet6(value_inet6) { .inet6 = value_inet6 } + #define f_socket_address_initialize_local(value_local) { .local = value_local } + #define f_socket_address_initialize_arp(value_arp) { .arp = value_arp } + #define f_socket_address_initialize_at(value_at) { .at = value_at } + #define f_socket_address_initialize_ax25(value_ax25) { .ax25 = value_ax25 } + #define f_socket_address_initialize_dl(value_dl) { .dl = value_dl } + #define f_socket_address_initialize_eon(value_eon) { .local = value_eon } + #define f_socket_address_initialize_ipx(value_ipx) { .ipx = value_ipx } + #define f_socket_address_initialize_iso(value_iso) { .iso = value_iso } + #define f_socket_address_initialize_ns(value_ns) { .ns = value_ns } + #define f_socket_address_initialize_x25(value_x25) { .x25 = value_x25 } +#endif // _di_f_socket_address_t_ + +/** + * An array of f_socket_address_t. + * + * Properties: + * - array: The array of f_socket_address_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_socket_addresss_t_ + typedef struct { + f_socket_address_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_socket_addresss_t; + + #define f_socket_addresss_t_initialize { 0, 0, 0 } + + #define macro_f_socket_addresss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_socket_addresss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_socket_addresss_t_ + +/** + * This holds an array of an array of f_socket_address_t. + * + * Properties: + * - array: The array of an array of f_socket_address_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_socket_addressss_t_ + typedef struct { + f_socket_addresss_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_socket_addressss_t; + + #define f_socket_addressss_t_initialize { 0, 0, 0 } + + #define macro_f_socket_addressss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_socket_addressss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_socket_addressss_t_ + +/** + * A callback intended to be passed to f_memory_arrays_resize() for an f_socket_addressss_t structure. + * + * This is only called when shrinking the array and generally should perform deallocations. + * + * This does not do parameter checking. + * + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. + * + * @return + * F_okay on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_dynamics_resize(). + * + * @see f_string_dynamics_resize() + */ +#ifndef _di_f_socket_addressss_delete_callback_ + extern f_status_t f_socket_addressss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_socket_addressss_delete_callback_ + +/** + * A callback intended to be passed to f_memory_arrays_adjust() for an f_socket_addressss_t structure. + * + * This is only called when shrinking the array and generally should perform deallocations. + * + * This does not do parameter checking. + * + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. + * + * @return + * F_okay on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_string_dynamics_adjust(). + * + * @see f_string_dynamics_adjust() + */ +#ifndef _di_f_socket_addressss_destroy_callback_ + extern f_status_t f_socket_addressss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_socket_addressss_destroy_callback_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_socket_address_h diff --git a/level_0/f_socket/c/socket/common.h b/level_0/f_socket/c/socket/common.h index e718df3..345b8ae 100644 --- a/level_0/f_socket/c/socket/common.h +++ b/level_0/f_socket/c/socket/common.h @@ -648,259 +648,6 @@ extern "C" { }; #endif // _di_f_socket_type_e_ -/** - * Provide a union to simplify using struct sockaddr in arrays. - * - * Managing different structures is not as practical. - * At the cost of resources, use the same space for all of these. - * This can then easily be used in a generic array that has a mixture of these. - * - * All of the properties may or may not be present, but inet4, inet6, and local are generally assumed to exist. - * - * Properties: - * - arp: Arp. - * - at: At. - * - ax25: Ax25. - * - dl: Dl. - * - eon: Eon. - * - inet4: Ipv4 internet network socket. - * - inet6: Ipv6 internet network socket.. - * - ipx: Ipx. - * - iso: Iso. - * - local: Local (aka: Unix) socket (socket file or localhost). - * - ns: Ns. - * - x25: X25. - */ -#ifndef _di_f_socket_address_t_ - typedef union { - struct sockaddr_in inet4; - struct sockaddr_in6 inet6; - struct sockaddr_un local; - - #ifdef _en_support_socket_address_arp_ - struct sockaddr_inarp arp; - #endif // _en_support_socket_address_arp_ - - #ifdef _en_support_socket_address_at_ - struct sockaddr_at at; - #endif // _en_support_socket_address_at_ - - #ifdef _en_support_socket_address_ax25_ - struct sockaddr_ax25 ax25; - #endif // _en_support_socket_address_ax25_ - - #ifdef _en_support_socket_address_dl_ - struct sockaddr_dl dl; - #endif // _en_support_socket_address_dl_ - - #ifdef _en_support_socket_address_eon_ - struct sockaddr_eon eon; - #endif // _en_support_socket_address_eon_ - - #ifdef _en_support_socket_address_ipx_ - struct sockaddr_ipx ipx; - #endif // _en_support_socket_address_ipx_ - - #ifdef _en_support_socket_address_iso_ - struct sockaddr_iso iso; - #endif // _en_support_socket_address_iso_ - - #ifdef _en_support_socket_address_ns_ - struct sockaddr_ns ns; - #endif // _en_support_socket_address_ns_ - - #ifdef _en_support_socket_address_x25_ - struct sockaddr_x25 x25; - #endif // _en_support_socket_address_x25_ - } f_socket_address_t; - - #define f_socket_address_t_initialize { 0 } - - #define f_socket_address_initialize_inet4(value_inet4) { .inet4 = value_inet4 } - #define f_socket_address_initialize_inet6(value_inet6) { .inet6 = value_inet6 } - #define f_socket_address_initialize_local(value_local) { .local = value_local } - #define f_socket_address_initialize_arp(value_arp) { .arp = value_arp } - #define f_socket_address_initialize_at(value_at) { .at = value_at } - #define f_socket_address_initialize_ax25(value_ax25) { .ax25 = value_ax25 } - #define f_socket_address_initialize_dl(value_dl) { .dl = value_dl } - #define f_socket_address_initialize_eon(value_eon) { .local = value_eon } - #define f_socket_address_initialize_ipx(value_ipx) { .ipx = value_ipx } - #define f_socket_address_initialize_iso(value_iso) { .iso = value_iso } - #define f_socket_address_initialize_ns(value_ns) { .ns = value_ns } - #define f_socket_address_initialize_x25(value_x25) { .x25 = value_x25 } -#endif // _di_f_socket_address_t_ - -/** - * Commonly used socket related properties, loosely based off of f_file_t. - * - * Properties: - * - id: Socket file descriptor, used for binding and listening. - * - id_data: Data file descriptor, used for reading and writing data from or to the socket. - * - domain: The socket domain (protocol family, such as f_socket_protocol_family_local_e). - * - protocol: The socket protocol (such as f_socket_protocol_tcp_e). - * - type: The socket type (address family, such as f_socket_address_family_local_e). - * - * - size_read: The default number of 1-byte characters to read at a time and is often used for the read buffer size. - * - size_write: The default number of 1-byte characters to read at a time and is often used for the write buffer size. - * - * - address: The socket address. - * - length: The length of the socket. - * - * - name: The name of the socket, if a name is given (for UNIX sockets this represents the path) (Must be a NULL terminated string). - * - * The clear and reset macros do not clear or reset the address (type f_socket_address_t) because the struct sockaddr is defined outside of the FLL project. - */ -#ifndef _di_f_socket_t_ - typedef struct { - int id; - int id_data; - int domain; - int protocol; - int type; - - size_t size_read; - size_t size_write; - - f_socket_address_t address; - socklen_t length; - - f_string_static_t name; - } f_socket_t; - - #define f_socket_t_initialize { -1, -1, 0, 0, 0, F_socket_default_read_size_d, F_socket_default_write_size_d, f_socket_address_t_initialize, 0, f_string_static_t_initialize } - - #define macro_f_socket_t_initialize_1(address, length) { \ - -1, \ - -1, \ - 0, \ - 0, \ - 0, \ - F_socket_default_read_size_d, \ - F_socket_default_write_size_d, \ - address, \ - length, \ - f_string_empty_s \ - } - - #define macro_f_socket_t_initialize_2(address, length, name) { \ - -1, \ - -1, \ - 0, \ - 0, \ - 0, \ - F_socket_default_read_size_d, \ - F_socket_default_write_size_d, \ - address, \ - length, \ - name \ - } - - #define macro_f_socket_t_initialize_3(id, domain, protocol, type, address, length, name) { \ - id, \ - -1, \ - domain, \ - protocol, \ - type, \ - F_socket_default_read_size_d, \ - F_socket_default_write_size_d, \ - address, \ - length, \ - name \ - } - - #define macro_f_socket_t_initialize_4(id, domain, protocol, type, size_read, size_write, address, length, name) { \ - id, \ - -1, \ - domain, \ - protocol, \ - type, \ - size_read, \ - size_write, \ - address, \ - length, \ - name \ - } - - #define macro_f_socket_t_initialize_5(id, id_data, domain, protocol, type, size_read, size_write, address, length, name) { \ - id, \ - id_data, \ - domain, \ - protocol, \ - type, \ - size_read, \ - size_write, \ - address, \ - length, \ - name \ - } - - #define macro_f_socket_t_clear(file) \ - file.id = -1; \ - file.id_data = -1; \ - file.domain = 0; \ - file.protocol = 0; \ - file.type = 0; \ - file.size_read = 0; \ - file.size_write = 0; \ - file.length = 0; \ - macro_f_string_static_t_clear(file); - - #define macro_f_socket_t_reset(file) \ - file.id = -1; \ - file.id_data = -1; \ - file.domain = 0; \ - file.protocol = 0; \ - file.type = 0; \ - file.size_read = F_socket_default_read_size_d; \ - file.size_write = F_socket_default_write_size_d; \ - file.length = 0; \ - macro_f_string_static_t_clear(file); -#endif // _di_f_socket_t_ - -/** - * An array of f_socket_t. - * - * Properties: - * - array: The array of f_socket_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_sockets_t_ - typedef struct { - f_socket_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_sockets_t; - - #define f_sockets_t_initialize { 0, 0, 0 } - - #define macro_f_sockets_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_sockets_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_sockets_t_ - -/** - * This holds an array of f_sockets_t. - * - * Properties: - * - array: The array of f_socket_t arrays. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_socketss_t_ - typedef struct { - f_sockets_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_socketss_t; - - #define f_socketss_t_initialize { 0, 0, 0 } - - #define macro_f_socketss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_socketss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_socketss_t_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_socket/c/socket/private-socket.c b/level_0/f_socket/c/socket/private-socket.c deleted file mode 100644 index 7c62cfa..0000000 --- a/level_0/f_socket/c/socket/private-socket.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "../socket.h" -#include "private-socket.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_) || !defined(_di_f_socketss_append_all_) - extern f_status_t private_f_sockets_append_all(const f_sockets_t source, f_sockets_t * const destination) { - - const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_socket_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_sockets_append_all_) || !defined(_di_f_socketss_append_) || !defined(_di_f_socketss_append_all_) - -#if !defined(_di_f_socketss_adjust_) || !defined(_di_f_socketss_decimate_by_) - f_status_t private_f_socketss_adjust(const f_number_unsigned_t length, f_socketss_t * const socketss) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < socketss->size; ++i) { - - status = f_memory_array_adjust(0, sizeof(f_socket_t), (void **) &socketss->array[i].array, &socketss->array[i].used, &socketss->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_adjust(length, sizeof(f_sockets_t), (void **) &socketss->array, &socketss->used, &socketss->size); - } -#endif // !defined(_di_f_socketss_adjust_) || !defined(_di_f_socketss_decimate_by_) - -#if !defined(_di_f_socketss_decrease_by_) || !defined(_di_f_socketss_increase_) || !defined(_di_f_socketss_increase_by_) || !defined(_di_f_socketss_resize_) - f_status_t private_f_socketss_resize(const f_number_unsigned_t length, f_socketss_t * const socketss) { - - f_status_t status = F_okay; - - for (f_number_unsigned_t i = length; i < socketss->size; ++i) { - - status = f_memory_array_resize(0, sizeof(f_socket_t), (void **) &socketss->array[i].array, &socketss->array[i].used, &socketss->array[i].size); - if (F_status_is_error(status)) return status; - } // for - - return f_memory_array_resize(length, sizeof(f_sockets_t), (void **) &socketss->array, &socketss->used, &socketss->size); - } -#endif // !defined(_di_f_socketss_decrease_by_) || !defined(_di_f_socketss_increase_) || !defined(_di_f_socketss_increase_by_) || !defined(_di_f_socketss_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/c/socket/private-socket.h b/level_0/f_socket/c/socket/private-socket.h deleted file mode 100644 index 7f85157..0000000 --- a/level_0/f_socket/c/socket/private-socket.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * 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_socket_socket_h -#define _PRIVATE_F_socket_socket_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Private implementation for appending the socket array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source sockets to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * F_okay on success. - * - * Errors (with error bit) from: f_memory_array_increase_by(). - * - * @see f_memory_array_increase_by() - * - * @see f_sockets_append_all() - * @see f_socketss_append() - * @see f_socketss_append_all() - */ -#if !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_) || !defined(_di_f_socketss_append_all_) - extern f_status_t private_f_sockets_append_all(const f_sockets_t source, f_sockets_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_) || !defined(_di_f_socketss_append_all_) - -/** - * Private implementation for resizing the socketss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to adjust to. - * @param socketss - * The socketss array to adjust. - * - * @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 new length is larger than max array length. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_adjust(). - * - * @see f_memory_array_adjust() - * - * @see f_socketss_adjust() - * @see f_socketss_decimate_by() - */ -#if !defined(_di_f_socketss_adjust_) || !defined(_di_f_socketss_decimate_by_) - extern f_status_t private_f_socketss_adjust(const f_number_unsigned_t length, f_socketss_t * const socketss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_socketss_adjust_) || !defined(_di_f_socketss_decimate_by_) - -/** - * Private implementation for resizing the socketss array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The length to resize to. - * @param socketss - * The socketss 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 new length is larger than max array length. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_resize(). - * - * @see f_memory_array_resize() - * - * @see f_socketss_decrease_by() - * @see f_socketss_increase() - * @see f_socketss_increase_by() - * @see f_socketss_resize() - */ -#if !defined(_di_f_socketss_decrease_by_) || !defined(_di_f_socketss_increase_) || !defined(_di_f_socketss_increase_by_) || !defined(_di_f_socketss_resize_) - extern f_status_t private_f_socketss_resize(const f_number_unsigned_t length, f_socketss_t * const socketss) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_socketss_decrease_by_) || !defined(_di_f_socketss_increase_) || !defined(_di_f_socketss_increase_by_) || !defined(_di_f_socketss_resize_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_socket_socket_h diff --git a/level_0/f_socket/c/socket/socket.c b/level_0/f_socket/c/socket/socket.c index 5632ae6..f885ac8 100644 --- a/level_0/f_socket/c/socket/socket.c +++ b/level_0/f_socket/c/socket/socket.c @@ -1,206 +1,49 @@ #include "../socket.h" #include "socket.h" -#include "private-socket.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_sockets_adjust_ - f_status_t f_sockets_adjust(const f_number_unsigned_t length, f_sockets_t * const sockets) { - #ifndef _di_level_0_parameter_checking_ - if (!sockets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_socketss_delete_callback_ + f_status_t f_socketss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - return f_memory_array_adjust(length, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size); - } -#endif // _di_f_sockets_adjust_ - -#ifndef _di_f_sockets_append_ - f_status_t f_sockets_append(const f_socket_t source, f_sockets_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_sockets_t * const array = (f_sockets_t *) void_array; + f_status_t status = F_okay; - const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; + for (f_number_unsigned_t i = start; i < stop; ++i) { - destination->array[destination->used++] = source; + if (array[i].size) { + status = f_memory_array_resize(0, sizeof(f_socket_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_sockets_append_ - -#ifndef _di_f_sockets_append_all_ - f_status_t f_sockets_append_all(const f_sockets_t source, f_sockets_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - return private_f_sockets_append_all(source, destination); - } -#endif // _di_f_sockets_append_all_ - -#ifndef _di_f_sockets_decimate_by_ - f_status_t f_sockets_decimate_by(const f_number_unsigned_t amount, f_sockets_t * const sockets) { - #ifndef _di_level_0_parameter_checking_ - if (!sockets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decimate_by(amount, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size); - } -#endif // _di_f_sockets_decimate_by_ - -#ifndef _di_f_sockets_decrease_by_ - f_status_t f_sockets_decrease_by(const f_number_unsigned_t amount, f_sockets_t * const sockets) { - #ifndef _di_level_0_parameter_checking_ - if (!sockets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decrease_by(amount, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size); - } -#endif // _di_f_sockets_decrease_by_ - -#ifndef _di_f_sockets_increase_ - f_status_t f_sockets_increase(const f_number_unsigned_t step, f_sockets_t * const sockets) { - #ifndef _di_level_0_parameter_checking_ - if (!sockets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size); - } -#endif // _di_f_sockets_increase_ +#endif // _di_f_socketss_delete_callback_ -#ifndef _di_f_sockets_increase_by_ - f_status_t f_sockets_increase_by(const f_number_unsigned_t amount, f_sockets_t * const sockets) { - #ifndef _di_level_0_parameter_checking_ - if (!sockets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_socketss_destroy_callback_ + f_status_t f_socketss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - return f_memory_array_increase_by(amount, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size); - } -#endif // _di_f_sockets_increase_by_ + { + f_sockets_t * const array = (f_sockets_t *) void_array; + f_status_t status = F_okay; -#ifndef _di_f_sockets_resize_ - f_status_t f_sockets_resize(const f_number_unsigned_t length, f_sockets_t * const sockets) { - #ifndef _di_level_0_parameter_checking_ - if (!sockets) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + for (f_number_unsigned_t i = start; i < stop; ++i) { - return f_memory_array_resize(length, sizeof(f_socket_t), (void **) &sockets->array, &sockets->used, &sockets->size); - } -#endif // _di_f_sockets_resize_ - -#ifndef _di_f_socketss_adjust_ - f_status_t f_socketss_adjust(const f_number_unsigned_t length, f_socketss_t * const socketss) { - #ifndef _di_level_0_parameter_checking_ - if (!socketss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_socketss_adjust(length, socketss); - } -#endif // _di_f_socketss_adjust_ - -#ifndef _di_f_socketss_append_ - f_status_t f_socketss_append(const f_sockets_t source, f_socketss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_sockets_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - - status = private_f_sockets_append_all(source, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - - ++destination->used; + if (array[i].size) { + status = f_memory_array_adjust(0, sizeof(f_socket_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_socketss_append_ - -#ifndef _di_f_socketss_append_all_ - f_status_t f_socketss_append_all(const f_socketss_t source, f_socketss_t * const destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_sockets_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_sockets_append_all(source.array[i], &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_okay; - } -#endif // _di_f_socketss_append_all_ - -#ifndef _di_f_socketss_decimate_by_ - f_status_t f_socketss_decimate_by(const f_number_unsigned_t amount, f_socketss_t * const socketss) { - #ifndef _di_level_0_parameter_checking_ - if (!socketss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - return private_f_socketss_adjust((socketss->size - amount > 0) ? socketss->size - amount : 0, socketss); - } -#endif // _di_f_socketss_decimate_by_ - -#ifndef _di_f_socketss_decrease_by_ - f_status_t f_socketss_decrease_by(const f_number_unsigned_t amount, f_socketss_t * const socketss) { - #ifndef _di_level_0_parameter_checking_ - if (!socketss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - return private_f_socketss_resize((socketss->size - amount > 0) ? socketss->size - amount : 0, socketss); - } -#endif // _di_f_socketss_decrease_by_ - -#ifndef _di_f_socketss_increase_ - f_status_t f_socketss_increase(const f_number_unsigned_t step, f_socketss_t * const socketss) { - #ifndef _di_level_0_parameter_checking_ - if (!socketss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_sockets_t), (void **) &socketss->array, &socketss->used, &socketss->size); - } -#endif // _di_f_socketss_increase_ - -#ifndef _di_f_socketss_increase_by_ - f_status_t f_socketss_increase_by(const f_number_unsigned_t amount, f_socketss_t * const socketss) { - #ifndef _di_level_0_parameter_checking_ - if (!socketss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase_by(amount, sizeof(f_sockets_t), (void **) &socketss->array, &socketss->used, &socketss->size); - } -#endif // _di_f_socketss_increase_by_ - -#ifndef _di_f_socketss_resize_ - f_status_t f_socketss_resize(const f_number_unsigned_t length, f_socketss_t * const socketss) { - #ifndef _di_level_0_parameter_checking_ - if (!socketss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_socketss_resize(length, socketss); - } -#endif // _di_f_socketss_resize_ +#endif // _di_f_socketss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_socket/c/socket/socket.h b/level_0/f_socket/c/socket/socket.h index 20487da..d2eab43 100644 --- a/level_0/f_socket/c/socket/socket.h +++ b/level_0/f_socket/c/socket/socket.h @@ -17,390 +17,231 @@ extern "C" { #endif /** - * Resize the string sockets array. - * - * @param length - * The new size to use. - * @param sockets - * The string sockets array to resize. - * - * @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() - */ -#ifndef _di_f_sockets_adjust_ - extern f_status_t f_sockets_adjust(const f_number_unsigned_t length, f_sockets_t * const sockets); -#endif // _di_f_sockets_adjust_ - -/** - * Append the single source socket onto the destination. - * - * @param source - * The source socket to append. - * @param destination - * The destination sockets the source is appended onto. - * - * @return - * F_okay on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_increase(). - * - * @see f_memory_array_increase() - */ -#ifndef _di_f_sockets_append_ - extern f_status_t f_sockets_append(const f_socket_t source, f_sockets_t * const destination); -#endif // _di_f_sockets_append_ - -/** - * Append the source sockets onto the destination. - * - * @param source - * The source sockets to append. - * @param destination - * The destination sockets the source is appended onto. - * - * @return - * F_okay on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). - * - * 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() - */ -#ifndef _di_f_sockets_append_all_ - extern f_status_t f_sockets_append_all(const f_sockets_t source, f_sockets_t * const destination); -#endif // _di_f_sockets_append_all_ - -/** - * Resize the string sockets array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to les than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param sockets - * The string sockets array to resize. - * - * @return - * Success from f_memory_array_decimate_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decimate_by(). - * - * @see f_memory_array_decimate_by() - */ -#ifndef _di_f_sockets_decimate_by_ - extern f_status_t f_sockets_decimate_by(const f_number_unsigned_t amount, f_sockets_t * const sockets); -#endif // _di_f_sockets_decimate_by_ - -/** - * Resize the string sockets array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to les than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param sockets - * The string sockets array to resize. - * - * @return - * Success from f_memory_array_decrease_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decrease_by(). - * - * @see f_memory_array_decrease_by() - */ -#ifndef _di_f_sockets_decrease_by_ - extern f_status_t f_sockets_decrease_by(const f_number_unsigned_t amount, f_sockets_t * const sockets); -#endif // _di_f_sockets_decrease_by_ - -/** - * Increase the size of the string sockets array, but only if necesary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param sockets - * The string sockets array to resize. - * - * @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() - */ -#ifndef _di_f_sockets_increase_ - extern f_status_t f_sockets_increase(const f_number_unsigned_t step, f_sockets_t * const sockets); -#endif // _di_f_sockets_increase_ - -/** - * Resize the string sockets 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 sockets - * The string sockets array to resize. - * - * @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() - */ -#ifndef _di_f_sockets_increase_by_ - extern f_status_t f_sockets_increase_by(const f_number_unsigned_t amount, f_sockets_t * const sockets); -#endif // _di_f_sockets_increase_by_ - -/** - * Resize the string sockets array. - * - * @param length - * The new size to use. - * @param sockets - * The string sockets array to adjust. - * - * @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() - */ -#ifndef _di_f_sockets_resize_ - extern f_status_t f_sockets_resize(const f_number_unsigned_t length, f_sockets_t * const sockets); -#endif // _di_f_sockets_resize_ - -/** - * Resize the string socketss array. - * - * @param length - * The new size to use. - * @param socketss - * The string socketss array to resize. + * Commonly used socket related properties, loosely based off of f_file_t. + * + * Properties: + * - id: Socket file descriptor, used for binding and listening. + * - id_data: Data file descriptor, used for reading and writing data from or to the socket. + * - domain: The socket domain (protocol family, such as f_socket_protocol_family_local_e). + * - protocol: The socket protocol (such as f_socket_protocol_tcp_e). + * - type: The socket type (address family, such as f_socket_address_family_local_e). + * + * - size_read: The default number of 1-byte characters to read at a time and is often used for the read buffer size. + * - size_write: The default number of 1-byte characters to read at a time and is often used for the write buffer size. + * + * - address: The socket address. + * - length: The length of the socket. + * + * - name: The name of the socket, if a name is given (for UNIX sockets this represents the path) (Must be a NULL terminated string). + * + * The clear and reset macros do not clear or reset the address (type f_socket_address_t) because the struct sockaddr is defined outside of the FLL project. + */ +#ifndef _di_f_socket_t_ + typedef struct { + int id; + int id_data; + int domain; + int protocol; + int type; + + size_t size_read; + size_t size_write; + + f_socket_address_t address; + socklen_t length; + + f_string_static_t name; + } f_socket_t; + + #define f_socket_t_initialize { -1, -1, 0, 0, 0, F_socket_default_read_size_d, F_socket_default_write_size_d, f_socket_address_t_initialize, 0, f_string_static_t_initialize } + + #define macro_f_socket_t_initialize_1(address, length) { \ + -1, \ + -1, \ + 0, \ + 0, \ + 0, \ + F_socket_default_read_size_d, \ + F_socket_default_write_size_d, \ + address, \ + length, \ + f_string_empty_s \ + } + + #define macro_f_socket_t_initialize_2(address, length, name) { \ + -1, \ + -1, \ + 0, \ + 0, \ + 0, \ + F_socket_default_read_size_d, \ + F_socket_default_write_size_d, \ + address, \ + length, \ + name \ + } + + #define macro_f_socket_t_initialize_3(id, domain, protocol, type, address, length, name) { \ + id, \ + -1, \ + domain, \ + protocol, \ + type, \ + F_socket_default_read_size_d, \ + F_socket_default_write_size_d, \ + address, \ + length, \ + name \ + } + + #define macro_f_socket_t_initialize_4(id, domain, protocol, type, size_read, size_write, address, length, name) { \ + id, \ + -1, \ + domain, \ + protocol, \ + type, \ + size_read, \ + size_write, \ + address, \ + length, \ + name \ + } + + #define macro_f_socket_t_initialize_5(id, id_data, domain, protocol, type, size_read, size_write, address, length, name) { \ + id, \ + id_data, \ + domain, \ + protocol, \ + type, \ + size_read, \ + size_write, \ + address, \ + length, \ + name \ + } + + #define macro_f_socket_t_clear(file) \ + file.id = -1; \ + file.id_data = -1; \ + file.domain = 0; \ + file.protocol = 0; \ + file.type = 0; \ + file.size_read = 0; \ + file.size_write = 0; \ + file.length = 0; \ + macro_f_string_static_t_clear(file); + + #define macro_f_socket_t_reset(file) \ + file.id = -1; \ + file.id_data = -1; \ + file.domain = 0; \ + file.protocol = 0; \ + file.type = 0; \ + file.size_read = F_socket_default_read_size_d; \ + file.size_write = F_socket_default_write_size_d; \ + file.length = 0; \ + macro_f_string_static_t_clear(file); +#endif // _di_f_socket_t_ + +/** + * An array of f_socket_t. + * + * Properties: + * - array: The array of f_socket_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_sockets_t_ + typedef struct { + f_socket_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_sockets_t; + + #define f_sockets_t_initialize { 0, 0, 0 } + + #define macro_f_sockets_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_sockets_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_sockets_t_ + +/** + * This holds an array of f_sockets_t. + * + * Properties: + * - array: The array of f_socket_t arrays. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_socketss_t_ + typedef struct { + f_sockets_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_socketss_t; + + #define f_socketss_t_initialize { 0, 0, 0 } + + #define macro_f_socketss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_socketss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_socketss_t_ + +/** + * A callback intended to be passed to f_memory_arrays_resize() for an f_socketss_t structure. + * + * This is only called when shrinking the array and generally should perform deallocations. + * + * This does not do parameter checking. + * + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_okay on success. * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_adjust(). + * Errors (with error bit) from: f_string_dynamics_resize(). * - * @see f_memory_array_adjust() + * @see f_string_dynamics_resize() */ -#ifndef _di_f_socketss_adjust_ - extern f_status_t f_socketss_adjust(const f_number_unsigned_t length, f_socketss_t * const socketss); -#endif // _di_f_socketss_adjust_ +#ifndef _di_f_socketss_delete_callback_ + extern f_status_t f_socketss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_socketss_delete_callback_ /** - * Append the single source sockets onto the destination. - * - * @param source - * The source sockets to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_okay on success. - * F_data_not on success, but there is nothing to append (size == 0). + * A callback intended to be passed to f_memory_arrays_adjust() for an f_socketss_t structure. * - * Success from f_memory_array_resize(). + * This is only called when shrinking the array and generally should perform deallocations. * - * 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(). + * This does not do parameter checking. * - * @see f_memory_array_increase() - * @see f_memory_array_increase_by() - */ -#ifndef _di_f_socketss_append_ - extern f_status_t f_socketss_append(const f_sockets_t source, f_socketss_t * const destination); -#endif // _di_f_socketss_append_ - -/** - * Append the source socketss onto the destination. - * - * @param source - * The source socketss to append. - * @param destination - * The destination ranges the source is appended onto. + * @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 on success, but there is nothing to append (size == 0). - * - * Success from f_memory_array_resize(). - * - * 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() - */ -#ifndef _di_f_socketss_append_all_ - extern f_status_t f_socketss_append_all(const f_socketss_t source, f_socketss_t * const destination); -#endif // _di_f_socketss_append_all_ - -/** - * Resize the string socketss 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 socketss - * The string socketss array to resize. - * - * @return - * F_data_not on success, but the amount to decrease by is 0. - * - * Success from f_memory_array_decimate_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decimate_by(). - * - * @see f_memory_array_decimate_by() - */ -#ifndef _di_f_socketss_decimate_by_ - extern f_status_t f_socketss_decimate_by(const f_number_unsigned_t amount, f_socketss_t * const socketss); -#endif // _di_f_socketss_decimate_by_ - -/** - * Resize the string socketss 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 socketss - * The string socketss array to resize. - * - * @return - * F_data_not on success, but the amount to decrease by is 0. - * - * Success from f_memory_array_decrease_by(). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_array_decrease_by(). - * - * @see f_memory_array_decrease_by() - */ -#ifndef _di_f_socketss_decrease_by_ - extern f_status_t f_socketss_decrease_by(const f_number_unsigned_t amount, f_socketss_t * const socketss); -#endif // _di_f_socketss_decrease_by_ - -/** - * Increase the size of the string socketss 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 socketss - * The string socketss array to resize. - * - * @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() - */ -#ifndef _di_f_socketss_increase_ - extern f_status_t f_socketss_increase(const f_number_unsigned_t step, f_socketss_t * const socketss); -#endif // _di_f_socketss_increase_ - -/** - * Resize the string socketss 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 socketss - * The string socketss array to resize. - * - * @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() - */ -#ifndef _di_f_socketss_increase_by_ - extern f_status_t f_socketss_increase_by(const f_number_unsigned_t amount, f_socketss_t * const socketss); -#endif // _di_f_socketss_increase_by_ - -/** - * Resize the string socketss array. - * - * @param length - * The new size to use. - * @param socketss - * The string socketss array to adjust. - * - * @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_dynamics_adjust(). * - * @see f_memory_array_resize() + * @see f_string_dynamics_adjust() */ -#ifndef _di_f_socketss_resize_ - extern f_status_t f_socketss_resize(const f_number_unsigned_t length, f_socketss_t * const socketss); -#endif // _di_f_socketss_resize_ +#ifndef _di_f_socketss_destroy_callback_ + extern f_status_t f_socketss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_socketss_destroy_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_socket/data/build/settings b/level_0/f_socket/data/build/settings index d401687..801ce3f 100644 --- a/level_0/f_socket/data/build/settings +++ b/level_0/f_socket/data/build/settings @@ -32,9 +32,9 @@ build_language c build_libraries -lc build_libraries-individual -lf_memory -lf_string -build_sources_library socket.c socket/socket.c socket/private-socket.c +build_sources_library socket.c socket/address.c socket/socket.c -build_sources_headers socket.h socket/socket.h socket/common.h +build_sources_headers socket.h socket/address.h socket/socket.h socket/common.h build_script yes build_shared yes diff --git a/level_0/f_socket/data/build/settings-mocks b/level_0/f_socket/data/build/settings-mocks index 77b53fd..9643c14 100644 --- a/level_0/f_socket/data/build/settings-mocks +++ b/level_0/f_socket/data/build/settings-mocks @@ -30,9 +30,10 @@ build_language c build_libraries -lc build_libraries-individual -lf_memory -lf_string -build_sources_library socket.c socket/socket.c socket/private-socket.c ../../tests/unit/c/mock-socket.c +build_sources_library socket.c socket/address.c socket/socket.c +build_sources_library ../../tests/unit/c/mock-socket.c -build_sources_headers socket.h socket/socket.h socket/common.h +build_sources_headers socket.h socket/address.h socket/socket.h socket/common.h build_script yes build_shared yes @@ -61,6 +62,8 @@ flags-coverage --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ flags_library -fPIC # Inject mocks. +flags -Wl,--wrap=f_memory_array_adjust +flags -Wl,--wrap=f_memory_array_resize flags -Wl,--wrap=accept flags -Wl,--wrap=bind flags -Wl,--wrap=close diff --git a/level_0/f_socket/data/build/settings-tests b/level_0/f_socket/data/build/settings-tests index 1795ff7..e1e8e41 100644 --- a/level_0/f_socket/data/build/settings-tests +++ b/level_0/f_socket/data/build/settings-tests @@ -26,8 +26,8 @@ build_libraries -lc -lcmocka build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_socket build_sources_program test-socket-accept.c test-socket-bind.c test-socket-bind_inet4.c test-socket-bind_inet6.c test-socket-bind_local.c test-socket-connect.c test-socket-create.c test-socket-create_pair.c test-socket-disconnect.c test-socket-listen.c test-socket-name_host.c test-socket-name_peer.c test-socket-option_get.c test-socket-option_set.c test-socket-read.c test-socket-read_message.c test-socket-read_stream.c test-socket-write.c test-socket-write_message.c test-socket-write_stream.c -build_sources_program test-socket-sockets_adjust.c test-socket-sockets_append.c test-socket-sockets_append_all.c test-socket-sockets_decimate_by.c test-socket-sockets_decrease_by.c test-socket-sockets_increase.c test-socket-sockets_increase_by.c test-socket-sockets_resize.c -build_sources_program test-socket-socketss_adjust.c test-socket-socketss_append.c test-socket-socketss_append_all.c test-socket-socketss_decimate_by.c test-socket-socketss_decrease_by.c test-socket-socketss_increase.c test-socket-socketss_increase_by.c test-socket-socketss_resize.c +build_sources_program test-socket-addressss_delete_callback.c test-socket-addressss_destroy_callback.c +build_sources_program test-socket-ss_delete_callback.c test-socket-ss_destroy_callback.c build_sources_program test-socket.c diff --git a/level_0/f_socket/tests/unit/c/mock-socket.c b/level_0/f_socket/tests/unit/c/mock-socket.c index efe49b8..a57d82f 100644 --- a/level_0/f_socket/tests/unit/c/mock-socket.c +++ b/level_0/f_socket/tests/unit/c/mock-socket.c @@ -4,6 +4,43 @@ 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); +} + int __wrap_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { const bool failure = mock_type(bool); diff --git a/level_0/f_socket/tests/unit/c/mock-socket.h b/level_0/f_socket/tests/unit/c/mock-socket.h index 8cbabb7..2329458 100644 --- a/level_0/f_socket/tests/unit/c/mock-socket.h +++ b/level_0/f_socket/tests/unit/c/mock-socket.h @@ -28,24 +28,33 @@ extern "C" { const static int mock_errno_generic = 32767; -int __wrap_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); -int __wrap_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -int __wrap_close(int fd); -int __wrap_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -int __wrap_gethostname(char *name, size_t len); -int __wrap_getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen); -int __wrap_getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); -int __wrap_listen(int sockfd, int backlog); -ssize_t __wrap_recv(int sockfd, void *buf, size_t len, int flags); -ssize_t __wrap_recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); -ssize_t __wrap_recvmsg(int sockfd, struct msghdr *msg, int flags); -ssize_t __wrap_send(int sockfd, const void *buf, size_t len, int flags); -ssize_t __wrap_sendmsg(int sockfd, const struct msghdr *msg, int flags); -ssize_t __wrap_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); -int __wrap_setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); -int __wrap_shutdown(int sockfd, int how); -int __wrap_socket(int domain, int type, int protocol); -int __wrap_socketpair(int domain, int type, int protocol, int sv[2]); +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); + +extern int __wrap_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); +extern int __wrap_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +extern int __wrap_close(int fd); +extern int __wrap_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +extern int __wrap_gethostname(char *name, size_t len); +extern int __wrap_getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen); +extern int __wrap_getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); +extern int __wrap_listen(int sockfd, int backlog); +extern ssize_t __wrap_recv(int sockfd, void *buf, size_t len, int flags); +extern ssize_t __wrap_recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); +extern ssize_t __wrap_recvmsg(int sockfd, struct msghdr *msg, int flags); +extern ssize_t __wrap_send(int sockfd, const void *buf, size_t len, int flags); +extern ssize_t __wrap_sendmsg(int sockfd, const struct msghdr *msg, int flags); +extern ssize_t __wrap_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); +extern int __wrap_setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); +extern int __wrap_shutdown(int sockfd, int how); +extern int __wrap_socket(int domain, int type, int protocol); +extern int __wrap_socketpair(int domain, int type, int protocol, int sv[2]); #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_socket/tests/unit/c/test-socket-addressss_delete_callback.c b/level_0/f_socket/tests/unit/c/test-socket-addressss_delete_callback.c new file mode 100644 index 0000000..76df482 --- /dev/null +++ b/level_0/f_socket/tests/unit/c/test-socket-addressss_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-socket.h" +#include "test-socket-addressss_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_socket_addressss_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_socket_address_t data = f_socket_address_t_initialize; + f_socket_address_t data_array[] = { data }; + f_socket_addresss_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_socket_addresss_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_socket_addressss_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_socket_addressss_delete_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_socket_addressss_t datass = f_socket_addressss_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_socket_addresss_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_socket_address_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_socket_addressss_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_socket/tests/unit/c/test-socket-addressss_delete_callback.h b/level_0/f_socket/tests/unit/c/test-socket-addressss_delete_callback.h new file mode 100644 index 0000000..ce30c8a --- /dev/null +++ b/level_0/f_socket/tests/unit/c/test-socket-addressss_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Socket + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_socket__addressss_delete_callback +#define _TEST__F_socket__addressss_delete_callback + +/** + * Test that the function fails. + * + * @see f_socket_addressss_delete_callback() + */ +extern void test__f_socket_addressss_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_socket_addressss_delete_callback() + */ +extern void test__f_socket_addressss_delete_callback__works(void **state); + +#endif // _TEST__F_socket__addressss_delete_callback diff --git a/level_0/f_socket/tests/unit/c/test-socket-addressss_destroy_callback.c b/level_0/f_socket/tests/unit/c/test-socket-addressss_destroy_callback.c new file mode 100644 index 0000000..0494e5b --- /dev/null +++ b/level_0/f_socket/tests/unit/c/test-socket-addressss_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-socket.h" +#include "test-socket-addressss_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_socket_addressss_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_socket_address_t data = f_socket_address_t_initialize; + f_socket_address_t data_array[] = { data }; + f_socket_addresss_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_socket_addresss_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_socket_addressss_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_socket_addressss_destroy_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_socket_addressss_t datass = f_socket_addressss_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_socket_addresss_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_socket_address_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_socket_addressss_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_socket/tests/unit/c/test-socket-addressss_destroy_callback.h b/level_0/f_socket/tests/unit/c/test-socket-addressss_destroy_callback.h new file mode 100644 index 0000000..6604023 --- /dev/null +++ b/level_0/f_socket/tests/unit/c/test-socket-addressss_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Socket + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_socket__addressss_destroy_callback +#define _TEST__F_socket__addressss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_socket_addressss_destroy_callback() + */ +extern void test__f_socket_addressss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_socket_addressss_destroy_callback() + */ +extern void test__f_socket_addressss_destroy_callback__works(void **state); + +#endif // _TEST__F_socket__addressss_destroy_callback diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_adjust.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_adjust.c deleted file mode 100644 index 6db60d4..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-socket.h" -#include "test-socket-sockets_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_sockets_adjust__parameter_checking(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_sockets_adjust__works(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_adjust.h b/level_0/f_socket/tests/unit/c/test-socket-sockets_adjust.h deleted file mode 100644 index 1d59f2e..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__sockets_adjust -#define _TEST__F_socket__sockets_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_sockets_adjust() - */ -extern void test__f_socket_sockets_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_sockets_adjust() - */ -extern void test__f_socket_sockets_adjust__works(void **state); - -#endif // _TEST__F_socket__sockets_adjust diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_append.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_append.c deleted file mode 100644 index 9f1acd3..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_append.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "test-socket.h" -#include "test-socket-sockets_append.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_sockets_append__parameter_checking(void **state) { - - const f_socket_t data = f_socket_t_initialize; - - { - const f_status_t status = f_sockets_append(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_socket_sockets_append__works(void **state) { - - f_string_static_t test = macro_f_string_static_t_initialize_1("test", 0, 4); - const f_socket_t source = macro_f_socket_t_initialize_3(1, 2, 3, 4, f_socket_address_t_initialize, 0, test); - f_sockets_t destination = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_append(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, 1); - assert_int_equal(destination.array[0].id, source.id); - assert_int_equal(destination.array[0].domain, source.domain); - assert_int_equal(destination.array[0].protocol, source.protocol); - assert_int_equal(destination.array[0].type, source.type); - assert_int_equal(destination.array[0].name.used, source.name.used); - - assert_string_equal(destination.array[0].name.string, source.name.string); - } - - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_append.h b/level_0/f_socket/tests/unit/c/test-socket-sockets_append.h deleted file mode 100644 index 6bbfce2..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_append.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__sockets_append -#define _TEST__F_socket__sockets_append - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_sockets_append() - */ -extern void test__f_socket_sockets_append__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_sockets_append() - */ -extern void test__f_socket_sockets_append__works(void **state); - -#endif // _TEST__F_socket__sockets_append diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.c deleted file mode 100644 index e256556..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.c +++ /dev/null @@ -1,101 +0,0 @@ -#include "test-socket.h" -#include "test-socket-sockets_append_all.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_sockets_append_all__parameter_checking(void **state) { - - const f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_append_all(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_socket_sockets_append_all__returns_data_not(void **state) { - - const int length = 5; - f_sockets_t source = f_sockets_t_initialize; - f_sockets_t destination = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_sockets_append_all(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_socket_sockets_append_all__works(void **state) { - - const int length = 5; - const int length_used = 2; - - f_string_static_t tests[] = { - macro_f_string_static_t_initialize_1("test_1", 0, 6), - macro_f_string_static_t_initialize_1("test_2", 0, 6), - }; - - f_socket_t sources[] = { - macro_f_socket_t_initialize_3(1, 2, 3, 4, f_socket_address_t_initialize, 0, tests[0]), - macro_f_socket_t_initialize_3(5, 6, 7, 8, f_socket_address_t_initialize, 0, tests[1]), - }; - - f_sockets_t source = f_sockets_t_initialize; - f_sockets_t destination = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length_used; ++source.used) { - source.array[source.used] = sources[source.used]; - //memcpy((void *) &source.array[source.used], (void *) &sources[source.used], sizeof(f_sockets_t)); - } // for - - { - const f_status_t status = f_sockets_append_all(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - - assert_int_equal(destination.array[i].id, sources[i].id); - assert_int_equal(destination.array[i].domain, sources[i].domain); - assert_int_equal(destination.array[i].protocol, sources[i].protocol); - assert_int_equal(destination.array[i].type, sources[i].type); - assert_int_equal(destination.array[i].name.used, sources[i].name.used); - - assert_string_equal(destination.array[i].name.string, sources[i].name.string); - } // for - } - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.h b/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.h deleted file mode 100644 index 6f0649b..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__sockets_append_all -#define _TEST__F_socket__sockets_append_all - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_sockets_append_all() - */ -extern void test__f_socket_sockets_append_all__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_sockets_append_all() - */ -extern void test__f_socket_sockets_append_all__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_sockets_append_all() - */ -extern void test__f_socket_sockets_append_all__works(void **state); - -#endif // _TEST__F_socket__sockets_append_all diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_decimate_by.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_decimate_by.c deleted file mode 100644 index 6b36e57..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_decimate_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-socket.h" -#include "test-socket-sockets_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_sockets_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_sockets_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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_sockets_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_socket_sockets_decimate_by__works(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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_sockets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_decimate_by.h b/level_0/f_socket/tests/unit/c/test-socket-sockets_decimate_by.h deleted file mode 100644 index e289854..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__sockets_decimate_by -#define _TEST__F_socket__sockets_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_sockets_decimate_by() - */ -extern void test__f_socket_sockets_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_sockets_decimate_by() - */ -extern void test__f_socket_sockets_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_sockets_decimate_by() - */ -extern void test__f_socket_sockets_decimate_by__works(void **state); - -#endif // _TEST__F_socket__sockets_decimate_by diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_decrease_by.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_decrease_by.c deleted file mode 100644 index 8910dea..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_decrease_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-socket.h" -#include "test-socket-sockets_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_sockets_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_sockets_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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_sockets_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_socket_sockets_decrease_by__works(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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_sockets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_decrease_by.h b/level_0/f_socket/tests/unit/c/test-socket-sockets_decrease_by.h deleted file mode 100644 index 9d1f1f9..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__sockets_decrease_by -#define _TEST__F_socket__sockets_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_sockets_decrease_by() - */ -extern void test__f_socket_sockets_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_sockets_decrease_by() - */ -extern void test__f_socket_sockets_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_sockets_decrease_by() - */ -extern void test__f_socket_sockets_decrease_by__works(void **state); - -#endif // _TEST__F_socket__sockets_decrease_by diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_increase.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_increase.c deleted file mode 100644 index d008c9a..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-socket.h" -#include "test-socket-sockets_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_sockets_increase__parameter_checking(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_socket_sockets_increase__returns_data_not(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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_sockets_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_socket_sockets_increase__works(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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_sockets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_increase.h b/level_0/f_socket/tests/unit/c/test-socket-sockets_increase.h deleted file mode 100644 index 1d60619..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__sockets_increase -#define _TEST__F_socket__sockets_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_sockets_increase() - */ -extern void test__f_socket_sockets_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_sockets_increase() - */ -extern void test__f_socket_sockets_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_sockets_increase() - */ -extern void test__f_socket_sockets_increase__works(void **state); - -#endif // _TEST__F_socket__sockets_increase diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_increase_by.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_increase_by.c deleted file mode 100644 index 8e86a71..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-socket.h" -#include "test-socket-sockets_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_sockets_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_sockets_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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_sockets_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_socket_sockets_increase_by__works(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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_sockets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_increase_by.h b/level_0/f_socket/tests/unit/c/test-socket-sockets_increase_by.h deleted file mode 100644 index 4a58726..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__sockets_increase_by -#define _TEST__F_socket__sockets_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_sockets_increase_by() - */ -extern void test__f_socket_sockets_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_sockets_increase_by() - */ -extern void test__f_socket_sockets_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_sockets_increase_by() - */ -extern void test__f_socket_sockets_increase_by__works(void **state); - -#endif // _TEST__F_socket__sockets_increase_by diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_resize.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_resize.c deleted file mode 100644 index bcbb025..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-socket.h" -#include "test-socket-sockets_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_sockets_resize__parameter_checking(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_sockets_resize__works(void **state) { - - const int length = 5; - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_sockets_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_resize.h b/level_0/f_socket/tests/unit/c/test-socket-sockets_resize.h deleted file mode 100644 index 3065bc9..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__sockets_resize -#define _TEST__F_socket__sockets_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_sockets_resize() - */ -extern void test__f_socket_sockets_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_sockets_resize() - */ -extern void test__f_socket_sockets_resize__works(void **state); - -#endif // _TEST__F_socket__sockets_resize diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_adjust.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_adjust.c deleted file mode 100644 index 566a3bd..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-socket.h" -#include "test-socket-socketss_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_socketss_adjust__parameter_checking(void **state) { - - const int length = 5; - f_socketss_t data = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_socketss_adjust__works(void **state) { - - const int length = 5; - f_socketss_t data = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_adjust.h b/level_0/f_socket/tests/unit/c/test-socket-socketss_adjust.h deleted file mode 100644 index 847c212..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_adjust.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__socketss_adjust -#define _TEST__F_socket__socketss_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_socketss_adjust() - */ -extern void test__f_socket_socketss_adjust__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_socketss_increase_by() - */ -extern void test__f_socket_socketss_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_socketss_adjust() - */ -extern void test__f_socket_socketss_adjust__works(void **state); - -#endif // _TEST__F_socket__socketss_adjust diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_append.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_append.c deleted file mode 100644 index 23a10fb..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_append.c +++ /dev/null @@ -1,110 +0,0 @@ -#include "test-socket.h" -#include "test-socket-socketss_append.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_socketss_append__parameter_checking(void **state) { - - f_sockets_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_append(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_socket_socketss_append__returns_data_not(void **state) { - - const int length = 5; - f_sockets_t source = f_sockets_t_initialize; - f_socketss_t destination = f_socketss_t_initialize; - - { - const f_status_t status = f_sockets_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_socketss_append(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_socket_socketss_append__works(void **state) { - - const int length = 5; - - f_string_static_t tests[] = { - macro_f_string_static_t_initialize_1("test_1", 0, 6), - macro_f_string_static_t_initialize_1("test_2", 0, 6), - macro_f_string_static_t_initialize_1("test_3", 0, 6), - macro_f_string_static_t_initialize_1("test_4", 0, 6), - macro_f_string_static_t_initialize_1("test_5", 0, 6), - }; - - f_socket_t sources[] = { - macro_f_socket_t_initialize_3(1, 2, 3, 4, f_socket_address_t_initialize, 0, tests[0]), - macro_f_socket_t_initialize_3(5, 6, 7, 8, f_socket_address_t_initialize, 0, tests[1]), - macro_f_socket_t_initialize_3(9, 10, 11, 12, f_socket_address_t_initialize, 0, tests[2]), - macro_f_socket_t_initialize_3(13, 14, 15, 16, f_socket_address_t_initialize, 0, tests[3]), - macro_f_socket_t_initialize_3(17, 18, 19, 20, f_socket_address_t_initialize, 0, tests[4]), - }; - - f_sockets_t source = f_sockets_t_initialize; - f_socketss_t destination = f_socketss_t_initialize; - - { - const f_status_t status = f_sockets_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - for (; source.used < length; ++source.used) { - source.array[source.used] = sources[source.used]; - } // for - - { - const f_status_t status = f_socketss_append(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, 1); - assert_int_equal(destination.array[0].used, source.used); - assert_int_equal(destination.array[0].size, source.used); - - for (f_number_unsigned_t i = 0; i < destination.array[0].used; ++i) { - - assert_int_equal(destination.array[0].array[i].id, sources[i].id); - assert_int_equal(destination.array[0].array[i].domain, sources[i].domain); - assert_int_equal(destination.array[0].array[i].protocol, sources[i].protocol); - assert_int_equal(destination.array[0].array[i].type, sources[i].type); - assert_int_equal(destination.array[0].array[i].name.used, sources[i].name.used); - - assert_string_equal(destination.array[0].array[i].name.string, sources[i].name.string); - } // for - } - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - free((void *) destination.array[i].array); - } // for - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_append.h b/level_0/f_socket/tests/unit/c/test-socket-socketss_append.h deleted file mode 100644 index 1282cd8..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_append.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__socketss_append -#define _TEST__F_socket__socketss_append - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_socketss_append() - */ -extern void test__f_socket_socketss_append__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_socketss_append() - */ -extern void test__f_socket_socketss_append__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_socketss_append() - */ -extern void test__f_socket_socketss_append__works(void **state); - -#endif // _TEST__F_socket__socketss_append diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.c deleted file mode 100644 index d4ce3b0..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.c +++ /dev/null @@ -1,123 +0,0 @@ -#include "test-socket.h" -#include "test-socket-socketss_append_all.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_socketss_append_all__parameter_checking(void **state) { - - const f_socketss_t data = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_append_all(data, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - -void test__f_socket_socketss_append_all__returns_data_not(void **state) { - - const int length = 5; - f_socketss_t source = f_socketss_t_initialize; - f_socketss_t destination = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - const f_status_t status = f_socketss_append_all(source, &destination); - - assert_int_equal(status, F_data_not); - assert_int_equal(destination.used, 0); - assert_int_equal(destination.size, 0); - assert_null(destination.array); - } - - free((void *) source.array); -} - -void test__f_socket_socketss_append_all__works(void **state) { - - const int length = 5; - const int length_inner = 2; - - f_string_static_t tests[] = { - macro_f_string_static_t_initialize_1("test_1", 0, 6), - macro_f_string_static_t_initialize_1("test_2", 0, 6), - }; - - f_socket_t sources[] = { - macro_f_socket_t_initialize_3(1, 2, 3, 4, f_socket_address_t_initialize, 0, tests[0]), - macro_f_socket_t_initialize_3(5, 6, 7, 8, f_socket_address_t_initialize, 0, tests[1]), - }; - - f_socketss_t source = f_socketss_t_initialize; - f_socketss_t destination = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_resize(length, &source); - - assert_int_equal(status, F_okay); - assert_int_equal(source.used, 0); - assert_int_equal(source.size, length); - } - - { - for (; source.used < length; ++source.used) { - - const f_status_t status = f_sockets_resize(length_inner, &source.array[source.used]); - - assert_int_equal(status, F_okay); - - for (f_number_unsigned_t i = 0; i < length_inner; ++i) { - source.array[source.used].array[source.array[source.used].used++] = sources[i]; - } // for - } // for - } - - { - const f_status_t status = f_socketss_append_all(source, &destination); - - assert_int_equal(status, F_okay); - assert_int_equal(destination.used, source.used); - assert_int_equal(destination.size, source.used); - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - - assert_int_equal(destination.array[i].used, length_inner); - assert_int_equal(destination.array[i].size, length_inner); - - for (f_number_unsigned_t j = 0; j < length_inner; ++j) { - - assert_int_equal(destination.array[i].array[j].id, sources[j].id); - assert_int_equal(destination.array[i].array[j].domain, sources[j].domain); - assert_int_equal(destination.array[i].array[j].protocol, sources[j].protocol); - assert_int_equal(destination.array[i].array[j].type, sources[j].type); - assert_int_equal(destination.array[i].array[j].name.used, sources[j].name.used); - - assert_string_equal(destination.array[i].array[j].name.string, sources[j].name.string); - } // for - } // for - } - - for (f_number_unsigned_t i = 0; i < source.used; ++i) { - free((void *) source.array[i].array); - } // for - - for (f_number_unsigned_t i = 0; i < destination.used; ++i) { - free((void *) destination.array[i].array); - } // for - - free((void *) source.array); - free((void *) destination.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.h b/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.h deleted file mode 100644 index c38eac9..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__socketss_append_all -#define _TEST__F_socket__socketss_append_all - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_socketss_append_all() - */ -extern void test__f_socket_socketss_append_all__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_socketss_append_all() - */ -extern void test__f_socket_socketss_append_all__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_socketss_append_all() - */ -extern void test__f_socket_socketss_append_all__works(void **state); - -#endif // _TEST__F_socket__socketss_append_all diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_decimate_by.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_decimate_by.c deleted file mode 100644 index 0fa2f61..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_decimate_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-socket.h" -#include "test-socket-socketss_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_socketss_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_socketss_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_socketss_t data = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_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_socketss_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_socket_socketss_decimate_by__works(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_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_socketss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_decimate_by.h b/level_0/f_socket/tests/unit/c/test-socket-socketss_decimate_by.h deleted file mode 100644 index f4bad75..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__socketss_decimate_by -#define _TEST__F_socket__socketss_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_socketss_decimate_by() - */ -extern void test__f_socket_socketss_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_socket_socketss_decimate_by() - */ -extern void test__f_socket_socketss_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_socketss_decimate_by() - */ -extern void test__f_socket_socketss_decimate_by__works(void **state); - -#endif // _TEST__F_socket__socketss_decimate_by diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_decrease_by.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_decrease_by.c deleted file mode 100644 index 1741b27..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_decrease_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-socket.h" -#include "test-socket-socketss_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_socketss_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_socketss_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_socketss_t data = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_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_socketss_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_socket_socketss_decrease_by__works(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_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_socketss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_decrease_by.h b/level_0/f_socket/tests/unit/c/test-socket-socketss_decrease_by.h deleted file mode 100644 index 9fe87f5..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__socketss_decrease_by -#define _TEST__F_socket__socketss_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_socketss_decrease_by() - */ -extern void test__f_socket_socketss_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_socketss_decrease_by() - */ -extern void test__f_socket_socketss_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_socketss_decrease_by() - */ -extern void test__f_socket_socketss_decrease_by__works(void **state); - -#endif // _TEST__F_socket__socketss_decrease_by diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_increase.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_increase.c deleted file mode 100644 index d54233b..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-socket.h" -#include "test-socket-socketss_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_socketss_increase__parameter_checking(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_socket_socketss_increase__returns_data_not(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_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_socketss_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_socket_socketss_increase__works(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_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_socketss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_increase.h b/level_0/f_socket/tests/unit/c/test-socket-socketss_increase.h deleted file mode 100644 index 9d3eb05..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__socketss_increase -#define _TEST__F_socket__socketss_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_socketss_increase() - */ -extern void test__f_socket_socketss_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_socketss_increase() - */ -extern void test__f_socket_socketss_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_socketss_increase() - */ -extern void test__f_socket_socketss_increase__works(void **state); - -#endif // _TEST__F_socket__socketss_increase diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_increase_by.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_increase_by.c deleted file mode 100644 index 0d80f80..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_increase_by.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "test-socket.h" -#include "test-socket-socketss_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_socketss_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_socketss_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_socketss_t data = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_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_socketss_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_socketss_increase_by(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_socket_socketss_increase_by__works(void **state) { - - const int length = 5; - f_socketss_t data = f_sockets_t_initialize; - - { - const f_status_t status = f_socketss_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_socketss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_increase_by.h b/level_0/f_socket/tests/unit/c/test-socket-socketss_increase_by.h deleted file mode 100644 index 540c8ef..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__socketss_increase_by -#define _TEST__F_socket__socketss_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_socketss_increase_by() - */ -extern void test__f_socket_socketss_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_socketss_increase_by() - */ -extern void test__f_socket_socketss_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_socketss_increase_by() - */ -extern void test__f_socket_socketss_increase_by__works(void **state); - -#endif // _TEST__F_socket__socketss_increase_by diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_resize.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_resize.c deleted file mode 100644 index dfb0f62..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-socket.h" -#include "test-socket-socketss_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_socket_socketss_resize__parameter_checking(void **state) { - - const int length = 5; - f_socketss_t data = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_socket_socketss_resize__works(void **state) { - - const int length = 5; - f_socketss_t data = f_socketss_t_initialize; - - { - const f_status_t status = f_socketss_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); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_resize.h b/level_0/f_socket/tests/unit/c/test-socket-socketss_resize.h deleted file mode 100644 index 5613a6e..0000000 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Socket - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_socket__socketss_resize -#define _TEST__F_socket__socketss_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_socketss_resize() - */ -extern void test__f_socket_socketss_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_socketss_resize() - */ -extern void test__f_socket_socketss_resize__works(void **state); - -#endif // _TEST__F_socket__socketss_resize diff --git a/level_0/f_socket/tests/unit/c/test-socket-ss_delete_callback.c b/level_0/f_socket/tests/unit/c/test-socket-ss_delete_callback.c new file mode 100644 index 0000000..1e19fff --- /dev/null +++ b/level_0/f_socket/tests/unit/c/test-socket-ss_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-socket.h" +#include "test-socket-ss_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_socket_ss_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_socket_t data = f_socket_t_initialize; + f_socket_t data_array[] = { data }; + f_sockets_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_sockets_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_socketss_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_socket_ss_delete_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_socketss_t datass = f_socketss_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_sockets_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_socket_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_socketss_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_socket/tests/unit/c/test-socket-ss_delete_callback.h b/level_0/f_socket/tests/unit/c/test-socket-ss_delete_callback.h new file mode 100644 index 0000000..3ebb1e7 --- /dev/null +++ b/level_0/f_socket/tests/unit/c/test-socket-ss_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Socket + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_socket__ss_delete_callback +#define _TEST__F_socket__ss_delete_callback + +/** + * Test that the function fails. + * + * @see f_socketss_delete_callback() + */ +extern void test__f_socket_ss_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_socketss_delete_callback() + */ +extern void test__f_socket_ss_delete_callback__works(void **state); + +#endif // _TEST__F_socket__ss_delete_callback diff --git a/level_0/f_socket/tests/unit/c/test-socket-ss_destroy_callback.c b/level_0/f_socket/tests/unit/c/test-socket-ss_destroy_callback.c new file mode 100644 index 0000000..0a84229 --- /dev/null +++ b/level_0/f_socket/tests/unit/c/test-socket-ss_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-socket.h" +#include "test-socket-ss_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_socket_ss_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_socket_t data = f_socket_t_initialize; + f_socket_t data_array[] = { data }; + f_sockets_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_sockets_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_socketss_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_socket_ss_destroy_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_unsigned_t length = 1; + + f_socketss_t datass = f_socketss_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_sockets_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_socket_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_socketss_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_socket/tests/unit/c/test-socket-ss_destroy_callback.h b/level_0/f_socket/tests/unit/c/test-socket-ss_destroy_callback.h new file mode 100644 index 0000000..e6f783e --- /dev/null +++ b/level_0/f_socket/tests/unit/c/test-socket-ss_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Socket + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_socket__ss_destroy_callback +#define _TEST__F_socket__ss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_socketss_destroy_callback() + */ +extern void test__f_socket_ss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_socketss_destroy_callback() + */ +extern void test__f_socket_ss_destroy_callback__works(void **state); + +#endif // _TEST__F_socket__ss_destroy_callback diff --git a/level_0/f_socket/tests/unit/c/test-socket.c b/level_0/f_socket/tests/unit/c/test-socket.c index 3c0a00a..a8f8e63 100644 --- a/level_0/f_socket/tests/unit/c/test-socket.c +++ b/level_0/f_socket/tests/unit/c/test-socket.c @@ -85,36 +85,17 @@ int main(void) { cmocka_unit_test(test__f_socket_write_stream__fails), cmocka_unit_test(test__f_socket_write_stream__works), - cmocka_unit_test(test__f_socket_sockets_append_all__returns_data_not), - cmocka_unit_test(test__f_socket_sockets_decimate_by__returns_data_not), - cmocka_unit_test(test__f_socket_sockets_decrease_by__returns_data_not), - cmocka_unit_test(test__f_socket_sockets_increase__returns_data_not), - cmocka_unit_test(test__f_socket_sockets_increase_by__returns_data_not), - - cmocka_unit_test(test__f_socket_sockets_adjust__works), - cmocka_unit_test(test__f_socket_sockets_append__works), - cmocka_unit_test(test__f_socket_sockets_append_all__works), - cmocka_unit_test(test__f_socket_sockets_decimate_by__works), - cmocka_unit_test(test__f_socket_sockets_decrease_by__works), - cmocka_unit_test(test__f_socket_sockets_increase__works), - cmocka_unit_test(test__f_socket_sockets_increase_by__works), - cmocka_unit_test(test__f_socket_sockets_resize__works), - - cmocka_unit_test(test__f_socket_socketss_append__returns_data_not), - cmocka_unit_test(test__f_socket_socketss_append_all__returns_data_not), - cmocka_unit_test(test__f_socket_socketss_decimate_by__returns_data_not), - cmocka_unit_test(test__f_socket_socketss_decrease_by__returns_data_not), - cmocka_unit_test(test__f_socket_socketss_increase__returns_data_not), - cmocka_unit_test(test__f_socket_socketss_increase_by__returns_data_not), - - cmocka_unit_test(test__f_socket_socketss_adjust__works), - cmocka_unit_test(test__f_socket_socketss_append__works), - cmocka_unit_test(test__f_socket_socketss_append_all__works), - cmocka_unit_test(test__f_socket_socketss_decimate_by__works), - cmocka_unit_test(test__f_socket_socketss_decrease_by__works), - cmocka_unit_test(test__f_socket_socketss_increase__works), - cmocka_unit_test(test__f_socket_socketss_increase_by__works), - cmocka_unit_test(test__f_socket_socketss_resize__works), + cmocka_unit_test(test__f_socket_addressss_destroy_callback__fails), + cmocka_unit_test(test__f_socket_addressss_delete_callback__fails), + + cmocka_unit_test(test__f_socket_addressss_delete_callback__works), + cmocka_unit_test(test__f_socket_addressss_destroy_callback__works), + + cmocka_unit_test(test__f_socket_ss_destroy_callback__fails), + cmocka_unit_test(test__f_socket_ss_delete_callback__fails), + + cmocka_unit_test(test__f_socket_ss_delete_callback__works), + cmocka_unit_test(test__f_socket_ss_destroy_callback__works), #ifndef _di_level_0_parameter_checking_ cmocka_unit_test(test__f_socket_accept__parameter_checking), @@ -137,23 +118,11 @@ int main(void) { cmocka_unit_test(test__f_socket_write_message__parameter_checking), cmocka_unit_test(test__f_socket_write_stream__parameter_checking), - cmocka_unit_test(test__f_socket_sockets_adjust__parameter_checking), - cmocka_unit_test(test__f_socket_sockets_append__parameter_checking), - cmocka_unit_test(test__f_socket_sockets_append_all__parameter_checking), - cmocka_unit_test(test__f_socket_sockets_decimate_by__parameter_checking), - cmocka_unit_test(test__f_socket_sockets_decrease_by__parameter_checking), - cmocka_unit_test(test__f_socket_sockets_increase__parameter_checking), - cmocka_unit_test(test__f_socket_sockets_increase_by__parameter_checking), - cmocka_unit_test(test__f_socket_sockets_resize__parameter_checking), - - cmocka_unit_test(test__f_socket_socketss_adjust__parameter_checking), - cmocka_unit_test(test__f_socket_socketss_append__parameter_checking), - cmocka_unit_test(test__f_socket_socketss_append_all__parameter_checking), - cmocka_unit_test(test__f_socket_socketss_decimate_by__parameter_checking), - cmocka_unit_test(test__f_socket_socketss_decrease_by__parameter_checking), - cmocka_unit_test(test__f_socket_socketss_increase__parameter_checking), - cmocka_unit_test(test__f_socket_socketss_increase_by__parameter_checking), - cmocka_unit_test(test__f_socket_socketss_resize__parameter_checking), + // f_socket_addressss_destroy_callback() doesn't use parameter checking. + // f_socket_addressss_delete_callback() doesn't use parameter checking. + + // f_socket_ss_destroy_callback() doesn't use parameter checking. + // f_socket_ss_delete_callback() doesn't use parameter checking. #endif // _di_level_0_parameter_checking_ }; diff --git a/level_0/f_socket/tests/unit/c/test-socket.h b/level_0/f_socket/tests/unit/c/test-socket.h index 681ad71..db42327 100644 --- a/level_0/f_socket/tests/unit/c/test-socket.h +++ b/level_0/f_socket/tests/unit/c/test-socket.h @@ -27,6 +27,8 @@ // Test includes. #include "test-socket-accept.h" +#include "test-socket-addressss_delete_callback.h" +#include "test-socket-addressss_destroy_callback.h" #include "test-socket-bind.h" #include "test-socket-bind_inet4.h" #include "test-socket-bind_inet6.h" @@ -43,22 +45,8 @@ #include "test-socket-read.h" #include "test-socket-read_message.h" #include "test-socket-read_stream.h" -#include "test-socket-sockets_adjust.h" -#include "test-socket-sockets_append.h" -#include "test-socket-sockets_append_all.h" -#include "test-socket-sockets_decimate_by.h" -#include "test-socket-sockets_decrease_by.h" -#include "test-socket-sockets_increase.h" -#include "test-socket-sockets_increase_by.h" -#include "test-socket-sockets_resize.h" -#include "test-socket-socketss_adjust.h" -#include "test-socket-socketss_append.h" -#include "test-socket-socketss_append_all.h" -#include "test-socket-socketss_decimate_by.h" -#include "test-socket-socketss_decrease_by.h" -#include "test-socket-socketss_increase.h" -#include "test-socket-socketss_increase_by.h" -#include "test-socket-socketss_resize.h" +#include "test-socket-ss_delete_callback.h" +#include "test-socket-ss_destroy_callback.h" #include "test-socket-write.h" #include "test-socket-write_message.h" #include "test-socket-write_stream.h" -- 1.8.3.1