From 8b7925bfe07899a9b9a4ac7102e54119d24522f3 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 27 Mar 2022 23:30:30 -0500 Subject: [PATCH] Update: Bring f_utf project in sync with f_string. I have been explicitly avoiding making change to f_utf until I finished updating and successfully vetted the f_string project. Now that the f_string has tests that pass, mass update the f_utf project. This changes the functions and structure to be inline with how f_string works. Many of the fixes are brought over. I have observed that several of the bugs that were recently in f_string is also present in f_utf. These bugs in f_utf should now be fixed as well. This tests are brought over. Only the tests for functions that are shared between f_string and f_utf are implemented. And then those tests currently cannot be compiled. The reason is that normal quoted strings cannot be used with the special UTF dynamic strings. I simply did not have the time to get to this to finish writing these tests for f_utf. There are some parts of f_string that make no sense in f_utf, such as f_string_range_t and f_string_quantity_t (both of which can be used on f_string and f_utf strings). These have been omitted when copying the relevant f_string into f_utf code. --- build/level_0/settings | 6 +- build/monolithic/settings | 6 +- level_0/f_utf/c/utf.h | 4 +- level_0/f_utf/c/utf/dynamic.c | 584 ++++++++++++--------- level_0/f_utf/c/utf/dynamic.h | 544 ++++++++++++------- level_0/f_utf/c/utf/map.c | 270 ++++++---- level_0/f_utf/c/utf/map.h | 280 +++++----- level_0/f_utf/c/utf/map_multi.c | 305 +++++++++++ level_0/f_utf/c/utf/map_multi.h | 472 +++++++++++++++++ level_0/f_utf/c/utf/private-dynamic.c | 218 ++++++++ level_0/f_utf/c/utf/private-dynamic.h | 382 ++++++++++++++ level_0/f_utf/c/utf/private-map.c | 160 ++++++ level_0/f_utf/c/utf/private-map.h | 152 ++++++ level_0/f_utf/c/utf/private-map_multi.c | 160 ++++++ level_0/f_utf/c/utf/private-map_multi.h | 152 ++++++ level_0/f_utf/c/utf/private-string.c | 388 ++------------ level_0/f_utf/c/utf/private-string.h | 368 +------------ level_0/f_utf/c/utf/private-triple.c | 172 ++++++ level_0/f_utf/c/utf/private-triple.h | 152 ++++++ level_0/f_utf/c/utf/static.c | 13 + level_0/f_utf/c/utf/static.h | 115 ++++ level_0/f_utf/c/utf/string.c | 72 +-- level_0/f_utf/c/utf/string.h | 70 +-- level_0/f_utf/c/utf/triple.c | 224 +++++++- level_0/f_utf/c/utf/triple.h | 269 +++++++++- level_0/f_utf/data/build/settings | 4 +- level_0/f_utf/data/build/settings-tests | 71 +++ level_0/f_utf/data/build/testfile | 45 ++ level_0/f_utf/tests/unit/c/test-utf-append.c | 39 ++ level_0/f_utf/tests/unit/c/test-utf-append.h | 27 + .../f_utf/tests/unit/c/test-utf-append_assure.c | 50 ++ .../f_utf/tests/unit/c/test-utf-append_assure.h | 27 + .../tests/unit/c/test-utf-append_assure_nulless.c | 49 ++ .../tests/unit/c/test-utf-append_assure_nulless.h | 27 + .../f_utf/tests/unit/c/test-utf-append_nulless.c | 39 ++ .../f_utf/tests/unit/c/test-utf-append_nulless.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamic_adjust.c | 42 ++ .../f_utf/tests/unit/c/test-utf-dynamic_adjust.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamic_append.c | 39 ++ .../f_utf/tests/unit/c/test-utf-dynamic_append.h | 27 + .../tests/unit/c/test-utf-dynamic_append_assure.c | 50 ++ .../tests/unit/c/test-utf-dynamic_append_assure.h | 27 + .../c/test-utf-dynamic_append_assure_nulless.c | 49 ++ .../c/test-utf-dynamic_append_assure_nulless.h | 27 + .../tests/unit/c/test-utf-dynamic_append_nulless.c | 39 ++ .../tests/unit/c/test-utf-dynamic_append_nulless.h | 27 + .../tests/unit/c/test-utf-dynamic_decimate_by.c | 50 ++ .../tests/unit/c/test-utf-dynamic_decimate_by.h | 27 + .../tests/unit/c/test-utf-dynamic_decrease_by.c | 50 ++ .../tests/unit/c/test-utf-dynamic_decrease_by.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamic_increase.c | 76 +++ .../f_utf/tests/unit/c/test-utf-dynamic_increase.h | 34 ++ .../tests/unit/c/test-utf-dynamic_increase_by.c | 52 ++ .../tests/unit/c/test-utf-dynamic_increase_by.h | 27 + level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.c | 54 ++ level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.h | 27 + .../tests/unit/c/test-utf-dynamic_mash_nulless.c | 52 ++ .../tests/unit/c/test-utf-dynamic_mash_nulless.h | 27 + level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.c | 54 ++ level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.h | 27 + .../tests/unit/c/test-utf-dynamic_mish_nulless.c | 52 ++ .../tests/unit/c/test-utf-dynamic_mish_nulless.h | 27 + .../tests/unit/c/test-utf-dynamic_partial_append.c | 42 ++ .../tests/unit/c/test-utf-dynamic_partial_append.h | 27 + .../c/test-utf-dynamic_partial_append_assure.c | 53 ++ .../c/test-utf-dynamic_partial_append_assure.h | 27 + ...est-utf-dynamic_partial_append_assure_nulless.c | 51 ++ ...est-utf-dynamic_partial_append_assure_nulless.h | 27 + .../c/test-utf-dynamic_partial_append_nulless.c | 41 ++ .../c/test-utf-dynamic_partial_append_nulless.h | 27 + .../tests/unit/c/test-utf-dynamic_partial_mash.c | 57 ++ .../tests/unit/c/test-utf-dynamic_partial_mash.h | 27 + .../unit/c/test-utf-dynamic_partial_mash_nulless.c | 54 ++ .../unit/c/test-utf-dynamic_partial_mash_nulless.h | 27 + .../tests/unit/c/test-utf-dynamic_partial_mish.c | 57 ++ .../tests/unit/c/test-utf-dynamic_partial_mish.h | 26 + .../unit/c/test-utf-dynamic_partial_mish_nulless.c | 54 ++ .../unit/c/test-utf-dynamic_partial_mish_nulless.h | 27 + .../unit/c/test-utf-dynamic_partial_prepend.c | 42 ++ .../unit/c/test-utf-dynamic_partial_prepend.h | 27 + .../c/test-utf-dynamic_partial_prepend_assure.c | 53 ++ .../c/test-utf-dynamic_partial_prepend_assure.h | 27 + ...st-utf-dynamic_partial_prepend_assure_nulless.c | 51 ++ ...st-utf-dynamic_partial_prepend_assure_nulless.h | 27 + .../c/test-utf-dynamic_partial_prepend_nulless.c | 41 ++ .../c/test-utf-dynamic_partial_prepend_nulless.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamic_prepend.c | 39 ++ .../f_utf/tests/unit/c/test-utf-dynamic_prepend.h | 27 + .../tests/unit/c/test-utf-dynamic_prepend_assure.c | 50 ++ .../tests/unit/c/test-utf-dynamic_prepend_assure.h | 27 + .../c/test-utf-dynamic_prepend_assure_nulless.c | 49 ++ .../c/test-utf-dynamic_prepend_assure_nulless.h | 27 + .../unit/c/test-utf-dynamic_prepend_nulless.c | 39 ++ .../unit/c/test-utf-dynamic_prepend_nulless.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamic_resize.c | 42 ++ .../f_utf/tests/unit/c/test-utf-dynamic_resize.h | 27 + .../tests/unit/c/test-utf-dynamic_seek_line.c | 82 +++ .../tests/unit/c/test-utf-dynamic_seek_line.h | 48 ++ .../tests/unit/c/test-utf-dynamic_seek_line_to.c | 104 ++++ .../tests/unit/c/test-utf-dynamic_seek_line_to.h | 55 ++ .../f_utf/tests/unit/c/test-utf-dynamic_seek_to.c | 87 +++ .../f_utf/tests/unit/c/test-utf-dynamic_seek_to.h | 48 ++ .../tests/unit/c/test-utf-dynamic_terminate.c | 69 +++ .../tests/unit/c/test-utf-dynamic_terminate.h | 34 ++ .../unit/c/test-utf-dynamic_terminate_after.c | 73 +++ .../unit/c/test-utf-dynamic_terminate_after.h | 34 ++ .../f_utf/tests/unit/c/test-utf-dynamics_adjust.c | 42 ++ .../f_utf/tests/unit/c/test-utf-dynamics_adjust.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamics_append.c | 41 ++ .../f_utf/tests/unit/c/test-utf-dynamics_append.h | 27 + .../tests/unit/c/test-utf-dynamics_append_all.c | 103 ++++ .../tests/unit/c/test-utf-dynamics_append_all.h | 34 ++ .../tests/unit/c/test-utf-dynamics_decimate_by.c | 50 ++ .../tests/unit/c/test-utf-dynamics_decimate_by.h | 27 + .../tests/unit/c/test-utf-dynamics_decrease_by.c | 50 ++ .../tests/unit/c/test-utf-dynamics_decrease_by.h | 27 + .../tests/unit/c/test-utf-dynamics_increase.c | 76 +++ .../tests/unit/c/test-utf-dynamics_increase.h | 34 ++ .../tests/unit/c/test-utf-dynamics_increase_by.c | 52 ++ .../tests/unit/c/test-utf-dynamics_increase_by.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamics_resize.c | 42 ++ .../f_utf/tests/unit/c/test-utf-dynamics_resize.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamicss_adjust.c | 42 ++ .../f_utf/tests/unit/c/test-utf-dynamicss_adjust.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamicss_append.c | 102 ++++ .../f_utf/tests/unit/c/test-utf-dynamicss_append.h | 34 ++ .../tests/unit/c/test-utf-dynamicss_append_all.c | 130 +++++ .../tests/unit/c/test-utf-dynamicss_append_all.h | 34 ++ .../tests/unit/c/test-utf-dynamicss_decimate_by.c | 50 ++ .../tests/unit/c/test-utf-dynamicss_decimate_by.h | 27 + .../tests/unit/c/test-utf-dynamicss_decrease_by.c | 50 ++ .../tests/unit/c/test-utf-dynamicss_decrease_by.h | 27 + .../tests/unit/c/test-utf-dynamicss_increase.c | 76 +++ .../tests/unit/c/test-utf-dynamicss_increase.h | 34 ++ .../tests/unit/c/test-utf-dynamicss_increase_by.c | 52 ++ .../tests/unit/c/test-utf-dynamicss_increase_by.h | 27 + .../f_utf/tests/unit/c/test-utf-dynamicss_resize.c | 42 ++ .../f_utf/tests/unit/c/test-utf-dynamicss_resize.h | 27 + .../tests/unit/c/test-utf-map_multis_adjust.c | 42 ++ .../tests/unit/c/test-utf-map_multis_adjust.h | 27 + .../tests/unit/c/test-utf-map_multis_append.c | 81 +++ .../tests/unit/c/test-utf-map_multis_append.h | 27 + .../tests/unit/c/test-utf-map_multis_append_all.c | 126 +++++ .../tests/unit/c/test-utf-map_multis_append_all.h | 34 ++ .../tests/unit/c/test-utf-map_multis_decimate_by.c | 50 ++ .../tests/unit/c/test-utf-map_multis_decimate_by.h | 27 + .../tests/unit/c/test-utf-map_multis_decrease_by.c | 50 ++ .../tests/unit/c/test-utf-map_multis_decrease_by.h | 27 + .../tests/unit/c/test-utf-map_multis_increase.c | 76 +++ .../tests/unit/c/test-utf-map_multis_increase.h | 34 ++ .../tests/unit/c/test-utf-map_multis_increase_by.c | 52 ++ .../tests/unit/c/test-utf-map_multis_increase_by.h | 27 + .../tests/unit/c/test-utf-map_multis_resize.c | 42 ++ .../tests/unit/c/test-utf-map_multis_resize.h | 27 + .../tests/unit/c/test-utf-map_multiss_adjust.c | 42 ++ .../tests/unit/c/test-utf-map_multiss_adjust.h | 27 + .../tests/unit/c/test-utf-map_multiss_append.c | 142 +++++ .../tests/unit/c/test-utf-map_multiss_append.h | 34 ++ .../tests/unit/c/test-utf-map_multiss_append_all.c | 169 ++++++ .../tests/unit/c/test-utf-map_multiss_append_all.h | 34 ++ .../unit/c/test-utf-map_multiss_decimate_by.c | 50 ++ .../unit/c/test-utf-map_multiss_decimate_by.h | 27 + .../unit/c/test-utf-map_multiss_decrease_by.c | 50 ++ .../unit/c/test-utf-map_multiss_decrease_by.h | 27 + .../tests/unit/c/test-utf-map_multiss_increase.c | 76 +++ .../tests/unit/c/test-utf-map_multiss_increase.h | 34 ++ .../unit/c/test-utf-map_multiss_increase_by.c | 52 ++ .../unit/c/test-utf-map_multiss_increase_by.h | 27 + .../tests/unit/c/test-utf-map_multiss_resize.c | 42 ++ .../tests/unit/c/test-utf-map_multiss_resize.h | 27 + level_0/f_utf/tests/unit/c/test-utf-maps_adjust.c | 42 ++ level_0/f_utf/tests/unit/c/test-utf-maps_adjust.h | 27 + level_0/f_utf/tests/unit/c/test-utf-maps_append.c | 63 +++ level_0/f_utf/tests/unit/c/test-utf-maps_append.h | 27 + .../f_utf/tests/unit/c/test-utf-maps_append_all.c | 112 ++++ .../f_utf/tests/unit/c/test-utf-maps_append_all.h | 34 ++ .../f_utf/tests/unit/c/test-utf-maps_decimate_by.c | 50 ++ .../f_utf/tests/unit/c/test-utf-maps_decimate_by.h | 27 + .../f_utf/tests/unit/c/test-utf-maps_decrease_by.c | 50 ++ .../f_utf/tests/unit/c/test-utf-maps_decrease_by.h | 27 + .../f_utf/tests/unit/c/test-utf-maps_increase.c | 76 +++ .../f_utf/tests/unit/c/test-utf-maps_increase.h | 34 ++ .../f_utf/tests/unit/c/test-utf-maps_increase_by.c | 52 ++ .../f_utf/tests/unit/c/test-utf-maps_increase_by.h | 27 + level_0/f_utf/tests/unit/c/test-utf-maps_resize.c | 42 ++ level_0/f_utf/tests/unit/c/test-utf-maps_resize.h | 27 + level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.c | 42 ++ level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.h | 27 + level_0/f_utf/tests/unit/c/test-utf-mapss_append.c | 120 +++++ level_0/f_utf/tests/unit/c/test-utf-mapss_append.h | 34 ++ .../f_utf/tests/unit/c/test-utf-mapss_append_all.c | 147 ++++++ .../f_utf/tests/unit/c/test-utf-mapss_append_all.h | 34 ++ .../tests/unit/c/test-utf-mapss_decimate_by.c | 50 ++ .../tests/unit/c/test-utf-mapss_decimate_by.h | 27 + .../tests/unit/c/test-utf-mapss_decrease_by.c | 50 ++ .../tests/unit/c/test-utf-mapss_decrease_by.h | 27 + .../f_utf/tests/unit/c/test-utf-mapss_increase.c | 76 +++ .../f_utf/tests/unit/c/test-utf-mapss_increase.h | 34 ++ .../tests/unit/c/test-utf-mapss_increase_by.c | 52 ++ .../tests/unit/c/test-utf-mapss_increase_by.h | 27 + level_0/f_utf/tests/unit/c/test-utf-mapss_resize.c | 42 ++ level_0/f_utf/tests/unit/c/test-utf-mapss_resize.h | 27 + level_0/f_utf/tests/unit/c/test-utf-mash.c | 54 ++ level_0/f_utf/tests/unit/c/test-utf-mash.h | 27 + level_0/f_utf/tests/unit/c/test-utf-mash_nulless.c | 52 ++ level_0/f_utf/tests/unit/c/test-utf-mash_nulless.h | 27 + level_0/f_utf/tests/unit/c/test-utf-mish.c | 54 ++ level_0/f_utf/tests/unit/c/test-utf-mish.h | 27 + level_0/f_utf/tests/unit/c/test-utf-mish_nulless.c | 52 ++ level_0/f_utf/tests/unit/c/test-utf-mish_nulless.h | 27 + level_0/f_utf/tests/unit/c/test-utf-prepend.c | 39 ++ level_0/f_utf/tests/unit/c/test-utf-prepend.h | 27 + .../f_utf/tests/unit/c/test-utf-prepend_assure.c | 50 ++ .../f_utf/tests/unit/c/test-utf-prepend_assure.h | 27 + .../tests/unit/c/test-utf-prepend_assure_nulless.c | 49 ++ .../tests/unit/c/test-utf-prepend_assure_nulless.h | 27 + .../f_utf/tests/unit/c/test-utf-prepend_nulless.c | 39 ++ .../f_utf/tests/unit/c/test-utf-prepend_nulless.h | 27 + level_0/f_utf/tests/unit/c/test-utf-seek_line.c | 66 +++ level_0/f_utf/tests/unit/c/test-utf-seek_line.h | 41 ++ level_0/f_utf/tests/unit/c/test-utf-seek_line_to.c | 87 +++ level_0/f_utf/tests/unit/c/test-utf-seek_line_to.h | 48 ++ level_0/f_utf/tests/unit/c/test-utf-seek_to.c | 70 +++ level_0/f_utf/tests/unit/c/test-utf-seek_to.h | 41 ++ .../f_utf/tests/unit/c/test-utf-triples_adjust.c | 42 ++ .../f_utf/tests/unit/c/test-utf-triples_adjust.h | 27 + .../f_utf/tests/unit/c/test-utf-triples_append.c | 50 ++ .../f_utf/tests/unit/c/test-utf-triples_append.h | 27 + .../tests/unit/c/test-utf-triples_append_all.c | 96 ++++ .../tests/unit/c/test-utf-triples_append_all.h | 34 ++ .../tests/unit/c/test-utf-triples_decimate_by.c | 50 ++ .../tests/unit/c/test-utf-triples_decimate_by.h | 27 + .../tests/unit/c/test-utf-triples_decrease_by.c | 50 ++ .../tests/unit/c/test-utf-triples_decrease_by.h | 27 + .../f_utf/tests/unit/c/test-utf-triples_increase.c | 76 +++ .../f_utf/tests/unit/c/test-utf-triples_increase.h | 34 ++ .../tests/unit/c/test-utf-triples_increase_by.c | 52 ++ .../tests/unit/c/test-utf-triples_increase_by.h | 27 + .../f_utf/tests/unit/c/test-utf-triples_resize.c | 42 ++ .../f_utf/tests/unit/c/test-utf-triples_resize.h | 27 + .../f_utf/tests/unit/c/test-utf-tripless_adjust.c | 42 ++ .../f_utf/tests/unit/c/test-utf-tripless_adjust.h | 27 + .../f_utf/tests/unit/c/test-utf-tripless_append.c | 96 ++++ .../f_utf/tests/unit/c/test-utf-tripless_append.h | 34 ++ .../tests/unit/c/test-utf-tripless_append_all.c | 122 +++++ .../tests/unit/c/test-utf-tripless_append_all.h | 34 ++ .../tests/unit/c/test-utf-tripless_decimate_by.c | 50 ++ .../tests/unit/c/test-utf-tripless_decimate_by.h | 27 + .../tests/unit/c/test-utf-tripless_decrease_by.c | 50 ++ .../tests/unit/c/test-utf-tripless_decrease_by.h | 27 + .../tests/unit/c/test-utf-tripless_increase.c | 76 +++ .../tests/unit/c/test-utf-tripless_increase.h | 34 ++ .../tests/unit/c/test-utf-tripless_increase_by.c | 52 ++ .../tests/unit/c/test-utf-tripless_increase_by.h | 27 + .../f_utf/tests/unit/c/test-utf-tripless_resize.c | 42 ++ .../f_utf/tests/unit/c/test-utf-tripless_resize.h | 27 + level_0/f_utf/tests/unit/c/test-utf.c | 358 +++++++++++++ level_0/f_utf/tests/unit/c/test-utf.h | 185 +++++++ 258 files changed, 14926 insertions(+), 1506 deletions(-) create mode 100644 level_0/f_utf/c/utf/map_multi.c create mode 100644 level_0/f_utf/c/utf/map_multi.h create mode 100644 level_0/f_utf/c/utf/private-dynamic.c create mode 100644 level_0/f_utf/c/utf/private-dynamic.h create mode 100644 level_0/f_utf/c/utf/private-map.c create mode 100644 level_0/f_utf/c/utf/private-map.h create mode 100644 level_0/f_utf/c/utf/private-map_multi.c create mode 100644 level_0/f_utf/c/utf/private-map_multi.h create mode 100644 level_0/f_utf/c/utf/private-triple.c create mode 100644 level_0/f_utf/c/utf/private-triple.h create mode 100644 level_0/f_utf/c/utf/static.c create mode 100644 level_0/f_utf/c/utf/static.h create mode 100644 level_0/f_utf/data/build/settings-tests create mode 100644 level_0/f_utf/data/build/testfile create mode 100644 level_0/f_utf/tests/unit/c/test-utf-append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-append_assure.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-append_assure.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-append_assure_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-append_assure_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-append_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-append_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_append_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_append_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_mash_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_mash_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_mish_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_mish_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line_to.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line_to.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_to.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_to.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate_after.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate_after.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_append_all.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_append_all.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamics_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_append_all.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_append_all.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-dynamicss_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_append_all.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_append_all.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multis_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_append_all.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_append_all.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-map_multiss_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_append_all.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_append_all.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-maps_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_append_all.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_append_all.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mapss_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mash.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mash.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mash_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mash_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mish.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mish.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mish_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-mish_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-prepend.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-prepend.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-prepend_assure.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-prepend_assure.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-prepend_assure_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-prepend_assure_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-prepend_nulless.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-prepend_nulless.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-seek_line.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-seek_line.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-seek_line_to.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-seek_line_to.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-seek_to.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-seek_to.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_append_all.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_append_all.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-triples_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_adjust.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_adjust.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_append.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_append.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_append_all.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_append_all.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_decimate_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_decimate_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_decrease_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_decrease_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_increase.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_increase.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_increase_by.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_increase_by.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_resize.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf-tripless_resize.h create mode 100644 level_0/f_utf/tests/unit/c/test-utf.c create mode 100644 level_0/f_utf/tests/unit/c/test-utf.h diff --git a/build/level_0/settings b/build/level_0/settings index ccdc938..62764be 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -53,10 +53,10 @@ build_sources_library serialize.c private-serialize.c serialize/common.c build_sources_library signal.c build_sources_library socket.c build_sources_library status_string.c -build_sources_library string.c private-string.c string/common.c string/private-dynamic.c string/private-map.c string/private-map_multi.c string/private-quantity.c string/private-range.c string/private-triple.c string/dynamic.c string/map.c string/map_multi.c string/quantity.c string/range.c string/static.c string/triple.c +build_sources_library string.c private-string.c string/common.c string/dynamic.c string/map.c string/map_multi.c string/private-dynamic.c string/private-map.c string/private-map_multi.c string/private-quantity.c string/private-range.c string/private-triple.c string/quantity.c string/range.c string/static.c string/triple.c build_sources_library type_array/array_length.c type_array/cell.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c build_sources_library type_array/private-array_length.c type_array/private-cell.c type_array/private-fll_id.c type_array/private-int8.c type_array/private-int16.c type_array/private-int32.c type_array/private-int64.c type_array/private-int128.c type_array/private-state.c type_array/private-status.c type_array/private-uint8.c type_array/private-uint16.c type_array/private-uint32.c type_array/private-uint64.c type_array/private-uint128.c -build_sources_library utf.c private-utf.c utf/common.c utf/convert.c utf/dynamic.c utf/is.c utf/is_character.c utf/map.c utf/private-is_unassigned.c utf/private-string.c utf/string.c utf/triple.c +build_sources_library utf.c private-utf.c utf/common.c utf/convert.c utf/dynamic.c utf/is.c utf/is_character.c utf/map.c utf/private-dynamic.c utf/private-map.c utf/private-map_multi.c utf/private-triple.c utf/private-is_unassigned.c utf/private-string.c utf/static.c utf/string.c utf/triple.c build_sources_library-level thread.c private-thread.c build_sources_library_shared build_sources_library_static @@ -92,7 +92,7 @@ build_sources_headers string.h string/common.h string/dynamic.h string/map.h str build_sources_headers type.h build_sources_headers type_array.h type_array/common.h build_sources_headers type_array/array_length.h type_array/cell.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h -build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/is.h utf/is_character.h utf/map.h utf/string.h utf/triple.h +build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/is.h utf/is_character.h utf/map.h utf/map_multi.h utf/static.h utf/string.h utf/triple.h build_sources_headers-level thread.h thread/common.h build_sources_headers_shared build_sources_headers_static diff --git a/build/monolithic/settings b/build/monolithic/settings index 2301b60..678f01e 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -53,10 +53,10 @@ build_sources_library level_0/serialize.c level_0/private-serialize.c level_0/se build_sources_library level_0/signal.c build_sources_library level_0/socket.c build_sources_library level_0/status_string.c -build_sources_library level_0/string.c level_0/private-string.c level_0/string/common.c level_0/string/private-dynamic.c level_0/string/private-map.c level_0/string/private-map_multi.c level_0/string/private-quantity.c level_0/string/private-range.c level_0/string/private-triple.c level_0/string/dynamic.c level_0/string/map.c level_0/string/map_multi.c level_0/string/quantity.c level_0/string/range.c level_0/string/static.c level_0/string/triple.c +build_sources_library level_0/string.c level_0/private-string.c level_0/string/common.c level_0/string/dynamic.c level_0/string/map.c level_0/string/map_multi.c level_0/string/private-dynamic.c level_0/string/private-map.c level_0/string/private-map_multi.c level_0/string/private-quantity.c level_0/string/private-range.c level_0/string/private-triple.c level_0/string/quantity.c level_0/string/range.c level_0/string/static.c level_0/string/triple.c build_sources_library level_0/type_array/array_length.c level_0/type_array/cell.c level_0/type_array/fll_id.c level_0/type_array/int8.c level_0/type_array/int16.c level_0/type_array/int32.c level_0/type_array/int64.c level_0/type_array/int128.c level_0/type_array/state.c level_0/type_array/status.c level_0/type_array/uint8.c level_0/type_array/uint16.c level_0/type_array/uint32.c level_0/type_array/uint64.c level_0/type_array/uint128.c build_sources_library level_0/type_array/private-array_length.c level_0/type_array/private-cell.c level_0/type_array/private-fll_id.c level_0/type_array/private-int8.c level_0/type_array/private-int16.c level_0/type_array/private-int32.c level_0/type_array/private-int64.c level_0/type_array/private-int128.c level_0/type_array/private-state.c level_0/type_array/private-status.c level_0/type_array/private-uint8.c level_0/type_array/private-uint16.c level_0/type_array/private-uint32.c level_0/type_array/private-uint64.c level_0/type_array/private-uint128.c -build_sources_library level_0/utf.c level_0/private-utf.c level_0/utf/common.c level_0/utf/convert.c level_0/utf/dynamic.c level_0/utf/is.c level_0/utf/is_character.c level_0/utf/map.c level_0/utf/string.c level_0/utf/triple.c level_0/utf/private-is_unassigned.c level_0/utf/private-string.c +build_sources_library level_0/utf.c level_0/private-utf.c level_0/utf/common.c level_0/utf/convert.c level_0/utf/dynamic.c level_0/utf/is.c level_0/utf/is_character.c level_0/utf/map.c level_0/utf/map_multi.c level_0/utf/static.c level_0/utf/string.c level_0/utf/triple.c level_0/utf/private-dynamic.c level_0/utf/private-is_unassigned.c level_0/utf/private-map.c level_0/utf/private-map_multi.c level_0/utf/private-triple.c level_0/utf/private-string.c build_sources_library level_1/control_group.c build_sources_library level_1/conversion.c level_1/private-conversion.c build_sources_library level_1/directory.c level_1/private-directory.c @@ -114,7 +114,7 @@ build_sources_headers level_0/string.h level_0/string/common.h level_0/string/dy build_sources_headers level_0/type.h build_sources_headers level_0/type_array.h level_0/type_array/common.h build_sources_headers level_0/type_array/array_length.h level_0/type_array/cell.h level_0/type_array/fll_id.h level_0/type_array/int8.h level_0/type_array/int16.h level_0/type_array/int32.h level_0/type_array/int64.h level_0/type_array/int128.h level_0/type_array/state.h level_0/type_array/status.h level_0/type_array/uint8.h level_0/type_array/uint16.h level_0/type_array/uint32.h level_0/type_array/uint64.h level_0/type_array/uint128.h -build_sources_headers level_0/utf.h level_0/utf/common.h level_0/utf/convert.h level_0/utf/dynamic.h level_0/utf/is.h level_0/utf/is_character.h level_0/utf/map.h level_0/utf/string.h level_0/utf/triple.h +build_sources_headers level_0/utf.h level_0/utf/common.h level_0/utf/convert.h level_0/utf/dynamic.h level_0/utf/is.h level_0/utf/is_character.h level_0/utf/map.h level_0/utf/map_multi.h level_0/utf/static.h level_0/utf/string.h level_0/utf/triple.h build_sources_headers level_1/control_group.h build_sources_headers level_1/conversion.h build_sources_headers level_1/directory.h level_1/directory/common.h diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index 87061af..c2927bc 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -47,11 +47,13 @@ // FLL-0 utf includes. #include -#include +#include #include +#include #include #include #include +#include #include #include diff --git a/level_0/f_utf/c/utf/dynamic.c b/level_0/f_utf/c/utf/dynamic.c index 489c608..ec8bf7b 100644 --- a/level_0/f_utf/c/utf/dynamic.c +++ b/level_0/f_utf/c/utf/dynamic.c @@ -1,17 +1,15 @@ #include "../utf.h" #include "../private-utf.h" +#include "static.h" +#include "private-dynamic.h" #include "private-string.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_utf_string_static_empty_s_ - const f_utf_string_static_t f_utf_string_static_empty_s = macro_f_utf_string_static_t_initialize(0, 0); -#endif // _di_f_utf_string_static_empty_s_ - #ifndef _di_f_utf_string_dynamic_adjust_ - f_status_t f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t *dynamic) { + f_status_t f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t * const dynamic) { #ifndef _di_level_0_parameter_checking_ if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -21,26 +19,24 @@ extern "C" { #endif // _di_f_utf_string_dynamic_adjust_ #ifndef _di_f_utf_string_dynamic_append_ - f_status_t f_utf_string_dynamic_append(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_append(const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; - } + if (!source.used) return F_data_not; return private_f_utf_string_append(source.string, source.used, destination); } #endif // _di_f_utf_string_dynamic_append_ #ifndef _di_f_utf_string_dynamic_append_assure_ - f_status_t f_utf_string_dynamic_append_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_append_assure(const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; + if (!source.used) return F_data_not; if (destination->used < source.used) { return private_f_utf_string_append(source.string, source.used, destination); @@ -51,17 +47,6 @@ extern "C" { while (i <= source.used && j <= destination->used) { - if (!source.string[source.used - i]) { - ++i; - continue; - } - - if (!destination->string[destination->used - j]) { - ++j; - - continue; - } - if (source.string[source.used - i] != destination->string[destination->used - j]) { return private_f_utf_string_append(source.string, source.used, destination); } @@ -75,14 +60,14 @@ extern "C" { #endif // _di_f_utf_string_dynamic_append_assure_ #ifndef _di_f_utf_string_dynamic_append_assure_nulless_ - f_status_t f_utf_string_dynamic_append_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_append_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; + if (!source.used) return F_data_not; - if (destination->used < source.used) { + if (!destination->used) { return private_f_utf_string_append_nulless(source.string, source.used, destination); } @@ -116,24 +101,25 @@ extern "C" { #endif // _di_f_utf_string_dynamic_append_assure_nulless_ #ifndef _di_f_utf_string_dynamic_append_nulless_ - f_status_t f_utf_string_dynamic_append_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_append_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; + if (!source.used) return F_data_not; return private_f_utf_string_append_nulless(source.string, source.used, destination); } #endif // _di_f_utf_string_dynamic_append_nulless_ #ifndef _di_f_utf_string_dynamic_decimate_by_ - f_status_t f_utf_string_dynamic_decimate_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic) { + f_status_t f_utf_string_dynamic_decimate_by(const f_array_length_t amount, f_utf_string_dynamic_t * const dynamic) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) return F_data_not; + if (dynamic->size - amount > 0) { return private_f_utf_string_dynamic_adjust(dynamic->size - amount, dynamic); } @@ -143,12 +129,13 @@ extern "C" { #endif // _di_f_utf_string_dynamic_decimate_by_ #ifndef _di_f_utf_string_dynamic_decrease_by_ - f_status_t f_utf_string_dynamic_decrease_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic) { + f_status_t f_utf_string_dynamic_decrease_by(const f_array_length_t amount, f_utf_string_dynamic_t * const dynamic) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) return F_data_not; + if (dynamic->size - amount > 0) { return private_f_utf_string_dynamic_resize(dynamic->size - amount, dynamic); } @@ -158,13 +145,12 @@ extern "C" { #endif // _di_f_utf_string_dynamic_decrease_by_ #ifndef _di_f_utf_string_dynamic_increase_ - f_status_t f_utf_string_dynamic_increase(const f_array_length_t step, f_utf_string_dynamic_t *dynamic) { + f_status_t f_utf_string_dynamic_increase(const f_array_length_t step, f_utf_string_dynamic_t * const dynamic) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (dynamic->used + 1 > dynamic->size) { + if (step && dynamic->used + 1 > dynamic->size) { f_array_length_t size = dynamic->used + step; if (size > F_string_t_size_d) { @@ -183,27 +169,27 @@ extern "C" { #endif // _di_f_utf_string_dynamic_increase_ #ifndef _di_f_utf_string_dynamic_increase_by_ - f_status_t f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic) { + f_status_t f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t * const dynamic) { #ifndef _di_level_0_parameter_checking_ if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) return F_data_not; + return private_f_utf_string_dynamic_increase_by(amount, dynamic); } #endif // _di_f_utf_string_dynamic_increase_by_ #ifndef _di_f_utf_string_dynamic_mash_ - f_status_t f_utf_string_dynamic_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_mash(const f_utf_string_static_t glue, const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; - } + if (!source.used) return F_data_not; - if (glue_length && destination->used) { - const f_status_t status = private_f_utf_string_append(glue, glue_length, destination); + if (glue.used && destination->used) { + const f_status_t status = private_f_utf_string_append(glue.string, glue.used, destination); if (F_status_is_error(status)) return status; } @@ -212,17 +198,15 @@ extern "C" { #endif // _di_f_utf_string_dynamic_mash_ #ifndef _di_f_utf_string_dynamic_mash_nulless_ - f_status_t f_utf_string_dynamic_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_mash_nulless(const f_utf_string_static_t glue, const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; - } + if (!source.used) return F_data_not; - if (glue_length && destination->used) { - const f_status_t status = private_f_utf_string_append_nulless(glue, glue_length, destination); + if (glue.used && destination->used) { + const f_status_t status = private_f_utf_string_append_nulless(glue.string, glue.used, destination); if (F_status_is_error(status)) return status; } @@ -231,17 +215,15 @@ extern "C" { #endif // _di_f_utf_string_dynamic_mash_nulless_ #ifndef _di_f_utf_string_dynamic_mish_ - f_status_t f_utf_string_dynamic_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_mish(const f_utf_string_static_t glue, const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; - } + if (!source.used) return F_data_not; - if (glue_length && destination->used) { - const f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); + if (glue.used && destination->used) { + const f_status_t status = private_f_utf_string_prepend(glue.string, glue.used, destination); if (F_status_is_error(status)) return status; } @@ -250,17 +232,15 @@ extern "C" { #endif // _di_f_utf_string_dynamic_mish_ #ifndef _di_f_utf_string_dynamic_mish_nulless_ - f_status_t f_utf_string_dynamic_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_mish_nulless(const f_utf_string_static_t glue, const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; - } + if (!source.used) return F_data_not; - if (glue_length && destination->used) { - const f_status_t status = private_f_utf_string_prepend_nulless(glue, glue_length, destination); + if (glue.used && destination->used) { + const f_status_t status = private_f_utf_string_prepend_nulless(glue.string, glue.used, destination); if (F_status_is_error(status)) return status; } @@ -269,18 +249,17 @@ extern "C" { #endif // _di_f_utf_string_dynamic_mish_nulless_ #ifndef _di_f_utf_string_dynamic_partial_append_ - f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (range.stop >= source.used) { + return private_f_utf_string_append(source.string + range.start, source.used - range.start, destination); } return private_f_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -288,44 +267,28 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_append_ #ifndef _di_f_utf_string_dynamic_partial_append_assure_ - f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - const f_array_length_t length = (range.stop - range.start) + 1; + const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; if (destination->used < length) { return private_f_utf_string_append(source.string + range.start, length, destination); } + const f_array_length_t stop = range.stop >= source.used ? source.used : range.stop + 1; f_array_length_t i = 1; f_array_length_t j = 1; while (i <= length && j <= destination->used) { - if (!source.string[range.stop - i]) { - ++i; - - continue; - } - - if (!destination->string[destination->used - j]) { - ++j; - - continue; - } - - if (source.string[range.stop - i] != destination->string[destination->used - j]) { + if (source.string[stop - i] != destination->string[destination->used - j]) { return private_f_utf_string_append(source.string + range.start, length, destination); } @@ -338,27 +301,28 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_append_assure_ #ifndef _di_f_utf_string_dynamic_partial_append_assure_nulless_ - f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) return F_data_not_eos; + if (!source.used) return F_data_not; if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - const f_array_length_t length = (range.stop - range.start) + 1; + const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; - if (destination->used < length) { + if (!destination->used) { return private_f_utf_string_append_nulless(source.string + range.start, length, destination); } + const f_array_length_t stop = range.stop >= source.used ? source.used : range.stop + 1; f_array_length_t i = 1; f_array_length_t j = 1; while (i <= length && j <= destination->used) { - if (!source.string[range.stop - i]) { + if (!source.string[stop - i]) { ++i; continue; @@ -370,7 +334,7 @@ extern "C" { continue; } - if (source.string[range.stop - i] != destination->string[destination->used - j]) { + if (source.string[stop - i] != destination->string[destination->used - j]) { return private_f_utf_string_append_nulless(source.string + range.start, length, destination); } @@ -383,18 +347,17 @@ extern "C" { #endif // _di_f_utf_string_dynamic_append_assure_nulless_ #ifndef _di_f_utf_string_dynamic_partial_append_nulless_ - f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (range.stop >= source.used) { + return private_f_utf_string_append_nulless(source.string + range.start, source.used - range.start, destination); } return private_f_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -402,23 +365,22 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_append_nulless_ #ifndef _di_f_utf_string_dynamic_partial_mash_ - f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_static_t glue, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (glue.used && destination->used) { + const f_status_t status = private_f_utf_string_append(glue.string, glue.used, destination); + if (F_status_is_error(status)) return status; } - if (glue_length && destination->used) { - f_status_t status = private_f_utf_string_append(glue, glue_length, destination); - if (F_status_is_error(status)) return status; + if (range.stop >= source.used) { + return private_f_utf_string_append(source.string + range.start, source.used - range.start, destination); } return private_f_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -426,23 +388,22 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_mash_ #ifndef _di_f_utf_string_dynamic_partial_mash_nulless_ - f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_static_t glue, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (glue.used && destination->used) { + const f_status_t status = private_f_utf_string_append_nulless(glue.string, glue.used, destination); + if (F_status_is_error(status)) return status; } - if (glue_length && destination->used) { - f_status_t status = private_f_utf_string_append_nulless(glue, glue_length, destination); - if (F_status_is_error(status)) return status; + if (range.stop >= source.used) { + return private_f_utf_string_append(source.string + range.start, source.used - range.start, destination); } return private_f_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -450,23 +411,22 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_mash_nulless_ #ifndef _di_f_utf_string_dynamic_partial_mish_ - f_status_t f_utf_string_partial_dynamic_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_mish(const f_utf_string_static_t glue, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (glue.used && destination->used) { + const f_status_t status = private_f_utf_string_prepend(glue.string, glue.used, destination); + if (F_status_is_error(status)) return status; } - if (glue_length && destination->used) { - f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); - if (F_status_is_error(status)) return status; + if (range.stop >= source.used) { + return private_f_utf_string_append(source.string + range.start, source.used - range.start, destination); } return private_f_utf_string_prepend(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -474,23 +434,22 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_mish_ #ifndef _di_f_utf_string_dynamic_partial_mish_nulless_ - f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_static_t glue, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (glue.used && destination->used) { + const f_status_t status = private_f_utf_string_prepend_nulless(glue.string, glue.used, destination); + if (F_status_is_error(status)) return status; } - if (glue_length && destination->used) { - f_status_t status = private_f_utf_string_prepend_nulless(glue, glue_length, destination); - if (F_status_is_error(status)) return status; + if (range.stop >= source.used) { + return private_f_utf_string_append(source.string + range.start, source.used - range.start, destination); } return private_f_utf_string_prepend_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -498,18 +457,17 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_mish_nulless_ #ifndef _di_f_utf_string_dynamic_partial_prepend_ - f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - if (range.start > range.stop) { - return F_data_not_stop; + if (range.stop >= source.used) { + return private_f_utf_string_append(source.string + range.start, source.used - range.start, destination); } return private_f_utf_string_prepend(source.string + range.start, (range.stop - range.start) + 1, destination); @@ -517,21 +475,16 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_prepend_ #ifndef _di_f_utf_string_dynamic_partial_prepend_assure_ - f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - const f_array_length_t length = (range.stop - range.start) + 1; + const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; if (destination->used < length) { return private_f_utf_string_prepend(source.string + range.start, length, destination); @@ -542,19 +495,7 @@ extern "C" { while (i < length && j < destination->used) { - if (!source.string[i + range.start]) { - ++i; - - continue; - } - - if (!destination->string[j]) { - ++j; - - continue; - } - - if (source.string[i + range.start] != destination->string[i]) { + if (source.string[i + range.start] != destination->string[j]) { return private_f_utf_string_prepend(source.string + range.start, length, destination); } @@ -567,23 +508,18 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_prepend_assure_ #ifndef _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ - f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not_eos; - } - - if (range.start > range.stop) { - return F_data_not_stop; - } + if (!source.used) return F_data_not; + if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; - const f_array_length_t length = (range.stop - range.start) + 1; + const f_array_length_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; - if (destination->used < length) { + if (!destination->used) { return private_f_utf_string_prepend_nulless(source.string + range.start, length, destination); } @@ -604,7 +540,7 @@ extern "C" { continue; } - if (source.string[i + range.start] != destination->string[i]) { + if (source.string[i + range.start] != destination->string[j]) { return private_f_utf_string_prepend_nulless(source.string + range.start, length, destination); } @@ -617,38 +553,38 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_prepend_assure_nulless #ifndef _di_f_utf_string_dynamic_partial_prepend_nulless_ - f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) return F_data_not_eos; + if (!source.used) return F_data_not; if (range.start > range.stop) return F_data_not_stop; + if (range.start >= source.used) return F_data_not_eos; return private_f_utf_string_prepend_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); } #endif // _di_f_utf_string_dynamic_partial_prepend_nulless #ifndef _di_f_utf_string_dynamic_prepend_ - f_status_t f_utf_string_dynamic_prepend(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_prepend(const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; + if (!source.used) return F_data_not; return private_f_utf_string_prepend(source.string, source.used, destination); } #endif // _di_f_utf_string_dynamic_prepend_ #ifndef _di_f_utf_string_dynamic_prepend_assure_ - f_status_t f_utf_string_dynamic_prepend_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_prepend_assure(const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; + if (!source.used) return F_data_not; if (destination->used < source.used) { return private_f_utf_string_prepend(source.string, source.used, destination); @@ -659,19 +595,7 @@ extern "C" { while (i < source.used && j < destination->used) { - if (!source.string[i]) { - ++i; - - continue; - } - - if (!destination->string[j]) { - ++j; - - continue; - } - - if (source.string[i] != destination->string[i]) { + if (source.string[i] != destination->string[j]) { return private_f_utf_string_prepend(source.string, source.used, destination); } @@ -684,16 +608,14 @@ extern "C" { #endif // _di_f_utf_string_dynamic_prepend_assure_ #ifndef _di_f_utf_string_dynamic_prepend_assure_nulless_ - f_status_t f_utf_string_dynamic_prepend_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_prepend_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; - } + if (!source.used) return F_data_not; - if (destination->used < source.used) { + if (!destination->used) { return private_f_utf_string_prepend_nulless(source.string, source.used, destination); } @@ -714,7 +636,7 @@ extern "C" { continue; } - if (source.string[i] != destination->string[i]) { + if (source.string[i] != destination->string[j]) { return private_f_utf_string_prepend_nulless(source.string, source.used, destination); } @@ -727,19 +649,19 @@ extern "C" { #endif // _di_f_utf_string_dynamic_prepend_assure_nulless_ #ifndef _di_f_utf_string_dynamic_prepend_nulless_ - f_status_t f_utf_string_dynamic_prepend_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_prepend_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_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_eos; + if (!source.used) return F_data_not; return private_f_utf_string_prepend_nulless(source.string, source.used, destination); } #endif // _di_f_utf_string_dynamic_prepend_nulless_ #ifndef _di_f_utf_string_dynamic_resize_ - f_status_t f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *buffer) { + f_status_t f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t * const buffer) { #ifndef _di_level_0_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -749,12 +671,12 @@ extern "C" { #endif // _di_f_utf_string_dynamic_resize_ #ifndef _di_f_utf_string_dynamic_seek_line_ - f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_string_range_t *range) { + f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_string_range_t * const range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!buffer.used) return F_data_not_eos; + if (!buffer.used) return F_data_not; if (range->start > range->stop) return F_data_not_stop; while (buffer.string[range->start] != F_utf_character_t_eol_d) { @@ -774,12 +696,12 @@ extern "C" { #endif // _di_f_utf_string_dynamic_seek_line_ #ifndef _di_f_utf_string_dynamic_seek_line_to_ - f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, const f_char_t seek_to_this, f_string_range_t *range) { + f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, const f_char_t seek_to_this, f_string_range_t * const range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!buffer.used) return F_data_not_eos; + if (!buffer.used) return F_data_not; if (range->start > range->stop) return F_data_not_stop; while (buffer.string[range->start] != seek_to_this) { @@ -801,12 +723,12 @@ extern "C" { #endif // _di_f_utf_string_dynamic_seek_line_to_ #ifndef _di_f_utf_string_dynamic_seek_to_ - f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, const f_char_t seek_to_this, f_string_range_t *range) { + f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, const f_char_t seek_to_this, f_string_range_t * const range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!buffer.used) return F_data_not_eos; + if (!buffer.used) return F_data_not; if (range->start > range->stop) return F_data_not_stop; while (buffer.string[range->start] != seek_to_this) { @@ -826,12 +748,12 @@ extern "C" { #endif // _di_f_utf_string_dynamic_seek_to_ #ifndef _di_f_utf_string_dynamic_terminate_ - f_status_t f_utf_string_dynamic_terminate(f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_terminate(f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!destination->used && destination->size && !destination->string[destination->used - 1]) { + if (destination->used && !destination->string[destination->used - 1]) { return F_none; } @@ -839,54 +761,46 @@ extern "C" { return F_status_set_error(F_string_too_large); } - const f_array_length_t total = destination->used + 1; - - if (total > destination->size) { - const f_status_t status = private_f_utf_string_dynamic_resize(total, destination); + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_utf_string_dynamic_resize(destination->used + (destination->used + 1 == F_string_t_size_d ? 1 : F_memory_default_allocation_small_d), destination); if (F_status_is_error(status)) return status; } - destination->string[destination->used] = 0; - destination->used = total; + destination->string[destination->used++] = 0; return F_none; } #endif // _di_f_utf_string_dynamic_terminate_ #ifndef _di_f_utf_string_dynamic_terminate_after_ - f_status_t f_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (destination->used) { - for (; destination->used; --destination->used) { - - if (!destination->string[destination->used - 1]) continue; - break; - } // for + if (destination->used < destination->size) { + if (!destination->string[destination->used]) { + return F_none; + } } if (destination->used == F_string_t_size_d) { return F_status_set_error(F_string_too_large); } - const f_array_length_t total = destination->used + 1; - - if (total > destination->size) { - const f_status_t status = private_f_utf_string_dynamic_resize(total, destination); + if (destination->used + 1 > destination->size) { + const f_status_t status = private_f_utf_string_dynamic_resize(destination->used + (destination->used + 1 == F_string_t_size_d ? 1 : F_memory_default_allocation_small_d), destination); if (F_status_is_error(status)) return status; } destination->string[destination->used] = 0; - destination->used = total - 1; return F_none; } #endif // _di_f_utf_string_dynamic_terminate_after_ #ifndef _di_f_utf_string_dynamics_adjust_ - f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t *dynamics) { + f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -896,7 +810,7 @@ extern "C" { #endif // _di_f_utf_string_dynamics_adjust_ #ifndef _di_f_utf_string_dynamics_append_ - f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t *destination) { + f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -907,13 +821,26 @@ extern "C" { } #endif // _di_f_utf_string_dynamics_append_ +#ifndef _di_f_utf_string_dynamics_append_all_ + f_status_t f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + return private_f_utf_string_dynamics_append_all(source, destination); + } +#endif // _di_f_utf_string_dynamics_append_all_ + #ifndef _di_f_utf_string_dynamics_decimate_by_ - f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics) { + f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) return F_data_not; + if (dynamics->size - amount > 0) { return private_f_utf_string_dynamics_adjust(dynamics->size - amount, dynamics); } @@ -923,12 +850,13 @@ extern "C" { #endif // _di_f_utf_string_dynamics_decimate_by_ #ifndef _di_f_utf_string_dynamics_decrease_by_ - f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics) { + f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!amount) return F_data_not; + if (dynamics->size - amount > 0) { return private_f_utf_string_dynamics_resize(dynamics->size - amount, dynamics); } @@ -938,12 +866,13 @@ extern "C" { #endif // _di_f_utf_string_dynamics_decrease_by_ #ifndef _di_f_utf_string_dynamics_increase_ - f_status_t f_utf_string_dynamics_increase(const f_array_length_t step, f_utf_string_dynamics_t *dynamics) { + f_status_t f_utf_string_dynamics_increase(const f_array_length_t step, f_utf_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!step) return F_data_not; + if (dynamics->used + 1 > dynamics->size) { f_array_length_t size = dynamics->used + step; @@ -963,7 +892,7 @@ extern "C" { #endif // _di_f_utf_string_dynamics_increase_ #ifndef _di_f_utf_string_dynamics_increase_by_ - f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics) { + f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -981,7 +910,7 @@ extern "C" { #endif // _di_f_utf_string_dynamics_increase_by_ #ifndef _di_f_utf_string_dynamics_resize_ - f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t *dynamics) { + f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { #ifndef _di_level_0_parameter_checking_ if (!dynamics) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -990,6 +919,161 @@ extern "C" { } #endif // _di_f_utf_string_dynamics_resize_ +#ifndef _di_f_utf_string_dynamicss_adjust_ + f_status_t f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamicss_adjust(length, dynamicss); + } +#endif // _di_f_utf_string_dynamicss_adjust_ + +#ifndef _di_f_utf_string_dynamicss_append_ + f_status_t f_utf_string_dynamicss_append(const f_utf_string_dynamics_t source, f_utf_string_dynamicss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_dynamicss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_dynamics_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_dynamicss_append_ + +#ifndef _di_f_utf_string_dynamicss_append_all_ + f_status_t f_utf_string_dynamicss_append_all(const f_utf_string_dynamicss_t source, f_utf_string_dynamicss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_dynamicss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_dynamics_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_dynamicss_append_all_ + +#ifndef _di_f_utf_string_dynamicss_decimate_by_ + f_status_t f_utf_string_dynamicss_decimate_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (dynamicss->size - amount > 0) { + return private_f_utf_string_dynamicss_adjust(dynamicss->size - amount, dynamicss); + } + + return private_f_utf_string_dynamicss_adjust(0, dynamicss); + } +#endif // _di_f_utf_string_dynamicss_decimate_by_ + +#ifndef _di_f_utf_string_dynamicss_decrease_by_ + f_status_t f_utf_string_dynamicss_decrease_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (dynamicss->size - amount > 0) { + return private_f_utf_string_dynamicss_resize(dynamicss->size - amount, dynamicss); + } + + return private_f_utf_string_dynamicss_resize(0, dynamicss); + } +#endif // _di_f_utf_string_dynamicss_decrease_by_ + +#ifndef _di_f_utf_string_dynamicss_increase_ + f_status_t f_utf_string_dynamicss_increase(const f_array_length_t step, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!step) return F_data_not; + + if (dynamicss->used + 1 > dynamicss->size) { + f_array_length_t size = dynamicss->used + step; + + if (size > F_array_length_t_size_d) { + if (dynamicss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_dynamicss_resize(size, dynamicss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamicss_increase_ + +#ifndef _di_f_utf_string_dynamicss_increase_by_ + f_status_t f_utf_string_dynamicss_increase_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (dynamicss->used + amount > dynamicss->size) { + if (dynamicss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_dynamicss_resize(dynamicss->used + amount, dynamicss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamicss_increase_by_ + +#ifndef _di_f_utf_string_dynamicss_resize_ + f_status_t f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamicss_resize(length, dynamicss); + } +#endif // _di_f_utf_string_dynamicss_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/dynamic.h b/level_0/f_utf/c/utf/dynamic.h index 255f2c8..dbccbbe 100644 --- a/level_0/f_utf/c/utf/dynamic.h +++ b/level_0/f_utf/c/utf/dynamic.h @@ -9,50 +9,14 @@ * * This is auto-included by utf.h and should not need to be explicitly included. */ -#ifndef _F_utf_string_dynamic_h -#define _F_utf_string_dynamic_h +#ifndef _F_utf_dynamic_h +#define _F_utf_dynamic_h #ifdef __cplusplus extern "C" { #endif /** - * A string that is analogous to f_utf_string_dynamic_t but intended for static-only uses. - * - * The f_utf_string_static_t type should never be directly allocated or deallocated. - * - * A special macro_f_utf_string_static_t_initialize() is provided for the special purpose of easily initialize a static string. - * - * string: the string. - * size: total amount of space available. - * used: total number of space used. - */ -#ifndef _di_f_utf_string_static_t_ - typedef struct { - f_utf_string_t string; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_static_t; - - #define f_utf_string_static_t_initialize { 0, 0, 0 } - - #define macro_f_utf_string_static_t_clear(string_static) \ - string_static.string = 0; \ - string_static.size = 0; \ - string_static.used = 0; - - #define macro_f_utf_string_static_t_initialize(string, length) { string, length, length } -#endif // _di_f_utf_string_static_t_ - -/** - * Define a a global empty UTF-8 string. - */ -#ifndef _di_f_utf_string_static_empty_s_ - const extern f_utf_string_static_t f_utf_string_static_empty_s; -#endif // _di_f_utf_string_static_empty_s_ - -/** * A string that supports contains a size attribute to handle dynamic allocations and deallocations. * * Save the string size along with the string, so that strlen(..) commands can be avoided as much as possible. @@ -60,15 +24,18 @@ extern "C" { * This is a sub-type of f_utf_string_static_t, allowing it to be passed into any f_utf_string_static_t type. * It is recommended that f_utf_string_static_t are not otherwise casted into f_utf_string_dynamic_t to avoid potential memory allocation issues. * - * string: the string. - * size: total amount of allocated space. - * used: total number of allocated spaces used. + * string: The string. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. */ #ifndef _di_f_utf_string_dynamic_t_ typedef f_utf_string_static_t f_utf_string_dynamic_t; #define f_utf_string_dynamic_t_initialize f_utf_string_static_t_initialize + #define macro_f_utf_string_dynamic_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_dynamic_t_initialize2(array, length) { array, length, length } + #define macro_f_utf_string_dynamic_t_clear(dynamic) macro_f_utf_string_static_t_clear(dynamic) #define macro_f_utf_string_dynamic_t_resize(status, dynamic, length) status = f_utf_string_dynamic_resize(length, &dynamic); @@ -84,40 +51,20 @@ extern "C" { #endif // _di_f_utf_string_dynamic_t_ /** - * An array of static dynamics. - * - * array: the array of static dynamics. - * size: total amount of space available. - * used: total number of space used. - */ -#ifndef _di_f_utf_string_statics_t_ - typedef struct { - f_utf_string_static_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_statics_t; - - #define f_utf_string_statics_t_initialize { 0, 0, 0 } - - #define macro_f_utf_string_statics_t_clear(statics) \ - statics.array = 0; \ - statics.size = 0; \ - statics.used = 0; -#endif // _di_f_utf_string_statics_t_ - -/** * An array of dynamic dynamics. * - * array: the array of dynamic dynamics. - * size: total amount of allocated space. - * used: total number of allocated spaces used. + * array: The array of dynamic dynamics. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. */ #ifndef _di_f_utf_string_dynamics_t_ typedef f_utf_string_statics_t f_utf_string_dynamics_t; #define f_utf_string_dynamics_t_initialize f_utf_string_statics_t_initialize + #define macro_f_utf_string_dynamics_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_dynamics_t_initialize2(array, length) { array, length, length } + #define macro_f_utf_string_dynamics_t_clear(dynamics) macro_f_utf_string_statics_t_clear(dynamics) #define macro_f_utf_string_dynamics_t_resize(status, dynamics, length) status = f_utf_string_dynamics_resize(length, &dynamics); @@ -126,13 +73,42 @@ extern "C" { #define macro_f_utf_string_dynamics_t_delete_simple(dynamics) f_utf_string_dynamics_resize(0, &dynamics); #define macro_f_utf_string_dynamics_t_destroy_simple(dynamics) f_utf_string_dynamics_adjust(0, &dynamics); - #define macro_f_utf_string_dynamics_t_increase(status, dynamics) status = f_utf_string_dynamics_increase(&dynamics); + #define macro_f_utf_string_dynamics_t_increase(status, step, dynamics) status = f_utf_string_dynamics_increase(step, &dynamics); #define macro_f_utf_string_dynamics_t_increase_by(status, dynamics, amount) status = f_utf_string_dynamics_increase_by(amount, &dynamics); #define macro_f_utf_string_dynamics_t_decrease_by(status, dynamics, amount) status = f_utf_string_dynamics_decrease_by(amount, &dynamics); #define macro_f_utf_string_dynamics_t_decimate_by(status, dynamics, amount) status = f_utf_string_dynamics_decimate_by(amount, &dynamics); #endif // _di_f_utf_string_dynamics_t_ /** + * An array of dynamic dynamicss. + * + * array: The array of dynamic dynamicss. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_dynamicss_t_ + typedef f_utf_string_staticss_t f_utf_string_dynamicss_t; + + #define f_utf_string_dynamicss_t_initialize f_utf_string_staticss_t_initialize + + #define macro_f_utf_string_dynamicss_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_dynamicss_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_dynamicss_t_clear(dynamicss) macro_f_utf_string_staticss_t_clear(dynamicss) + + #define macro_f_utf_string_dynamicss_t_resize(status, dynamicss, length) status = f_utf_string_dynamicss_resize(length, &dynamicss); + #define macro_f_utf_string_dynamicss_t_adjust(status, dynamicss, length) status = f_utf_string_dynamicss_adjust(length, &dynamicss); + + #define macro_f_utf_string_dynamicss_t_delete_simple(dynamicss) f_utf_string_dynamicss_resize(0, &dynamicss); + #define macro_f_utf_string_dynamicss_t_destroy_simple(dynamicss) f_utf_string_dynamicss_adjust(0, &dynamicss); + + #define macro_f_utf_string_dynamicss_t_increase(status, step, dynamicss) status = f_utf_string_dynamicss_increase(step, &dynamicss); + #define macro_f_utf_string_dynamicss_t_increase_by(status, dynamicss, amount) status = f_utf_string_dynamicss_increase_by(amount, &dynamicss); + #define macro_f_utf_string_dynamicss_t_decrease_by(status, dynamicss, amount) status = f_utf_string_dynamicss_decrease_by(amount, &dynamicss); + #define macro_f_utf_string_dynamicss_t_decimate_by(status, dynamicss, amount) status = f_utf_string_dynamicss_decimate_by(amount, &dynamicss); +#endif // _di_f_utf_string_dynamicss_t_ + +/** * Resize the dynamic string. * * @param length @@ -147,7 +123,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_utf_string_dynamic_adjust_ - extern f_status_t f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t *dynamic); + extern f_status_t f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t * const dynamic); #endif // _di_f_utf_string_dynamic_adjust_ /** @@ -160,7 +136,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -168,11 +144,11 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_append_ - extern f_status_t f_utf_string_dynamic_append(const f_utf_string_dynamic_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_append(const f_utf_string_dynamic_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_append_ /** - * Append the source string onto the destination. + * Append the source string onto the destination only if the string is not already at the end. * * @param source * The source string to append. @@ -181,7 +157,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -189,11 +165,11 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_append_assure_ - extern f_status_t f_utf_string_dynamic_append_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_append_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_append_assure_ /** - * Append the source string onto the destination. + * Append the source string onto the destination only if the string is not already at the end. * * Skips over NULL characters from source when appending. * @@ -204,7 +180,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -212,7 +188,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_append_assure_nulless_ - extern f_status_t f_utf_string_dynamic_append_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_append_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_append_assure_nulless_ /** @@ -227,7 +203,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -235,7 +211,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_append_nulless_ - extern f_status_t f_utf_string_dynamic_append_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_append_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_append_nulless_ /** @@ -252,6 +228,32 @@ extern "C" { * * @return * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamic_decimate_by_ + extern f_status_t f_utf_string_dynamic_decimate_by(const f_array_length_t amount, f_utf_string_dynamic_t * const dynamic); +#endif // _di_f_utf_string_dynamic_decimate_by_ + +/** + * Resize the dynamic string to a smaller size. + * + * This will resize making the string 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 dynamic + * The string to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -259,7 +261,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_decrease_by_ - extern f_status_t f_utf_string_dynamic_decrease_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic); + extern f_status_t f_utf_string_dynamic_decrease_by(const f_array_length_t amount, f_utf_string_dynamic_t * const dynamic); #endif // _di_f_utf_string_dynamic_decrease_by_ /** @@ -277,7 +279,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * F_data_not on success, but there is no reason to increase size (used + 1 <= size) (or step is 0). * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -285,7 +287,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_increase_ - extern f_status_t f_utf_string_dynamic_increase(const f_array_length_t step, f_utf_string_dynamic_t *dynamic); + extern f_status_t f_utf_string_dynamic_increase(const f_array_length_t step, f_utf_string_dynamic_t * const dynamic); #endif // _di_f_utf_string_dynamic_increase_ /** @@ -310,7 +312,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_increase_by_ - extern f_status_t f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic); + extern f_status_t f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t * const dynamic); #endif // _di_f_utf_string_dynamic_increase_by_ /** @@ -320,8 +322,6 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. * @param source * The source string to append. * @param destination @@ -329,7 +329,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -337,7 +337,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_mash_ - extern f_status_t f_utf_string_dynamic_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_mash(const f_utf_string_static_t glue, const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_mash_ /** @@ -349,8 +349,6 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. * @param source * The source string to append. * @param destination @@ -358,7 +356,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -366,7 +364,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_mash_nulless_ - extern f_status_t f_utf_string_dynamic_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_mash_nulless(const f_utf_string_static_t glue, const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_mash_nulless_ /** @@ -376,8 +374,6 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. * @param source * The source string to append. * @param destination @@ -385,7 +381,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -393,7 +389,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_mish_ - extern f_status_t f_utf_string_dynamic_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_mish(const f_utf_string_static_t glue, const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_mish_ /** @@ -405,8 +401,6 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. * @param source * The source string to append. * @param destination @@ -414,7 +408,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -422,12 +416,14 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_mish_nulless_ - extern f_status_t f_utf_string_dynamic_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_mish_nulless(const f_utf_string_static_t glue, const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_mish_nulless_ /** * Append the source string onto the destination, but restricted to the given range. * + * If range.stop is on or after source.used, then source.used - 1 is used as the stopping point. + * * @param source * The source string to append. * @param range @@ -437,7 +433,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -446,13 +443,11 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_append_ - extern f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_append_ /** - * Append the source string onto the destination, but only if the string is not already at the end and restricted to the given range - * - * This ignores NULL characters when comparing both the source and the destination. + * Append the source string onto the destination only if the string is not already at the end and restricted to the given range. * * @param source * The source string to append. @@ -463,7 +458,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -472,11 +468,11 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_append_assure_ - extern f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_append_assure_ /** - * Append the source string onto the destination, but only if the string is not already at the end and restricted to the given range + * Append the source string onto the destination only if the string is not already at the end and restricted to the given range. * * This ignores NULL characters when comparing both the source and the destination. * @@ -491,7 +487,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -500,7 +497,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_append_assure_nulless_ - extern f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_append_assure_nulless_ /** @@ -517,7 +514,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -526,7 +524,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_append_nulless_ - extern f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_append_nulless_ /** @@ -536,8 +534,6 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. * @param source * The source string to append. * @param range @@ -547,7 +543,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -556,7 +553,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_mash_ - extern f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_static_t glue, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_mash_ /** @@ -568,8 +565,6 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. * @param source * The source string to append. * @param range @@ -579,7 +574,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -588,7 +584,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_mash_nulless_ - extern f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_static_t glue, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_mash_nulless_ /** @@ -598,8 +594,6 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. * @param source * The source string to append. * @param range @@ -609,7 +603,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -618,7 +613,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_mish_ - extern f_status_t f_utf_string_dynamic_partial_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_mish(const f_utf_string_static_t glue, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_mish_ /** @@ -630,8 +625,6 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. * @param source * The source string to append. * @param range @@ -641,7 +634,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -650,7 +644,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_mish_nulless_ - extern f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_static_t glue, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_mish_nulless_ /** @@ -667,7 +661,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -676,16 +671,14 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_prepend_ - extern f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_prepend_ /** - * Prepend the source string onto the destination, but only if the string is not already at the end and restricted to the given range + * Prepend the source string onto the destination only if the string is not already at the beginning and restricted to the given range. * * Prepend operations require memory move operations and are therefore likely more expensive than append operations. * - * This ignores NULL characters when comparing both the source and the destination. - * * @param source * The source string to prepend. * @param range @@ -695,7 +688,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -704,11 +698,11 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_prepend_assure_ - extern f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_prepend_assure_ /** - * Prepend the source string onto the destination, but only if the string is not already at the end and restricted to the given range + * Prepend the source string onto the destination only if the string is not already at the beginning and restricted to the given range. * * Prepend operations require memory move operations and are therefore likely more expensive than append operations. * @@ -723,7 +717,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -732,7 +727,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ - extern f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ /** @@ -749,7 +744,8 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. + * F_data_not_eos if range.start >= source.used. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -758,7 +754,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_prepend_nulless_ - extern f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_partial_prepend_nulless_ /** @@ -773,8 +769,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -782,16 +777,14 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_prepend_ - extern f_status_t f_utf_string_dynamic_prepend(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_prepend(const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_prepend_ /** - * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * Prepend the source string onto the destination only if the string is not already at the beginning. * * Prepend operations require memory move operations and are therefore likely more expensive than append operations. * - * This ignores NULL characters when comparing both the source and the destination. - * * @param source * The source string to prepend. * @param destination @@ -799,8 +792,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -808,11 +800,11 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_prepend_assure_ - extern f_status_t f_utf_string_dynamic_prepend_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_prepend_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_prepend_assure_ /** - * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * Prepend the source string onto the destination only if the string is not already at the beginning. * * Prepend operations require memory move operations and are therefore likely more expensive than append operations. * @@ -825,8 +817,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -834,7 +825,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_prepend_assure_nulless_ - extern f_status_t f_utf_string_dynamic_prepend_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_prepend_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_prepend_assure_nulless_ /** @@ -849,8 +840,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -858,7 +848,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_prepend_nulless_ - extern f_status_t f_utf_string_dynamic_prepend_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_prepend_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_prepend_nulless_ /** @@ -877,7 +867,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_resize_ - extern f_status_t f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *buffer); + extern f_status_t f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t * const buffer); #endif // _di_f_utf_string_dynamic_resize_ /** @@ -893,16 +883,15 @@ extern "C" { * F_none on success. * F_none_eos on success, but stopped at end of string. * F_none_stop on success, but stopped at end of range. - * F_data_not_eos on success, but there was no string data to seek. + * F_data_not on success, but there was no string data to seek. * F_data_not_stop on success, but the range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is invalid UTF-8. * * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_seek_line_ - extern f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_string_range_t *range); + extern f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_string_range_t * const range); #endif // _di_f_utf_string_dynamic_seek_line_ /** @@ -920,16 +909,15 @@ extern "C" { * F_none on success. * F_none_eos on success, but stopped at end of string. * F_none_stop on success, but stopped at end of range. - * F_data_not_eos on success, but there was no string data to seek. + * F_data_not on success, but there was no string data to seek. * F_data_not_stop on success, but the range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is invalid UTF-8. * * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_seek_line_to_ - extern f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, const f_char_t seek_to_this, f_string_range_t *range); + extern f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, const f_char_t seek_to_this, f_string_range_t * const range); #endif // _di_f_utf_string_dynamic_seek_line_to_ /** @@ -947,16 +935,15 @@ extern "C" { * F_none on success. * F_none_eos on success, but stopped at end of string. * F_none_stop on success, but stopped at end of range. - * F_data_not_eos on success, but there was no string data to seek. + * F_data_not on success, but there was no string data to seek. * F_data_not_stop on success, but the range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is invalid UTF-8. * * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_seek_to_ - extern f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, const f_char_t seek_to_this, f_string_range_t *range); + extern f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, const f_char_t seek_to_this, f_string_range_t * const range); #endif // _di_f_utf_string_dynamic_seek_to_ /** @@ -979,7 +966,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_terminate_ - extern f_status_t f_utf_string_dynamic_terminate(f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_terminate(f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_terminate_ /** @@ -1004,7 +991,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_terminate_after_ - extern f_status_t f_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_dynamic_terminate_after_ /** @@ -1023,14 +1010,14 @@ extern "C" { * Errors (with error bit) from: f_memory_adjust(). */ #ifndef _di_f_utf_string_dynamics_adjust_ - extern f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t *dynamics); + extern f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics); #endif // _di_f_utf_string_dynamics_adjust_ /** - * Append the source strings onto the destination. + * Append the single source string onto the destination. * * @param source - * The source strings to append. + * The source string to append. * @param destination * The destination strings the source is appended onto. * @@ -1044,10 +1031,31 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamics_append_ - extern f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t *destination); + extern f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination); #endif // _di_f_utf_string_dynamics_append_ /** + * Append the source strings onto the destination. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_append_all_ + extern f_status_t f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination); +#endif // _di_f_utf_string_dynamics_append_all_ + +/** * Resize the dynamic string array to a smaller size. * * This will resize making the array smaller based on (size - given length). @@ -1061,14 +1069,14 @@ extern "C" { * * @return * F_none on success. - * F_data_not if amount is 0. + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). * * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamics_decimate_by_ - extern f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics); + extern f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); #endif // _di_f_utf_string_dynamics_decimate_by_ /** @@ -1085,14 +1093,14 @@ extern "C" { * * @return * F_none on success. - * F_data_not if amount is 0. + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). * * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamics_decrease_by_ - extern f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics); + extern f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); #endif // _di_f_utf_string_dynamics_decrease_by_ /** @@ -1117,7 +1125,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamics_increase_ - extern f_status_t f_utf_string_dynamics_increase(const f_array_length_t step, f_utf_string_dynamics_t *dynamics); + extern f_status_t f_utf_string_dynamics_increase(const f_array_length_t step, f_utf_string_dynamics_t * const dynamics); #endif // _di_f_utf_string_dynamics_increase_ /** @@ -1142,7 +1150,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamics_increase_by_ - extern f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics); + extern f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t * const dynamics); #endif // _di_f_utf_string_dynamics_increase_by_ /** @@ -1161,11 +1169,189 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamics_resize_ - extern f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t *dynamics); + extern f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics); #endif // _di_f_utf_string_dynamics_resize_ +/** + * Resize the dynamics string array. + * + * @param length + * The new size to use. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_adjust(). + */ +#ifndef _di_f_utf_string_dynamicss_adjust_ + extern f_status_t f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_adjust_ + +/** + * Append the single source string onto the destination. + * + * @param source + * The source string to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_append_ + extern f_status_t f_utf_string_dynamicss_append(const f_utf_string_dynamics_t source, f_utf_string_dynamicss_t * const destination); +#endif // _di_f_utf_string_dynamicss_append_ + +/** + * Append the source strings onto the destination. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_append_all_ + extern f_status_t f_utf_string_dynamicss_append_all(const f_utf_string_dynamicss_t source, f_utf_string_dynamicss_t * const destination); +#endif // _di_f_utf_string_dynamicss_append_all_ + +/** + * Resize the dynamics string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * 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 dynamicss + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_decimate_by_ + extern f_status_t f_utf_string_dynamicss_decimate_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_decimate_by_ + +/** + * Resize the dynamics string 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 dynamicss + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0) (or amount is 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_decrease_by_ + extern f_status_t f_utf_string_dynamicss_decrease_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_decrease_by_ + +/** + * Increase the size of the dynamics string array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_increase_ + extern f_status_t f_utf_string_dynamicss_increase(const f_array_length_t step, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_increase_ + +/** + * Resize the dynamics string 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_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_increase_by_ + extern f_status_t f_utf_string_dynamicss_increase_by(const f_array_length_t amount, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_increase_by_ + +/** + * Resize the dynamics string array. + * + * @param length + * The new size to use. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamicss_resize_ + extern f_status_t f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss); +#endif // _di_f_utf_string_dynamicss_resize_ + #ifdef __cplusplus } // extern "C" #endif -#endif // _F_utf_string_dynamic_h +#endif // _F_utf_dynamic_h diff --git a/level_0/f_utf/c/utf/map.c b/level_0/f_utf/c/utf/map.c index 9f71496..93dfa6a 100644 --- a/level_0/f_utf/c/utf/map.c +++ b/level_0/f_utf/c/utf/map.c @@ -1,150 +1,192 @@ #include "../utf.h" #include "../private-utf.h" #include "private-string.h" +#include "private-map.h" #ifdef __cplusplus extern "C" { #endif -#ifndef _di_f_utf_string_map_multis_adjust_ - f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t *map_multis) { +#ifndef _di_f_utf_string_maps_adjust_ + f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_utf_string_map_multis_adjust(length, map_multis); + return private_f_utf_string_maps_adjust(length, maps); } -#endif // _di_f_utf_string_map_multis_adjust_ +#endif // _di_f_utf_string_maps_adjust_ -#ifndef _di_f_utf_string_map_multis_append_ - f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t *destination) { +#ifndef _di_f_utf_string_maps_append_ + f_status_t f_utf_string_maps_append(const f_utf_string_map_t source, f_utf_string_maps_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ f_status_t status = F_none; - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_map_multis_resize(destination->used + source.used, destination); + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_maps_resize(destination->used + F_memory_default_allocation_small_d, destination); if (F_status_is_error(status)) return status; } - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; + if (source.name.used) { + status = private_f_utf_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } - if (source.array[i].name.used) { - status = private_f_utf_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } + if (source.value.used) { + status = private_f_utf_string_append(source.value.string, source.value.used, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } - if (source.array[i].value.used) { - status = private_f_utf_string_dynamics_append(source.array[i].value, &destination->array[destination->used].value); - if (F_status_is_error(status)) return status; - } - } // for + ++destination->used; return F_none; } -#endif // _di_f_utf_string_map_multis_append_ +#endif // _di_f_utf_string_maps_append_ + +#ifndef _di_f_utf_string_maps_append_all_ + f_status_t f_utf_string_maps_append_all(const f_utf_string_maps_t source, f_utf_string_maps_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + return private_f_utf_string_maps_append_all(source, destination); + } +#endif // _di_f_utf_string_maps_append_all_ -#ifndef _di_f_utf_string_map_multis_decimate_by_ - f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis) { +#ifndef _di_f_utf_string_maps_decimate_by_ + f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!map_multis) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (map_multis->size - amount > 0) { - return private_f_utf_string_map_multis_adjust(map_multis->size - amount, map_multis); + if (!amount) return F_data_not; + + if (maps->size - amount > 0) { + return private_f_utf_string_maps_adjust(maps->size - amount, maps); } - return private_f_utf_string_map_multis_adjust(0, map_multis); + return private_f_utf_string_maps_adjust(0, maps); } -#endif // _di_f_utf_string_map_multis_decimate_by_ +#endif // _di_f_utf_string_maps_decimate_by_ -#ifndef _di_f_utf_string_map_multis_decrease_by_ - f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis) { +#ifndef _di_f_utf_string_maps_decrease_by_ + f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!map_multis) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (map_multis->size - amount > 0) { - return private_f_utf_string_map_multis_resize(map_multis->size - amount, map_multis); + if (!amount) return F_data_not; + + if (maps->size - amount > 0) { + return private_f_utf_string_maps_resize(maps->size - amount, maps); } - return private_f_utf_string_map_multis_resize(0, map_multis); + return private_f_utf_string_maps_resize(0, maps); } -#endif // _di_f_utf_string_map_multis_decrease_by_ +#endif // _di_f_utf_string_maps_decrease_by_ -#ifndef _di_f_utf_string_map_multis_increase_ - f_status_t f_utf_string_map_multis_increase(const f_array_length_t step, f_utf_string_map_multis_t *map_multis) { +#ifndef _di_f_utf_string_maps_increase_ + f_status_t f_utf_string_maps_increase(const f_array_length_t step, f_utf_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); - if (!map_multis) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (map_multis->used + 1 > map_multis->size) { - f_array_length_t size = map_multis->used + step; + if (step && maps->used + 1 > maps->size) { + f_array_length_t size = maps->used + step; if (size > F_array_length_t_size_d) { - if (map_multis->used + 1 > F_array_length_t_size_d) { + if (maps->used + 1 > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); } size = F_array_length_t_size_d; } - return private_f_utf_string_map_multis_resize(size, map_multis); + return private_f_utf_string_maps_resize(size, maps); } return F_data_not; } -#endif // _di_f_utf_string_map_multis_increase_ +#endif // _di_f_utf_string_maps_increase_ -#ifndef _di_f_utf_string_map_multis_increase_by_ - f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis) { +#ifndef _di_f_utf_string_maps_increase_by_ + f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!map_multis) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (map_multis->used + amount > map_multis->size) { - if (map_multis->used + amount > F_array_length_t_size_d) { + if (!amount) return F_data_not; + + if (maps->used + amount > maps->size) { + if (maps->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); } - return private_f_utf_string_map_multis_resize(map_multis->used + amount, map_multis); + return private_f_utf_string_maps_resize(maps->used + amount, maps); } return F_data_not; } -#endif // _di_f_utf_string_map_multis_increase_by_ +#endif // _di_f_utf_string_maps_increase_by_ -#ifndef _di_f_utf_string_map_multis_resize_ - f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t *map_multis) { +#ifndef _di_f_utf_string_maps_resize_ + f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps) { #ifndef _di_level_0_parameter_checking_ - if (!map_multis) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_utf_string_map_multis_resize(length, map_multis); + return private_f_utf_string_maps_resize(length, maps); } -#endif // _di_f_utf_string_map_multis_resize_ +#endif // _di_f_utf_string_maps_resize_ -#ifndef _di_f_utf_string_maps_adjust_ - f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t *maps) { +#ifndef _di_f_utf_string_mapss_adjust_ + f_status_t f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_utf_string_maps_adjust(length, maps); + return private_f_utf_string_mapss_adjust(length, mapss); } -#endif // _di_f_utf_string_maps_adjust_ +#endif // _di_f_utf_string_mapss_adjust_ -#ifndef _di_f_utf_string_maps_append_ - f_status_t f_utf_string_maps_append(const f_utf_string_maps_t source, f_utf_string_maps_t *destination) { +#ifndef _di_f_utf_string_mapss_append_ + f_status_t f_utf_string_mapss_append(const f_utf_string_maps_t source, f_utf_string_mapss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_mapss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_maps_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_mapss_append_ + +#ifndef _di_f_utf_string_mapss_append_all_ + f_status_t f_utf_string_mapss_append_all(const f_utf_string_mapss_t source, f_utf_string_mapss_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -154,113 +196,109 @@ extern "C" { f_status_t status = F_none; if (destination->used + source.used > destination->size) { - status = private_f_utf_string_maps_resize(destination->used + source.used, destination); + status = private_f_utf_string_mapss_resize(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - destination->array[destination->used].name.used = 0; - destination->array[destination->used].value.used = 0; + destination->array[destination->used].used = 0; - if (source.array[i].name.used) { - status = private_f_utf_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); - if (F_status_is_error(status)) return status; - } - - if (source.array[i].value.used) { - status = private_f_utf_string_append(source.array[i].value.string, source.array[i].value.used, &destination->array[destination->used].value); + if (source.array[i].used) { + status = private_f_utf_string_maps_append_all(source.array[i], &destination->array[destination->used]); if (F_status_is_error(status)) return status; } } // for return F_none; } -#endif // _di_f_utf_string_maps_append_ +#endif // _di_f_utf_string_mapss_append_all_ -#ifndef _di_f_utf_string_maps_decimate_by_ - f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t *maps) { +#ifndef _di_f_utf_string_mapss_decimate_by_ + f_status_t f_utf_string_mapss_decimate_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!maps) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (maps->size - amount > 0) { - return private_f_utf_string_maps_adjust(maps->size - amount, maps); + if (!amount) return F_data_not; + + if (mapss->size - amount > 0) { + return private_f_utf_string_mapss_adjust(mapss->size - amount, mapss); } - return private_f_utf_string_maps_adjust(0, maps); + return private_f_utf_string_mapss_adjust(0, mapss); } -#endif // _di_f_utf_string_maps_decimate_by_ +#endif // _di_f_utf_string_mapss_decimate_by_ -#ifndef _di_f_utf_string_maps_decrease_by_ - f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t *maps) { +#ifndef _di_f_utf_string_mapss_decrease_by_ + f_status_t f_utf_string_mapss_decrease_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!maps) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (maps->size - amount > 0) { - return private_f_utf_string_maps_resize(maps->size - amount, maps); + if (!amount) return F_data_not; + + if (mapss->size - amount > 0) { + return private_f_utf_string_mapss_resize(mapss->size - amount, mapss); } - return private_f_utf_string_maps_resize(0, maps); + return private_f_utf_string_mapss_resize(0, mapss); } -#endif // _di_f_utf_string_maps_decrease_by_ +#endif // _di_f_utf_string_mapss_decrease_by_ -#ifndef _di_f_utf_string_maps_increase_ - f_status_t f_utf_string_maps_increase(const f_array_length_t step, f_utf_string_maps_t *maps) { +#ifndef _di_f_utf_string_mapss_increase_ + f_status_t f_utf_string_mapss_increase(const f_array_length_t step, f_utf_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); - if (!maps) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (maps->used + 1 > maps->size) { - f_array_length_t size = maps->used + step; + if (step && mapss->used + 1 > mapss->size) { + f_array_length_t size = mapss->used + step; if (size > F_array_length_t_size_d) { - if (maps->used + 1 > F_array_length_t_size_d) { + if (mapss->used + 1 > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); } size = F_array_length_t_size_d; } - return private_f_utf_string_maps_resize(size, maps); + return private_f_utf_string_mapss_resize(size, mapss); } return F_data_not; } -#endif // _di_f_utf_string_maps_increase_ +#endif // _di_f_utf_string_mapss_increase_ -#ifndef _di_f_utf_string_maps_increase_by_ - f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t *maps) { +#ifndef _di_f_utf_string_mapss_increase_by_ + f_status_t f_utf_string_mapss_increase_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!maps) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (maps->used + amount > maps->size) { - if (maps->used + amount > F_array_length_t_size_d) { + if (!amount) return F_data_not; + + if (mapss->used + amount > mapss->size) { + if (mapss->used + amount > F_array_length_t_size_d) { return F_status_set_error(F_array_too_large); } - return private_f_utf_string_maps_resize(maps->used + amount, maps); + return private_f_utf_string_mapss_resize(mapss->used + amount, mapss); } return F_data_not; } -#endif // _di_f_utf_string_maps_increase_by_ +#endif // _di_f_utf_string_mapss_increase_by_ -#ifndef _di_f_utf_string_maps_resize_ - f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t *maps) { +#ifndef _di_f_utf_string_mapss_resize_ + f_status_t f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_utf_string_maps_resize(length, maps); + return private_f_utf_string_mapss_resize(length, mapss); } -#endif // _di_f_utf_string_maps_resize_ +#endif // _di_f_utf_string_mapss_resize_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_utf/c/utf/map.h b/level_0/f_utf/c/utf/map.h index c04bc30..77d7b2d 100644 --- a/level_0/f_utf/c/utf/map.h +++ b/level_0/f_utf/c/utf/map.h @@ -9,8 +9,8 @@ * * This is auto-included by utf.h and should not need to be explicitly included. */ -#ifndef _F_utf_string_map_h -#define _F_utf_string_map_h +#ifndef _F_utf_map_h +#define _F_utf_map_h #ifdef __cplusplus extern "C" { @@ -30,6 +30,8 @@ extern "C" { #define f_utf_string_map_t_initialize { f_utf_string_dynamic_t_initialize, f_utf_string_dynamic_t_initialize } + #define macro_f_utf_string_map_t_initialize(name, value) { name, value } + #define macro_f_utf_string_map_t_clear(map) \ macro_f_utf_string_dynamic_t_clear(map.name) \ macro_f_utf_string_dynamic_t_clear(map.value) @@ -60,6 +62,9 @@ extern "C" { #define f_utf_string_maps_t_initialize f_utf_string_statics_t_initialize + #define macro_f_utf_string_maps_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_maps_t_initialize2(array, length) { array, length, length } + #define macro_f_utf_string_maps_t_clear(maps) macro_f_memory_structure_clear(maps) #define macro_f_utf_string_maps_t_resize(status, maps, length) status = f_utf_string_maps_resize(length, &maps); @@ -68,77 +73,53 @@ extern "C" { #define macro_f_utf_string_maps_t_delete_simple(maps) f_utf_string_maps_resize(0, &maps); #define macro_f_utf_string_maps_t_destroy_simple(maps) f_utf_string_maps_adjust(0, &maps); - #define macro_f_utf_string_maps_t_increase(status, maps) status = f_utf_string_maps_increase(maps); + #define macro_f_utf_string_maps_t_increase(status, step, maps) status = f_utf_string_maps_increase(step, maps); #define macro_f_utf_string_maps_t_increase_by(status, maps, amount) status = f_utf_string_maps_increase_by(amount, maps); #define macro_f_utf_string_maps_t_decrease_by(status, maps, amount) status = f_utf_string_maps_decrease_by(amount, maps); #define macro_f_utf_string_maps_t_decimate_by(status, maps, amount) status = f_utf_string_maps_decimate_by(amount, maps); #endif // _di_f_utf_string_maps_t_ /** - * A string map consisting of a name and multiple values. - * - * name: A string representing the map name. - * value: An array of strings representing the map value. - */ -#ifndef _di_f_utf_string_map_multi_t_ - typedef struct { - f_utf_string_dynamic_t name; - f_utf_string_dynamics_t value; - } f_utf_string_map_multi_t; - - #define f_utf_string_map_multi_t_initialize { f_utf_string_dynamic_t_initialize, f_utf_string_dynamics_t_initialize } - - #define macro_f_utf_string_map_multi_t_clear(map) \ - macro_f_utf_string_dynamic_t_clear(map.name) \ - macro_f_utf_string_dynamics_t_clear(map.value) - - #define macro_f_utf_string_map_multi_t_delete_simple(map) \ - macro_f_utf_string_dynamic_t_delete_simple(map.name) \ - macro_f_utf_string_dynamics_t_delete_simple(map.value) - - #define macro_f_utf_string_map_multi_t_destroy_simple(map) \ - macro_f_utf_string_dynamic_t_destroy_simple(map.name) \ - macro_f_utf_string_dynamics_t_destroy_simple(map.value) -#endif // _di_f_utf_string_map_multi_t_ - -/** * An array of string maps. * - * array: the array of string maps. + * array: the array of an array of string maps. * size: total amount of allocated space. * used: total number of allocated spaces used. */ -#ifndef _di_f_utf_string_map_multis_t_ +#ifndef _di_f_utf_string_mapss_t_ typedef struct { - f_utf_string_map_multi_t *array; + f_utf_string_maps_t *array; f_array_length_t size; f_array_length_t used; - } f_utf_string_map_multis_t; + } f_utf_string_mapss_t; - #define f_utf_string_map_multis_t_initialize f_utf_string_statics_t_initialize + #define f_utf_string_mapss_t_initialize f_utf_string_statics_t_initialize - #define macro_f_utf_string_map_multis_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) + #define macro_f_utf_string_mapss_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_mapss_t_initialize2(array, length) { array, length, length } - #define macro_f_utf_string_map_multis_t_resize(status, map_multis, length) status = f_utf_string_map_multis_resize(length, &map_multis); - #define macro_f_utf_string_map_multis_t_adjust(status, map_multis, length) status = f_utf_string_map_multis_adjust(length, &map_multis); + #define macro_f_utf_string_mapss_t_clear(maps) macro_f_memory_structure_clear(maps) - #define macro_f_utf_string_map_multis_t_delete_simple(map_multis) f_utf_string_map_multis_resize(0, &map_multis); - #define macro_f_utf_string_map_multis_t_destroy_simple(map_multis) f_utf_string_map_multis_adjust(0, &map_multis); + #define macro_f_utf_string_mapss_t_resize(status, maps, length) status = f_utf_string_mapss_resize(length, &maps); + #define macro_f_utf_string_mapss_t_adjust(status, maps, length) status = f_utf_string_mapss_adjust(length, &maps); - #define macro_f_utf_string_map_multis_t_increase(status, map_multis) status = f_utf_string_map_multis_increase(&map_multis); - #define macro_f_utf_string_map_multis_t_increase_by(status, map_multis, amount) status = f_utf_string_map_multis_increase_by(amount, &map_multis); - #define macro_f_utf_string_map_multis_t_decrease_by(status, map_multis, amount) status = f_utf_string_map_multis_decrease_by(amount, &map_multis); - #define macro_f_utf_string_map_multis_t_decimate_by(status, map_multis, amount) status = f_utf_string_map_multis_decimate_by(amount, &map_multis); -#endif // _di_f_utf_string_map_multis_t_ + #define macro_f_utf_string_mapss_t_delete_simple(maps) f_utf_string_mapss_resize(0, &maps); + #define macro_f_utf_string_mapss_t_destroy_simple(maps) f_utf_string_mapss_adjust(0, &maps); + + #define macro_f_utf_string_mapss_t_increase(status, step, maps) status = f_utf_string_mapss_increase(step, maps); + #define macro_f_utf_string_mapss_t_increase_by(status, maps, amount) status = f_utf_string_mapss_increase_by(amount, maps); + #define macro_f_utf_string_mapss_t_decrease_by(status, maps, amount) status = f_utf_string_mapss_decrease_by(amount, maps); + #define macro_f_utf_string_mapss_t_decimate_by(status, maps, amount) status = f_utf_string_mapss_decimate_by(amount, maps); +#endif // _di_f_utf_string_mapss_t_ /** - * Resize the map_multis array. + * Resize the string maps array. * * @param length * The new size to use. - * @param map_multis - * The map_multis array to resize. + * @param maps + * The string maps array to resize. * * @return * F_none on success. @@ -147,12 +128,32 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_map_multis_adjust_ - extern f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t *map_multis); -#endif // _di_f_utf_string_map_multis_adjust_ +#ifndef _di_f_utf_string_maps_adjust_ + extern f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_adjust_ /** - * Append the source map_multis onto the destination. + * Append a single source map onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_append_ + extern f_status_t f_utf_string_maps_append(const f_utf_string_map_t source, f_utf_string_maps_t * const destination); +#endif // _di_f_utf_string_maps_append_ + +/** + * Append the source maps onto the destination. * * @param source * The source maps to append. @@ -168,12 +169,12 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_map_multis_append_ - f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t *destination); -#endif // _di_f_utf_string_map_multis_append_ +#ifndef _di_f_utf_string_maps_append_all_ + extern f_status_t f_utf_string_maps_append_all(const f_utf_string_maps_t source, f_utf_string_maps_t * const destination); +#endif // _di_f_utf_string_maps_append_all_ /** - * Resize the map_multis array to a smaller size. + * Resize the string maps array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -181,8 +182,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param map_multis - * The map_multis array to resize. + * @param maps + * The string maps array to resize. * * @return * F_none on success. @@ -192,12 +193,12 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_map_multis_decimate_by_ - extern f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis); -#endif // _di_f_utf_string_map_multis_decimate_by_ +#ifndef _di_f_utf_string_maps_decimate_by_ + extern f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_decimate_by_ /** - * Resize the map_multis array to a smaller size. + * Resize the string maps array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -205,23 +206,22 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param map_multis - * The map_multis array to resize. + * @param maps + * The string maps array to resize. * * @return * F_none on success. - * F_data_not if amount is 0. * * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_map_multis_decrease_by_ - extern f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis); -#endif // _di_f_utf_string_map_multis_decrease_by_ +#ifndef _di_f_utf_string_maps_decrease_by_ + extern f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_decrease_by_ /** - * Increase the size of the map_multis array, but only if necessary. + * Increase the size of the string maps array, but only if necessary. * * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). * If already set to the maximum buffer size, then the resize will fail. @@ -229,8 +229,8 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param map_multis - * The map_multis array to resize. + * @param maps + * The string maps array to resize. * * @return * F_none on success. @@ -241,12 +241,12 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_map_multis_increase_ - extern f_status_t f_utf_string_map_multis_increase(const f_array_length_t step, f_utf_string_map_multis_t *map_multis); -#endif // _di_f_utf_string_map_multis_increase_ +#ifndef _di_f_utf_string_maps_increase_ + extern f_status_t f_utf_string_maps_increase(const f_array_length_t step, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_increase_ /** - * Resize the map_multis array to a larger size. + * Resize the string maps array to a larger size. * * This will resize making the string larger based on the given length. * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). @@ -254,8 +254,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param map_multis - * The map_multis array to resize. + * @param maps + * The string maps array to resize. * * @return * F_none on success. @@ -266,17 +266,17 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_map_multis_increase_by_ - extern f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis); -#endif // _di_f_utf_string_map_multis_increase_by_ +#ifndef _di_f_utf_string_maps_increase_by_ + extern f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_increase_by_ /** - * Resize the map_multis array. + * Resize the string maps array. * * @param length * The new size to use. - * @param map_multis - * The map_multis array to adjust. + * @param maps + * The string maps array to adjust. * * @return * F_none on success. @@ -285,17 +285,17 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_map_multis_resize_ - extern f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t *map_multis); -#endif // _di_f_utf_string_map_multis_resize_ +#ifndef _di_f_utf_string_maps_resize_ + extern f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps); +#endif // _di_f_utf_string_maps_resize_ /** - * Resize the string maps array. + * Resize the string mapss array. * * @param length * The new size to use. - * @param maps - * The string maps array to resize. + * @param mapss + * The string mapss array to resize. * * @return * F_none on success. @@ -304,17 +304,37 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_maps_adjust_ - extern f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t *maps); -#endif // _di_f_utf_string_maps_adjust_ +#ifndef _di_f_utf_string_mapss_adjust_ + extern f_status_t f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_adjust_ /** - * Append the source maps onto the destination. + * Append a single source maps onto the destination. * * @param source - * The source maps to append. + * The source mapss to append. * @param destination - * The destination maps the source is appended onto. + * The destination mapss the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_mapss_append_ + extern f_status_t f_utf_string_mapss_append(const f_utf_string_maps_t source, f_utf_string_mapss_t * const destination); +#endif // _di_f_utf_string_mapss_append_ + +/** + * Append the source mapss onto the destination. + * + * @param source + * The source mapss to append. + * @param destination + * The destination mapss the source is appended onto. * * @return * F_none on success. @@ -325,12 +345,12 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_maps_append_ - extern f_status_t f_utf_string_maps_append(const f_utf_string_maps_t source, f_utf_string_maps_t *destination); -#endif // _di_f_utf_string_maps_append_ +#ifndef _di_f_utf_string_mapss_append_all_ + extern f_status_t f_utf_string_mapss_append_all(const f_utf_string_mapss_t source, f_utf_string_mapss_t * const destination); +#endif // _di_f_utf_string_mapss_append_all_ /** - * Resize the string maps array to a smaller size. + * Resize the string mapss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -338,8 +358,8 @@ extern "C" { * * @param amount * A positive number representing how much to decimate the size by. - * @param maps - * The string maps array to resize. + * @param mapss + * The string mapss array to resize. * * @return * F_none on success. @@ -349,12 +369,12 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_maps_decimate_by_ - extern f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t *maps); -#endif // _di_f_utf_string_maps_decimate_by_ +#ifndef _di_f_utf_string_mapss_decimate_by_ + extern f_status_t f_utf_string_mapss_decimate_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_decimate_by_ /** - * Resize the string maps array to a smaller size. + * Resize the string mapss array to a smaller size. * * This will resize making the array smaller based on (size - given length). * If the given length is too small, then the resize will fail. @@ -362,8 +382,8 @@ extern "C" { * * @param amount * A positive number representing how much to decrease the size by. - * @param maps - * The string maps array to resize. + * @param mapss + * The string mapss array to resize. * * @return * F_none on success. @@ -373,12 +393,12 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_maps_decrease_by_ - extern f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t *maps); -#endif // _di_f_utf_string_maps_decrease_by_ +#ifndef _di_f_utf_string_mapss_decrease_by_ + extern f_status_t f_utf_string_mapss_decrease_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_decrease_by_ /** - * Increase the size of the string maps array, but only if necessary. + * Increase the size of the string mapss array, but only if necessary. * * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). * If already set to the maximum buffer size, then the resize will fail. @@ -386,24 +406,24 @@ extern "C" { * @param step * The allocation step to use. * Must be greater than 0. - * @param maps - * The string maps array to resize. + * @param mapss + * The string mapss array to resize. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * F_data_not on success, but there is no reason to increase size (used + 1 <= size) (or step is 0). * * F_array_too_large (with error bit) if the new array length is too large. * F_parameter (with error bit) if a parameter is invalid. * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_maps_increase_ - extern f_status_t f_utf_string_maps_increase(const f_array_length_t step, f_utf_string_maps_t *maps); -#endif // _di_f_utf_string_maps_increase_ +#ifndef _di_f_utf_string_mapss_increase_ + extern f_status_t f_utf_string_mapss_increase(const f_array_length_t step, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_increase_ /** - * Resize the string maps array to a larger size. + * Resize the string mapss array to a larger size. * * This will resize making the string larger based on the given length. * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). @@ -411,8 +431,8 @@ extern "C" { * * @param amount * A positive number representing how much to increase the size by. - * @param maps - * The string maps array to resize. + * @param mapss + * The string mapss array to resize. * * @return * F_none on success. @@ -423,17 +443,17 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_maps_increase_by_ - extern f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t *maps); -#endif // _di_f_utf_string_maps_increase_by_ +#ifndef _di_f_utf_string_mapss_increase_by_ + extern f_status_t f_utf_string_mapss_increase_by(const f_array_length_t amount, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_increase_by_ /** - * Resize the string maps array. + * Resize the string mapss array. * * @param length * The new size to use. - * @param maps - * The string maps array to adjust. + * @param mapss + * The string mapss array to adjust. * * @return * F_none on success. @@ -442,12 +462,12 @@ extern "C" { * * Errors (with error bit) from: f_memory_resize(). */ -#ifndef _di_f_utf_string_maps_resize_ - extern f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t *maps); -#endif // _di_f_utf_string_maps_resize_ +#ifndef _di_f_utf_string_mapss_resize_ + extern f_status_t f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss); +#endif // _di_f_utf_string_mapss_resize_ #ifdef __cplusplus } // extern "C" #endif -#endif // _F_utf_string_map_h +#endif // _F_utf_map_h diff --git a/level_0/f_utf/c/utf/map_multi.c b/level_0/f_utf/c/utf/map_multi.c new file mode 100644 index 0000000..6d5464c --- /dev/null +++ b/level_0/f_utf/c/utf/map_multi.c @@ -0,0 +1,305 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-map_multi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_map_multis_adjust_ + f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multis_adjust(length, map_multis); + } +#endif // _di_f_utf_string_map_multis_adjust_ + +#ifndef _di_f_utf_string_map_multis_append_ + f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multi_t source, f_utf_string_map_multis_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_map_multis_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.name.used) { + status = private_f_utf_string_append(source.name.string, source.name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.value.used) { + status = private_f_utf_string_dynamics_append_all(source.value, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_map_multis_append_ + +#ifndef _di_f_utf_string_map_multis_append_all_ + f_status_t f_utf_string_map_multis_append_all(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + return private_f_utf_string_map_multis_append_all(source, destination); + } +#endif // _di_f_utf_string_map_multis_append_all_ + +#ifndef _di_f_utf_string_map_multis_decimate_by_ + f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->size - amount > 0) { + return private_f_utf_string_map_multis_adjust(map_multis->size - amount, map_multis); + } + + return private_f_utf_string_map_multis_adjust(0, map_multis); + } +#endif // _di_f_utf_string_map_multis_decimate_by_ + +#ifndef _di_f_utf_string_map_multis_decrease_by_ + f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->size - amount > 0) { + return private_f_utf_string_map_multis_resize(map_multis->size - amount, map_multis); + } + + return private_f_utf_string_map_multis_resize(0, map_multis); + } +#endif // _di_f_utf_string_map_multis_decrease_by_ + +#ifndef _di_f_utf_string_map_multis_increase_ + f_status_t f_utf_string_map_multis_increase(const f_array_length_t step, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && map_multis->used + 1 > map_multis->size) { + f_array_length_t size = map_multis->used + step; + + if (size > F_array_length_t_size_d) { + if (map_multis->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_map_multis_resize(size, map_multis); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multis_increase_ + +#ifndef _di_f_utf_string_map_multis_increase_by_ + f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multis->used + amount > map_multis->size) { + if (map_multis->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_map_multis_resize(map_multis->used + amount, map_multis); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multis_increase_by_ + +#ifndef _di_f_utf_string_map_multis_resize_ + f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multis_resize(length, map_multis); + } +#endif // _di_f_utf_string_map_multis_resize_ + +#ifndef _di_f_utf_string_map_multiss_adjust_ + f_status_t f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multiss_adjust(length, map_multiss); + } +#endif // _di_f_utf_string_map_multiss_adjust_ + +#ifndef _di_f_utf_string_map_multiss_append_ + f_status_t f_utf_string_map_multiss_append(const f_utf_string_map_multis_t source, f_utf_string_map_multiss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_map_multiss_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_map_multis_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_map_multiss_append_ + +#ifndef _di_f_utf_string_map_multiss_append_all_ + f_status_t f_utf_string_map_multiss_append_all(const f_utf_string_map_multiss_t source, f_utf_string_map_multiss_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_map_multiss_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_map_multis_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_map_multiss_append_all_ + +#ifndef _di_f_utf_string_map_multiss_decimate_by_ + f_status_t f_utf_string_map_multiss_decimate_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->size - amount > 0) { + return private_f_utf_string_map_multiss_adjust(map_multiss->size - amount, map_multiss); + } + + return private_f_utf_string_map_multiss_adjust(0, map_multiss); + } +#endif // _di_f_utf_string_map_multiss_decimate_by_ + +#ifndef _di_f_utf_string_map_multiss_decrease_by_ + f_status_t f_utf_string_map_multiss_decrease_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->size - amount > 0) { + return private_f_utf_string_map_multiss_resize(map_multiss->size - amount, map_multiss); + } + + return private_f_utf_string_map_multiss_resize(0, map_multiss); + } +#endif // _di_f_utf_string_map_multiss_decrease_by_ + +#ifndef _di_f_utf_string_map_multiss_increase_ + f_status_t f_utf_string_map_multiss_increase(const f_array_length_t step, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && map_multiss->used + 1 > map_multiss->size) { + f_array_length_t size = map_multiss->used + step; + + if (size > F_array_length_t_size_d) { + if (map_multiss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_map_multiss_resize(size, map_multiss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multiss_increase_ + +#ifndef _di_f_utf_string_map_multiss_increase_by_ + f_status_t f_utf_string_map_multiss_increase_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (map_multiss->used + amount > map_multiss->size) { + if (map_multiss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_map_multiss_resize(map_multiss->used + amount, map_multiss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multiss_increase_by_ + +#ifndef _di_f_utf_string_map_multiss_resize_ + f_status_t f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multiss_resize(length, map_multiss); + } +#endif // _di_f_utf_string_map_multiss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/map_multi.h b/level_0/f_utf/c/utf/map_multi.h new file mode 100644 index 0000000..34e8199 --- /dev/null +++ b/level_0/f_utf/c/utf/map_multi.h @@ -0,0 +1,472 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines map string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_map_multi_h +#define _F_utf_map_multi_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A string map consisting of a name and multiple values. + * + * name: A string representing the map name. + * value: An array of strings representing the map value. + */ +#ifndef _di_f_utf_string_map_multi_t_ + typedef struct { + f_utf_string_dynamic_t name; + f_utf_string_dynamics_t value; + } f_utf_string_map_multi_t; + + #define f_utf_string_map_multi_t_initialize { f_utf_string_dynamic_t_initialize, f_utf_string_dynamics_t_initialize } + + #define macro_f_utf_string_map_t_initialize(name, value) { name, value } + + #define macro_f_utf_string_map_multi_t_clear(map) \ + macro_f_utf_string_dynamic_t_clear(map.name) \ + macro_f_utf_string_dynamics_t_clear(map.value) + + #define macro_f_utf_string_map_multi_t_delete_simple(map) \ + macro_f_utf_string_dynamic_t_delete_simple(map.name) \ + macro_f_utf_string_dynamics_t_delete_simple(map.value) + + #define macro_f_utf_string_map_multi_t_destroy_simple(map) \ + macro_f_utf_string_dynamic_t_destroy_simple(map.name) \ + macro_f_utf_string_dynamics_t_destroy_simple(map.value) +#endif // _di_f_utf_string_map_multi_t_ + +/** + * An array of string maps. + * + * array: the array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_map_multis_t_ + typedef struct { + f_utf_string_map_multi_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_map_multis_t; + + #define f_utf_string_map_multis_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_map_multis_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_map_multis_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_map_multis_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) + + #define macro_f_utf_string_map_multis_t_resize(status, map_multis, length) status = f_utf_string_map_multis_resize(length, &map_multis); + #define macro_f_utf_string_map_multis_t_adjust(status, map_multis, length) status = f_utf_string_map_multis_adjust(length, &map_multis); + + #define macro_f_utf_string_map_multis_t_delete_simple(map_multis) f_utf_string_map_multis_resize(0, &map_multis); + #define macro_f_utf_string_map_multis_t_destroy_simple(map_multis) f_utf_string_map_multis_adjust(0, &map_multis); + + #define macro_f_utf_string_map_multis_t_increase(status, step, map_multis) status = f_utf_string_map_multis_increase(step, &map_multis); + #define macro_f_utf_string_map_multis_t_increase_by(status, map_multis, amount) status = f_utf_string_map_multis_increase_by(amount, &map_multis); + #define macro_f_utf_string_map_multis_t_decrease_by(status, map_multis, amount) status = f_utf_string_map_multis_decrease_by(amount, &map_multis); + #define macro_f_utf_string_map_multis_t_decimate_by(status, map_multis, amount) status = f_utf_string_map_multis_decimate_by(amount, &map_multis); +#endif // _di_f_utf_string_map_multis_t_ + +/** + * An array of string maps. + * + * array: the array of an array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_map_multiss_t_ + typedef struct { + f_utf_string_map_multis_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_map_multiss_t; + + #define f_utf_string_map_multiss_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_map_multiss_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_map_multiss_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_map_multiss_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) + + #define macro_f_utf_string_map_multiss_t_resize(status, map_multis, length) status = f_utf_string_map_multiss_resize(length, &map_multis); + #define macro_f_utf_string_map_multiss_t_adjust(status, map_multis, length) status = f_utf_string_map_multiss_adjust(length, &map_multis); + + #define macro_f_utf_string_map_multiss_t_delete_simple(map_multis) f_utf_string_map_multiss_resize(0, &map_multis); + #define macro_f_utf_string_map_multiss_t_destroy_simple(map_multis) f_utf_string_map_multiss_adjust(0, &map_multis); + + #define macro_f_utf_string_map_multiss_t_increase(status, step, map_multis) status = f_utf_string_map_multiss_increase(step, &map_multis); + #define macro_f_utf_string_map_multiss_t_increase_by(status, map_multis, amount) status = f_utf_string_map_multiss_increase_by(amount, &map_multis); + #define macro_f_utf_string_map_multiss_t_decrease_by(status, map_multis, amount) status = f_utf_string_map_multiss_decrease_by(amount, &map_multis); + #define macro_f_utf_string_map_multiss_t_decimate_by(status, map_multis, amount) status = f_utf_string_map_multiss_decimate_by(amount, &map_multis); +#endif // _di_f_utf_string_map_multiss_t_ + +/** + * Resize the map_multis array. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_adjust_ + extern f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_adjust_ + +/** + * Append a single source map_multi onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_append_ + f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multi_t source, f_utf_string_map_multis_t *destination); +#endif // _di_f_utf_string_map_multis_append_ + +/** + * Append the source map_multis onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_append_all_ + f_status_t f_utf_string_map_multis_append_all(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t *destination); +#endif // _di_f_utf_string_map_multis_append_all_ + +/** + * Resize the map_multis array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_decimate_by_ + extern f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_decimate_by_ + +/** + * Resize the map_multis array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_decrease_by_ + extern f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_decrease_by_ + +/** + * Increase the size of the map_multis array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_increase_ + extern f_status_t f_utf_string_map_multis_increase(const f_array_length_t step, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_increase_ + +/** + * Resize the map_multis array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param map_multis + * The map_multis array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_increase_by_ + extern f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_increase_by_ + +/** + * Resize the map_multis array. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_resize_ + extern f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis); +#endif // _di_f_utf_string_map_multis_resize_ + +/** + * Resize the map_multiss array. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_adjust_ + extern f_status_t f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_adjust_ + +/** + * Append a single source map_multis onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_append_ + f_status_t f_utf_string_map_multiss_append(const f_utf_string_map_multis_t source, f_utf_string_map_multiss_t *destination); +#endif // _di_f_utf_string_map_multiss_append_ + +/** + * Append the source map_multiss onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_append_all_ + f_status_t f_utf_string_map_multiss_append_all(const f_utf_string_map_multiss_t source, f_utf_string_map_multiss_t *destination); +#endif // _di_f_utf_string_map_multiss_append_all_ + +/** + * Resize the map_multiss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_decimate_by_ + extern f_status_t f_utf_string_map_multiss_decimate_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_decimate_by_ + +/** + * Resize the map_multiss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_decrease_by_ + extern f_status_t f_utf_string_map_multiss_decrease_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_decrease_by_ + +/** + * Increase the size of the map_multiss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_increase_ + extern f_status_t f_utf_string_map_multiss_increase(const f_array_length_t step, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_increase_ + +/** + * Resize the map_multiss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param map_multiss + * The map_multiss array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_increase_by_ + extern f_status_t f_utf_string_map_multiss_increase_by(const f_array_length_t amount, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_increase_by_ + +/** + * Resize the map_multiss array. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multiss_resize_ + extern f_status_t f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss); +#endif // _di_f_utf_string_map_multiss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_map_multi_h diff --git a/level_0/f_utf/c/utf/private-dynamic.c b/level_0/f_utf/c/utf/private-dynamic.c new file mode 100644 index 0000000..ea502db --- /dev/null +++ b/level_0/f_utf/c/utf/private-dynamic.c @@ -0,0 +1,218 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + f_status_t private_f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t * const dynamic) { + + const f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_char_t), (void **) & dynamic->string); + if (F_status_is_error(status)) return status; + + dynamic->size = length; + + if (dynamic->used > dynamic->size) { + dynamic->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) + f_status_t private_f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t * const dynamic) { + + if (dynamic->used + amount > dynamic->size) { + if (dynamic->used + amount > F_string_t_size_d) { + return F_status_set_error(F_string_too_large); + } + + return private_f_utf_string_dynamic_resize(dynamic->used + amount, dynamic); + } + + return F_data_not; + } +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) + +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) + f_status_t private_f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t * const dynamic) { + + const f_status_t status = f_memory_resize(dynamic->size, length, sizeof(f_char_t), (void **) & dynamic->string); + if (F_status_is_error(status)) return status; + + dynamic->size = length; + + if (dynamic->used > dynamic->size) { + dynamic->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) + +#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { + + if (dynamics->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamics->size; ++i) { + + status = private_f_utf_string_dynamic_adjust(0, &dynamics->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); + if (F_status_is_error(status)) return status; + + dynamics->size = length; + + if (dynamics->used > dynamics->size) { + dynamics->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_dynamics_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_append(source.string, source.used, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + + +#if !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + f_status_t private_f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_dynamics_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_append(source.array[i].string, source.array[i].used, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + +#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(f_utf_string_map_multis_append) + f_status_t private_f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) { + + if (dynamics->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamics->size; ++i) { + + status = private_f_utf_string_dynamic_resize(0, &dynamics->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); + if (F_status_is_error(status)) return status; + + dynamics->size = length; + + if (dynamics->used > dynamics->size) { + dynamics->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) || !defined(f_utf_string_map_multis_append) + +#if !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + f_status_t private_f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { + + if (dynamicss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamicss->size; ++i) { + + status = private_f_utf_string_dynamics_adjust(0, &dynamicss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(dynamicss->size, length, sizeof(f_utf_string_dynamics_t), (void **) & dynamicss->array); + if (F_status_is_error(status)) return status; + + dynamicss->size = length; + + if (dynamicss->used > dynamicss->size) { + dynamicss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +#if !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) + f_status_t private_f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) { + + if (dynamicss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamicss->size; ++i) { + + status = private_f_utf_string_dynamics_resize(0, &dynamicss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(dynamicss->size, length, sizeof(f_utf_string_dynamics_t), (void **) & dynamicss->array); + if (F_status_is_error(status)) return status; + + dynamicss->size = length; + + if (dynamicss->used > dynamicss->size) { + dynamicss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-dynamic.h b/level_0/f_utf/c/utf/private-dynamic.h new file mode 100644 index 0000000..8eea46a --- /dev/null +++ b/level_0/f_utf/c/utf/private-dynamic.h @@ -0,0 +1,382 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_utf_dynamic_h +#define _PRIVATE_F_utf_dynamic_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation of f_utf_string_append(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param length + * Length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see memcpy() + * + * @see f_utf_string_append() + * @see f_utf_string_append_assure() + * @see f_utf_string_dynamic_append() + * @see f_utf_string_dynamic_append_assure() + * @see f_utf_string_dynamic_mash() + * @see f_utf_string_dynamic_partial_append) + * @see f_utf_string_dynamic_partial_append_assure() + * @see f_utf_string_dynamic_partial_mash() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_mash() + * @see f_utf_string_maps_append() + * @see f_utf_string_triples_append() + */ +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) + extern f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) + +/** + * Private implementation of f_utf_string_append_nulless(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param length + * Length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * + * F_string_too_large (with error bit) if the combined string is too large. + * + * @see memcpy() + * + * @see f_utf_string_append_assure_nulless() + * @see f_utf_string_append_nulless() + * @see f_utf_string_dynamic_append_assure_nulless() + * @see f_utf_string_dynamic_append_nulless() + * @see f_utf_string_dynamic_mash_nulless() + * @see f_utf_string_dynamic_partial_append_assure_nulless() + * @see f_utf_string_dynamic_partial_append_nulless() + * @see f_utf_string_dynamic_partial_mash_nulless() + * @see f_utf_string_mash_nulless() + */ +#if !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) + extern f_status_t private_f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamic + * The string to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_dynamic_adjust() + * @see f_utf_string_dynamic_decimate_by() + * @see f_utf_string_dynamics_adjust() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_dynamics_decimate_by() + * @see f_utf_string_map_multis_adjust() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_triples_adjust() + * @see f_utf_string_triples_decimate_by() + */ +#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + extern f_status_t private_f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + +/** + * Private implementation of f_utf_string_dynamic_increase_by(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see memcpy() + * + * @see f_utf_string_append() + * @see f_utf_string_append_assure() + * @see f_utf_string_append_mash() + * @see f_utf_string_append_nulless() + * @see f_utf_string_dynamic_append() + * @see f_utf_string_dynamic_append_assure() + * @see f_utf_string_dynamic_append_nulless() + * @see f_utf_string_dynamic_increase_by() + * @see f_utf_string_dynamic_mash() + * @see f_utf_string_dynamic_mash_nulless() + * @see f_utf_string_dynamic_partial_append) + * @see f_utf_string_dynamic_partial_append_assure() + * @see f_utf_string_dynamic_partial_mash() + * @see f_utf_string_dynamic_prepend() + * @see f_utf_string_dynamic_prepend_nulless() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_mash() + * @see f_utf_string_mash_nulless() + * @see f_utf_string_maps_append() + * @see f_utf_string_prepend() + * @see f_utf_string_prepend_nulless() + * @see f_utf_string_triples_append() + */ +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) + extern f_status_t private_f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_append() + * @see f_utf_string_append_assure() + * @see f_utf_string_append_mash() + * @see f_utf_string_append_nulless() + * @see f_utf_string_dynamic_append() + * @see f_utf_string_dynamic_append_assure() + * @see f_utf_string_dynamic_append_nulless() + * @see f_utf_string_dynamic_decrease_by() + * @see f_utf_string_dynamic_increase() + * @see f_utf_string_dynamic_increase_by() + * @see f_utf_string_dynamic_mash() + * @see f_utf_string_dynamic_mash_nulless() + * @see f_utf_string_dynamic_partial_append) + * @see f_utf_string_dynamic_partial_append_assure() + * @see f_utf_string_dynamic_partial_mash() + * @see f_utf_string_dynamic_prepend() + * @see f_utf_string_dynamic_prepend_nulless() + * @see f_utf_string_dynamic_terminate() + * @see f_utf_string_dynamic_terminate_after() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_mash_nulless() + * @see f_utf_string_mash() + * @see f_utf_string_maps_append() + * @see f_utf_string_prepend() + * @see f_utf_string_prepend_nulless() + * @see f_utf_string_triples_append() + */ +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) + extern f_status_t private_f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamics + * The strings to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_dynamics_adjust() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_dynamics_decimate_by() + * @see f_utf_string_map_multis_adjust() + * @see f_utf_string_map_multis_append() + */ +#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + extern f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_map_multis_append_all() + */ +#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + extern f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamic_t source, f_utf_string_dynamics_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamics_append_all() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_map_multis_append_all() + */ +#if !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + extern f_status_t private_f_utf_string_dynamics_append_all(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamics_append_all_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_map_multis_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamics + * The strings to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamics_decrease_by() + * @see f_utf_string_dynamics_increase() + * @see f_utf_string_dynamics_increase_by() + */ +#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) + extern f_status_t private_f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t * const dynamics) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamicss + * The strings to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_dynamicss_adjust() + * @see f_utf_string_dynamicss_append() + * @see f_utf_string_dynamicss_decimate_by() + * @see f_utf_string_map_multis_adjust() + * @see f_utf_string_map_multis_append() + */ +#if !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + extern f_status_t private_f_utf_string_dynamicss_adjust(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamicss_adjust_) || !defined(_di_f_utf_string_dynamicss_append_) || !defined(_di_f_utf_string_dynamicss_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamicss + * The strings to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamicss_append_all() + * @see f_utf_string_dynamicss_decrease_by() + * @see f_utf_string_dynamicss_increase() + * @see f_utf_string_dynamicss_increase_by() + * @see f_utf_string_map_multis_append_all() + */ +#if !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) + extern f_status_t private_f_utf_string_dynamicss_resize(const f_array_length_t length, f_utf_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_dynamicss_decrease_by_) || !defined(_di_f_utf_string_dynamicss_increase_) || !defined(_di_f_utf_string_dynamicss_increase_by_) || !defined(_di_f_utf_string_dynamicss_append_all_) || !defined(_di_f_utf_string_map_multis_append_all_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_utf_dynamic_h diff --git a/level_0/f_utf/c/utf/private-map.c b/level_0/f_utf/c/utf/private-map.c new file mode 100644 index 0000000..ae45b45 --- /dev/null +++ b/level_0/f_utf/c/utf/private-map.c @@ -0,0 +1,160 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-map.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) + f_status_t private_f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t * const maps) { + + if (maps->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < maps->size; ++i) { + + status = private_f_utf_string_dynamic_adjust(0, &maps->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_adjust(0, &maps->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(maps->size, length, sizeof(f_utf_string_map_t), (void **) & maps->array); + if (F_status_is_error(status)) return status; + + maps->size = length; + + if (maps->used > maps->size) { + maps->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) + +#if !defined(_di_f_utf_string_maps_append_all_) || !defined(_di_f_utf_string_mapss_append_) || !defined(_di_f_utf_string_mapss_append_all_) + f_status_t private_f_utf_string_maps_append_all(const f_utf_string_maps_t source, f_utf_string_maps_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_maps_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.array[i].name.used) { + status = private_f_utf_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].value.used) { + status = private_f_utf_string_append(source.array[i].value.string, source.array[i].value.used, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_utf_string_maps_append_all_) || !defined(_di_f_utf_string_mapss_append_) || !defined(_di_f_utf_string_mapss_append_all_) + +#if !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) + f_status_t private_f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps) { + + if (maps->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < maps->size; ++i) { + + status = private_f_utf_string_dynamic_resize(0, &maps->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_resize(0, &maps->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(maps->size, length, sizeof(f_utf_string_map_t), (void **) & maps->array); + if (F_status_is_error(status)) return status; + + maps->size = length; + + if (maps->used > maps->size) { + maps->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) + +#if !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) + f_status_t private_f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { + + if (mapss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < mapss->size; ++i) { + + status = private_f_utf_string_maps_adjust(0, &mapss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(mapss->size, length, sizeof(f_utf_string_maps_t), (void **) & mapss->array); + if (F_status_is_error(status)) return status; + + mapss->size = length; + + if (mapss->used > mapss->size) { + mapss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) + +#if !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) + f_status_t private_f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) { + + if (mapss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < mapss->size; ++i) { + + status = private_f_utf_string_maps_resize(0, &mapss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(mapss->size, length, sizeof(f_utf_string_maps_t), (void **) & mapss->array); + if (F_status_is_error(status)) return status; + + mapss->size = length; + + if (mapss->used > mapss->size) { + mapss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-map.h b/level_0/f_utf/c/utf/private-map.h new file mode 100644 index 0000000..4d3f494 --- /dev/null +++ b/level_0/f_utf/c/utf/private-map.h @@ -0,0 +1,152 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_utf_map_h +#define _PRIVATE_F_utf_map_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param maps + * The maps to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_maps_adjust() + */ +#if !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) + extern f_status_t private_f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t * const maps) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_maps_append_all() + * @see f_utf_string_mapss_append() + * @see f_utf_string_mapss_append_all() + */ +#if !defined(_di_f_utf_string_maps_append_all_) || !defined(_di_f_utf_string_mapss_append_) || !defined(_di_f_utf_string_mapss_append_all_) + extern f_status_t private_f_utf_string_maps_append_all(const f_utf_string_maps_t source, f_utf_string_maps_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_maps_append_all_) || !defined(_di_f_utf_string_mapss_append_) || !defined(_di_f_utf_string_mapss_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param maps + * The maps to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_maps_decrease_by() + * @see f_utf_string_maps_increase() + * @see f_utf_string_maps_increase_by() + * @see f_utf_string_maps_terminate() + * @see f_utf_string_maps_terminate_after() + */ +#if !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) + extern f_status_t private_f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t * const maps) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mapss + * The mapss to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_mapss_adjust() + */ +#if !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) + extern f_status_t private_f_utf_string_mapss_adjust(const f_array_length_t length, f_utf_string_mapss_t * const mapss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_mapss_adjust_) || !defined(_di_f_utf_string_mapss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mapss + * The mapss to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_mapss_decrease_by() + * @see f_utf_string_mapss_increase() + * @see f_utf_string_mapss_increase_by() + * @see f_utf_string_mapss_terminate() + * @see f_utf_string_mapss_terminate_after() + */ +#if !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) + extern f_status_t private_f_utf_string_mapss_resize(const f_array_length_t length, f_utf_string_mapss_t * const mapss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_mapss_decrease_by_) || !defined(_di_f_utf_string_mapss_increase_) || !defined(_di_f_utf_string_mapss_increase_by_) || !defined(_di_f_utf_string_mapss_terminate_) || !defined(_di_f_utf_string_mapss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_utf_map_h diff --git a/level_0/f_utf/c/utf/private-map_multi.c b/level_0/f_utf/c/utf/private-map_multi.c new file mode 100644 index 0000000..7c6e226 --- /dev/null +++ b/level_0/f_utf/c/utf/private-map_multi.c @@ -0,0 +1,160 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-map_multi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) + f_status_t private_f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) { + + if (map_multis->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multis->size; ++i) { + + status = private_f_utf_string_dynamic_adjust(0, &map_multis->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamics_adjust(0, &map_multis->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(map_multis->size, length, sizeof(f_utf_string_map_multi_t), (void **) & map_multis->array); + if (F_status_is_error(status)) return status; + + map_multis->size = length; + + if (map_multis->used > map_multis->size) { + map_multis->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) + +#if !defined(_di_f_utf_string_map_multis_append_all_) || !defined(_di_f_utf_string_map_multiss_append_) || !defined(_di_f_utf_string_map_multiss_append_all_) + f_status_t private_f_utf_string_map_multis_append_all(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_map_multis_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.array[i].name.used) { + status = private_f_utf_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].value.used) { + status = private_f_utf_string_dynamics_append_all(source.array[i].value, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_utf_string_map_multis_append_all_) || !defined(_di_f_utf_string_map_multiss_append_) || !defined(_di_f_utf_string_map_multiss_append_all_) + +#if !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) + f_status_t private_f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) { + + if (map_multis->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multis->size; ++i) { + + status = private_f_utf_string_dynamic_resize(0, &map_multis->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamics_resize(0, &map_multis->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(map_multis->size, length, sizeof(f_utf_string_map_multi_t), (void **) & map_multis->array); + if (F_status_is_error(status)) return status; + + map_multis->size = length; + + if (map_multis->used > map_multis->size) { + map_multis->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) + +#if !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) + f_status_t private_f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { + + if (map_multiss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multiss->size; ++i) { + + status = private_f_utf_string_map_multis_adjust(0, &map_multiss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(map_multiss->size, length, sizeof(f_utf_string_map_multis_t), (void **) & map_multiss->array); + if (F_status_is_error(status)) return status; + + map_multiss->size = length; + + if (map_multiss->used > map_multiss->size) { + map_multiss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) + +#if !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) + f_status_t private_f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) { + + if (map_multiss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multiss->size; ++i) { + + status = private_f_utf_string_map_multis_resize(0, &map_multiss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(map_multiss->size, length, sizeof(f_utf_string_map_multis_t), (void **) & map_multiss->array); + if (F_status_is_error(status)) return status; + + map_multiss->size = length; + + if (map_multiss->used > map_multiss->size) { + map_multiss->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-map_multi.h b/level_0/f_utf/c/utf/private-map_multi.h new file mode 100644 index 0000000..b35a4dd --- /dev/null +++ b/level_0/f_utf/c/utf/private-map_multi.h @@ -0,0 +1,152 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_map_multi_h +#define _PRIVATE_F_map_multi_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_map_multis_adjust() + */ +#if !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) + extern f_status_t private_f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source map_multis to append. + * @param destination + * The destination map_multis the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_map_multis_append_all() + * @see f_utf_string_map_multiss_append() + * @see f_utf_string_map_multiss_append_all() + */ +#if !defined(_di_f_utf_string_map_multis_append_all_) || !defined(_di_f_utf_string_map_multiss_append_) || !defined(_di_f_utf_string_map_multiss_append_all_) + extern f_status_t private_f_utf_string_map_multis_append_all(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_map_multis_append_all_) || !defined(_di_f_utf_string_map_multiss_append_) || !defined(_di_f_utf_string_map_multiss_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_map_multis_decrease_by() + * @see f_utf_string_map_multis_increase() + * @see f_utf_string_map_multis_increase_by() + * @see f_utf_string_map_multis_terminate() + * @see f_utf_string_map_multis_terminate_after() + */ +#if !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) + extern f_status_t private_f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t * const map_multis) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_map_multiss_adjust() + */ +#if !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) + extern f_status_t private_f_utf_string_map_multiss_adjust(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_map_multiss_adjust_) || !defined(_di_f_utf_string_map_multiss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_map_multiss_decrease_by() + * @see f_utf_string_map_multiss_increase() + * @see f_utf_string_map_multiss_increase_by() + * @see f_utf_string_map_multiss_terminate() + * @see f_utf_string_map_multiss_terminate_after() + */ +#if !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) + extern f_status_t private_f_utf_string_map_multiss_resize(const f_array_length_t length, f_utf_string_map_multiss_t * const map_multiss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_map_multiss_decrease_by_) || !defined(_di_f_utf_string_map_multiss_increase_) || !defined(_di_f_utf_string_map_multiss_increase_by_) || !defined(_di_f_utf_string_map_multiss_terminate_) || !defined(_di_f_utf_string_map_multiss_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_map_multi_h diff --git a/level_0/f_utf/c/utf/private-string.c b/level_0/f_utf/c/utf/private-string.c index 507daa9..e15b5d3 100644 --- a/level_0/f_utf/c/utf/private-string.c +++ b/level_0/f_utf/c/utf/private-string.c @@ -1,4 +1,5 @@ #include "../utf.h" +#include "private-dynamic.h" #include "private-string.h" #ifdef __cplusplus @@ -6,47 +7,50 @@ extern "C" { #endif #if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) - f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { - if (destination->used + length > destination->size) { - const f_status_t status = private_f_utf_string_dynamic_increase_by(length, destination); + if (destination->used + length + 1 > destination->size) { + const f_status_t status = private_f_utf_string_dynamic_increase_by(length + 1, destination); if (F_status_is_error(status)) return status; } - memcpy(destination->string + destination->used, source, sizeof(f_char_t) * length); - destination->used = destination->used + length; + memcpy(destination->string + destination->used, source, sizeof(f_utf_character_t) * length); + destination->used += length; + destination->string[destination->used] = 0; return F_none; } #endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) #if !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) - f_status_t private_f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { - - if (destination->used + length > F_string_t_size_d) { - return F_status_set_error(F_string_too_large); - } + f_status_t private_f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { f_status_t status = F_none; f_array_length_t i = 0; - f_array_length_t first = 0; f_array_length_t size = 0; + // Count all of the NULLs and subtract them from the total size. for (; i < length; ++i) { + if (source[i]) ++size; + } // for + + if (destination->used + size + 1 > destination->size) { + status = private_f_utf_string_dynamic_increase_by(size + 1, destination); + if (F_status_is_error(status)) return status; + } + + f_array_length_t first = 0; + + for (i = 0, size = 0; i < length; ++i) { if (source[i]) continue; if (i && i > first) { size = i - first; - if (destination->used + size > destination->size) { - status = private_f_utf_string_dynamic_increase_by(size, destination); - if (F_status_is_error(status)) return status; - } - - memcpy(destination->string + destination->used, source + first, sizeof(f_char_t) * size); - destination->used = destination->used + size; + memcpy(destination->string + destination->used, source + first, sizeof(f_utf_character_t) * size); + destination->used += size; } while (i + 1 < length && !source[i + 1]) { @@ -59,271 +63,18 @@ extern "C" { if (i > first) { size = i - first; - if (destination->used + size > destination->size) { - status = private_f_utf_string_dynamic_increase_by(size, destination); - if (F_status_is_error(status)) return status; - } - - memcpy(destination->string + destination->used, source + first, sizeof(f_char_t) * size); - destination->used = destination->used + size; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) - -#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) - f_status_t private_f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t *dynamic) { - - const f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_utf_string_t), (void **) & dynamic->string); - if (F_status_is_error(status)) return status; - - dynamic->size = length; - - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) - -#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) - f_status_t private_f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic) { - - if (dynamic->used + amount > dynamic->size) { - if (dynamic->used + amount > F_string_t_size_d) { - return F_status_set_error(F_string_too_large); - } - - return private_f_utf_string_dynamic_resize(dynamic->used + amount, dynamic); - } - - return F_data_not; - } -#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) - -#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) - f_status_t private_f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *dynamic) { - - const f_status_t status = f_memory_resize(dynamic->size, length, sizeof(f_utf_string_t), (void **) & dynamic->string); - if (F_status_is_error(status)) return status; - - dynamic->size = length; - - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) - -#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t *dynamics) { - - if (dynamics->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamics->size; ++i) { - - status = private_f_utf_string_dynamic_adjust(0, &dynamics->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); - if (F_status_is_error(status)) return status; - - dynamics->size = length; - - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - -#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) - f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t *destination) { - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_dynamics_adjust(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].used = 0; - - if (source.array[i].used) { - status = private_f_utf_string_append(source.array[i].string, source.array[i].used, &destination->array[destination->used]); - if (F_status_is_error(status)) return status; - } - } // for - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) - -#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) - f_status_t private_f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t *dynamics) { - - if (dynamics->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < dynamics->size; ++i) { - status = private_f_utf_string_dynamic_resize(0, &dynamics->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); - if (F_status_is_error(status)) return status; - - dynamics->size = length; - - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) - -#if !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) - f_status_t private_f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t *map_multis) { - - if (map_multis->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < map_multis->size; ++i) { - - status = private_f_utf_string_dynamic_adjust(0, &map_multis->array[i].name); - if (F_status_is_error(status)) return status; - - status = private_f_utf_string_dynamics_adjust(0, &map_multis->array[i].value); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(map_multis->size, length, sizeof(f_utf_string_map_multi_t), (void **) & map_multis->array); - if (F_status_is_error(status)) return status; - - map_multis->size = length; - - if (map_multis->used > map_multis->size) { - map_multis->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) - -#if !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) - f_status_t private_f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t *map_multis) { - - if (map_multis->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < map_multis->size; ++i) { - - status = private_f_utf_string_dynamic_resize(0, &map_multis->array[i].name); - if (F_status_is_error(status)) return status; - - status = private_f_utf_string_dynamics_resize(0, &map_multis->array[i].value); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(map_multis->size, length, sizeof(f_utf_string_map_multi_t), (void **) & map_multis->array); - if (F_status_is_error(status)) return status; - - map_multis->size = length; - - if (map_multis->used > map_multis->size) { - map_multis->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) - -#if !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) - f_status_t private_f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t *maps) { - - if (maps->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); + memcpy(destination->string + destination->used, source + first, sizeof(f_utf_character_t) * size); + destination->used += size; } - f_status_t status = F_none; - - for (f_array_length_t i = length; i < maps->size; ++i) { - - status = private_f_utf_string_dynamic_adjust(0, &maps->array[i].name); - if (F_status_is_error(status)) return status; - - status = private_f_utf_string_dynamic_adjust(0, &maps->array[i].value); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(maps->size, length, sizeof(f_utf_string_map_t), (void **) & maps->array); - if (F_status_is_error(status)) return status; - - maps->size = length; - - if (maps->used > maps->size) { - maps->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) - -#if !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) - f_status_t private_f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t *maps) { - - if (maps->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < maps->size; ++i) { - - status = private_f_utf_string_dynamic_resize(0, &maps->array[i].name); - if (F_status_is_error(status)) return status; - - status = private_f_utf_string_dynamic_resize(0, &maps->array[i].value); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(maps->size, length, sizeof(f_utf_string_map_t), (void **) & maps->array); - if (F_status_is_error(status)) return status; - - maps->size = length; - - if (maps->used > maps->size) { - maps->used = length; - } + destination->string[destination->used] = 0; return F_none; } -#endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) +#endif // !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) #if !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) - f_status_t private_f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t private_f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { if (destination->used + length > F_string_t_size_d) { return F_status_set_error(F_string_too_large); @@ -336,20 +87,19 @@ extern "C" { if (destination->used) { memmove(destination->string + length, destination->string, destination->used); - memcpy(destination->string, source, sizeof(f_char_t) * length); + memcpy(destination->string, source, sizeof(f_utf_character_t) * length); } else { - memcpy(destination->string, source, sizeof(f_char_t) * length); + memcpy(destination->string, source, sizeof(f_utf_character_t) * length); } - destination->used = destination->used + length; - + destination->used += length; return F_none; } #endif // !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) #if !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) - f_status_t private_f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t private_f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) { if (destination->used + length > F_string_t_size_d) { return F_status_set_error(F_string_too_large); @@ -374,9 +124,9 @@ extern "C" { } memmove(destination->string + offset + size, destination->string + offset, destination->used - offset); - memcpy(destination->string + offset, source + first, sizeof(f_char_t) * size); + memcpy(destination->string + offset, source + first, size); - destination->used = destination->used + size; + destination->used += size; offset += size; } @@ -394,9 +144,9 @@ extern "C" { } memmove(destination->string + offset + size, destination->string + offset, destination->used - offset); - memcpy(destination->string + offset, source + first, sizeof(f_char_t) * size); + memcpy(destination->string + offset, source + first, sizeof(f_utf_character_t) * size); - destination->used = destination->used + size; + destination->used += size; offset += size; } } @@ -414,74 +164,6 @@ extern "C" { } #endif // !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) -#if !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) - f_status_t private_f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t *triples) { - - if (triples->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < triples->size; ++i) { - - status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].a); - if (F_status_is_error(status)) return status; - - status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].b); - if (F_status_is_error(status)) return status; - - status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].c); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(triples->size, length, sizeof(f_utf_string_triple_t), (void **) & triples->array); - if (F_status_is_error(status)) return status; - - triples->size = length; - - if (triples->used > triples->size) { - triples->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) - -#if !defined(_di_f_utf_string_triples_decrease_) || !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) - f_status_t private_f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t *triples) { - - if (triples->used + length > F_array_length_t_size_d) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < triples->size; ++i) { - - status = private_f_utf_string_dynamic_resize(0, &triples->array[i].a); - if (F_status_is_error(status)) return status; - - status = private_f_utf_string_dynamic_resize(0, &triples->array[i].b); - if (F_status_is_error(status)) return status; - - status = private_f_utf_string_dynamic_resize(0, &triples->array[i].c); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(triples->size, length, sizeof(f_utf_string_triple_t), (void **) & triples->array); - if (F_status_is_error(status)) return status; - - triples->size = length; - - if (triples->used > triples->size) { - triples->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_utf_string_triples_decrease_) || !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/private-string.h b/level_0/f_utf/c/utf/private-string.h index e7679f1..faefd4b 100644 --- a/level_0/f_utf/c/utf/private-string.h +++ b/level_0/f_utf/c/utf/private-string.h @@ -53,7 +53,7 @@ extern "C" { * @see f_utf_string_triples_append() */ #if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) - extern f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) /** @@ -86,318 +86,10 @@ extern "C" { * @see f_utf_string_mash_nulless() */ #if !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) - extern f_status_t private_f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) /** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param string - * The string to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_dynamic_adjust() - * @see f_utf_string_dynamic_decimate_by() - * @see f_utf_string_dynamics_adjust() - * @see f_utf_string_dynamics_append() - * @see f_utf_string_dynamics_decimate_by() - * @see f_utf_string_map_multis_adjust() - * @see f_utf_string_map_multis_append() - * @see f_utf_string_triples_adjust() - * @see f_utf_string_triples_decimate_by() - */ -#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) - extern f_status_t private_f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t *string) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) - -/** - * Private implementation of f_utf_string_dynamic_increase_by(). - * - * Intended to be shared to each of the different implementation variations. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param string - * The string to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see memcpy() - * - * @see f_utf_string_append() - * @see f_utf_string_append_assure() - * @see f_utf_string_append_mash() - * @see f_utf_string_append_nulless() - * @see f_utf_string_dynamic_append() - * @see f_utf_string_dynamic_append_assure() - * @see f_utf_string_dynamic_append_nulless() - * @see f_utf_string_dynamic_increase_by() - * @see f_utf_string_dynamic_mash() - * @see f_utf_string_dynamic_mash_nulless() - * @see f_utf_string_dynamic_partial_append) - * @see f_utf_string_dynamic_partial_append_assure() - * @see f_utf_string_dynamic_partial_mash() - * @see f_utf_string_dynamic_prepend() - * @see f_utf_string_dynamic_prepend_nulless() - * @see f_utf_string_dynamics_append() - * @see f_utf_string_map_multis_append() - * @see f_utf_string_mash() - * @see f_utf_string_mash_nulless() - * @see f_utf_string_maps_append() - * @see f_utf_string_prepend() - * @see f_utf_string_prepend_nulless() - * @see f_utf_string_triples_append() - */ -#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) - extern f_status_t private_f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t *string) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param string - * The string to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_utf_string_append() - * @see f_utf_string_append_assure() - * @see f_utf_string_append_mash() - * @see f_utf_string_append_nulless() - * @see f_utf_string_dynamic_append() - * @see f_utf_string_dynamic_append_assure() - * @see f_utf_string_dynamic_append_nulless() - * @see f_utf_string_dynamic_decrease_by() - * @see f_utf_string_dynamic_increase() - * @see f_utf_string_dynamic_increase_by() - * @see f_utf_string_dynamic_mash() - * @see f_utf_string_dynamic_mash_nulless() - * @see f_utf_string_dynamic_partial_append) - * @see f_utf_string_dynamic_partial_append_assure() - * @see f_utf_string_dynamic_partial_mash() - * @see f_utf_string_dynamic_prepend() - * @see f_utf_string_dynamic_prepend_nulless() - * @see f_utf_string_dynamic_terminate() - * @see f_utf_string_dynamic_terminate_after() - * @see f_utf_string_dynamics_append() - * @see f_utf_string_map_multis_append() - * @see f_utf_string_mash_nulless() - * @see f_utf_string_mash() - * @see f_utf_string_maps_append() - * @see f_utf_string_prepend() - * @see f_utf_string_prepend_nulless() - * @see f_utf_string_triples_append() - */ -#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) - extern f_status_t private_f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *string) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param strings - * The strings to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_dynamics_adjust() - * @see f_utf_string_dynamics_append() - * @see f_utf_string_dynamics_decimate_by() - * @see f_utf_string_map_multis_adjust() - * @see f_utf_string_map_multis_append() - */ -#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - extern f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t *strings) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) - -/** - * Private implementation for appending. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source strings to append. - * @param destination - * The destination strings the source is appended onto. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_utf_string_dynamics_append() - * @see f_utf_string_map_multis_append() - */ -#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) - extern f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t *destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param strings - * The strings to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_utf_string_dynamics_decrease_by() - * @see f_utf_string_dynamics_increase() - * @see f_utf_string_dynamics_increase_by() - */ -#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) - extern f_status_t private_f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t *strings) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param map_multis - * The map_multis to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_map_multis_adjust() - */ -#if !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) - extern f_status_t private_f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t *map_multis) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param map_multis - * The map_multis to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_utf_string_map_multis_decrease_by() - * @see f_utf_string_map_multis_increase() - * @see f_utf_string_map_multis_increase_by() - * @see f_utf_string_map_multis_terminate() - * @see f_utf_string_map_multis_terminate_after() - */ -#if !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) - extern f_status_t private_f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t *map_multis) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param maps - * The maps to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_maps_adjust() - */ -#if !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) - extern f_status_t private_f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t *maps) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param maps - * The maps to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_adjust() - * @see f_utf_string_maps_decrease_by() - * @see f_utf_string_maps_increase() - * @see f_utf_string_maps_increase_by() - * @see f_utf_string_maps_terminate() - * @see f_utf_string_maps_terminate_after() - */ -#if !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) - extern f_status_t private_f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t *maps) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) - -/** * Private implementation of f_utf_string_prepend(). * * Intended to be shared to each of the different implementation variations. @@ -430,7 +122,7 @@ extern "C" { * @see f_utf_string_prepend() */ #if !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) - extern f_status_t private_f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) /** @@ -466,61 +158,9 @@ extern "C" { * @see f_utf_string_prepend_nulless() */ #if !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) - extern f_status_t private_f_utf_string_prepend_nulless(const f_utf_string_t source, f_array_length_t length, f_utf_string_dynamic_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_utf_string_prepend_nulless(const f_utf_string_t source, f_array_length_t length, f_utf_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param triples - * The triples to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_utf_string_triples_adjust() - * @see f_utf_string_triples_decimate_by() - */ -#if !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) - extern f_status_t private_f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t *triples) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param triples - * The triples to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_utf_string_triples_decrease_by() - * @see f_utf_string_triples_increase() - * @see f_utf_string_triples_increase_by() - * @see f_utf_string_triples_terminate() - * @see f_utf_string_triples_terminate_after() - */ -#if !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) - extern f_status_t private_f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t *triples) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_utf/c/utf/private-triple.c b/level_0/f_utf/c/utf/private-triple.c new file mode 100644 index 0000000..34bd775 --- /dev/null +++ b/level_0/f_utf/c/utf/private-triple.c @@ -0,0 +1,172 @@ +#include "../utf.h" +#include "../private-utf.h" +#include "private-dynamic.h" +#include "private-triple.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + f_status_t private_f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t * const triples) { + + if (triples->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < triples->size; ++i) { + + status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].a); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].b); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].c); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(triples->size, length, sizeof(f_utf_string_triple_t), (void **) & triples->array); + if (F_status_is_error(status)) return status; + + triples->size = length; + + if (triples->used > triples->size) { + triples->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + +#if !defined(_di_f_utf_string_triples_append_all_) || !defined(_di_f_utf_string_tripless_append_) || !defined(_di_f_utf_string_tripless_append_all_) + f_status_t private_f_utf_string_triples_append_all(const f_utf_string_triples_t source, f_utf_string_triples_t * const destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_triples_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].a.used = 0; + destination->array[destination->used].b.used = 0; + destination->array[destination->used].c.used = 0; + + if (source.array[i].a.used) { + status = private_f_utf_string_append(source.array[i].a.string, source.array[i].a.used, &destination->array[destination->used].a); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].b.used) { + status = private_f_utf_string_append(source.array[i].b.string, source.array[i].b.used, &destination->array[destination->used].b); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].c.used) { + status = private_f_utf_string_append(source.array[i].c.string, source.array[i].c.used, &destination->array[destination->used].c); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_utf_string_triples_append_all_) || !defined(_di_f_utf_string_tripless_append_) || !defined(_di_f_utf_string_tripless_append_all_) + +#if !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) + f_status_t private_f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples) { + + if (triples->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < triples->size; ++i) { + + status = private_f_utf_string_dynamic_resize(0, &triples->array[i].a); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_resize(0, &triples->array[i].b); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_resize(0, &triples->array[i].c); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(triples->size, length, sizeof(f_utf_string_triple_t), (void **) & triples->array); + if (F_status_is_error(status)) return status; + + triples->size = length; + + if (triples->used > triples->size) { + triples->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) + +#if !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) + f_status_t private_f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { + + if (tripless->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < tripless->size; ++i) { + + status = private_f_utf_string_triples_adjust(0, &tripless->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(tripless->size, length, sizeof(f_utf_string_triples_t), (void **) & tripless->array); + if (F_status_is_error(status)) return status; + + tripless->size = length; + + if (tripless->used > tripless->size) { + tripless->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) + +#if !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) + f_status_t private_f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { + + if (tripless->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < tripless->size; ++i) { + + status = private_f_utf_string_triples_resize(0, &tripless->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(tripless->size, length, sizeof(f_utf_string_triples_t), (void **) & tripless->array); + if (F_status_is_error(status)) return status; + + tripless->size = length; + + if (tripless->used > tripless->size) { + tripless->used = length; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/private-triple.h b/level_0/f_utf/c/utf/private-triple.h new file mode 100644 index 0000000..d8c4b45 --- /dev/null +++ b/level_0/f_utf/c/utf/private-triple.h @@ -0,0 +1,152 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_utf_triple_h +#define _PRIVATE_F_utf_triple_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param triples + * The triples to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_triples_adjust() + */ +#if !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + extern f_status_t private_f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t * const triples) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source triples to append. + * @param destination + * The destination triples the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_triples_append_all() + * @see f_utf_string_tripless_append() + * @see f_utf_string_tripless_append_all() + */ +#if !defined(_di_f_utf_string_triples_append_all_) || !defined(_di_f_utf_string_tripless_append_) || !defined(_di_f_utf_string_tripless_append_all_) + extern f_status_t private_f_utf_string_triples_append_all(const f_utf_string_triples_t source, f_utf_string_triples_t * const destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_triples_append_all_) || !defined(_di_f_utf_string_tripless_append_) || !defined(_di_f_utf_string_tripless_append_all_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param triples + * The triples to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_triples_decrease_by() + * @see f_utf_string_triples_increase() + * @see f_utf_string_triples_increase_by() + * @see f_utf_string_triples_terminate() + * @see f_utf_string_triples_terminate_after() + */ +#if !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) + extern f_status_t private_f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param tripless + * The tripless to adjust. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_tripless_adjust() + */ +#if !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) + extern f_status_t private_f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_tripless_adjust_) || !defined(_di_f_utf_string_tripless_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param tripless + * The tripless to resize. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_tripless_decrease_by() + * @see f_utf_string_tripless_increase() + * @see f_utf_string_tripless_increase_by() + * @see f_utf_string_tripless_terminate() + * @see f_utf_string_tripless_terminate_after() + */ +#if !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) + extern f_status_t private_f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_utf_string_tripless_decrease_by_) || !defined(_di_f_utf_string_tripless_increase_) || !defined(_di_f_utf_string_tripless_increase_by_) || !defined(_di_f_utf_string_tripless_terminate_) || !defined(_di_f_utf_string_tripless_terminate_after_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_utf_triple_h diff --git a/level_0/f_utf/c/utf/static.c b/level_0/f_utf/c/utf/static.c new file mode 100644 index 0000000..7ec218e --- /dev/null +++ b/level_0/f_utf/c/utf/static.c @@ -0,0 +1,13 @@ +#include "../utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_empty_s_ + const f_utf_string_static_t f_utf_string_empty_s = macro_f_utf_string_static_t_initialize(0, 0, 0); +#endif // _di_f_utf_string_empty_s_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf/static.h b/level_0/f_utf/c/utf/static.h new file mode 100644 index 0000000..2bea07d --- /dev/null +++ b/level_0/f_utf/c/utf/static.h @@ -0,0 +1,115 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Defines static string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_static_h +#define _F_utf_static_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A string that is analogous to f_utf_string_dynamic_t but intended for static-only uses. + * + * The f_utf_string_static_t type should never be directly allocated or deallocated. + * + * A special macro_f_utf_string_static_t_initialize() is provided for the special purpose of easily initialize a static string. + * A special macro_f_utf_string_static_t_initialize2() is provided for the special purpose of easily initialize a static string with an identical used and size. + * + * string: The string. + * size: Total amount of space available. + * used: Total number of space used. + */ +#ifndef _di_f_utf_string_static_t_ + typedef struct { + f_utf_string_t string; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_static_t; + + #define f_utf_string_static_t_initialize { 0, 0, 0 } + + #define macro_f_utf_string_static_t_initialize(string, size, used) { string, size, used } + #define macro_f_utf_string_static_t_initialize2(string, length) { string, length, length } + + #define macro_f_utf_string_static_t_clear(string_static) \ + string_static.string = 0; \ + string_static.size = 0; \ + string_static.used = 0; +#endif // _di_f_utf_string_static_t_ + +/** + * An array of static strings. + * + * array: The array of static strings. + * size: Total amount of space available. + * used: Total number of space used. + */ +#ifndef _di_f_utf_string_statics_t_ + typedef struct { + f_utf_string_static_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_statics_t; + + #define f_utf_string_statics_t_initialize { 0, 0, 0 } + + #define macro_f_utf_string_statics_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_statics_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_statics_t_clear(statics) \ + statics.array = 0; \ + statics.size = 0; \ + statics.used = 0; +#endif // _di_f_utf_string_statics_t_ + +/** + * An array of static strings. + * + * array: The array of static strings. + * size: Total amount of space available. + * used: Total number of space used. + */ +#ifndef _di_f_utf_string_staticss_t_ + typedef struct { + f_utf_string_statics_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_staticss_t; + + #define f_utf_string_staticss_t_initialize { 0, 0, 0 } + + #define macro_f_utf_string_staticss_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_staticss_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_staticss_t_clear(staticss) \ + staticss.array = 0; \ + staticss.size = 0; \ + staticss.used = 0; +#endif // _di_f_utf_string_staticss_t_ + +/** + * Provide a static empty string. + * + * This is intended to represent an empty string. + */ +#ifndef _di_f_utf_string_empty_s_ + extern const f_utf_string_static_t f_utf_string_empty_s; +#endif // _di_f_utf_string_empty_s_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_static_h diff --git a/level_0/f_utf/c/utf/string.c b/level_0/f_utf/c/utf/string.c index a3fc569..f836462 100644 --- a/level_0/f_utf/c/utf/string.c +++ b/level_0/f_utf/c/utf/string.c @@ -1,4 +1,5 @@ #include "../utf.h" +#include "private-dynamic.h" #include "private-string.h" #ifdef __cplusplus @@ -6,25 +7,28 @@ extern "C" { #endif #ifndef _di_f_utf_string_append_ - f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) return F_data_not; return private_f_utf_string_append(source, length, destination); } #endif // _di_f_utf_string_append_ #ifndef _di_f_utf_string_append_assure_ - f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; - if (destination->used < length) return private_f_utf_string_append(source, length, destination); + if (!length) return F_data_not; + + if (destination->used < length) { + return private_f_utf_string_append(source, length, destination); + } f_array_length_t i = 1; f_array_length_t j = 1; @@ -56,16 +60,14 @@ extern "C" { #endif // _di_f_utf_string_append_assure_ #ifndef _di_f_utf_string_append_assure_nulless_ - f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) { - return F_data_not_eos; - } + if (!length) return F_data_not; - if (destination->used < length) { + if (!destination->used) { return private_f_utf_string_append_nulless(source, length, destination); } @@ -99,24 +101,26 @@ extern "C" { #endif // _di_f_utf_string_append_assure_nulless_ #ifndef _di_f_utf_string_append_nulless_ - f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) return F_data_not; return private_f_utf_string_append_nulless(source, length, destination); } #endif // _di_f_utf_string_append_nulless_ #ifndef _di_f_utf_string_mash_ - f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) { + return F_data_not; + } if (glue_length && destination->used) { f_status_t status = private_f_utf_string_append(glue, glue_length, destination); @@ -128,12 +132,12 @@ extern "C" { #endif // _di_f_utf_string_mash_ #ifndef _di_f_utf_string_mash_nulless_ - f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) return F_data_not; if (glue_length && destination->used) { f_status_t status = private_f_utf_string_append_nulless(glue, glue_length, destination); @@ -145,12 +149,12 @@ extern "C" { #endif // _di_f_utf_string_mash_nulless_ #ifndef _di_f_utf_string_mish_ - f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) return F_data_not; if (glue_length && destination->used) { f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); @@ -162,12 +166,12 @@ extern "C" { #endif // _di_f_utf_string_mish_ #ifndef _di_f_utf_string_mish_nulless_ - f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) return F_data_not; if (glue_length && destination->used) { f_status_t status = private_f_utf_string_prepend_nulless(glue, glue_length, destination); @@ -179,24 +183,24 @@ extern "C" { #endif // _di_f_utf_string_mish_nulless_ #ifndef _di_f_utf_string_prepend_ - f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) return F_data_not; return private_f_utf_string_prepend(source, length, destination); } #endif // _di_f_utf_string_prepend_ #ifndef _di_f_utf_string_prepend_assure_ - f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) return F_data_not; if (destination->used < length) { return private_f_utf_string_prepend(source, length, destination); @@ -219,7 +223,7 @@ extern "C" { continue; } - if (source[i] != destination->string[i]) { + if (source[i] != destination->string[j]) { return private_f_utf_string_prepend(source, length, destination); } @@ -232,16 +236,14 @@ extern "C" { #endif // _di_f_utf_string_prepend_assure_ #ifndef _di_f_utf_string_prepend_assure_nulless_ - f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) { - return F_data_not_eos; - } + if (!length) return F_data_not; - if (destination->used < length) { + if (!destination->used) { return private_f_utf_string_prepend_nulless(source, length, destination); } @@ -262,7 +264,7 @@ extern "C" { continue; } - if (source[i] != destination->string[i]) { + if (source[i] != destination->string[j]) { return private_f_utf_string_prepend_nulless(source, length, destination); } @@ -275,12 +277,12 @@ extern "C" { #endif // _di_f_utf_string_prepend_assure_nulless_ #ifndef _di_f_utf_string_prepend_nulless_ - f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_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 (!length) return F_data_not_eos; + if (!length) return F_data_not; return private_f_utf_string_prepend_nulless(source, length, destination); } @@ -314,7 +316,7 @@ extern "C" { #endif // _di_f_utf_string_seek_line_ #ifndef _di_f_utf_string_seek_line_to_ - f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const uint8_t seek_to, f_string_range_t *range) { + f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const f_char_t seek_to, f_string_range_t * const range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -345,7 +347,7 @@ extern "C" { #endif // _di_f_utf_string_seek_line_to_ #ifndef _di_f_utf_string_seek_to_ - f_status_t f_utf_string_seek_to(const f_utf_string_t string, const uint8_t seek_to, f_string_range_t *range) { + f_status_t f_utf_string_seek_to(const f_utf_string_t string, const f_char_t seek_to, f_string_range_t * const range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_utf/c/utf/string.h b/level_0/f_utf/c/utf/string.h index b322ad6..98083d8 100644 --- a/level_0/f_utf/c/utf/string.h +++ b/level_0/f_utf/c/utf/string.h @@ -28,19 +28,21 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. * * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() */ #ifndef _di_f_utf_string_append_ - extern f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_append_ /** - * Append the source string onto the destination, but only if the string is not already at the end. + * Append the source string onto the destination only if the string is not already at the end. * * This ignores NULL characters when comparing both the source and the destination. * @@ -53,19 +55,21 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. * * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() */ #ifndef _di_f_utf_string_append_assure_ - extern f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_append_assure_ /** - * Append the source string onto the destination, but only if the string is not already at the end. + * Append the source string onto the destination only if the string is not already at the end. * * This ignores NULL characters when comparing both the source and the destination. * Skips over NULL characters from source when appending. @@ -79,7 +83,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -87,7 +91,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_append_assure_nulless_ - extern f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_append_assure_nulless_ /** @@ -104,7 +108,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -112,7 +116,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_append_nulless_ - extern f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_append_nulless_ /** @@ -133,7 +137,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -141,7 +145,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_mash_ - extern f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_mash_ /** @@ -164,7 +168,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -172,7 +176,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_mash_nulless_ - extern f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_mash_nulless_ /** @@ -193,7 +197,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -201,7 +205,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_mish_ - extern f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_mish_ /** @@ -224,7 +228,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -232,7 +236,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_mish_nulless_ - extern f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_mish_nulless_ /** @@ -249,7 +253,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -257,11 +261,11 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_prepend_ - extern f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_prepend_ /** - * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * Prepend the source string onto the destination only if the string is not already at the beginning. * * Prepend operations require memory move operations and are therefore likely more expensive than append operations. * @@ -276,7 +280,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -284,11 +288,11 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_prepend_assure_ - extern f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_prepend_assure_ /** - * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * Prepend the source string onto the destination only if the string is not already at the beginning. * * Prepend operations require memory move operations and are therefore likely more expensive than append operations. * @@ -304,7 +308,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -312,7 +316,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_prepend_assure_nulless_ - extern f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_prepend_assure_nulless_ /** @@ -332,7 +336,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not_eos if source length is 0. + * F_data_not if source length is 0. * * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. @@ -340,7 +344,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_prepend_nulless_ - extern f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t * const destination); #endif // _di_f_utf_string_prepend_nulless_ /** @@ -364,7 +368,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_seek_line_ - extern f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_string_range_t *range); + extern f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_string_range_t * const range); #endif // _di_f_utf_string_seek_line_ /** @@ -381,7 +385,7 @@ extern "C" { * @return * F_none on success. * F_none_eol on success, but stopped at EOL. - * F_none_stop on success, but stopped stop location. + * F_none_stop on success, but stopped at the stop location. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -389,7 +393,7 @@ extern "C" { * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. */ #ifndef _di_f_utf_string_seek_line_to_ - extern f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const uint8_t seek_to, f_string_range_t *range); + extern f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const f_char_t seek_to, f_string_range_t * const range); #endif // _di_f_utf_string_seek_line_to_ /** @@ -405,7 +409,7 @@ extern "C" { * * @return * F_none on success. - * F_none_stop on success, but stopped stop location. + * F_none_stop on success, but stopped at the stop location. * F_data_not_stop if range.start > range.stop. * * F_parameter (with error bit) if a parameter is invalid. @@ -413,7 +417,7 @@ extern "C" { * F_utf_fragment (with error bit) if character is an incomplete UTF-8 fragment. */ #ifndef _di_f_utf_string_seek_to_ - extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, const uint8_t seek_to, f_string_range_t *range); + extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, const f_char_t seek_to, f_string_range_t * const range); #endif // _di_f_utf_string_seek_to_ #ifdef __cplusplus diff --git a/level_0/f_utf/c/utf/triple.c b/level_0/f_utf/c/utf/triple.c index ce2320d..864f9db 100644 --- a/level_0/f_utf/c/utf/triple.c +++ b/level_0/f_utf/c/utf/triple.c @@ -1,13 +1,14 @@ #include "../utf.h" #include "../private-utf.h" #include "private-string.h" +#include "private-triple.h" #ifdef __cplusplus extern "C" { #endif #ifndef _di_f_utf_string_triples_adjust_ - f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t *triples) { + f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -17,15 +18,51 @@ extern "C" { #endif // _di_f_utf_string_triples_adjust_ #ifndef _di_f_utf_string_triples_append_ - f_status_t f_utf_string_triples_append(const f_utf_string_triples_t source, f_utf_string_triples_t *destination) { + f_status_t f_utf_string_triples_append(const f_utf_string_triple_t source, f_utf_string_triples_t * const destination) { #ifndef _di_level_0_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!source.used) { - return F_data_not; + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_triples_adjust(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].a.used = 0; + destination->array[destination->used].b.used = 0; + destination->array[destination->used].c.used = 0; + + if (source.a.used) { + status = private_f_utf_string_append(source.a.string, source.a.used, &destination->array[destination->used].a); + if (F_status_is_error(status)) return status; + } + + if (source.b.used) { + status = private_f_utf_string_append(source.b.string, source.b.used, &destination->array[destination->used].b); + if (F_status_is_error(status)) return status; + } + + if (source.c.used) { + status = private_f_utf_string_append(source.c.string, source.c.used, &destination->array[destination->used].c); + if (F_status_is_error(status)) return status; } + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_triples_append_ + +#ifndef _di_f_utf_string_triples_append_all_ + f_status_t f_utf_string_triples_append_all(const f_utf_string_triples_t source, f_utf_string_triples_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + f_status_t status = F_none; if (destination->used + source.used > destination->size) { @@ -57,18 +94,14 @@ extern "C" { return F_none; } -#endif // _di_f_utf_string_triples_append_ +#endif // _di_f_utf_string_triples_append_all_ #ifndef _di_f_utf_string_triples_decimate_by_ - f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { + f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } - if (triples->size - amount > 0) { return private_f_utf_string_triples_adjust(triples->size - amount, triples); } @@ -78,14 +111,12 @@ extern "C" { #endif // _di_f_utf_string_triples_decimate_by_ #ifndef _di_f_utf_string_triples_decrease_by_ - f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { + f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (triples->size - amount > 0) { return private_f_utf_string_triples_resize(triples->size - amount, triples); @@ -96,13 +127,13 @@ extern "C" { #endif // _di_f_utf_string_triples_decrease_by_ #ifndef _di_f_utf_string_triples_increase_ - f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t *triples) { + f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (step && triples->used + 1 > triples->size) { - f_array_length_t size = triples->used + step; + f_array_length_t size = triples->used + F_memory_default_allocation_small_d; if (size > F_array_length_t_size_d) { if (triples->used + 1 > F_array_length_t_size_d) { @@ -120,14 +151,12 @@ extern "C" { #endif // _di_f_utf_string_triples_increase_ #ifndef _di_f_utf_string_triples_increase_by_ - f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { + f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) { - return F_data_not; - } + if (!amount) return F_data_not; if (triples->used + amount > triples->size) { if (triples->used + amount > F_array_length_t_size_d) { @@ -142,7 +171,7 @@ extern "C" { #endif // _di_f_utf_string_triples_increase_by_ #ifndef _di_f_utf_string_triples_resize_ - f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t *triples) { + f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples) { #ifndef _di_level_0_parameter_checking_ if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -151,6 +180,159 @@ extern "C" { } #endif // _di_f_utf_string_triples_resize_ +#ifndef _di_f_utf_string_tripless_append_ + f_status_t f_utf_string_tripless_append(const f_utf_string_triples_t source, f_utf_string_tripless_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + 1 > destination->size) { + status = private_f_utf_string_tripless_resize(destination->used + F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) return status; + } + + destination->array[destination->used].used = 0; + + if (source.used) { + status = private_f_utf_string_triples_append_all(source, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + + ++destination->used; + + return F_none; + } +#endif // _di_f_utf_string_tripless_append_ + +#ifndef _di_f_utf_string_tripless_append_all_ + f_status_t f_utf_string_tripless_append_all(const f_utf_string_tripless_t source, f_utf_string_tripless_t * const destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_tripless_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_triples_append_all(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_tripless_append_all_ + +#ifndef _di_f_utf_string_tripless_adjust_ + f_status_t f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_tripless_adjust(length, tripless); + } +#endif // _di_f_utf_string_tripless_adjust_ + +#ifndef _di_f_utf_string_tripless_decimate_by_ + f_status_t f_utf_string_tripless_decimate_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (tripless->size - amount > 0) { + return private_f_utf_string_tripless_adjust(tripless->size - amount, tripless); + } + + return private_f_utf_string_tripless_adjust(0, tripless); + } +#endif // _di_f_utf_string_tripless_decimate_by_ + +#ifndef _di_f_utf_string_tripless_decrease_by_ + f_status_t f_utf_string_tripless_decrease_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (tripless->size - amount > 0) { + return private_f_utf_string_tripless_resize(tripless->size - amount, tripless); + } + + return private_f_utf_string_tripless_resize(0, tripless); + } +#endif // _di_f_utf_string_tripless_decrease_by_ + +#ifndef _di_f_utf_string_tripless_increase_ + f_status_t f_utf_string_tripless_increase(const f_array_length_t step, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (step && tripless->used + 1 > tripless->size) { + f_array_length_t size = tripless->used + step; + + if (size > F_array_length_t_size_d) { + if (tripless->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_utf_string_tripless_resize(size, tripless); + } + + return F_data_not; + } +#endif // _di_f_utf_string_tripless_increase_ + +#ifndef _di_f_utf_string_tripless_increase_by_ + f_status_t f_utf_string_tripless_increase_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!amount) return F_data_not; + + if (tripless->used + amount > tripless->size) { + if (tripless->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_tripless_resize(tripless->used + amount, tripless); + } + + return F_data_not; + } +#endif // _di_f_utf_string_tripless_increase_by_ + +#ifndef _di_f_utf_string_tripless_resize_ + f_status_t f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless) { + #ifndef _di_level_0_parameter_checking_ + if (!tripless) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_tripless_resize(length, tripless); + } +#endif // _di_f_utf_string_tripless_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf/triple.h b/level_0/f_utf/c/utf/triple.h index 15a6891..dd5e7ff 100644 --- a/level_0/f_utf/c/utf/triple.h +++ b/level_0/f_utf/c/utf/triple.h @@ -9,8 +9,8 @@ * * This is auto-included by utf.h and should not need to be explicitly included. */ -#ifndef _F_utf_string_triple_h -#define _F_utf_string_triple_h +#ifndef _F_utf_triple_h +#define _F_utf_triple_h #ifdef __cplusplus extern "C" { @@ -43,6 +43,8 @@ extern "C" { triple.c.size = 0; \ triple.c.used = 0; + #define macro_f_utf_string_triple_t_initialize(a, b, c) { a, b, c } + #define macro_f_utf_string_triple_t_delete_simple(triple) \ macro_f_utf_string_dynamic_t_delete_simple(triple.a) \ macro_f_utf_string_dynamic_t_delete_simple(triple.b) \ @@ -57,9 +59,9 @@ extern "C" { /** * An array of string triples. * - * array: the array of string triples. - * size: total amount of allocated space. - * used: total number of allocated spaces used. + * array: The array of string triples. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. */ #ifndef _di_f_utf_string_triples_t_ typedef struct { @@ -71,6 +73,9 @@ extern "C" { #define f_utf_string_triples_t_initialize f_utf_string_statics_t_initialize + #define macro_f_utf_string_triples_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_triples_t_initialize2(array, length) { array, length, length } + #define macro_f_utf_string_triples_t_clear(triples) macro_f_memory_structure_clear(triples) #define macro_f_utf_string_triples_t_resize(status, triples, length) status = f_utf_string_triples_resize(length, &triples); @@ -79,13 +84,47 @@ extern "C" { #define macro_f_utf_string_triples_t_delete_simple(triples) f_utf_string_triples_resize(0, &triples); #define macro_f_utf_string_triples_t_destroy_simple(triples) f_utf_string_triples_adjust(0, &triples); - #define macro_f_utf_string_triples_t_increase(status, triples) status = f_utf_string_triples_increase(triples); + #define macro_f_utf_string_triples_t_increase(status, step, triples) status = f_utf_string_triples_increase(step, triples); #define macro_f_utf_string_triples_t_increase_by(status, triples, amount) status = f_utf_string_triples_increase_by(amount, triples); #define macro_f_utf_string_triples_t_decrease_by(status, triples, amount) status = f_utf_string_triples_decrease_by(amount, triples); #define macro_f_utf_string_triples_t_decimate_by(status, triples, amount) status = f_utf_string_triples_decimate_by(amount, triples); #endif // _di_f_utf_string_triples_t_ /** + * An array of string tripless. + * + * array: The array of string triples. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_tripless_t_ + typedef struct { + f_utf_string_triples_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_tripless_t; + + #define f_utf_string_tripless_t_initialize f_utf_string_statics_t_initialize + + #define macro_f_utf_string_tripless_t_initialize(array, size, used) { array, size, used } + #define macro_f_utf_string_tripless_t_initialize2(array, length) { array, length, length } + + #define macro_f_utf_string_tripless_t_clear(tripless) macro_f_memory_structure_clear(tripless) + + #define macro_f_utf_string_tripless_t_resize(status, tripless, length) status = f_utf_string_tripless_resize(length, &tripless); + #define macro_f_utf_string_tripless_t_adjust(status, tripless, length) status = f_utf_string_tripless_adjust(length, &tripless); + + #define macro_f_utf_string_tripless_t_delete_simple(tripless) f_utf_string_tripless_resize(0, &tripless); + #define macro_f_utf_string_tripless_t_destroy_simple(tripless) f_utf_string_tripless_adjust(0, &tripless); + + #define macro_f_utf_string_tripless_t_increase(status, step, tripless) status = f_utf_string_tripless_increase(step, tripless); + #define macro_f_utf_string_tripless_t_increase_by(status, tripless, amount) status = f_utf_string_tripless_increase_by(amount, tripless); + #define macro_f_utf_string_tripless_t_decrease_by(status, tripless, amount) status = f_utf_string_tripless_decrease_by(amount, tripless); + #define macro_f_utf_string_tripless_t_decimate_by(status, tripless, amount) status = f_utf_string_tripless_decimate_by(amount, tripless); +#endif // _di_f_utf_string_tripless_t_ + +/** * Resize the string triples array. * * @param length @@ -100,14 +139,14 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_utf_string_triples_adjust_ - extern f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t *triples); + extern f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t * const triples); #endif // _di_f_utf_string_triples_adjust_ /** - * Append the source triples onto the destination. + * Append the single source triples onto the destination. * * @param source - * The source triples to append. + * The source triple to append. * @param destination * The destination triples the source is appended onto. * @@ -121,10 +160,31 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_triples_append_ - extern f_status_t f_utf_string_triples_append(const f_utf_string_triples_t source, f_utf_string_triples_t *destination); + extern f_status_t f_utf_string_triples_append(const f_utf_string_triple_t source, f_utf_string_triples_t * const destination); #endif // _di_f_utf_string_triples_append_ /** + * Append the source triples onto the destination. + * + * @param source + * The source triples to append. + * @param destination + * The destination triples the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_append_all_ + extern f_status_t f_utf_string_triples_append_all(const f_utf_string_triples_t source, f_utf_string_triples_t * const destination); +#endif // _di_f_utf_string_triples_append_all_ + +/** * Resize the string triples array to a smaller size. * * This will resize making the array smaller based on (size - given length). @@ -145,7 +205,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_triples_decimate_by_ - extern f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t *triples); + extern f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); #endif // _di_f_utf_string_triples_decimate_by_ /** @@ -169,7 +229,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_triples_decrease_by_ - extern f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t *triples); + extern f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); #endif // _di_f_utf_string_triples_decrease_by_ /** @@ -194,7 +254,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_triples_increase_ - extern f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t *triples); + extern f_status_t f_utf_string_triples_increase(const f_array_length_t step, f_utf_string_triples_t * const triples); #endif // _di_f_utf_string_triples_increase_ /** @@ -219,7 +279,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_triples_increase_by_ - extern f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t *triples); + extern f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t * const triples); #endif // _di_f_utf_string_triples_increase_by_ /** @@ -238,11 +298,188 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_triples_resize_ - extern f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t *triples); + extern f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t * const triples); #endif // _di_f_utf_string_triples_resize_ +/** + * Resize the string tripless array. + * + * @param length + * The new size to use. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_tripless_adjust_ + extern f_status_t f_utf_string_tripless_adjust(const f_array_length_t length, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_adjust_ + +/** + * Append the single source triples onto the destination. + * + * @param source + * The source triples to append. + * @param destination + * The destination tripless the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_append_ + extern f_status_t f_utf_string_tripless_append(const f_utf_string_triples_t source, f_utf_string_tripless_t * const destination); +#endif // _di_f_utf_string_tripless_append_ + +/** + * Append the source tripless onto the destination. + * + * @param source + * The source tripless to append. + * @param destination + * The destination tripless the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_append_all_ + extern f_status_t f_utf_string_tripless_append_all(const f_utf_string_tripless_t source, f_utf_string_tripless_t * const destination); +#endif // _di_f_utf_string_tripless_append_all_ + +/** + * Resize the string tripless array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_decimate_by_ + extern f_status_t f_utf_string_tripless_decimate_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_decimate_by_ + +/** + * Resize the string tripless array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not if amount is 0. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_decrease_by_ + extern f_status_t f_utf_string_tripless_decrease_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_decrease_by_ + +/** + * Increase the size of the string tripless array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_increase_ + extern f_status_t f_utf_string_tripless_increase(const f_array_length_t step, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_increase_ + +/** + * Resize the string tripless array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param tripless + * The string tripless array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_increase_by_ + extern f_status_t f_utf_string_tripless_increase_by(const f_array_length_t amount, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_increase_by_ + +/** + * Resize the string tripless array. + * + * @param length + * The new size to use. + * @param tripless + * The string tripless array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_tripless_resize_ + extern f_status_t f_utf_string_tripless_resize(const f_array_length_t length, f_utf_string_tripless_t * const tripless); +#endif // _di_f_utf_string_tripless_resize_ + #ifdef __cplusplus } // extern "C" #endif -#endif // _F_utf_string_triple_h +#endif // _F_utf_triple_h diff --git a/level_0/f_utf/data/build/settings b/level_0/f_utf/data/build/settings index 26c3e41..6bd0350 100644 --- a/level_0/f_utf/data/build/settings +++ b/level_0/f_utf/data/build/settings @@ -31,7 +31,7 @@ build_objects_library_static build_objects_program build_objects_program_shared build_objects_program_static -build_sources_library utf.c private-utf.c utf/common.c utf/convert.c utf/dynamic.c utf/is.c utf/is_character.c utf/map.c utf/private-is_unassigned.c utf/private-string.c utf/string.c utf/triple.c +build_sources_library utf.c private-utf.c utf/common.c utf/convert.c utf/dynamic.c utf/is.c utf/is_character.c utf/map.c utf/map_multi.c utf/private-is_unassigned.c utf/private-dynamic.c utf/private-map.c utf/private-map_multi.c utf/private-string.c utf/private-triple.c utf/static.c utf/string.c utf/triple.c build_sources_library_shared build_sources_library_static build_sources_object @@ -40,7 +40,7 @@ build_sources_object_static build_sources_program build_sources_program_shared build_sources_program_static -build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/is.h utf/is_character.h utf/map.h utf/string.h utf/triple.h +build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/is.h utf/is_character.h utf/map.h utf/map_multi.h utf/static.h utf/string.h utf/triple.h build_sources_headers_shared build_sources_headers_static build_sources_script diff --git a/level_0/f_utf/data/build/settings-tests b/level_0/f_utf/data/build/settings-tests new file mode 100644 index 0000000..f8a5ce5 --- /dev/null +++ b/level_0/f_utf/data/build/settings-tests @@ -0,0 +1,71 @@ +# fss-0001 + +build_name test-f_utf + +version_major 0 +version_minor 5 +version_micro 9 +version_file major +version_target major + +modes individual level monolithic clang test +modes_default individual + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c +build_libraries -lc -lcmocka +build_libraries-individual -lf_memory -lf_string -lf_utf +build_libraries-level -lfll_0 +build_libraries-monolithic -lfll +build_sources_program test-utf-append.c test-utf-append_assure.c test-utf-append_assure_nulless.c test-utf-append_nulless.c +build_sources_program test-utf-dynamic_adjust.c test-utf-dynamic_append.c test-utf-dynamic_append_assure.c test-utf-dynamic_append_assure_nulless.c test-utf-dynamic_append_nulless.c +build_sources_program test-utf-dynamic_decimate_by.c test-utf-dynamic_decrease_by.c test-utf-dynamic_increase.c test-utf-dynamic_increase_by.c +build_sources_program test-utf-dynamic_mash.c test-utf-dynamic_mash_nulless.c +build_sources_program test-utf-dynamic_mish.c test-utf-dynamic_mish_nulless.c +build_sources_program test-utf-dynamic_partial_append.c test-utf-dynamic_partial_append_assure.c test-utf-dynamic_partial_append_assure_nulless.c test-utf-dynamic_partial_append_nulless.c +build_sources_program test-utf-dynamic_partial_mash.c test-utf-dynamic_partial_mash_nulless.c +build_sources_program test-utf-dynamic_partial_mish.c test-utf-dynamic_partial_mish_nulless.c +build_sources_program test-utf-dynamic_partial_prepend.c test-utf-dynamic_partial_prepend_assure.c test-utf-dynamic_partial_prepend_assure_nulless.c test-utf-dynamic_partial_prepend_nulless.c +build_sources_program test-utf-dynamic_prepend.c test-utf-dynamic_prepend_assure.c test-utf-dynamic_prepend_assure_nulless.c test-utf-dynamic_prepend_nulless.c +build_sources_program test-utf-dynamic_resize.c +build_sources_program test-utf-dynamic_seek_line.c test-utf-dynamic_seek_line_to.c test-utf-dynamic_seek_to.c +build_sources_program test-utf-dynamic_terminate.c test-utf-dynamic_terminate_after.c +build_sources_program test-utf-dynamics_adjust.c test-utf-dynamics_append.c test-utf-dynamics_append_all.c test-utf-dynamics_decimate_by.c test-utf-dynamics_decrease_by.c test-utf-dynamics_increase.c test-utf-dynamics_increase_by.c test-utf-dynamics_resize.c test-utf-dynamicss_adjust.c test-utf-dynamicss_append.c test-utf-dynamicss_append_all.c test-utf-dynamicss_decimate_by.c test-utf-dynamicss_decrease_by.c test-utf-dynamicss_increase.c test-utf-dynamicss_increase_by.c test-utf-dynamicss_resize.c +build_sources_program test-utf-map_multis_adjust.c test-utf-map_multis_append.c test-utf-map_multis_append_all.c test-utf-map_multis_decimate_by.c test-utf-map_multis_decrease_by.c test-utf-map_multis_increase.c test-utf-map_multis_increase_by.c test-utf-map_multis_resize.c test-utf-map_multiss_adjust.c test-utf-map_multiss_append.c test-utf-map_multiss_append_all.c test-utf-map_multiss_decimate_by.c test-utf-map_multiss_decrease_by.c test-utf-map_multiss_increase.c test-utf-map_multiss_increase_by.c test-utf-map_multiss_resize.c +build_sources_program test-utf-maps_adjust.c test-utf-maps_append.c test-utf-maps_append_all.c test-utf-maps_decimate_by.c test-utf-maps_decrease_by.c test-utf-maps_increase.c test-utf-maps_increase_by.c test-utf-maps_resize.c test-utf-mapss_adjust.c test-utf-mapss_append.c test-utf-mapss_append_all.c test-utf-mapss_decimate_by.c test-utf-mapss_decrease_by.c test-utf-mapss_increase.c test-utf-mapss_increase_by.c test-utf-mapss_resize.c +build_sources_program test-utf-mash.c test-utf-mash_nulless.c +build_sources_program test-utf-mish.c test-utf-mish_nulless.c +build_sources_program test-utf-prepend.c test-utf-prepend_assure.c test-utf-prepend_assure_nulless.c test-utf-prepend_nulless.c +build_sources_program test-utf-seek_line.c test-utf-seek_line_to.c test-utf-seek_to.c +build_sources_program test-utf-triples_adjust.c test-utf-triples_append.c test-utf-triples_append_all.c test-utf-triples_decimate_by.c test-utf-triples_decrease_by.c test-utf-triples_increase.c test-utf-triples_increase_by.c test-utf-triples_resize.c test-utf-tripless_adjust.c test-utf-tripless_append.c test-utf-tripless_append_all.c test-utf-tripless_decimate_by.c test-utf-tripless_decrease_by.c test-utf-tripless_increase.c test-utf-tripless_increase_by.c test-utf-tripless_resize.c +build_sources_program test-utf.c +build_script no +build_shared yes +build_static no + +path_headers tests/unit/c +path_sources tests/unit/c + +has_path_standard no +preserve_path_headers no + +search_exclusive yes +search_shared yes +search_static yes + +defines +defines -Ibuild/includes +defines_static -Lbuild/libraries/static +defines_shared -Lbuild/libraries/shared + +flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses +flags-clang -Wno-logical-op-parentheses +flags-test -fstack-protector +flags_program -fPIE +flags_program_shared +flags_program_static +flags_shared +flags_static diff --git a/level_0/f_utf/data/build/testfile b/level_0/f_utf/data/build/testfile new file mode 100644 index 0000000..e310b54 --- /dev/null +++ b/level_0/f_utf/data/build/testfile @@ -0,0 +1,45 @@ +# fss-0005 iki-0002 + +settings: + load_build yes + fail exit + + environment LD_LIBRARY_PATH + +main: + build settings + build settings-tests + + operate ld_library_path + + if exists build/programs/shared/test-f_utf + shell build/programs/shared/test-f_utf + + if exists build/programs/static/test-f_utf + shell build/programs/static/test-f_utf + + if not exists build/programs/shared/test-f_utf + and not exists build/programs/static/test-f_utf + operate not_created + +not_created: + print + print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"' + + exit failure + +ld_library_path: + if defined environment LD_LIBRARY_PATH + and defined parameter work + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared:define:"LD_LIBRARY_PATH"' + + else + if defined environment LD_LIBRARY_PATH + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:define:"LD_LIBRARY_PATH"' + + else + if defined parameter work + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared' + + else + define LD_LIBRARY_PATH build/libraries/shared diff --git a/level_0/f_utf/tests/unit/c/test-utf-append.c b/level_0/f_utf/tests/unit/c/test-utf-append.c new file mode 100644 index 0000000..95bcd92 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-append.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_append__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_append(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_append__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_append(data.string, data.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-append.h b/level_0/f_utf/tests/unit/c/test-utf-append.h new file mode 100644 index 0000000..ac9a384 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_append_h +#define _TEST__F_utf_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_append() + */ +extern void test__f_utf_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_append() + */ +extern void test__f_utf_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-append_assure.c b/level_0/f_utf/tests/unit/c/test-utf-append_assure.c new file mode 100644 index 0000000..49a22b3 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-append_assure.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-append_assure.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_append_assure__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_append_assure(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_append_assure(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_append_assure__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_append_assure(data.string, data.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-append_assure.h b/level_0/f_utf/tests/unit/c/test-utf-append_assure.h new file mode 100644 index 0000000..a990cc2 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-append_assure.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_append_assure_h +#define _TEST__F_utf_append_assure_h + +/** + * Test that the function works. + * + * @see f_utf_string_append_assure() + */ +extern void test__f_utf_append_assure__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_append_assure() + */ +extern void test__f_utf_append_assure__parameter_checking(void **state); + +#endif // _TEST__F_utf_append_assure_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-append_assure_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-append_assure_nulless.c new file mode 100644 index 0000000..350b089 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-append_assure_nulless.c @@ -0,0 +1,49 @@ +#include "test-utf.h" +#include "test-utf-append_assure_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_append_assure_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_append_assure_nulless(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_append_assure_nulless(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_append_assure_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_append_assure_nulless(data.string, data.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-append_assure_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-append_assure_nulless.h new file mode 100644 index 0000000..fa7fd1a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-append_assure_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_append_assure_nulless_h +#define _TEST__F_utf_append_assure_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_append_assure_nulless() + */ +extern void test__f_utf_append_assure_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_append_assure_nulless() + */ +extern void test__f_utf_append_assure_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_append_assure_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-append_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-append_nulless.c new file mode 100644 index 0000000..0169d3e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-append_nulless.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-append_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_append_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_append_nulless(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_append_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_append_nulless(data.string, data.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-append_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-append_nulless.h new file mode 100644 index 0000000..5306e17 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-append_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_append_nulless_h +#define _TEST__F_utf_append_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_append_nulless() + */ +extern void test__f_utf_append_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_append_nulless() + */ +extern void test__f_utf_append_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_append_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_adjust.c new file mode 100644 index 0000000..5ebc997 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-dynamic_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_adjust__works(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.string); +} + +void test__f_utf_dynamic_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_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.string); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_adjust.h new file mode 100644 index 0000000..b9d2e02 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf__string_dynamic_adjust +#define _TEST__F_utf__string_dynamic_adjust + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_adjust() + */ +extern void test__f_utf_dynamic_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_adjust() + */ +extern void test__f_utf_dynamic_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf__string_dynamic_adjust diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_append.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append.c new file mode 100644 index 0000000..af7e4e6 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-dynamic_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_append__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_append__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_append.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append.h new file mode 100644 index 0000000..d1322f4 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_append_h +#define _TEST__F_utf_dynamic_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_append() + */ +extern void test__f_utf_dynamic_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_append() + */ +extern void test__f_utf_dynamic_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure.c new file mode 100644 index 0000000..8240ec0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-dynamic_append_assure.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_append_assure__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append_assure(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_dynamic_append_assure(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_append_assure__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append_assure(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure.h new file mode 100644 index 0000000..3d546fa --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_append_assure_h +#define _TEST__F_utf_dynamic_append_assure_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_append_assure() + */ +extern void test__f_utf_dynamic_append_assure__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_append_assure() + */ +extern void test__f_utf_dynamic_append_assure__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_append_assure_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure_nulless.c new file mode 100644 index 0000000..978a8e1 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure_nulless.c @@ -0,0 +1,49 @@ +#include "test-utf.h" +#include "test-utf-dynamic_append_assure_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_append_assure_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append_assure_nulless(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_dynamic_append_assure_nulless(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_append_assure_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append_assure_nulless(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure_nulless.h new file mode 100644 index 0000000..ae7f524 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_assure_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_append_assure_nulless_h +#define _TEST__F_utf_dynamic_append_assure_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_append_assure_nulless() + */ +extern void test__f_utf_dynamic_append_assure_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_append_assure_nulless() + */ +extern void test__f_utf_dynamic_append_assure_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_append_assure_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_nulless.c new file mode 100644 index 0000000..c4dc1f6 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_nulless.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-dynamic_append_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_append_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append_nulless(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_append_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append_nulless(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_nulless.h new file mode 100644 index 0000000..d12f1ab --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_append_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_append_nulless_h +#define _TEST__F_utf_dynamic_append_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_append_nulless() + */ +extern void test__f_utf_dynamic_append_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_append_nulless() + */ +extern void test__f_utf_dynamic_append_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_append_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_decimate_by.c new file mode 100644 index 0000000..396cde3 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-dynamic_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamic_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.string); +} + +void test__f_utf_dynamic_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_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.string); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_decimate_by.h new file mode 100644 index 0000000..4f556bb --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_dynamic_decimate_by_h +#define _TEST__F_dynamic_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_decimate_by() + */ +extern void test__f_utf_dynamic_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_decimate_by() + */ +extern void test__f_utf_dynamic_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_dynamic_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_decrease_by.c new file mode 100644 index 0000000..15523be --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-dynamic_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamic_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.string); +} + +void test__f_utf_dynamic_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_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.string); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_decrease_by.h new file mode 100644 index 0000000..f777a97 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_decrease_by_h +#define _TEST__F_utf_dynamic_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_decrease_by() + */ +extern void test__f_utf_dynamic_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_decrease_by() + */ +extern void test__f_utf_dynamic_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase.c new file mode 100644 index 0000000..8b3a459 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-dynamic_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_increase__works(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_dynamic_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.string); +} + +void test__f_utf_dynamic_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamic_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.string); +} + +void test__f_utf_dynamic_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_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.string); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase.h new file mode 100644 index 0000000..e530fd7 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_increase_h +#define _TEST__F_utf_dynamic_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_increase() + */ +extern void test__f_utf_dynamic_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_dynamic_increase() + */ +extern void test__f_utf_dynamic_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_increase() + */ +extern void test__f_utf_dynamic_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase_by.c new file mode 100644 index 0000000..1ff7e54 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-dynamic_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_dynamic_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.string); +} + +void test__f_utf_dynamic_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_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.string); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase_by.h new file mode 100644 index 0000000..a207103 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_increase_by_h +#define _TEST__F_utf_dynamic_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_increase_by() + */ +extern void test__f_utf_dynamic_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_increase_by() + */ +extern void test__f_utf_dynamic_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.c new file mode 100644 index 0000000..b0772dd --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.c @@ -0,0 +1,54 @@ +#include "test-utf.h" +#include "test-utf-dynamic_mash.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_mash__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("te\0st:te\0st", 0, 11); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_mash(glue, source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_dynamic_mash(glue, source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + assert_string_equal(destination.string + 9, expected.string + 9); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_mash__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + + { + const f_status_t status = f_utf_string_dynamic_mash(glue, source, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.h new file mode 100644 index 0000000..c821f07 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_mash_h +#define _TEST__F_utf_dynamic_mash_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_mash() + */ +extern void test__f_utf_dynamic_mash__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_mash() + */ +extern void test__f_utf_dynamic_mash__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_mash_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash_nulless.c new file mode 100644 index 0000000..ad27a0c --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash_nulless.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-dynamic_mash_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_mash_nulless__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected1 = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_utf_string_static_t expected2 = macro_f_utf_string_static_t_initialize("test:test", 0, 9); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_mash_nulless(glue, source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected1.used); + + assert_string_equal(destination.string, expected1.string); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_dynamic_mash_nulless(glue, source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected2.used); + + assert_string_equal(destination.string, expected2.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_mash_nulless__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + + { + const f_status_t status = f_utf_string_dynamic_mash_nulless(glue, source, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash_nulless.h new file mode 100644 index 0000000..74e93c9 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mash_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_mash_nulless_h +#define _TEST__F_utf_dynamic_mash_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_mash_nulless() + */ +extern void test__f_utf_dynamic_mash_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_mash_nulless() + */ +extern void test__f_utf_dynamic_mash_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_mash_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.c new file mode 100644 index 0000000..7dc482d --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.c @@ -0,0 +1,54 @@ +#include "test-utf.h" +#include "test-utf-dynamic_mish.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_mish__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("te\0st:te\0st", 0, 11); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_mish(glue, source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_dynamic_mish(glue, source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + assert_string_equal(destination.string + 9, expected.string + 9); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_mish__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + + { + const f_status_t status = f_utf_string_dynamic_mish(glue, source, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.h new file mode 100644 index 0000000..bd6856a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_mish_h +#define _TEST__F_utf_dynamic_mish_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_mish() + */ +extern void test__f_utf_dynamic_mish__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_mish() + */ +extern void test__f_utf_dynamic_mish__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_mish_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish_nulless.c new file mode 100644 index 0000000..b50121e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish_nulless.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-dynamic_mish_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_mish_nulless__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected1 = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_utf_string_static_t expected2 = macro_f_utf_string_static_t_initialize("test:test", 0, 9); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_mish_nulless(glue, source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected1.used); + + assert_string_equal(destination.string, expected1.string); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_dynamic_mish_nulless(glue, source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected2.used); + + assert_string_equal(destination.string, expected2.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_mish_nulless__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + + { + const f_status_t status = f_utf_string_dynamic_mish_nulless(glue, source, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish_nulless.h new file mode 100644 index 0000000..5722d93 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_mish_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_mish_nulless_h +#define _TEST__F_utf_dynamic_mish_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_mish_nulless() + */ +extern void test__f_utf_dynamic_mish_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_mish_nulless() + */ +extern void test__f_utf_dynamic_mish_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_mish_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append.c new file mode 100644 index 0000000..50d94d8 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_append__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_append(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_append__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_append(data, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append.h new file mode 100644 index 0000000..cd3f616 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_append_h +#define _TEST__F_utf_dynamic_partial_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_append() + */ +extern void test__f_utf_dynamic_partial_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_append() + */ +extern void test__f_utf_dynamic_partial_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure.c new file mode 100644 index 0000000..e30e6f5 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure.c @@ -0,0 +1,53 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_append_assure.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_append_assure__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append(expected, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_dynamic_partial_append_assure(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_append_assure__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_append_assure(data, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure.h new file mode 100644 index 0000000..4d7799a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_append_assure_h +#define _TEST__F_utf_dynamic_partial_append_assure_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_append_assure() + */ +extern void test__f_utf_dynamic_partial_append_assure__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_append_assure() + */ +extern void test__f_utf_dynamic_partial_append_assure__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_append_assure_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure_nulless.c new file mode 100644 index 0000000..2a245ee --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure_nulless.c @@ -0,0 +1,51 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_append_assure_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_append_assure_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_append(expected, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_dynamic_partial_append_assure_nulless(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_append_assure_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_append_assure_nulless(data, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure_nulless.h new file mode 100644 index 0000000..8e32669 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_assure_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_append_assure_nulless_h +#define _TEST__F_utf_dynamic_partial_append_assure_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_append_assure_nulless() + */ +extern void test__f_utf_dynamic_partial_append_assure_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_append_assure_nulless() + */ +extern void test__f_utf_dynamic_partial_append_assure_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_append_assure_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_nulless.c new file mode 100644 index 0000000..485f5dc --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_nulless.c @@ -0,0 +1,41 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_append_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_append_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_append_nulless(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_append_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_append_nulless(data, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_nulless.h new file mode 100644 index 0000000..25040fb --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_append_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_append_nulless_h +#define _TEST__F_utf_dynamic_partial_append_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_append_nulless() + */ +extern void test__f_utf_dynamic_partial_append_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_append_nulless() + */ +extern void test__f_utf_dynamic_partial_append_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_append_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash.c new file mode 100644 index 0000000..eda4a16 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash.c @@ -0,0 +1,57 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_mash.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_mash__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected1 = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected2 = macro_f_utf_string_static_t_initialize("te\0st:te\0st", 0, 11); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_mash(glue, source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected1.used); + + assert_string_equal(destination.string, expected1.string); + assert_string_equal(destination.string + 3, expected1.string + 3); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_dynamic_partial_mash(glue, source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected2.used); + + assert_string_equal(destination.string, expected2.string); + assert_string_equal(destination.string + 3, expected2.string + 3); + assert_string_equal(destination.string + 9, expected2.string + 9); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_mash__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_mash(glue, source, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash.h new file mode 100644 index 0000000..8191fc7 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_mash_h +#define _TEST__F_utf_dynamic_partial_mash_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_mash() + */ +extern void test__f_utf_dynamic_partial_mash__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_mash() + */ +extern void test__f_utf_dynamic_partial_mash__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_mash_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash_nulless.c new file mode 100644 index 0000000..ccbe0da --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash_nulless.c @@ -0,0 +1,54 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_mash_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_mash_nulless__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected1 = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_utf_string_static_t expected2 = macro_f_utf_string_static_t_initialize("test:test", 0, 9); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_mash_nulless(glue, source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected1.used); + + assert_string_equal(destination.string, expected1.string); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_dynamic_partial_mash_nulless(glue, source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected2.used); + + assert_string_equal(destination.string, expected2.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_mash_nulless__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_mash_nulless(glue, source, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash_nulless.h new file mode 100644 index 0000000..7ca68cc --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mash_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_mash_nulless_h +#define _TEST__F_utf_dynamic_partial_mash_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_mash_nulless() + */ +extern void test__f_utf_dynamic_partial_mash_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_mash_nulless() + */ +extern void test__f_utf_dynamic_partial_mash_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_mash_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish.c new file mode 100644 index 0000000..ff68bb3 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish.c @@ -0,0 +1,57 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_mish.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_mish__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected1 = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected2 = macro_f_utf_string_static_t_initialize("te\0st:te\0st", 0, 11); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_mish(glue, source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected1.used); + + assert_string_equal(destination.string, expected1.string); + assert_string_equal(destination.string + 3, expected1.string + 3); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_dynamic_partial_mish(glue, source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected2.used); + + assert_string_equal(destination.string, expected2.string); + assert_string_equal(destination.string + 3, expected2.string + 3); + assert_string_equal(destination.string + 9, expected2.string + 9); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_mish__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_mish(glue, source, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish.h new file mode 100644 index 0000000..78fcc75 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish.h @@ -0,0 +1,26 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_mish_h +#define _TEST__F_utf_dynamic_partial_mish_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_mish() + */ +extern void test__f_utf_dynamic_partial_mish__works(void **state); +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_mish() + */ +extern void test__f_utf_dynamic_partial_mish__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_mish_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish_nulless.c new file mode 100644 index 0000000..cbc62db --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish_nulless.c @@ -0,0 +1,54 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_mish_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_mish_nulless__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected1 = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_utf_string_static_t expected2 = macro_f_utf_string_static_t_initialize("test:test", 0, 9); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_mish_nulless(glue, source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected1.used); + + assert_string_equal(destination.string, expected1.string); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_dynamic_partial_mish_nulless(glue, source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected2.used); + + assert_string_equal(destination.string, expected2.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_mish_nulless__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_mish_nulless(glue, source, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish_nulless.h new file mode 100644 index 0000000..0e27aff --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_mish_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_mish_nulless_h +#define _TEST__F_utf_dynamic_partial_mish_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_mish_nulless() + */ +extern void test__f_utf_dynamic_partial_mish_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_mish_nulless() + */ +extern void test__f_utf_dynamic_partial_mish_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_mish_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend.c new file mode 100644 index 0000000..5e60c6c --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_prepend.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_prepend__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_prepend(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_prepend__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_prepend(data, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend.h new file mode 100644 index 0000000..0de7484 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_prepend_h +#define _TEST__F_utf_dynamic_partial_prepend_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_prepend() + */ +extern void test__f_utf_dynamic_partial_prepend__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_prepend() + */ +extern void test__f_utf_dynamic_partial_prepend__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_prepend_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure.c new file mode 100644 index 0000000..12fd2c5 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure.c @@ -0,0 +1,53 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_prepend_assure.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_prepend_assure__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_prepend_assure(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_dynamic_partial_prepend_assure(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_prepend_assure__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_prepend_assure(data, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure.h new file mode 100644 index 0000000..8a54a38 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_prepend_assure_h +#define _TEST__F_utf_dynamic_partial_prepend_assure_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_prepend_assure() + */ +extern void test__f_utf_dynamic_partial_prepend_assure__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_prepend_assure() + */ +extern void test__f_utf_dynamic_partial_prepend_assure__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_prepend_assure_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure_nulless.c new file mode 100644 index 0000000..a2a3a88 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure_nulless.c @@ -0,0 +1,51 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_prepend_assure_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_prepend_assure_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_prepend_assure_nulless(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_dynamic_partial_prepend_assure_nulless(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_prepend_assure_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_prepend_assure_nulless(data, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure_nulless.h new file mode 100644 index 0000000..96106e1 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_assure_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_prepend_assure_nulless_h +#define _TEST__F_utf_dynamic_partial_prepend_assure_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_prepend_assure_nulless() + */ +extern void test__f_utf_dynamic_partial_prepend_assure_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_prepend_assure_nulless() + */ +extern void test__f_utf_dynamic_partial_prepend_assure_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_prepend_assure_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_nulless.c new file mode 100644 index 0000000..c8f50d0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_nulless.c @@ -0,0 +1,41 @@ +#include "test-utf.h" +#include "test-utf-dynamic_partial_prepend_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_partial_prepend_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("_te\0st_", 0, 7); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_utf_string_range_t_initialize(1, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_prepend_nulless(source, partial, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_partial_prepend_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + const f_string_range_t partial = f_utf_string_range_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_partial_prepend_nulless(data, partial, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_nulless.h new file mode 100644 index 0000000..4860d72 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_partial_prepend_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_partial_prepend_nulless_h +#define _TEST__F_utf_dynamic_partial_prepend_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_partial_prepend_nulless() + */ +extern void test__f_utf_dynamic_partial_prepend_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_partial_prepend_nulless() + */ +extern void test__f_utf_dynamic_partial_prepend_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_partial_prepend_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend.c new file mode 100644 index 0000000..1cc88b4 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-dynamic_prepend.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_prepend__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_prepend(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_prepend__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_prepend(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend.h new file mode 100644 index 0000000..a8eca84 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_prepend_h +#define _TEST__F_utf_dynamic_prepend_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_prepend() + */ +extern void test__f_utf_dynamic_prepend__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_prepend() + */ +extern void test__f_utf_dynamic_prepend__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_prepend_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure.c new file mode 100644 index 0000000..e6ee446 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-dynamic_prepend_assure.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_prepend_assure__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_prepend_assure(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_dynamic_prepend_assure(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_prepend_assure__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_prepend_assure(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure.h new file mode 100644 index 0000000..3e21479 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_prepend_assure_h +#define _TEST__F_utf_dynamic_prepend_assure_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_prepend_assure() + */ +extern void test__f_utf_dynamic_prepend_assure__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_prepend_assure() + */ +extern void test__f_utf_dynamic_prepend_assure__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_prepend_assure_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure_nulless.c new file mode 100644 index 0000000..8a5a39a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure_nulless.c @@ -0,0 +1,49 @@ +#include "test-utf.h" +#include "test-utf-dynamic_prepend_assure_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_prepend_assure_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_prepend_assure_nulless(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_dynamic_prepend_assure_nulless(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_prepend_assure_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_prepend_assure_nulless(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure_nulless.h new file mode 100644 index 0000000..381edf9 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_assure_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_prepend_assure_nulless_h +#define _TEST__F_utf_dynamic_prepend_assure_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_prepend_assure_nulless() + */ +extern void test__f_utf_dynamic_prepend_assure_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_prepend_assure_nulless() + */ +extern void test__f_utf_dynamic_prepend_assure_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_prepend_assure_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_nulless.c new file mode 100644 index 0000000..ba61a9a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_nulless.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-dynamic_prepend_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_prepend_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_prepend_nulless(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_dynamic_prepend_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_prepend_nulless(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_nulless.h new file mode 100644 index 0000000..1d5d7b9 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_prepend_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_prepend_nulless_h +#define _TEST__F_utf_dynamic_prepend_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_prepend_nulless() + */ +extern void test__f_utf_dynamic_prepend_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_prepend_nulless() + */ +extern void test__f_utf_dynamic_prepend_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_prepend_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_resize.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_resize.c new file mode 100644 index 0000000..4c77837 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-dynamic_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_resize__works(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.string); +} + +void test__f_utf_dynamic_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamic_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.string); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_resize.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_resize.h new file mode 100644 index 0000000..7521879 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_resize_h +#define _TEST__F_utf_dynamic_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_resize() + */ +extern void test__f_utf_dynamic_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_resize() + */ +extern void test__f_utf_dynamic_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line.c new file mode 100644 index 0000000..708952a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line.c @@ -0,0 +1,82 @@ +#include "test-utf.h" +#include "test-utf-dynamic_seek_line.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_seek_line__returns_data_not_stop(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = f_utf_string_range_t_initialize; + + const f_status_t status = f_utf_string_dynamic_seek_line(source, &range); + + assert_int_equal(status, F_data_not_stop); + } +} + +void test__f_utf_dynamic_seek_line__returns_none_eos(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test", 0, 4); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_dynamic_seek_line(source, &range); + + assert_int_equal(status, F_none_eos); + + assert_int_equal(range.start, source.used); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_dynamic_seek_line__returns_none_stop(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test", 0, 4); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 2); + + const f_status_t status = f_utf_string_dynamic_seek_line(source, &range); + + assert_int_equal(status, F_none_stop); + + assert_int_equal(range.start, source.used - 1); + assert_int_equal(range.stop, source.used - 2); + } +} + +void test__f_utf_dynamic_seek_line__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_dynamic_seek_line(source, &range); + + assert_int_equal(status, F_none); + + assert_int_equal(range.start, 4); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_dynamic_seek_line__parameter_checking(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("teX\nst", 0, 6); + + { + const f_status_t status = f_utf_string_dynamic_seek_line(source, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line.h new file mode 100644 index 0000000..279df6f --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line.h @@ -0,0 +1,48 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_seek_line_h +#define _TEST__F_utf_dynamic_seek_line_h + +/** + * Test that the function returns F_data_not_stop because range is an empty range (range.start > range.stop). + * + * @see f_utf_string_dynamic_seek_line() + */ +extern void test__f_utf_dynamic_seek_line__returns_data_not_stop(void **state); + +/** + * Test that the function returns F_none_eos stopped after end of string because no newline is found. + * + * @see f_utf_string_dynamic_seek_line() + */ +extern void test__f_utf_dynamic_seek_line__returns_none_eos(void **state); + +/** + * Test that the function returns F_none_stop stopped after end of range because no newline is found. + * + * @see f_utf_string_dynamic_seek_line() + */ +extern void test__f_utf_dynamic_seek_line__returns_none_stop(void **state); + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_seek_line() + */ +extern void test__f_utf_dynamic_seek_line__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_seek_line() + */ +extern void test__f_utf_dynamic_seek_line__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_seek_line_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line_to.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line_to.c new file mode 100644 index 0000000..9587891 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line_to.c @@ -0,0 +1,104 @@ +#include "test-utf.h" +#include "test-utf-dynamic_seek_line_to.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_seek_line_to__at_newline(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\nXst", 0, 6); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_dynamic_seek_line_to(source, to.string[0], &range); + + assert_int_equal(status, F_none_eol); + + assert_int_equal(range.start, 2); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_dynamic_seek_line_to__returns_data_not_stop(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = f_utf_string_range_t_initialize; + + const f_status_t status = f_utf_string_dynamic_seek_line_to(source, to.string[0], &range); + + assert_int_equal(status, F_data_not_stop); + } +} + +void test__f_utf_dynamic_seek_line_to__returns_none_eos(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test", 0, 4); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_dynamic_seek_line_to(source, to.string[0], &range); + + assert_int_equal(status, F_none_eos); + + assert_int_equal(range.start, source.used); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_dynamic_seek_line_to__returns_none_stop(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test", 0, 4); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 2); + + const f_status_t status = f_utf_string_dynamic_seek_line_to(source, to.string[0], &range); + + assert_int_equal(status, F_none_stop); + + assert_int_equal(range.start, source.used - 1); + assert_int_equal(range.stop, source.used - 2); + } +} + +void test__f_utf_dynamic_seek_line_to__works(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("teX\nst", 0, 6); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_dynamic_seek_line_to(source, to.string[0], &range); + + assert_int_equal(status, F_none); + + assert_int_equal(range.start, 2); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_dynamic_seek_line_to__parameter_checking(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("teX\nst", 0, 6); + + { + const f_status_t status = f_utf_string_dynamic_seek_line_to(source, to.string[0], 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line_to.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line_to.h new file mode 100644 index 0000000..1652881 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_line_to.h @@ -0,0 +1,55 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_seek_line_to_h +#define _TEST__F_utf_dynamic_seek_line_to_h + +/** + * Test that the function works but stops at newline rather than search string. + * + * @see f_utf_string_dynamic_seek_line_to() + */ +extern void test__f_utf_dynamic_seek_line_to__at_newline(void **state); + +/** + * Test that the function returns F_data_not_stop because range is an empty range (range.start > range.stop). + * + * @see f_utf_string_dynamic_seek_line_to() + */ +extern void test__f_utf_dynamic_seek_line_to__returns_data_not_stop(void **state); + +/** + * Test that the function returns F_none_eos stopped after end of string because no newline is found. + * + * @see f_utf_string_dynamic_seek_line_to() + */ +extern void test__f_utf_dynamic_seek_line_to__returns_none_eos(void **state); + +/** + * Test that the function returns F_none_stop stopped after end of range because no newline is found. + * + * @see f_utf_string_dynamic_seek_line_to() + */ +extern void test__f_utf_dynamic_seek_line_to__returns_none_stop(void **state); + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_seek_line_to() + */ +extern void test__f_utf_dynamic_seek_line_to__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_seek_line_to() + */ +extern void test__f_utf_dynamic_seek_line_to__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_seek_line_to_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_to.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_to.c new file mode 100644 index 0000000..532b55e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_to.c @@ -0,0 +1,87 @@ +#include "test-utf.h" +#include "test-utf-dynamic_seek_to.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_seek_to__returns_data_not_stop(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = f_utf_string_range_t_initialize; + + const f_status_t status = f_utf_string_dynamic_seek_to(source, to.string[0], &range); + + assert_int_equal(status, F_data_not_stop); + } +} + +void test__f_utf_dynamic_seek_to__returns_none_eos(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_dynamic_seek_to(source, to.string[0], &range); + + assert_int_equal(status, F_none_eos); + + assert_int_equal(range.start, source.used); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_dynamic_seek_to__returns_none_stop(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 2); + + const f_status_t status = f_utf_string_dynamic_seek_to(source, to.string[0], &range); + + assert_int_equal(status, F_none_stop); + + assert_int_equal(range.start, source.used - 1); + assert_int_equal(range.stop, source.used - 2); + } +} + +void test__f_utf_dynamic_seek_to__works(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\nXst", 0, 6); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_dynamic_seek_to(source, to.string[0], &range); + + assert_int_equal(status, F_none); + + assert_int_equal(range.start, 3); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_dynamic_seek_to__parameter_checking(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("teX\nst", 0, 6); + + { + const f_status_t status = f_utf_string_dynamic_seek_to(source, to.string[0], 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_to.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_to.h new file mode 100644 index 0000000..03cc984 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_seek_to.h @@ -0,0 +1,48 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_seek_to_h +#define _TEST__F_utf_dynamic_seek_to_h + +/** + * Test that the function returns F_data_not_stop because range is an empty range (range.start > range.stop). + * + * @see f_utf_string_dynamic_seek_to() + */ +extern void test__f_utf_dynamic_seek_to__returns_data_not_stop(void **state); + +/** + * Test that the function returns F_none_eos stopped after end of string because no newline is found. + * + * @see f_utf_string_dynamic_seek_to() + */ +extern void test__f_utf_dynamic_seek_to__returns_none_eos(void **state); + +/** + * Test that the function returns F_none_stop stopped after end of range because no newline is found. + * + * @see f_utf_string_dynamic_seek_to() + */ +extern void test__f_utf_dynamic_seek_to__returns_none_stop(void **state); + +/** + * Test that the function works. + * + * @see f_utf_string_dynamic_seek_to() + */ +extern void test__f_utf_dynamic_seek_to__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_seek_to() + */ +extern void test__f_utf_dynamic_seek_to__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_seek_to_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate.c new file mode 100644 index 0000000..026749d --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate.c @@ -0,0 +1,69 @@ +#include "test-utf.h" +#include "test-utf-dynamic_terminate.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamic_terminate__appends_null(void **state) { + + const f_array_length_t length = 2; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + // Put some value in the unused section at the end so that it gets overridden. + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + + data.string[0] = 'X'; + } + + { + const f_status_t status = f_utf_string_dynamic_terminate(&data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 1); + assert_int_equal(data.string[0], 0); + } + + free((void *) data.string); +} + +void test__f_utf_dynamic_terminate__doesnt_append_null(void **state) { + + const f_array_length_t length = 2; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + // Ensure a NULL already exists so that the test can confirm that another NULL is not appended. + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + + data.string[0] = 0; + } + + { + const f_status_t status = f_utf_string_dynamic_terminate(&data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 1); + assert_int_equal(data.string[0], 0); + } + + free((void *) data.string); +} + +void test__f_utf_dynamic_terminate__parameter_checking(void **state) { + + { + const f_status_t status = f_utf_string_dynamic_terminate(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate.h new file mode 100644 index 0000000..bac5555 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_terminate_h +#define _TEST__F_utf_dynamic_terminate_h + +/** + * Test that the function appends a NULL. + * + * @see f_utf_string_dynamic_terminate() + */ +extern void test__f_utf_dynamic_terminate__appends_null(void **state); + +/** + * Test that the function does not append a NULL. + * + * @see f_utf_string_dynamic_terminate() + */ +extern void test__f_utf_dynamic_terminate__doesnt_append_null(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_terminate() + */ +extern void test__f_utf_dynamic_terminate__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_terminate_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate_after.c b/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate_after.c new file mode 100644 index 0000000..3c83f1e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate_after.c @@ -0,0 +1,73 @@ +#include "test-utf.h" +#include "test-utf-dynamic_terminate_after.h" + +#ifdef __cplusplus +extern "C" { +#endif +void test__f_utf_dynamic_terminate_after__appends_null(void **state) { + + const f_array_length_t length = 2; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + // Put some value in the unused section at the end so that it gets overridden. + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + + data.string[0] = 'X'; + } + + { + const f_status_t status = f_utf_string_dynamic_terminate_after(&data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_in_range(data.size, 1, 1 + F_memory_default_allocation_small_d); + + assert_int_equal(data.string[data.used], 0); + } + + free((void *) data.string); +} + +void test__f_utf_dynamic_terminate_after__doesnt_append_null(void **state) { + + const f_array_length_t length = 2; + f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + // Ensure a NULL already exists so that the test can confirm that another NULL is not appended. + { + const f_status_t status = f_utf_string_dynamic_resize(length, &data); + + assert_int_equal(status, F_none); + assert_in_range(data.size, length, length + F_memory_default_allocation_small_d); + + data.string[0] = 0; + } + + { + const f_status_t status = f_utf_string_dynamic_terminate_after(&data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_in_range(data.size, length, length + F_memory_default_allocation_small_d); + + assert_int_equal(data.string[data.used], 0); + } + + free((void *) data.string); +} + +void test__f_utf_dynamic_terminate_after__parameter_checking(void **state) { + + { + const f_status_t status = f_utf_string_dynamic_terminate_after(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate_after.h b/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate_after.h new file mode 100644 index 0000000..654738a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamic_terminate_after.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamic_terminate_after_h +#define _TEST__F_utf_dynamic_terminate_after_h + +/** + * Test that the function appends a new line. + * + * @see f_utf_string_dynamic_terminate_after() + */ +extern void test__f_utf_dynamic_terminate_after__appends_null(void **state); + +/** + * Test that the function does not append a new line. + * + * @see f_utf_string_dynamic_terminate_after() + */ +extern void test__f_utf_dynamic_terminate_after__doesnt_append_null(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamic_terminate_after() + */ +extern void test__f_utf_dynamic_terminate_after__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamic_terminate_after_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-dynamics_adjust.c new file mode 100644 index 0000000..b98121e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-dynamics_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamics_adjust__works(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_dynamics_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-dynamics_adjust.h new file mode 100644 index 0000000..fe226f7 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf__string_dynamics_adjust +#define _TEST__F_utf__string_dynamics_adjust + +/** + * Test that the function works. + * + * @see f_utf_string_dynamics_adjust() + */ +extern void test__f_utf_dynamics_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamics_adjust() + */ +extern void test__f_utf_dynamics_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf__string_dynamics_adjust diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_append.c b/level_0/f_utf/tests/unit/c/test-utf-dynamics_append.c new file mode 100644 index 0000000..1fccbed --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_append.c @@ -0,0 +1,41 @@ +#include "test-utf.h" +#include "test-utf-dynamics_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamics_append__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamics_t destination = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].used, source.used); + + assert_string_equal(destination.array[0].string, source.string); + assert_string_equal(destination.array[0].string + 3, source.string + 3); + } + + free((void *) destination.array[0].string); + free((void *) destination.array); +} + +void test__f_utf_dynamics_append__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_append.h b/level_0/f_utf/tests/unit/c/test-utf-dynamics_append.h new file mode 100644 index 0000000..244d7eb --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamics_append_h +#define _TEST__F_utf_dynamics_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamics_append() + */ +extern void test__f_utf_dynamics_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamics_append() + */ +extern void test__f_utf_dynamics_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamics_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_append_all.c b/level_0/f_utf/tests/unit/c/test-utf-dynamics_append_all.c new file mode 100644 index 0000000..5c7ee66 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_append_all.c @@ -0,0 +1,103 @@ +#include "test-utf.h" +#include "test-utf-dynamics_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamics_append_all__works(void **state) { + + const int length_inner = 2; + f_utf_string_dynamics_t source = f_utf_string_dynamics_t_initialize; + f_utf_string_dynamics_t destination = f_utf_string_dynamics_t_initialize; + + const f_utf_string_static_t test_sources[] = { + macro_f_utf_string_static_t_initialize("te\0st1", 0, 6), + macro_f_utf_string_static_t_initialize("test2", 0, 5), + }; + + { + f_status_t status = f_utf_string_dynamics_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_utf_string_dynamic_append(test_sources[source.used], &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].used, test_sources[source.used].used); + + assert_string_equal(source.array[source.used].string, test_sources[source.used].string); + assert_string_equal(source.array[source.used].string + 3, test_sources[source.used].string + 3); + } // for + } + + { + const f_status_t status = f_utf_string_dynamics_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[i].used, source.array[i].used); + + assert_string_equal(destination.array[i].string, source.array[i].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].string); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].string); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_utf_dynamics_append_all__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_dynamics_t source = f_utf_string_dynamics_t_initialize; + f_utf_string_dynamics_t destination = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_dynamics_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_dynamics_append_all__parameter_checking(void **state) { + + const f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_append_all.h b/level_0/f_utf/tests/unit/c/test-utf-dynamics_append_all.h new file mode 100644 index 0000000..33d9059 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamics_append_all_h +#define _TEST__F_utf_dynamics_append_all_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamics_append_all() + */ +extern void test__f_utf_dynamics_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_dynamics_append_all() + */ +extern void test__f_utf_dynamics_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamics_append_all() + */ +extern void test__f_utf_dynamics_append_all__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamics_append_all_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamics_decimate_by.c new file mode 100644 index 0000000..22a1798 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-dynamics_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamics_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamics_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_dynamics_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamics_decimate_by.h new file mode 100644 index 0000000..6a36e21 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_dynamics_decimate_by_h +#define _TEST__F_dynamics_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamics_decimate_by() + */ +extern void test__f_utf_dynamics_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamics_decimate_by() + */ +extern void test__f_utf_dynamics_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_dynamics_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamics_decrease_by.c new file mode 100644 index 0000000..edb7496 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-dynamics_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamics_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamics_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_dynamics_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamics_decrease_by.h new file mode 100644 index 0000000..2b0926f --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamics_decrease_by_h +#define _TEST__F_utf_dynamics_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamics_decrease_by() + */ +extern void test__f_utf_dynamics_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamics_decrease_by() + */ +extern void test__f_utf_dynamics_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamics_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase.c b/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase.c new file mode 100644 index 0000000..7d8fd76 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-dynamics_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamics_increase__works(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_dynamics_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +void test__f_utf_dynamics_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamics_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_dynamics_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase.h b/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase.h new file mode 100644 index 0000000..545496a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamics_increase_h +#define _TEST__F_utf_dynamics_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamics_increase() + */ +extern void test__f_utf_dynamics_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_dynamics_increase() + */ +extern void test__f_utf_dynamics_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamics_increase() + */ +extern void test__f_utf_dynamics_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamics_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase_by.c new file mode 100644 index 0000000..ae1eb8c --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-dynamics_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamics_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_dynamics_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_utf_dynamics_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase_by.h new file mode 100644 index 0000000..9078ee1 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamics_increase_by_h +#define _TEST__F_utf_dynamics_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamics_increase_by() + */ +extern void test__f_utf_dynamics_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamics_increase_by() + */ +extern void test__f_utf_dynamics_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamics_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_resize.c b/level_0/f_utf/tests/unit/c/test-utf-dynamics_resize.c new file mode 100644 index 0000000..9061455 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-dynamics_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamics_resize__works(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_dynamics_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamics_resize.h b/level_0/f_utf/tests/unit/c/test-utf-dynamics_resize.h new file mode 100644 index 0000000..fae6388 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamics_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamics_resize_h +#define _TEST__F_utf_dynamics_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamics_resize() + */ +extern void test__f_utf_dynamics_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamics_resize() + */ +extern void test__f_utf_dynamics_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamics_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_adjust.c new file mode 100644 index 0000000..0998fd8 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-dynamicss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamicss_adjust__works(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamicss_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_dynamicss_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamicss_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_adjust.h new file mode 100644 index 0000000..f59825f --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamicss_adjust_h +#define _TEST__F_utf_dynamicss_adjust_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamicss_adjust() + */ +extern void test__f_utf_dynamicss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamicss_adjust() + */ +extern void test__f_utf_dynamicss_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamicss_adjust_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append.c b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append.c new file mode 100644 index 0000000..1f56ed7 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append.c @@ -0,0 +1,102 @@ +#include "test-utf.h" +#include "test-utf-dynamicss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamicss_append__works(void **state) { + + const int length_inner = 2; + f_utf_string_dynamics_t source = f_utf_string_dynamics_t_initialize; + f_utf_string_dynamicss_t destination = f_utf_string_dynamicss_t_initialize; + + const f_utf_string_static_t test_names[] = { + macro_f_utf_string_static_t_initialize("test1", 0, 5), + macro_f_utf_string_static_t_initialize("test2", 0, 5), + }; + + { + f_status_t status = f_utf_string_dynamics_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_utf_string_dynamic_append(test_names[source.used], &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].string, test_names[source.used].string); + assert_int_equal(source.array[source.used].used, test_names[source.used].used); + } // for + } + + { + const f_status_t status = f_utf_string_dynamicss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_inner); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[0].array[i].used, test_names[i].used); + assert_string_equal(destination.array[0].array[i].string, test_names[i].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].string); + } // for + + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + free((void *) destination.array[0].array[i].string); + } // for + + free((void *) destination.array[0].array); + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_utf_dynamicss_append__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_dynamics_t source = f_utf_string_dynamicss_t_initialize; + f_utf_string_dynamicss_t destination = f_utf_string_dynamicss_t_initialize; + + { + const f_status_t status = f_utf_string_dynamics_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_dynamicss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_dynamicss_append__parameter_checking(void **state) { + + f_utf_string_dynamics_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append.h b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append.h new file mode 100644 index 0000000..1818eb8 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamicss_append_h +#define _TEST__F_utf_dynamicss_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamicss_append() + */ +extern void test__f_utf_dynamicss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_dynamicss_append() + */ +extern void test__f_utf_dynamicss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamicss_append() + */ +extern void test__f_utf_dynamicss_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamicss_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append_all.c b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append_all.c new file mode 100644 index 0000000..7f701dd --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append_all.c @@ -0,0 +1,130 @@ +#include "test-utf.h" +#include "test-utf-dynamicss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamicss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + const int length_outer = 2; + f_utf_string_dynamicss_t source = f_utf_string_dynamicss_t_initialize; + f_utf_string_dynamicss_t destination = f_utf_string_dynamicss_t_initialize; + + const f_utf_string_static_t test_names[] = { + macro_f_utf_string_static_t_initialize("test1", 0, 5), + macro_f_utf_string_static_t_initialize("test2", 0, 5), + }; + + { + f_status_t status = f_utf_string_dynamicss_resize(length_outer, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length_outer); + + f_array_length_t i = 0; + f_array_length_t j = 0; + + for (; source.used < length_outer; ++source.used) { + + status = f_utf_string_dynamics_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].used, 0); + assert_int_equal(source.array[source.used].size, length_inner); + + for (i = 0; i < length_inner; ++i) { + + status = f_utf_string_dynamic_append(test_names[i], &source.array[source.used].array[i]); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].array[i].string, test_names[i].string); + assert_int_equal(source.array[source.used].array[i].used, test_names[i].used); + } // for + + source.array[source.used].used = length_inner; + } // for + } + + { + const f_status_t status = f_utf_string_dynamicss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[j].array[i].used, test_names[i].used); + + assert_string_equal(destination.array[j].array[i].string, test_names[i].string); + } // for + } // for + } + + for (f_array_length_t j = 0; j < source.used; ++j) { + + for (f_array_length_t i = 0; i < source.array[j].used; ++i) { + free((void *) source.array[j].array[i].string); + } // for + + free((void *) source.array[j].array); + } // for + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + free((void *) destination.array[j].array[i].string); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_utf_dynamicss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t source = f_utf_string_dynamicss_t_initialize; + f_utf_string_dynamicss_t destination = f_utf_string_dynamicss_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_dynamicss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_dynamicss_append_all__parameter_checking(void **state) { + + const f_utf_string_dynamicss_t data = f_utf_string_dynamicss_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append_all.h b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append_all.h new file mode 100644 index 0000000..60c3b61 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamicss_append_all_h +#define _TEST__F_utf_dynamicss_append_all_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamicss_append_all() + */ +extern void test__f_utf_dynamicss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_dynamicss_append_all() + */ +extern void test__f_utf_dynamicss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamicss_append_all() + */ +extern void test__f_utf_dynamicss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamicss_append_all_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decimate_by.c new file mode 100644 index 0000000..ffbdbe2 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-dynamicss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamicss_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamicss_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_dynamicss_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decimate_by.h new file mode 100644 index 0000000..ae9619a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamicss_decimate_by_h +#define _TEST__F_utf_dynamicss_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamicss_decimate_by() + */ +extern void test__f_utf_dynamicss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamicss_decimate_by() + */ +extern void test__f_utf_dynamicss_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamicss_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decrease_by.c new file mode 100644 index 0000000..0daad5b --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-dynamicss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamicss_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamicss_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_dynamicss_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decrease_by.h new file mode 100644 index 0000000..e5cd5e2 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamicss_decrease_by_h +#define _TEST__F_utf_dynamicss_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_utf_string_dynamicss_decrease_by() + */ +extern void test__f_utf_dynamicss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_utf_string_dynamicss_decrease_by() + */ +extern void test__f_utf_dynamicss_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamicss_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase.c b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase.c new file mode 100644 index 0000000..b44e4db --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-dynamicss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamicss_increase__works(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_dynamicss_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +void test__f_utf_dynamicss_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_dynamicss_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_dynamicss_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase.h b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase.h new file mode 100644 index 0000000..aa4e9e0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamicss_increase_h +#define _TEST__F_utf_dynamicss_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamicss_increase() + */ +extern void test__f_utf_dynamicss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_dynamicss_increase() + */ +extern void test__f_utf_dynamicss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamicss_increase() + */ +extern void test__f_utf_dynamicss_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamicss_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase_by.c new file mode 100644 index 0000000..00cea97 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-dynamicss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamicss_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_dynamicss_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_utf_dynamicss_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamics_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase_by.h new file mode 100644 index 0000000..ed20b57 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamicss_increase_by_h +#define _TEST__F_utf_dynamicss_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamicss_increase_by() + */ +extern void test__f_utf_dynamicss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamicss_increase_by() + */ +extern void test__f_utf_dynamicss_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamicss_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_resize.c b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_resize.c new file mode 100644 index 0000000..8d18c8b --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-dynamicss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_dynamicss_resize__works(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamicss_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_dynamicss_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_dynamicss_t data = f_utf_string_dynamicss_t_initialize; + + { + const f_status_t status = f_utf_string_dynamicss_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-dynamicss_resize.h b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_resize.h new file mode 100644 index 0000000..202945d --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-dynamicss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_dynamicss_resize_h +#define _TEST__F_utf_dynamicss_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_dynamicss_resize() + */ +extern void test__f_utf_dynamicss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_dynamicss_resize() + */ +extern void test__f_utf_dynamicss_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_dynamicss_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-map_multis_adjust.c new file mode 100644 index 0000000..db10964 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-map_multis_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multis_adjust__works(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_map_multis_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-map_multis_adjust.h new file mode 100644 index 0000000..d37e3c0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf__string_map_multis_adjust +#define _TEST__F_utf__string_map_multis_adjust + +/** + * Test that the function works. + * + * @see f_utf_string_map_multis_adjust() + */ +extern void test__f_utf_map_multis_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multis_adjust() + */ +extern void test__f_utf_map_multis_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf__string_map_multis_adjust diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_append.c b/level_0/f_utf/tests/unit/c/test-utf-map_multis_append.c new file mode 100644 index 0000000..c3e2b91 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_append.c @@ -0,0 +1,81 @@ +#include "test-utf.h" +#include "test-utf-map_multis_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multis_append__works(void **state) { + + const int length_values = 2; + f_utf_string_map_multi_t source = f_utf_string_map_multi_t_initialize; + f_utf_string_map_multis_t destination = f_utf_string_map_multis_t_initialize; + + f_utf_string_static_t test_value_array[] = { + macro_f_utf_string_static_t_initialize("test_value1", 0, 11), + macro_f_utf_string_static_t_initialize("test_value2", 0, 11), + }; + + const f_utf_string_static_t test_name = macro_f_utf_string_static_t_initialize("test_name", 0, 9); + const f_utf_string_statics_t test_value = macro_f_utf_string_statics_t_initialize(test_value_array, 0, length_values); + + { + f_status_t status = f_utf_string_dynamic_append(test_name, &source.name); + + assert_int_equal(status, F_none); + assert_int_equal(source.name.used, test_name.used); + assert_string_equal(source.name.string, test_name.string); + + status = f_utf_string_dynamics_append_all(test_value, &source.value); + + assert_int_equal(status, F_none); + assert_int_equal(source.value.used, test_value.used); + assert_int_equal(source.value.array[0].used, test_value.array[0].used); + assert_int_equal(source.value.array[1].used, test_value.array[1].used); + + assert_string_equal(source.value.array[0].string, test_value.array[0].string); + assert_string_equal(source.value.array[1].string, test_value.array[1].string); + } + + { + const f_status_t status = f_utf_string_map_multis_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].name.used, source.name.used); + assert_int_equal(destination.array[0].value.used, source.value.used); + assert_int_equal(destination.array[0].value.array[0].used, source.value.array[0].used); + assert_int_equal(destination.array[0].value.array[1].used, source.value.array[1].used); + + assert_string_equal(destination.array[0].name.string, source.name.string); + assert_string_equal(destination.array[0].value.array[0].string, source.value.array[0].string); + assert_string_equal(destination.array[0].value.array[1].string, source.value.array[1].string); + } + + free((void *) source.name.string); + free((void *) source.value.array[0].string); + free((void *) source.value.array[1].string); + free((void *) source.value.array); + + free((void *) destination.array[0].name.string); + free((void *) destination.array[0].value.array[0].string); + free((void *) destination.array[0].value.array[1].string); + free((void *) destination.array[0].value.array); + + free((void *) destination.array); +} + +void test__f_utf_map_multis_append__parameter_checking(void **state) { + + const f_utf_string_map_multi_t data = f_utf_string_map_multi_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_append.h b/level_0/f_utf/tests/unit/c/test-utf-map_multis_append.h new file mode 100644 index 0000000..77c908d --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multis_append_h +#define _TEST__F_utf_map_multis_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multis_append() + */ +extern void test__f_utf_map_multis_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multis_append() + */ +extern void test__f_utf_map_multis_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multis_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_append_all.c b/level_0/f_utf/tests/unit/c/test-utf-map_multis_append_all.c new file mode 100644 index 0000000..74b9468 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_append_all.c @@ -0,0 +1,126 @@ +#include "test-utf.h" +#include "test-utf-map_multis_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multis_append_all__works(void **state) { + + const int length_values = 2; + const int length_inner = 2; + f_utf_string_map_multis_t source = f_utf_string_map_multis_t_initialize; + f_utf_string_map_multis_t destination = f_utf_string_map_multis_t_initialize; + + f_utf_string_static_t test_value_array[] = { + macro_f_utf_string_static_t_initialize("test_value1", 0, 11), + macro_f_utf_string_static_t_initialize("test_value2", 0, 11), + }; + + const f_utf_string_static_t test_name = macro_f_utf_string_static_t_initialize("test_name", 0, 9); + const f_utf_string_statics_t test_value = macro_f_utf_string_statics_t_initialize(test_value_array, 0, length_values); + + { + f_status_t status = f_utf_string_map_multis_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_utf_string_dynamic_append(test_name, &source.array[source.used].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].name.string, test_name.string); + assert_int_equal(source.array[source.used].name.used, test_name.used); + + status = f_utf_string_dynamics_append_all(test_value, &source.array[source.used].value); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].value.array[0].used, test_value.array[0].used); + assert_int_equal(source.array[source.used].value.array[1].used, test_value.array[1].used); + assert_string_equal(source.array[source.used].value.array[0].string, test_value.array[0].string); + assert_string_equal(source.array[source.used].value.array[1].string, test_value.array[1].string); + } // for + } + + { + const f_status_t status = f_utf_string_map_multis_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[i].name.used, source.array[i].name.used); + assert_int_equal(destination.array[i].value.used, source.array[i].value.used); + assert_int_equal(destination.array[i].value.array[0].used, source.array[i].value.array[0].used); + assert_int_equal(destination.array[i].value.array[1].used, source.array[i].value.array[1].used); + + assert_string_equal(destination.array[i].name.string, source.array[i].name.string); + assert_string_equal(destination.array[i].value.array[0].string, source.array[i].value.array[0].string); + assert_string_equal(destination.array[i].value.array[1].string, source.array[i].value.array[1].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].name.string); + free((void *) source.array[i].value.array[0].string); + free((void *) source.array[i].value.array[1].string); + free((void *) source.array[i].value.array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + free((void *) destination.array[i].name.string); + free((void *) destination.array[i].value.array[0].string); + free((void *) destination.array[i].value.array[1].string); + free((void *) destination.array[i].value.array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_utf_map_multis_append_all__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_map_multis_t source = f_utf_string_map_multis_t_initialize; + f_utf_string_map_multis_t destination = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_map_multis_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_map_multis_append_all__parameter_checking(void **state) { + + const f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_append_all.h b/level_0/f_utf/tests/unit/c/test-utf-map_multis_append_all.h new file mode 100644 index 0000000..4388611 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multis_append_all_h +#define _TEST__F_utf_map_multis_append_all_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multis_append_all() + */ +extern void test__f_utf_map_multis_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_map_multis_append_all() + */ +extern void test__f_utf_map_multis_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multis_append_all() + */ +extern void test__f_utf_map_multis_append_all__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multis_append_all_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-map_multis_decimate_by.c new file mode 100644 index 0000000..b3fc895 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-map_multis_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multis_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_map_multis_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_map_multis_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-map_multis_decimate_by.h new file mode 100644 index 0000000..15d61a6 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_map_multis_decimate_by_h +#define _TEST__F_map_multis_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multis_decimate_by() + */ +extern void test__f_utf_map_multis_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multis_decimate_by() + */ +extern void test__f_utf_map_multis_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_map_multis_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-map_multis_decrease_by.c new file mode 100644 index 0000000..106ddb2 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-map_multis_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multis_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_map_multis_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_map_multis_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-map_multis_decrease_by.h new file mode 100644 index 0000000..5ffb3b7 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multis_decrease_by_h +#define _TEST__F_utf_map_multis_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multis_decrease_by() + */ +extern void test__f_utf_map_multis_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multis_decrease_by() + */ +extern void test__f_utf_map_multis_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multis_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase.c b/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase.c new file mode 100644 index 0000000..69da8fa --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-map_multis_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multis_increase__works(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_map_multis_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +void test__f_utf_map_multis_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_map_multis_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_map_multis_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase.h b/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase.h new file mode 100644 index 0000000..17a2118 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multis_increase_h +#define _TEST__F_utf_map_multis_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multis_increase() + */ +extern void test__f_utf_map_multis_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_map_multis_increase() + */ +extern void test__f_utf_map_multis_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multis_increase() + */ +extern void test__f_utf_map_multis_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multis_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase_by.c new file mode 100644 index 0000000..c161b2b --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-map_multis_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multis_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_map_multis_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_utf_map_multis_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase_by.h new file mode 100644 index 0000000..e3f2b55 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multis_increase_by_h +#define _TEST__F_utf_map_multis_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multis_increase_by() + */ +extern void test__f_utf_map_multis_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multis_increase_by() + */ +extern void test__f_utf_map_multis_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multis_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_resize.c b/level_0/f_utf/tests/unit/c/test-utf-map_multis_resize.c new file mode 100644 index 0000000..c9c0445 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-map_multis_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multis_resize__works(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_map_multis_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multis_resize.h b/level_0/f_utf/tests/unit/c/test-utf-map_multis_resize.h new file mode 100644 index 0000000..1b3959f --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multis_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multis_resize_h +#define _TEST__F_utf_map_multis_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multis_resize() + */ +extern void test__f_utf_map_multis_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multis_resize() + */ +extern void test__f_utf_map_multis_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multis_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_adjust.c new file mode 100644 index 0000000..849aea0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-map_multiss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multiss_adjust__works(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multiss_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_map_multiss_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multiss_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_adjust.h new file mode 100644 index 0000000..0a365cf --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multiss_adjust_h +#define _TEST__F_utf_map_multiss_adjust_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multiss_adjust() + */ +extern void test__f_utf_map_multiss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multiss_adjust() + */ +extern void test__f_utf_map_multiss_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multiss_adjust_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append.c b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append.c new file mode 100644 index 0000000..3c4db13 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append.c @@ -0,0 +1,142 @@ +#include "test-utf.h" +#include "test-utf-map_multiss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multiss_append__works(void **state) { + + const int length_values = 2; + const int length_values_set = 2; + const int length_inner = 2; + f_utf_string_map_multis_t source = f_utf_string_map_multis_t_initialize; + f_utf_string_map_multiss_t destination = f_utf_string_map_multiss_t_initialize; + + f_utf_string_static_t test_value_array1[] = { + macro_f_utf_string_static_t_initialize("test_value1", 0, 11), + macro_f_utf_string_static_t_initialize("test_value2", 0, 11), + }; + + f_utf_string_static_t test_value_array2[] = { + macro_f_utf_string_static_t_initialize("test_value3", 0, 11), + macro_f_utf_string_static_t_initialize("test_value4", 0, 11), + }; + + const f_utf_string_static_t test_names[] = { + macro_f_utf_string_static_t_initialize("test_name1", 0, 10), + macro_f_utf_string_static_t_initialize("test_name2", 0, 10), + }; + + const f_utf_string_statics_t test_values[] = { + macro_f_utf_string_statics_t_initialize(test_value_array1, 0, length_values), + macro_f_utf_string_statics_t_initialize(test_value_array2, 0, length_values), + }; + + { + f_status_t status = f_utf_string_map_multis_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_utf_string_dynamic_append(test_names[source.used], &source.array[source.used].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].name.string, test_names[source.used].string); + assert_int_equal(source.array[source.used].name.used, test_names[source.used].used); + + status = f_utf_string_dynamics_append_all(test_values[source.used], &source.array[source.used].value); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].value.used, test_values[source.used].used); + assert_int_equal(source.array[source.used].value.array[0].used, test_values[source.used].array[0].used); + assert_int_equal(source.array[source.used].value.array[1].used, test_values[source.used].array[1].used); + + assert_string_equal(source.array[source.used].value.array[0].string, test_values[source.used].array[0].string); + assert_string_equal(source.array[source.used].value.array[1].string, test_values[source.used].array[1].string); + } // for + } + + { + const f_status_t status = f_utf_string_map_multiss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_inner); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[0].array[i].name.used, test_names[i].used); + assert_int_equal(destination.array[0].array[i].value.used, test_values[i].used); + assert_int_equal(destination.array[0].array[i].value.array[0].used, test_values[i].array[0].used); + assert_int_equal(destination.array[0].array[i].value.array[1].used, test_values[i].array[1].used); + + assert_string_equal(destination.array[0].array[i].name.string, test_names[i].string); + assert_string_equal(destination.array[0].array[i].value.array[0].string, test_values[i].array[0].string); + assert_string_equal(destination.array[0].array[i].value.array[1].string, test_values[i].array[1].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].name.string); + free((void *) source.array[i].value.array[0].string); + free((void *) source.array[i].value.array[1].string); + free((void *) source.array[i].value.array); + } // for + + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + + free((void *) destination.array[0].array[i].name.string); + free((void *) destination.array[0].array[i].value.array[0].string); + free((void *) destination.array[0].array[i].value.array[1].string); + free((void *) destination.array[0].array[i].value.array); + } // for + + free((void *) source.array); + free((void *) destination.array[0].array); + free((void *) destination.array); +} + +void test__f_utf_map_multiss_append__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_map_multis_t source = f_utf_string_map_multiss_t_initialize; + f_utf_string_map_multiss_t destination = f_utf_string_map_multiss_t_initialize; + + { + const f_status_t status = f_utf_string_map_multis_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_map_multiss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_map_multiss_append__parameter_checking(void **state) { + + f_utf_string_map_multis_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append.h b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append.h new file mode 100644 index 0000000..805104f --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multiss_append_h +#define _TEST__F_utf_map_multiss_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multiss_append() + */ +extern void test__f_utf_map_multiss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_map_multiss_append() + */ +extern void test__f_utf_map_multiss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multiss_append() + */ +extern void test__f_utf_map_multiss_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multiss_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append_all.c b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append_all.c new file mode 100644 index 0000000..fe6dc69 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append_all.c @@ -0,0 +1,169 @@ +#include "test-utf.h" +#include "test-utf-map_multiss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multiss_append_all__works(void **state) { + + const int length_values = 2; + const int length_values_set = 2; + const int length_inner = 2; + const int length_outer = 2; + f_utf_string_map_multiss_t source = f_utf_string_map_multiss_t_initialize; + f_utf_string_map_multiss_t destination = f_utf_string_map_multiss_t_initialize; + + f_utf_string_static_t test_value_array1[] = { + macro_f_utf_string_static_t_initialize("test_value1", 0, 11), + macro_f_utf_string_static_t_initialize("test_value2", 0, 11), + }; + + f_utf_string_static_t test_value_array2[] = { + macro_f_utf_string_static_t_initialize("test_value3", 0, 11), + macro_f_utf_string_static_t_initialize("test_value4", 0, 11), + }; + + const f_utf_string_static_t test_names[] = { + macro_f_utf_string_static_t_initialize("test_name1", 0, 10), + macro_f_utf_string_static_t_initialize("test_name2", 0, 10), + }; + + const f_utf_string_statics_t test_values[] = { + macro_f_utf_string_statics_t_initialize(test_value_array1, 0, length_values), + macro_f_utf_string_statics_t_initialize(test_value_array2, 0, length_values), + }; + + { + f_status_t status = f_utf_string_map_multiss_resize(length_outer, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length_outer); + + f_array_length_t i = 0; + f_array_length_t j = 0; + + for (; source.used < length_outer; ++source.used) { + + status = f_utf_string_map_multis_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].used, 0); + assert_int_equal(source.array[source.used].size, length_inner); + + for (i = 0; i < length_inner; ++i) { + + status = f_utf_string_dynamic_append(test_names[i], &source.array[source.used].array[i].name); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].array[i].name.used, test_names[i].used); + assert_string_equal(source.array[source.used].array[i].name.string, test_names[i].string); + + status = f_utf_string_dynamics_append_all(test_values[i], &source.array[source.used].array[i].value); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].array[i].value.used, test_values[i].used); + assert_int_equal(source.array[source.used].array[i].value.array[0].used, test_values[i].array[0].used); + assert_int_equal(source.array[source.used].array[i].value.array[1].used, test_values[i].array[1].used); + + assert_string_equal(source.array[source.used].array[i].value.array[0].string, test_values[i].array[0].string); + assert_string_equal(source.array[source.used].array[i].value.array[1].string, test_values[i].array[1].string); + } // for + + source.array[source.used].used = length_inner; + } // for + } + + { + const f_status_t status = f_utf_string_map_multiss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[j].array[i].name.used, test_names[i].used); + assert_int_equal(destination.array[j].array[i].value.used, test_values[i].used); + assert_int_equal(destination.array[j].array[i].value.array[0].used, test_values[i].array[0].used); + assert_int_equal(destination.array[j].array[i].value.array[1].used, test_values[i].array[1].used); + + assert_string_equal(destination.array[j].array[i].name.string, test_names[i].string); + assert_string_equal(destination.array[j].array[i].value.array[0].string, test_values[i].array[0].string); + assert_string_equal(destination.array[j].array[i].value.array[1].string, test_values[i].array[1].string); + } // for + } // for + } + + for (f_array_length_t j = 0; j < source.used; ++j) { + + for (f_array_length_t i = 0; i < source.array[j].used; ++i) { + + free((void *) source.array[j].array[i].name.string); + free((void *) source.array[j].array[i].value.array[0].string); + free((void *) source.array[j].array[i].value.array[1].string); + free((void *) source.array[j].array[i].value.array); + } // for + + free((void *) source.array[j].array); + } // for + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + + free((void *) destination.array[j].array[i].name.string); + free((void *) destination.array[j].array[i].value.array[0].string); + free((void *) destination.array[j].array[i].value.array[1].string); + free((void *) destination.array[j].array[i].value.array); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_utf_map_multiss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t source = f_utf_string_map_multiss_t_initialize; + f_utf_string_map_multiss_t destination = f_utf_string_map_multiss_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_map_multiss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_map_multiss_append_all__parameter_checking(void **state) { + + const f_utf_string_map_multiss_t data = f_utf_string_map_multiss_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append_all.h b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append_all.h new file mode 100644 index 0000000..7d61e34 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multiss_append_all_h +#define _TEST__F_utf_map_multiss_append_all_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multiss_append_all() + */ +extern void test__f_utf_map_multiss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_map_multiss_append_all() + */ +extern void test__f_utf_map_multiss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multiss_append_all() + */ +extern void test__f_utf_map_multiss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multiss_append_all_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decimate_by.c new file mode 100644 index 0000000..6eff1fe --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-map_multiss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multiss_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_map_multiss_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_map_multiss_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decimate_by.h new file mode 100644 index 0000000..d7a65cb --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multiss_decimate_by_h +#define _TEST__F_utf_map_multiss_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multiss_decimate_by() + */ +extern void test__f_utf_map_multiss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multiss_decimate_by() + */ +extern void test__f_utf_map_multiss_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multiss_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decrease_by.c new file mode 100644 index 0000000..bf19034 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-map_multiss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multiss_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_map_multiss_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_map_multiss_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decrease_by.h new file mode 100644 index 0000000..b4305eb --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multiss_decrease_by_h +#define _TEST__F_utf_map_multiss_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multiss_decrease_by() + */ +extern void test__f_utf_map_multiss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multiss_decrease_by() + */ +extern void test__f_utf_map_multiss_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multiss_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase.c b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase.c new file mode 100644 index 0000000..fa7a995 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-map_multiss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multiss_increase__works(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_map_multiss_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +void test__f_utf_map_multiss_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_map_multiss_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_map_multiss_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase.h b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase.h new file mode 100644 index 0000000..80281e6 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multiss_increase_h +#define _TEST__F_utf_map_multiss_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multiss_increase() + */ +extern void test__f_utf_map_multiss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_map_multiss_increase() + */ +extern void test__f_utf_map_multiss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multiss_increase() + */ +extern void test__f_utf_map_multiss_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multiss_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase_by.c new file mode 100644 index 0000000..e09df37 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-map_multiss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multiss_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_map_multiss_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_utf_map_multiss_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multis_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase_by.h new file mode 100644 index 0000000..96983df --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multiss_increase_by_h +#define _TEST__F_utf_map_multiss_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multiss_increase_by() + */ +extern void test__f_utf_map_multiss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multiss_increase_by() + */ +extern void test__f_utf_map_multiss_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multiss_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_resize.c b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_resize.c new file mode 100644 index 0000000..8d2410f --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-map_multiss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_map_multiss_resize__works(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multiss_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_map_multiss_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_map_multiss_t data = f_utf_string_map_multiss_t_initialize; + + { + const f_status_t status = f_utf_string_map_multiss_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-map_multiss_resize.h b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_resize.h new file mode 100644 index 0000000..9b90a5a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-map_multiss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_map_multiss_resize_h +#define _TEST__F_utf_map_multiss_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_map_multiss_resize() + */ +extern void test__f_utf_map_multiss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_map_multiss_resize() + */ +extern void test__f_utf_map_multiss_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_map_multiss_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-maps_adjust.c new file mode 100644 index 0000000..3a49474 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-maps_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_maps_adjust__works(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_maps_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-maps_adjust.h new file mode 100644 index 0000000..90c7916 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf__string_maps_adjust +#define _TEST__F_utf__string_maps_adjust + +/** + * Test that the function works. + * + * @see f_utf_string_maps_adjust() + */ +extern void test__f_utf_maps_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_maps_adjust() + */ +extern void test__f_utf_maps_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf__string_maps_adjust diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_append.c b/level_0/f_utf/tests/unit/c/test-utf-maps_append.c new file mode 100644 index 0000000..23f79b9 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_append.c @@ -0,0 +1,63 @@ +#include "test-utf.h" +#include "test-utf-maps_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_maps_append__works(void **state) { + + f_utf_string_map_t source = f_utf_string_map_t_initialize; + f_utf_string_maps_t destination = f_utf_string_maps_t_initialize; + + const f_utf_string_static_t test_name = macro_f_utf_string_static_t_initialize("test_name", 0, 9); + const f_utf_string_static_t test_value = macro_f_utf_string_static_t_initialize("test_value", 0, 10); + + { + f_status_t status = f_utf_string_dynamic_append(test_name, &source.name); + + assert_int_equal(status, F_none); + assert_string_equal(source.name.string, test_name.string); + assert_int_equal(source.name.used, test_name.used); + + status = f_utf_string_dynamic_append(test_value, &source.value); + + assert_int_equal(status, F_none); + assert_string_equal(source.value.string, test_value.string); + assert_int_equal(source.value.used, test_value.used); + } + + { + const f_status_t status = f_utf_string_maps_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].name.used, source.name.used); + assert_int_equal(destination.array[0].value.used, source.value.used); + assert_string_equal(destination.array[0].name.string, source.name.string); + assert_string_equal(destination.array[0].value.string, source.value.string); + } + + free((void *) source.name.string); + free((void *) source.value.string); + + free((void *) destination.array[0].name.string); + free((void *) destination.array[0].value.string); + + free((void *) destination.array); +} + +void test__f_utf_maps_append__parameter_checking(void **state) { + + const f_utf_string_map_t data = f_utf_string_map_t_initialize; + + { + const f_status_t status = f_utf_string_maps_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_append.h b/level_0/f_utf/tests/unit/c/test-utf-maps_append.h new file mode 100644 index 0000000..67627f0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_maps_append_h +#define _TEST__F_utf_maps_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_maps_append() + */ +extern void test__f_utf_maps_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_maps_append() + */ +extern void test__f_utf_maps_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_maps_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_append_all.c b/level_0/f_utf/tests/unit/c/test-utf-maps_append_all.c new file mode 100644 index 0000000..a33d488 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_append_all.c @@ -0,0 +1,112 @@ +#include "test-utf.h" +#include "test-utf-maps_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_maps_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_utf_string_maps_t source = f_utf_string_maps_t_initialize; + f_utf_string_maps_t destination = f_utf_string_maps_t_initialize; + + const f_utf_string_static_t test_name = macro_f_utf_string_static_t_initialize("test_name", 0, 9); + const f_utf_string_static_t test_value = macro_f_utf_string_static_t_initialize("test_value", 0, 10); + + { + f_status_t status = f_utf_string_maps_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_utf_string_dynamic_append(test_name, &source.array[source.used].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].name.string, test_name.string); + assert_int_equal(source.array[source.used].name.used, test_name.used); + + status = f_utf_string_dynamic_append(test_value, &source.array[source.used].value); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].value.string, test_value.string); + assert_int_equal(source.array[source.used].value.used, test_value.used); + } // for + } + + { + const f_status_t status = f_utf_string_maps_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[i].name.used, source.array[i].name.used); + assert_int_equal(destination.array[i].value.used, source.array[i].value.used); + + assert_string_equal(destination.array[i].name.string, source.array[i].name.string); + assert_string_equal(destination.array[i].value.string, source.array[i].value.string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].name.string); + free((void *) source.array[i].value.string); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + free((void *) destination.array[i].name.string); + free((void *) destination.array[i].value.string); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_utf_maps_append_all__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_maps_t source = f_utf_string_maps_t_initialize; + f_utf_string_maps_t destination = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_maps_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_maps_append_all__parameter_checking(void **state) { + + const f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_append_all.h b/level_0/f_utf/tests/unit/c/test-utf-maps_append_all.h new file mode 100644 index 0000000..0414773 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_maps_append_all_h +#define _TEST__F_utf_maps_append_all_h + +/** + * Test that the function works. + * + * @see f_utf_string_maps_append_all() + */ +extern void test__f_utf_maps_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_maps_append_all() + */ +extern void test__f_utf_maps_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_maps_append_all() + */ +extern void test__f_utf_maps_append_all__parameter_checking(void **state); + +#endif // _TEST__F_utf_maps_append_all_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-maps_decimate_by.c new file mode 100644 index 0000000..fca2fa2 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-maps_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_maps_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_maps_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_maps_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-maps_decimate_by.h new file mode 100644 index 0000000..4911371 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_maps_decimate_by_h +#define _TEST__F_maps_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_maps_decimate_by() + */ +extern void test__f_utf_maps_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_maps_decimate_by() + */ +extern void test__f_utf_maps_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_maps_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-maps_decrease_by.c new file mode 100644 index 0000000..1385d9e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-maps_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_maps_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_maps_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_maps_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-maps_decrease_by.h new file mode 100644 index 0000000..0dea22d --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_maps_decrease_by_h +#define _TEST__F_utf_maps_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_maps_decrease_by() + */ +extern void test__f_utf_maps_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_maps_decrease_by() + */ +extern void test__f_utf_maps_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_maps_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_increase.c b/level_0/f_utf/tests/unit/c/test-utf-maps_increase.c new file mode 100644 index 0000000..3ff9973 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-maps_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_maps_increase__works(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_maps_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +void test__f_utf_maps_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_maps_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_maps_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_increase.h b/level_0/f_utf/tests/unit/c/test-utf-maps_increase.h new file mode 100644 index 0000000..aa9832b --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_maps_increase_h +#define _TEST__F_utf_maps_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_maps_increase() + */ +extern void test__f_utf_maps_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_maps_increase() + */ +extern void test__f_utf_maps_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_maps_increase() + */ +extern void test__f_utf_maps_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_maps_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-maps_increase_by.c new file mode 100644 index 0000000..3aa3f71 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-maps_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_maps_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_maps_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_utf_maps_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-maps_increase_by.h new file mode 100644 index 0000000..75d57c2 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_maps_increase_by_h +#define _TEST__F_utf_maps_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_maps_increase_by() + */ +extern void test__f_utf_maps_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_maps_increase_by() + */ +extern void test__f_utf_maps_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_maps_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_resize.c b/level_0/f_utf/tests/unit/c/test-utf-maps_resize.c new file mode 100644 index 0000000..a0aedc8 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-maps_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_maps_resize__works(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_maps_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-maps_resize.h b/level_0/f_utf/tests/unit/c/test-utf-maps_resize.h new file mode 100644 index 0000000..9b0c821 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-maps_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_maps_resize_h +#define _TEST__F_utf_maps_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_maps_resize() + */ +extern void test__f_utf_maps_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_maps_resize() + */ +extern void test__f_utf_maps_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_maps_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.c new file mode 100644 index 0000000..4f38857 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-mapss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mapss_adjust__works(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_mapss_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_mapss_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_mapss_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.h new file mode 100644 index 0000000..47ae354 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mapss_adjust_h +#define _TEST__F_utf_mapss_adjust_h + +/** + * Test that the function works. + * + * @see f_utf_string_mapss_adjust() + */ +extern void test__f_utf_mapss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mapss_adjust() + */ +extern void test__f_utf_mapss_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf_mapss_adjust_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_append.c b/level_0/f_utf/tests/unit/c/test-utf-mapss_append.c new file mode 100644 index 0000000..b508517 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_append.c @@ -0,0 +1,120 @@ +#include "test-utf.h" +#include "test-utf-mapss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mapss_append__works(void **state) { + + const int length_inner = 2; + f_utf_string_maps_t source = f_utf_string_maps_t_initialize; + f_utf_string_mapss_t destination = f_utf_string_mapss_t_initialize; + + const f_utf_string_static_t test_names[] = { + macro_f_utf_string_static_t_initialize("test_name1", 0, 10), + macro_f_utf_string_static_t_initialize("test_name2", 0, 10), + }; + + const f_utf_string_static_t test_values[] = { + macro_f_utf_string_static_t_initialize("test_value1", 0, 11), + macro_f_utf_string_static_t_initialize("test_value2", 0, 11), + }; + + { + f_status_t status = f_utf_string_maps_resize(length_inner, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.size, length_inner); + + for (; source.used < length_inner; ++source.used) { + + status = f_utf_string_dynamic_append(test_names[source.used], &source.array[source.used].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].name.string, test_names[source.used].string); + assert_int_equal(source.array[source.used].name.used, test_names[source.used].used); + + status = f_utf_string_dynamic_append(test_values[source.used], &source.array[source.used].value); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].value.string, test_values[source.used].string); + assert_int_equal(source.array[source.used].value.used, test_values[source.used].used); + } // for + } + + { + const f_status_t status = f_utf_string_mapss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_inner); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[0].array[i].name.used, test_names[i].used); + assert_int_equal(destination.array[0].array[i].value.used, test_values[i].used); + + assert_string_equal(destination.array[0].array[i].name.string, test_names[i].string); + assert_string_equal(destination.array[0].array[i].value.string, test_values[i].string); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + + free((void *) source.array[i].name.string); + free((void *) source.array[i].value.string); + } // for + + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + + free((void *) destination.array[0].array[i].name.string); + free((void *) destination.array[0].array[i].value.string); + } // for + + free((void *) destination.array[0].array); + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_utf_mapss_append__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_maps_t source = f_utf_string_mapss_t_initialize; + f_utf_string_mapss_t destination = f_utf_string_mapss_t_initialize; + + { + const f_status_t status = f_utf_string_maps_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_mapss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_mapss_append__parameter_checking(void **state) { + + f_utf_string_maps_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_append.h b/level_0/f_utf/tests/unit/c/test-utf-mapss_append.h new file mode 100644 index 0000000..4e4e58b --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mapss_append_h +#define _TEST__F_utf_mapss_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_mapss_append() + */ +extern void test__f_utf_mapss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_mapss_append() + */ +extern void test__f_utf_mapss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mapss_append() + */ +extern void test__f_utf_mapss_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_mapss_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_append_all.c b/level_0/f_utf/tests/unit/c/test-utf-mapss_append_all.c new file mode 100644 index 0000000..16d8e5e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_append_all.c @@ -0,0 +1,147 @@ +#include "test-utf.h" +#include "test-utf-mapss_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mapss_append_all__works(void **state) { + + const int length = 5; + const int length_inner = 2; + const int length_outer = 2; + f_utf_string_mapss_t source = f_utf_string_mapss_t_initialize; + f_utf_string_mapss_t destination = f_utf_string_mapss_t_initialize; + + const f_utf_string_static_t test_names[] = { + macro_f_utf_string_static_t_initialize("test_name1", 0, 10), + macro_f_utf_string_static_t_initialize("test_name2", 0, 10), + }; + + const f_utf_string_static_t test_values[] = { + macro_f_utf_string_static_t_initialize("test_value1", 0, 11), + macro_f_utf_string_static_t_initialize("test_value2", 0, 11), + }; + + { + f_status_t status = f_utf_string_mapss_resize(length_outer, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length_outer); + + f_array_length_t i = 0; + f_array_length_t j = 0; + + for (; source.used < length_outer; ++source.used) { + + status = f_utf_string_maps_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + assert_int_equal(source.array[source.used].used, 0); + assert_int_equal(source.array[source.used].size, length_inner); + + for (i = 0; i < length_inner; ++i) { + + status = f_utf_string_dynamic_append(test_names[i], &source.array[source.used].array[i].name); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].array[i].name.string, test_names[i].string); + assert_int_equal(source.array[source.used].array[i].name.used, test_names[i].used); + + status = f_utf_string_dynamic_append(test_values[i], &source.array[source.used].array[i].value); + + assert_int_equal(status, F_none); + assert_string_equal(source.array[source.used].array[i].value.string, test_values[i].string); + assert_int_equal(source.array[source.used].array[i].value.used, test_values[i].used); + } // for + + source.array[source.used].used = length_inner; + } // for + } + + { + const f_status_t status = f_utf_string_mapss_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_outer; ++j) { + + for (f_array_length_t i = 0; i < length_inner; ++i) { + + assert_int_equal(destination.array[j].array[i].name.used, test_names[i].used); + assert_int_equal(destination.array[j].array[i].value.used, test_values[i].used); + + assert_string_equal(destination.array[j].array[i].name.string, test_names[i].string); + assert_string_equal(destination.array[j].array[i].value.string, test_values[i].string); + } // for + } // for + } + + for (f_array_length_t j = 0; j < source.used; ++j) { + + for (f_array_length_t i = 0; i < source.array[j].used; ++i) { + + free((void *) source.array[j].array[i].name.string); + free((void *) source.array[j].array[i].value.string); + } // for + + free((void *) source.array[j].array); + } // for + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + + free((void *) destination.array[j].array[i].name.string); + free((void *) destination.array[j].array[i].value.string); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_utf_mapss_append_all__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_mapss_t source = f_utf_string_mapss_t_initialize; + f_utf_string_mapss_t destination = f_utf_string_mapss_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_mapss_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_mapss_append_all__parameter_checking(void **state) { + + const f_utf_string_mapss_t data = f_utf_string_mapss_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_append_all.h b/level_0/f_utf/tests/unit/c/test-utf-mapss_append_all.h new file mode 100644 index 0000000..fee1556 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mapss_append_all_h +#define _TEST__F_utf_mapss_append_all_h + +/** + * Test that the function works. + * + * @see f_utf_string_mapss_append_all() + */ +extern void test__f_utf_mapss_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_mapss_append_all() + */ +extern void test__f_utf_mapss_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mapss_append_all() + */ +extern void test__f_utf_mapss_append_all__parameter_checking(void **state); + +#endif // _TEST__F_utf_mapss_append_all_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-mapss_decimate_by.c new file mode 100644 index 0000000..33ee567 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-mapss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mapss_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_mapss_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_mapss_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-mapss_decimate_by.h new file mode 100644 index 0000000..71567a0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mapss_decimate_by_h +#define _TEST__F_utf_mapss_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_mapss_decimate_by() + */ +extern void test__f_utf_mapss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mapss_decimate_by() + */ +extern void test__f_utf_mapss_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_mapss_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-mapss_decrease_by.c new file mode 100644 index 0000000..7484e13 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-mapss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mapss_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_mapss_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_mapss_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-mapss_decrease_by.h new file mode 100644 index 0000000..0d21e3b --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mapss_decrease_by_h +#define _TEST__F_utf_mapss_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_mapss_decrease_by() + */ +extern void test__f_utf_mapss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mapss_decrease_by() + */ +extern void test__f_utf_mapss_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_mapss_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_increase.c b/level_0/f_utf/tests/unit/c/test-utf-mapss_increase.c new file mode 100644 index 0000000..67a911c --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-mapss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mapss_increase__works(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_mapss_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +void test__f_utf_mapss_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_mapss_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_mapss_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_increase.h b/level_0/f_utf/tests/unit/c/test-utf-mapss_increase.h new file mode 100644 index 0000000..2bbe66c --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mapss_increase_h +#define _TEST__F_utf_mapss_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_mapss_increase() + */ +extern void test__f_utf_mapss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_mapss_increase() + */ +extern void test__f_utf_mapss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mapss_increase() + */ +extern void test__f_utf_mapss_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_mapss_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-mapss_increase_by.c new file mode 100644 index 0000000..4151f00 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-mapss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mapss_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_mapss_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_utf_mapss_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_maps_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-mapss_increase_by.h new file mode 100644 index 0000000..4cd2dff --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mapss_increase_by_h +#define _TEST__F_utf_mapss_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_mapss_increase_by() + */ +extern void test__f_utf_mapss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mapss_increase_by() + */ +extern void test__f_utf_mapss_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_mapss_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_resize.c b/level_0/f_utf/tests/unit/c/test-utf-mapss_resize.c new file mode 100644 index 0000000..d5d6769 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-mapss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mapss_resize__works(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_mapss_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_mapss_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_mapss_t data = f_utf_string_mapss_t_initialize; + + { + const f_status_t status = f_utf_string_mapss_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mapss_resize.h b/level_0/f_utf/tests/unit/c/test-utf-mapss_resize.h new file mode 100644 index 0000000..f6cfc55 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mapss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mapss_resize_h +#define _TEST__F_utf_mapss_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_mapss_resize() + */ +extern void test__f_utf_mapss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mapss_resize() + */ +extern void test__f_utf_mapss_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_mapss_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mash.c b/level_0/f_utf/tests/unit/c/test-utf-mash.c new file mode 100644 index 0000000..9161476 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mash.c @@ -0,0 +1,54 @@ +#include "test-utf.h" +#include "test-utf-mash.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mash__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("te\0st:te\0st", 0, 11); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_mash(glue.string, glue.used, source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_mash(glue.string, glue.used, source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + assert_string_equal(destination.string + 9, expected.string + 9); + } + + free((void *) destination.string); +} + +void test__f_utf_mash__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + + { + const f_status_t status = f_utf_string_mash(glue.string, glue.used, source.string, source.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mash.h b/level_0/f_utf/tests/unit/c/test-utf-mash.h new file mode 100644 index 0000000..381a147 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mash.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mash_h +#define _TEST__F_utf_mash_h + +/** + * Test that the function works. + * + * @see f_utf_string_mash() + */ +extern void test__f_utf_mash__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mash() + */ +extern void test__f_utf_mash__parameter_checking(void **state); + +#endif // _TEST__F_utf_mash_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mash_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-mash_nulless.c new file mode 100644 index 0000000..9f62c60 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mash_nulless.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-mash_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mash_nulless__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected1 = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_utf_string_static_t expected2 = macro_f_utf_string_static_t_initialize("test:test", 0, 9); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_mash_nulless(glue.string, glue.used, source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected1.used); + + assert_string_equal(destination.string, expected1.string); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_mash_nulless(glue.string, glue.used, source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected2.used); + + assert_string_equal(destination.string, expected2.string); + } + + free((void *) destination.string); +} + +void test__f_utf_mash_nulless__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + + { + const f_status_t status = f_utf_string_mash_nulless(glue.string, glue.used, source.string, source.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mash_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-mash_nulless.h new file mode 100644 index 0000000..81612c0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mash_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mash_nulless_h +#define _TEST__F_utf_mash_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_mash_nulless() + */ +extern void test__f_utf_mash_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mash_nulless() + */ +extern void test__f_utf_mash_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_mash_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mish.c b/level_0/f_utf/tests/unit/c/test-utf-mish.c new file mode 100644 index 0000000..8eae1e4 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mish.c @@ -0,0 +1,54 @@ +#include "test-utf.h" +#include "test-utf-mish.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mish__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("te\0st:te\0st", 0, 11); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_mish(glue.string, glue.used, source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_mish(glue.string, glue.used, source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + assert_string_equal(destination.string + 3, expected.string + 3); + assert_string_equal(destination.string + 9, expected.string + 9); + } + + free((void *) destination.string); +} + +void test__f_utf_mish__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + + { + const f_status_t status = f_utf_string_mish(glue.string, glue.used, source.string, source.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mish.h b/level_0/f_utf/tests/unit/c/test-utf-mish.h new file mode 100644 index 0000000..fca1ea3 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mish.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mish_h +#define _TEST__F_utf_mish_h + +/** + * Test that the function works. + * + * @see f_utf_string_mish() + */ +extern void test__f_utf_mish__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mish() + */ +extern void test__f_utf_mish__parameter_checking(void **state); + +#endif // _TEST__F_utf_mish_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-mish_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-mish_nulless.c new file mode 100644 index 0000000..f03a9b1 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mish_nulless.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-mish_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_mish_nulless__works(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected1 = macro_f_utf_string_static_t_initialize("test", 0, 4); + const f_utf_string_static_t expected2 = macro_f_utf_string_static_t_initialize("test:test", 0, 9); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_mish_nulless(glue.string, glue.used, source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected1.used); + + assert_string_equal(destination.string, expected1.string); + } + + // Check that the glue is added. + { + const f_status_t status = f_utf_string_mish_nulless(glue.string, glue.used, source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected2.used); + + assert_string_equal(destination.string, expected2.string); + } + + free((void *) destination.string); +} + +void test__f_utf_mish_nulless__parameter_checking(void **state) { + + const f_utf_string_static_t glue = macro_f_utf_string_static_t_initialize(":", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + + { + const f_status_t status = f_utf_string_mish_nulless(glue.string, glue.used, source.string, source.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-mish_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-mish_nulless.h new file mode 100644 index 0000000..452ea35 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-mish_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_mish_nulless_h +#define _TEST__F_utf_mish_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_mish_nulless() + */ +extern void test__f_utf_mish_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_mish_nulless() + */ +extern void test__f_utf_mish_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_mish_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-prepend.c b/level_0/f_utf/tests/unit/c/test-utf-prepend.c new file mode 100644 index 0000000..716d4fe --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-prepend.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-prepend.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_prepend__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_prepend(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_prepend__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_prepend(data.string, data.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-prepend.h b/level_0/f_utf/tests/unit/c/test-utf-prepend.h new file mode 100644 index 0000000..bdab477 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-prepend.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_prepend_h +#define _TEST__F_utf_prepend_h + +/** + * Test that the function works. + * + * @see f_utf_string_prepend() + */ +extern void test__f_utf_prepend__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_prepend() + */ +extern void test__f_utf_prepend__parameter_checking(void **state); + +#endif // _TEST__F_utf_prepend_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-prepend_assure.c b/level_0/f_utf/tests/unit/c/test-utf-prepend_assure.c new file mode 100644 index 0000000..29423d4 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-prepend_assure.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-prepend_assure.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_prepend_assure__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_prepend_assure(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_prepend_assure(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + assert_string_equal(destination.string, source.string); + assert_string_equal(destination.string + 3, source.string + 3); + } + + free((void *) destination.string); +} + +void test__f_utf_prepend_assure__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_prepend_assure(data.string, data.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-prepend_assure.h b/level_0/f_utf/tests/unit/c/test-utf-prepend_assure.h new file mode 100644 index 0000000..711ccd1 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-prepend_assure.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_prepend_assure_h +#define _TEST__F_utf_prepend_assure_h + +/** + * Test that the function works. + * + * @see f_utf_string_prepend_assure() + */ +extern void test__f_utf_prepend_assure__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_prepend_assure() + */ +extern void test__f_utf_prepend_assure__parameter_checking(void **state); + +#endif // _TEST__F_utf_prepend_assure_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-prepend_assure_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-prepend_assure_nulless.c new file mode 100644 index 0000000..ac313e6 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-prepend_assure_nulless.c @@ -0,0 +1,49 @@ +#include "test-utf.h" +#include "test-utf-prepend_assure_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_prepend_assure_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_prepend_assure_nulless(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + // The string already exists, so destination should be unchanged. + { + const f_status_t status = f_utf_string_prepend_assure_nulless(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_prepend_assure_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_prepend_assure_nulless(data.string, data.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-prepend_assure_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-prepend_assure_nulless.h new file mode 100644 index 0000000..9e4bab4 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-prepend_assure_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_prepend_assure_nulless_h +#define _TEST__F_utf_prepend_assure_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_prepend_assure_nulless() + */ +extern void test__f_utf_prepend_assure_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_prepend_assure_nulless() + */ +extern void test__f_utf_prepend_assure_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_prepend_assure_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-prepend_nulless.c b/level_0/f_utf/tests/unit/c/test-utf-prepend_nulless.c new file mode 100644 index 0000000..a1554cc --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-prepend_nulless.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-prepend_nulless.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_prepend_nulless__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\0st", 0, 5); + const f_utf_string_static_t expected = macro_f_utf_string_static_t_initialize("test", 0, 4); + f_utf_string_dynamic_t destination = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_prepend_nulless(source.string, source.used, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, expected.used); + + assert_string_equal(destination.string, expected.string); + } + + free((void *) destination.string); +} + +void test__f_utf_prepend_nulless__parameter_checking(void **state) { + + const f_utf_string_dynamic_t data = f_utf_string_dynamic_t_initialize; + + { + const f_status_t status = f_utf_string_prepend_nulless(data.string, data.used, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-prepend_nulless.h b/level_0/f_utf/tests/unit/c/test-utf-prepend_nulless.h new file mode 100644 index 0000000..ff6b7dd --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-prepend_nulless.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_prepend_nulless_h +#define _TEST__F_utf_prepend_nulless_h + +/** + * Test that the function works. + * + * @see f_utf_string_prepend_nulless() + */ +extern void test__f_utf_prepend_nulless__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_prepend_nulless() + */ +extern void test__f_utf_prepend_nulless__parameter_checking(void **state); + +#endif // _TEST__F_utf_prepend_nulless_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-seek_line.c b/level_0/f_utf/tests/unit/c/test-utf-seek_line.c new file mode 100644 index 0000000..4ace602 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-seek_line.c @@ -0,0 +1,66 @@ +#include "test-utf.h" +#include "test-utf-seek_line.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_seek_line__returns_data_not_stop(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = f_utf_string_range_t_initialize; + + const f_status_t status = f_utf_string_seek_line(source.string, &range); + + assert_int_equal(status, F_data_not_stop); + } +} + +void test__f_utf_seek_line__returns_none_stop(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test", 0, 4); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_seek_line(source.string, &range); + + assert_int_equal(status, F_none_stop); + + assert_int_equal(range.start, source.used); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_seek_line__works(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_seek_line(source.string, &range); + + assert_int_equal(status, F_none); + + assert_int_equal(range.start, 4); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_seek_line__parameter_checking(void **state) { + + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("teX\nst", 0, 6); + + { + const f_status_t status = f_utf_string_seek_line(source.string, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-seek_line.h b/level_0/f_utf/tests/unit/c/test-utf-seek_line.h new file mode 100644 index 0000000..4d90784 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-seek_line.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_seek_line_h +#define _TEST__F_utf_seek_line_h + +/** + * Test that the function returns F_data_not_stop because range is an empty range (range.start > range.stop). + * + * @see f_utf_string_seek_line() + */ +extern void test__f_utf_seek_line__returns_data_not_stop(void **state); + +/** + * Test that the function returns F_none_stop stopped after end of range because no newline is found. + * + * @see f_utf_string_seek_line() + */ +extern void test__f_utf_seek_line__returns_none_stop(void **state); + +/** + * Test that the function works. + * + * @see f_utf_string_seek_line() + */ +extern void test__f_utf_seek_line__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_seek_line() + */ +extern void test__f_utf_seek_line__parameter_checking(void **state); + +#endif // _TEST__F_utf_seek_line_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-seek_line_to.c b/level_0/f_utf/tests/unit/c/test-utf-seek_line_to.c new file mode 100644 index 0000000..96b8da4 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-seek_line_to.c @@ -0,0 +1,87 @@ +#include "test-utf.h" +#include "test-utf-seek_line_to.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_seek_line_to__at_newline(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\nXst", 0, 6); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_seek_line_to(source.string, to.string[0], &range); + + assert_int_equal(status, F_none_eol); + + assert_int_equal(range.start, 2); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_seek_line_to__returns_data_not_stop(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = f_utf_string_range_t_initialize; + + const f_status_t status = f_utf_string_seek_line_to(source.string, to.string[0], &range); + + assert_int_equal(status, F_data_not_stop); + } +} + +void test__f_utf_seek_line_to__returns_none_stop(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test", 0, 4); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_seek_line_to(source.string, to.string[0], &range); + + assert_int_equal(status, F_none_stop); + + assert_int_equal(range.start, source.used); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_seek_line_to__works(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("teX\nst", 0, 6); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_seek_line_to(source.string, to.string[0], &range); + + assert_int_equal(status, F_none); + + assert_int_equal(range.start, 2); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_seek_line_to__parameter_checking(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("teX\nst", 0, 6); + + { + const f_status_t status = f_utf_string_seek_line_to(source.string, to.string[0], 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-seek_line_to.h b/level_0/f_utf/tests/unit/c/test-utf-seek_line_to.h new file mode 100644 index 0000000..4b79e9d --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-seek_line_to.h @@ -0,0 +1,48 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_seek_line_to_h +#define _TEST__F_utf_seek_line_to_h + +/** + * Test that the function works but stops at newline rather than search string. + * + * @see f_utf_string_seek_line_to() + */ +extern void test__f_utf_seek_line_to__at_newline(void **state); + +/** + * Test that the function returns F_data_not_stop because range is an empty range (range.start > range.stop). + * + * @see f_utf_string_seek_line_to() + */ +extern void test__f_utf_seek_line_to__returns_data_not_stop(void **state); + +/** + * Test that the function returns F_none_stop stopped after end of range because no newline is found. + * + * @see f_utf_string_seek_line_to() + */ +extern void test__f_utf_seek_line_to__returns_none_stop(void **state); + +/** + * Test that the function works. + * + * @see f_utf_string_seek_line_to() + */ +extern void test__f_utf_seek_line_to__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_seek_line_to() + */ +extern void test__f_utf_seek_line_to__parameter_checking(void **state); + +#endif // _TEST__F_utf_seek_line_to_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-seek_to.c b/level_0/f_utf/tests/unit/c/test-utf-seek_to.c new file mode 100644 index 0000000..09bd1e1 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-seek_to.c @@ -0,0 +1,70 @@ +#include "test-utf.h" +#include "test-utf-seek_to.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_seek_to__returns_data_not_stop(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = f_utf_string_range_t_initialize; + + const f_status_t status = f_utf_string_seek_to(source.string, to.string[0], &range); + + assert_int_equal(status, F_data_not_stop); + } +} + +void test__f_utf_seek_to__returns_none_stop(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("test\nafter", 0, 10); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_seek_to(source.string, to.string[0], &range); + + assert_int_equal(status, F_none_stop); + + assert_int_equal(range.start, source.used); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_seek_to__works(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("te\nXst", 0, 6); + + { + f_string_range_t range = macro_f_utf_string_range_t_initialize(0, source.used - 1); + + const f_status_t status = f_utf_string_seek_to(source.string, to.string[0], &range); + + assert_int_equal(status, F_none); + + assert_int_equal(range.start, 3); + assert_int_equal(range.stop, source.used - 1); + } +} + +void test__f_utf_seek_to__parameter_checking(void **state) { + + const f_utf_string_static_t to = macro_f_utf_string_static_t_initialize("X", 0, 1); + const f_utf_string_static_t source = macro_f_utf_string_static_t_initialize("teX\nst", 0, 6); + + { + const f_status_t status = f_utf_string_seek_to(source.string, to.string[0], 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-seek_to.h b/level_0/f_utf/tests/unit/c/test-utf-seek_to.h new file mode 100644 index 0000000..8678955 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-seek_to.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_seek_to_h +#define _TEST__F_utf_seek_to_h + +/** + * Test that the function returns F_data_not_stop because range is an empty range (range.start > range.stop). + * + * @see f_utf_string_seek_to() + */ +extern void test__f_utf_seek_to__returns_data_not_stop(void **state); + +/** + * Test that the function returns F_none_stop stopped after end of range because no newline is found. + * + * @see f_utf_string_seek_to() + */ +extern void test__f_utf_seek_to__returns_none_stop(void **state); + +/** + * Test that the function works. + * + * @see f_utf_string_seek_to() + */ +extern void test__f_utf_seek_to__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_seek_to() + */ +extern void test__f_utf_seek_to__parameter_checking(void **state); + +#endif // _TEST__F_utf_seek_to_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-triples_adjust.c new file mode 100644 index 0000000..2478756 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-triples_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_triples_adjust__works(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_triples_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-triples_adjust.h new file mode 100644 index 0000000..54c8bf2 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf__string_triples_adjust +#define _TEST__F_utf__string_triples_adjust + +/** + * Test that the function works. + * + * @see f_utf_string_triples_adjust() + */ +extern void test__f_utf_triples_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_triples_adjust() + */ +extern void test__f_utf_triples_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf__string_triples_adjust diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_append.c b/level_0/f_utf/tests/unit/c/test-utf-triples_append.c new file mode 100644 index 0000000..0b9a55a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_append.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-triples_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_triples_append__works(void **state) { + + const f_utf_string_static_t test_a = macro_f_utf_string_static_t_initialize("a", 0, 1); + const f_utf_string_static_t test_b = macro_f_utf_string_static_t_initialize("b", 0, 1); + const f_utf_string_static_t test_c = macro_f_utf_string_static_t_initialize("c", 0, 1); + + const f_utf_string_triple_t source = macro_f_utf_string_triple_t_initialize(test_a, test_b, test_c); + f_utf_string_triples_t destination = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, 1); + assert_int_equal(destination.array[0].a.used, source.a.used); + assert_int_equal(destination.array[0].b.used, source.b.used); + assert_int_equal(destination.array[0].c.used, source.c.used); + + assert_string_equal(destination.array[0].a.string, source.a.string); + assert_string_equal(destination.array[0].b.string, source.b.string); + assert_string_equal(destination.array[0].c.string, source.c.string); + } + + free((void *) destination.array[0].a.string); + free((void *) destination.array[0].b.string); + free((void *) destination.array[0].c.string); + free((void *) destination.array); +} + +void test__f_utf_triples_append__parameter_checking(void **state) { + + const f_utf_string_triple_t data = f_utf_string_triple_t_initialize; + + { + const f_status_t status = f_utf_string_triples_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_append.h b/level_0/f_utf/tests/unit/c/test-utf-triples_append.h new file mode 100644 index 0000000..5094660 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_append.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_triples_append_h +#define _TEST__F_utf_triples_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_triples_append() + */ +extern void test__f_utf_triples_append__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_triples_append() + */ +extern void test__f_utf_triples_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_triples_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_append_all.c b/level_0/f_utf/tests/unit/c/test-utf-triples_append_all.c new file mode 100644 index 0000000..9b6a642 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_append_all.c @@ -0,0 +1,96 @@ +#include "test-utf.h" +#include "test-utf-triples_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_triples_append_all__works(void **state) { + + const int length_sources = 2; + + const f_utf_string_static_t test_a = macro_f_utf_string_static_t_initialize("a", 0, 1); + const f_utf_string_static_t test_b = macro_f_utf_string_static_t_initialize("b", 0, 1); + const f_utf_string_static_t test_c = macro_f_utf_string_static_t_initialize("c", 0, 1); + + const f_utf_string_static_t test_d = macro_f_utf_string_static_t_initialize("d", 0, 1); + const f_utf_string_static_t test_e = macro_f_utf_string_static_t_initialize("e", 0, 1); + const f_utf_string_static_t test_f = macro_f_utf_string_static_t_initialize("f", 0, 1); + + f_utf_string_triple_t sources_array[] = { + macro_f_utf_string_triple_t_initialize(test_a, test_b, test_c), + macro_f_utf_string_triple_t_initialize(test_d, test_e, test_f), + }; + + const f_utf_string_triples_t source = macro_f_utf_string_triples_t_initialize(sources_array, 0, length_sources); + f_utf_string_triples_t destination = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[i].a.used, source.array[i].a.used); + assert_int_equal(destination.array[i].b.used, source.array[i].b.used); + assert_int_equal(destination.array[i].c.used, source.array[i].c.used); + + assert_string_equal(destination.array[i].a.string, source.array[i].a.string); + assert_string_equal(destination.array[i].b.string, source.array[i].b.string); + assert_string_equal(destination.array[i].c.string, source.array[i].c.string); + } // for + } + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + free((void *) destination.array[i].a.string); + free((void *) destination.array[i].b.string); + free((void *) destination.array[i].c.string); + } // for + + free((void *) destination.array); +} + +void test__f_utf_triples_append_all__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_triples_t source = f_utf_string_triples_t_initialize; + f_utf_string_triples_t destination = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_triples_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_triples_append_all__parameter_checking(void **state) { + + const f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_append_all.h b/level_0/f_utf/tests/unit/c/test-utf-triples_append_all.h new file mode 100644 index 0000000..21c43f6 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_triples_append_all_h +#define _TEST__F_utf_triples_append_all_h + +/** + * Test that the function works. + * + * @see f_utf_string_triples_append_all() + */ +extern void test__f_utf_triples_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_triples_append_all() + */ +extern void test__f_utf_triples_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_triples_append_all() + */ +extern void test__f_utf_triples_append_all__parameter_checking(void **state); + +#endif // _TEST__F_utf_triples_append_all_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-triples_decimate_by.c new file mode 100644 index 0000000..210273e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-triples_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_triples_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_triples_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_triples_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-triples_decimate_by.h new file mode 100644 index 0000000..b294b5f --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_triples_decimate_by_h +#define _TEST__F_triples_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_triples_decimate_by() + */ +extern void test__f_utf_triples_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_triples_decimate_by() + */ +extern void test__f_utf_triples_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_triples_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-triples_decrease_by.c new file mode 100644 index 0000000..46b305a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-triples_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_triples_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_triples_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_triples_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-triples_decrease_by.h new file mode 100644 index 0000000..eb94eca --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_triples_decrease_by_h +#define _TEST__F_utf_triples_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_triples_decrease_by() + */ +extern void test__f_utf_triples_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_triples_decrease_by() + */ +extern void test__f_utf_triples_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_triples_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_increase.c b/level_0/f_utf/tests/unit/c/test-utf-triples_increase.c new file mode 100644 index 0000000..1ff02e5 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-triples_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_triples_increase__works(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_triples_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +void test__f_utf_triples_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_triples_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_triples_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_increase.h b/level_0/f_utf/tests/unit/c/test-utf-triples_increase.h new file mode 100644 index 0000000..ddf9d5a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_triples_increase_h +#define _TEST__F_utf_triples_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_triples_increase() + */ +extern void test__f_utf_triples_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_triples_increase() + */ +extern void test__f_utf_triples_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_triples_increase() + */ +extern void test__f_utf_triples_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_triples_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-triples_increase_by.c new file mode 100644 index 0000000..66f1eb1 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-triples_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_triples_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_triples_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_utf_triples_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-triples_increase_by.h new file mode 100644 index 0000000..5c1ad01 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_triples_increase_by_h +#define _TEST__F_utf_triples_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_triples_increase_by() + */ +extern void test__f_utf_triples_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_triples_increase_by() + */ +extern void test__f_utf_triples_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_triples_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_resize.c b/level_0/f_utf/tests/unit/c/test-utf-triples_resize.c new file mode 100644 index 0000000..5ff770a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-triples_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_triples_resize__works(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_triples_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-triples_resize.h b/level_0/f_utf/tests/unit/c/test-utf-triples_resize.h new file mode 100644 index 0000000..4297dba --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-triples_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_triples_resize_h +#define _TEST__F_utf_triples_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_triples_resize() + */ +extern void test__f_utf_triples_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_triples_resize() + */ +extern void test__f_utf_triples_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_triples_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_adjust.c b/level_0/f_utf/tests/unit/c/test-utf-tripless_adjust.c new file mode 100644 index 0000000..b3da75d --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_adjust.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-tripless_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_tripless_adjust__works(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_tripless_adjust__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_adjust.h b/level_0/f_utf/tests/unit/c/test-utf-tripless_adjust.h new file mode 100644 index 0000000..a4ca68b --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_tripless_adjust_h +#define _TEST__F_utf_tripless_adjust_h + +/** + * Test that the function works. + * + * @see f_utf_string_tripless_adjust() + */ +extern void test__f_utf_tripless_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_tripless_adjust() + */ +extern void test__f_utf_tripless_adjust__parameter_checking(void **state); + +#endif // _TEST__F_utf_tripless_adjust_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_append.c b/level_0/f_utf/tests/unit/c/test-utf-tripless_append.c new file mode 100644 index 0000000..0a6b4ac --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_append.c @@ -0,0 +1,96 @@ +#include "test-utf.h" +#include "test-utf-tripless_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_tripless_append__works(void **state) { + + const int length_sources = 2; + + const f_utf_string_static_t test_a = macro_f_utf_string_static_t_initialize("a", 0, 1); + const f_utf_string_static_t test_b = macro_f_utf_string_static_t_initialize("b", 0, 1); + const f_utf_string_static_t test_c = macro_f_utf_string_static_t_initialize("c", 0, 1); + + const f_utf_string_static_t test_d = macro_f_utf_string_static_t_initialize("d", 0, 1); + const f_utf_string_static_t test_e = macro_f_utf_string_static_t_initialize("e", 0, 1); + const f_utf_string_static_t test_f = macro_f_utf_string_static_t_initialize("f", 0, 1); + + f_utf_string_triple_t sources_array[] = { + macro_f_utf_string_triple_t_initialize(test_a, test_b, test_c), + macro_f_utf_string_triple_t_initialize(test_d, test_e, test_f), + }; + + const f_utf_string_triples_t source = macro_f_utf_string_triples_t_initialize(sources_array, 0, length_sources); + f_utf_string_tripless_t destination = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.array[0].used, length_sources); + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[0].array[i].a.used, sources_array[i].a.used); + assert_int_equal(destination.array[0].array[i].b.used, sources_array[i].b.used); + assert_int_equal(destination.array[0].array[i].c.used, sources_array[i].c.used); + + assert_string_equal(destination.array[0].array[i].a.string, sources_array[i].a.string); + assert_string_equal(destination.array[0].array[i].b.string, sources_array[i].b.string); + assert_string_equal(destination.array[0].array[i].c.string, sources_array[i].c.string); + } // for + } + + for (f_array_length_t i = 0; i < destination.array[0].used; ++i) { + + free((void *) destination.array[0].array[i].a.string); + free((void *) destination.array[0].array[i].b.string); + free((void *) destination.array[0].array[i].c.string); + } // for + + free((void *) destination.array[0].array); + free((void *) destination.array); +} + +void test__f_utf_tripless_append__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_triples_t source = f_utf_string_tripless_t_initialize; + f_utf_string_tripless_t destination = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_triples_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_tripless_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_tripless_append__parameter_checking(void **state) { + + f_utf_string_triples_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_append.h b/level_0/f_utf/tests/unit/c/test-utf-tripless_append.h new file mode 100644 index 0000000..d18753e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_tripless_append_h +#define _TEST__F_utf_tripless_append_h + +/** + * Test that the function works. + * + * @see f_utf_string_tripless_append() + */ +extern void test__f_utf_tripless_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_tripless_append() + */ +extern void test__f_utf_tripless_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_tripless_append() + */ +extern void test__f_utf_tripless_append__parameter_checking(void **state); + +#endif // _TEST__F_utf_tripless_append_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_append_all.c b/level_0/f_utf/tests/unit/c/test-utf-tripless_append_all.c new file mode 100644 index 0000000..1104d40 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_append_all.c @@ -0,0 +1,122 @@ +#include "test-utf.h" +#include "test-utf-tripless_append_all.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_tripless_append_all__works(void **state) { + + const int length_sources = 2; + const int length_sources_set = 2; + + const f_utf_string_static_t test_a = macro_f_utf_string_static_t_initialize("a", 0, 1); + const f_utf_string_static_t test_b = macro_f_utf_string_static_t_initialize("b", 0, 1); + const f_utf_string_static_t test_c = macro_f_utf_string_static_t_initialize("c", 0, 1); + + const f_utf_string_static_t test_d = macro_f_utf_string_static_t_initialize("d", 0, 1); + const f_utf_string_static_t test_e = macro_f_utf_string_static_t_initialize("e", 0, 1); + const f_utf_string_static_t test_f = macro_f_utf_string_static_t_initialize("f", 0, 1); + + const f_utf_string_static_t test_g = macro_f_utf_string_static_t_initialize("g", 0, 1); + const f_utf_string_static_t test_h = macro_f_utf_string_static_t_initialize("h", 0, 1); + const f_utf_string_static_t test_i = macro_f_utf_string_static_t_initialize("i", 0, 1); + + const f_utf_string_static_t test_j = macro_f_utf_string_static_t_initialize("j", 0, 1); + const f_utf_string_static_t test_k = macro_f_utf_string_static_t_initialize("k", 0, 1); + const f_utf_string_static_t test_l = macro_f_utf_string_static_t_initialize("l", 0, 1); + + f_utf_string_triple_t sources_array1[] = { + macro_f_utf_string_triple_t_initialize(test_a, test_b, test_c), + macro_f_utf_string_triple_t_initialize(test_d, test_e, test_f), + }; + + f_utf_string_triple_t sources_array2[] = { + macro_f_utf_string_triple_t_initialize(test_g, test_h, test_i), + macro_f_utf_string_triple_t_initialize(test_j, test_k, test_l), + }; + + f_utf_string_triples_t sources_set_array[] = { + macro_f_utf_string_triples_t_initialize(sources_array1, 0, length_sources), + macro_f_utf_string_triples_t_initialize(sources_array2, 0, length_sources), + }; + + const f_utf_string_tripless_t source = macro_f_utf_string_tripless_t_initialize(sources_set_array, 0, length_sources_set); + f_utf_string_tripless_t destination = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_append_all(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + + for (f_array_length_t j = 0; j < length_sources_set; ++j) { + + for (f_array_length_t i = 0; i < length_sources; ++i) { + + assert_int_equal(destination.array[j].array[i].a.used, sources_set_array[j].array[i].a.used); + assert_int_equal(destination.array[j].array[i].b.used, sources_set_array[j].array[i].b.used); + assert_int_equal(destination.array[j].array[i].c.used, sources_set_array[j].array[i].c.used); + + assert_string_equal(destination.array[j].array[i].a.string, sources_set_array[j].array[i].a.string); + assert_string_equal(destination.array[j].array[i].b.string, sources_set_array[j].array[i].b.string); + assert_string_equal(destination.array[j].array[i].c.string, sources_set_array[j].array[i].c.string); + } // for + } // for + } + + for (f_array_length_t j = 0; j < destination.used; ++j) { + + for (f_array_length_t i = 0; i < destination.array[j].used; ++i) { + + free((void *) destination.array[j].array[i].a.string); + free((void *) destination.array[j].array[i].b.string); + free((void *) destination.array[j].array[i].c.string); + } // for + + free((void *) destination.array[j].array); + } // for + + free((void *) destination.array); +} + +void test__f_utf_tripless_append_all__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_tripless_t source = f_utf_string_tripless_t_initialize; + f_utf_string_tripless_t destination = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_utf_string_tripless_append_all(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + assert_null(destination.array); + } + + free((void *) source.array); +} + +void test__f_utf_tripless_append_all__parameter_checking(void **state) { + + const f_utf_string_tripless_t data = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_append_all(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_append_all.h b/level_0/f_utf/tests/unit/c/test-utf-tripless_append_all.h new file mode 100644 index 0000000..bbb2656 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_append_all.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_tripless_append_all_h +#define _TEST__F_utf_tripless_append_all_h + +/** + * Test that the function works. + * + * @see f_utf_string_tripless_append_all() + */ +extern void test__f_utf_tripless_append_all__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_tripless_append_all() + */ +extern void test__f_utf_tripless_append_all__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_tripless_append_all() + */ +extern void test__f_utf_tripless_append_all__parameter_checking(void **state); + +#endif // _TEST__F_utf_tripless_append_all_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_decimate_by.c b/level_0/f_utf/tests/unit/c/test-utf-tripless_decimate_by.c new file mode 100644 index 0000000..f6d2cc9 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-tripless_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_tripless_decimate_by__works(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_tripless_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_tripless_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_decimate_by.h b/level_0/f_utf/tests/unit/c/test-utf-tripless_decimate_by.h new file mode 100644 index 0000000..cac48d8 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_tripless_decimate_by_h +#define _TEST__F_utf_tripless_decimate_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_tripless_decimate_by() + */ +extern void test__f_utf_tripless_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_tripless_decimate_by() + */ +extern void test__f_utf_tripless_decimate_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_tripless_decimate_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_decrease_by.c b/level_0/f_utf/tests/unit/c/test-utf-tripless_decrease_by.c new file mode 100644 index 0000000..03f3a87 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-utf.h" +#include "test-utf-tripless_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_tripless_decrease_by__works(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_tripless_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_utf_tripless_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_decrease_by.h b/level_0/f_utf/tests/unit/c/test-utf-tripless_decrease_by.h new file mode 100644 index 0000000..8986aa3 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_tripless_decrease_by_h +#define _TEST__F_utf_tripless_decrease_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_tripless_decrease_by() + */ +extern void test__f_utf_tripless_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_tripless_decrease_by() + */ +extern void test__f_utf_tripless_decrease_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_tripless_decrease_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_increase.c b/level_0/f_utf/tests/unit/c/test-utf-tripless_increase.c new file mode 100644 index 0000000..a6ebc34 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_increase.c @@ -0,0 +1,76 @@ +#include "test-utf.h" +#include "test-utf-tripless_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_tripless_increase__works(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_tripless_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +void test__f_utf_tripless_increase__returns_data_not(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_utf_string_tripless_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_tripless_increase__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_increase.h b/level_0/f_utf/tests/unit/c/test-utf-tripless_increase.h new file mode 100644 index 0000000..14cafba --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_tripless_increase_h +#define _TEST__F_utf_tripless_increase_h + +/** + * Test that the function works. + * + * @see f_utf_string_tripless_increase() + */ +extern void test__f_utf_tripless_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_utf_string_tripless_increase() + */ +extern void test__f_utf_tripless_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_tripless_increase() + */ +extern void test__f_utf_tripless_increase__parameter_checking(void **state); + +#endif // _TEST__F_utf_tripless_increase_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_increase_by.c b/level_0/f_utf/tests/unit/c/test-utf-tripless_increase_by.c new file mode 100644 index 0000000..8ccf36a --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_increase_by.c @@ -0,0 +1,52 @@ +#include "test-utf.h" +#include "test-utf-tripless_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_tripless_increase_by__works(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_utf_string_tripless_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_utf_tripless_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_triples_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_increase_by.h b/level_0/f_utf/tests/unit/c/test-utf-tripless_increase_by.h new file mode 100644 index 0000000..135c6c3 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_tripless_increase_by_h +#define _TEST__F_utf_tripless_increase_by_h + +/** + * Test that the function works. + * + * @see f_utf_string_tripless_increase_by() + */ +extern void test__f_utf_tripless_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_tripless_increase_by() + */ +extern void test__f_utf_tripless_increase_by__parameter_checking(void **state); + +#endif // _TEST__F_utf_tripless_increase_by_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_resize.c b/level_0/f_utf/tests/unit/c/test-utf-tripless_resize.c new file mode 100644 index 0000000..17e2e07 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_resize.c @@ -0,0 +1,42 @@ +#include "test-utf.h" +#include "test-utf-tripless_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_tripless_resize__works(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_utf_tripless_resize__parameter_checking(void **state) { + + const int length = 5; + f_utf_string_tripless_t data = f_utf_string_tripless_t_initialize; + + { + const f_status_t status = f_utf_string_tripless_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-tripless_resize.h b/level_0/f_utf/tests/unit/c/test-utf-tripless_resize.h new file mode 100644 index 0000000..c4b08c5 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-tripless_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_utf_tripless_resize_h +#define _TEST__F_utf_tripless_resize_h + +/** + * Test that the function works. + * + * @see f_utf_string_tripless_resize() + */ +extern void test__f_utf_tripless_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_utf_string_tripless_resize() + */ +extern void test__f_utf_tripless_resize__parameter_checking(void **state); + +#endif // _TEST__F_utf_tripless_resize_h diff --git a/level_0/f_utf/tests/unit/c/test-utf.c b/level_0/f_utf/tests/unit/c/test-utf.c new file mode 100644 index 0000000..54ff2fb --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf.c @@ -0,0 +1,358 @@ +#include "test-utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int setup(void **state) { + + return 0; +} + +int setdown(void **state) { + + errno = 0; + + return 0; +} + +int main(void) { + + const struct CMUnitTest tests[] = { + cmocka_unit_test(test__f_utf_append__works), + cmocka_unit_test(test__f_utf_append_assure__works), + cmocka_unit_test(test__f_utf_append_assure_nulless__works), + cmocka_unit_test(test__f_utf_append_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_adjust__works), + + cmocka_unit_test(test__f_utf_dynamic_append__works), + cmocka_unit_test(test__f_utf_dynamic_append_assure__works), + cmocka_unit_test(test__f_utf_dynamic_append_assure_nulless__works), + cmocka_unit_test(test__f_utf_dynamic_append_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_decimate_by__works), + cmocka_unit_test(test__f_utf_dynamic_decrease_by__works), + cmocka_unit_test(test__f_utf_dynamic_increase__works), + cmocka_unit_test(test__f_utf_dynamic_increase__returns_data_not), + cmocka_unit_test(test__f_utf_dynamic_increase_by__works), + + cmocka_unit_test(test__f_utf_dynamic_mash__works), + cmocka_unit_test(test__f_utf_dynamic_mash_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_mish__works), + cmocka_unit_test(test__f_utf_dynamic_mish_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_partial_append__works), + cmocka_unit_test(test__f_utf_dynamic_partial_append_assure__works), + cmocka_unit_test(test__f_utf_dynamic_partial_append_assure_nulless__works), + cmocka_unit_test(test__f_utf_dynamic_partial_append_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_partial_mash__works), + cmocka_unit_test(test__f_utf_dynamic_partial_mash_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_partial_mish__works), + cmocka_unit_test(test__f_utf_dynamic_partial_mish_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_partial_prepend__works), + cmocka_unit_test(test__f_utf_dynamic_partial_prepend_assure__works), + cmocka_unit_test(test__f_utf_dynamic_partial_prepend_assure_nulless__works), + cmocka_unit_test(test__f_utf_dynamic_partial_prepend_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_prepend__works), + cmocka_unit_test(test__f_utf_dynamic_prepend_assure__works), + cmocka_unit_test(test__f_utf_dynamic_prepend_assure_nulless__works), + cmocka_unit_test(test__f_utf_dynamic_prepend_nulless__works), + + cmocka_unit_test(test__f_utf_dynamic_resize__works), + + cmocka_unit_test(test__f_utf_dynamic_seek_line__returns_data_not_stop), + cmocka_unit_test(test__f_utf_dynamic_seek_line__returns_none_eos), + cmocka_unit_test(test__f_utf_dynamic_seek_line__returns_none_stop), + cmocka_unit_test(test__f_utf_dynamic_seek_line__works), + + cmocka_unit_test(test__f_utf_dynamic_seek_line_to__at_newline), + cmocka_unit_test(test__f_utf_dynamic_seek_line_to__returns_data_not_stop), + cmocka_unit_test(test__f_utf_dynamic_seek_line_to__returns_none_eos), + cmocka_unit_test(test__f_utf_dynamic_seek_line_to__returns_none_stop), + cmocka_unit_test(test__f_utf_dynamic_seek_line_to__works), + + cmocka_unit_test(test__f_utf_dynamic_seek_to__returns_data_not_stop), + cmocka_unit_test(test__f_utf_dynamic_seek_to__returns_none_eos), + cmocka_unit_test(test__f_utf_dynamic_seek_to__returns_none_stop), + cmocka_unit_test(test__f_utf_dynamic_seek_to__works), + + cmocka_unit_test(test__f_utf_dynamic_terminate__appends_null), + cmocka_unit_test(test__f_utf_dynamic_terminate__doesnt_append_null), + + cmocka_unit_test(test__f_utf_dynamic_terminate_after__appends_null), + cmocka_unit_test(test__f_utf_dynamic_terminate_after__doesnt_append_null), + + cmocka_unit_test(test__f_utf_dynamics_adjust__works), + cmocka_unit_test(test__f_utf_dynamics_append__works), + cmocka_unit_test(test__f_utf_dynamics_append_all__works), + cmocka_unit_test(test__f_utf_dynamics_append_all__returns_data_not), + cmocka_unit_test(test__f_utf_dynamics_decimate_by__works), + cmocka_unit_test(test__f_utf_dynamics_decrease_by__works), + cmocka_unit_test(test__f_utf_dynamics_increase__works), + cmocka_unit_test(test__f_utf_dynamics_increase__returns_data_not), + cmocka_unit_test(test__f_utf_dynamics_increase_by__works), + cmocka_unit_test(test__f_utf_dynamics_resize__works), + + cmocka_unit_test(test__f_utf_dynamicss_adjust__works), + cmocka_unit_test(test__f_utf_dynamicss_append__works), + cmocka_unit_test(test__f_utf_dynamicss_append__returns_data_not), + cmocka_unit_test(test__f_utf_dynamicss_append_all__works), + cmocka_unit_test(test__f_utf_dynamicss_append_all__returns_data_not), + cmocka_unit_test(test__f_utf_dynamicss_decimate_by__works), + cmocka_unit_test(test__f_utf_dynamicss_decrease_by__works), + cmocka_unit_test(test__f_utf_dynamicss_increase__works), + cmocka_unit_test(test__f_utf_dynamicss_increase__returns_data_not), + cmocka_unit_test(test__f_utf_dynamicss_increase_by__works), + cmocka_unit_test(test__f_utf_dynamicss_resize__works), + + cmocka_unit_test(test__f_utf_map_multis_adjust__works), + cmocka_unit_test(test__f_utf_map_multis_append__works), + cmocka_unit_test(test__f_utf_map_multis_append_all__works), + cmocka_unit_test(test__f_utf_map_multis_append_all__returns_data_not), + cmocka_unit_test(test__f_utf_map_multis_decimate_by__works), + cmocka_unit_test(test__f_utf_map_multis_decrease_by__works), + cmocka_unit_test(test__f_utf_map_multis_increase__works), + cmocka_unit_test(test__f_utf_map_multis_increase__returns_data_not), + cmocka_unit_test(test__f_utf_map_multis_increase_by__works), + cmocka_unit_test(test__f_utf_map_multis_resize__works), + + cmocka_unit_test(test__f_utf_map_multiss_adjust__works), + cmocka_unit_test(test__f_utf_map_multiss_append__works), + cmocka_unit_test(test__f_utf_map_multiss_append__returns_data_not), + cmocka_unit_test(test__f_utf_map_multiss_append_all__works), + cmocka_unit_test(test__f_utf_map_multiss_append_all__returns_data_not), + cmocka_unit_test(test__f_utf_map_multiss_decimate_by__works), + cmocka_unit_test(test__f_utf_map_multiss_decrease_by__works), + cmocka_unit_test(test__f_utf_map_multiss_increase__works), + cmocka_unit_test(test__f_utf_map_multiss_increase__returns_data_not), + cmocka_unit_test(test__f_utf_map_multiss_increase_by__works), + cmocka_unit_test(test__f_utf_map_multiss_resize__works), + + cmocka_unit_test(test__f_utf_maps_adjust__works), + cmocka_unit_test(test__f_utf_maps_append__works), + cmocka_unit_test(test__f_utf_maps_append_all__works), + cmocka_unit_test(test__f_utf_maps_append_all__returns_data_not), + cmocka_unit_test(test__f_utf_maps_decimate_by__works), + cmocka_unit_test(test__f_utf_maps_decrease_by__works), + cmocka_unit_test(test__f_utf_maps_increase__works), + cmocka_unit_test(test__f_utf_maps_increase__returns_data_not), + cmocka_unit_test(test__f_utf_maps_increase_by__works), + cmocka_unit_test(test__f_utf_maps_resize__works), + + cmocka_unit_test(test__f_utf_mapss_adjust__works), + cmocka_unit_test(test__f_utf_mapss_append__works), + cmocka_unit_test(test__f_utf_mapss_append__returns_data_not), + cmocka_unit_test(test__f_utf_mapss_append_all__works), + cmocka_unit_test(test__f_utf_mapss_append_all__returns_data_not), + cmocka_unit_test(test__f_utf_mapss_decimate_by__works), + cmocka_unit_test(test__f_utf_mapss_decrease_by__works), + cmocka_unit_test(test__f_utf_mapss_increase__works), + cmocka_unit_test(test__f_utf_mapss_increase__returns_data_not), + cmocka_unit_test(test__f_utf_mapss_increase_by__works), + cmocka_unit_test(test__f_utf_mapss_resize__works), + + cmocka_unit_test(test__f_utf_mash__works), + cmocka_unit_test(test__f_utf_mash_nulless__works), + + cmocka_unit_test(test__f_utf_mish__works), + cmocka_unit_test(test__f_utf_mish_nulless__works), + + cmocka_unit_test(test__f_utf_prepend__works), + cmocka_unit_test(test__f_utf_prepend_assure__works), + cmocka_unit_test(test__f_utf_prepend_assure_nulless__works), + cmocka_unit_test(test__f_utf_prepend_nulless__works), + + cmocka_unit_test(test__f_utf_triples_adjust__works), + cmocka_unit_test(test__f_utf_triples_append__works), + cmocka_unit_test(test__f_utf_triples_append_all__works), + cmocka_unit_test(test__f_utf_triples_append_all__returns_data_not), + cmocka_unit_test(test__f_utf_triples_decimate_by__works), + cmocka_unit_test(test__f_utf_triples_decrease_by__works), + cmocka_unit_test(test__f_utf_triples_increase__works), + cmocka_unit_test(test__f_utf_triples_increase__returns_data_not), + cmocka_unit_test(test__f_utf_triples_increase_by__works), + cmocka_unit_test(test__f_utf_triples_resize__works), + + cmocka_unit_test(test__f_utf_tripless_adjust__works), + cmocka_unit_test(test__f_utf_tripless_append__works), + cmocka_unit_test(test__f_utf_tripless_append__returns_data_not), + cmocka_unit_test(test__f_utf_tripless_append_all__works), + cmocka_unit_test(test__f_utf_tripless_append_all__returns_data_not), + cmocka_unit_test(test__f_utf_tripless_decimate_by__works), + cmocka_unit_test(test__f_utf_tripless_decrease_by__works), + cmocka_unit_test(test__f_utf_tripless_increase__works), + cmocka_unit_test(test__f_utf_tripless_increase__returns_data_not), + cmocka_unit_test(test__f_utf_tripless_increase_by__works), + cmocka_unit_test(test__f_utf_tripless_resize__works), + + cmocka_unit_test(test__f_utf_seek_line__returns_data_not_stop), + cmocka_unit_test(test__f_utf_seek_line__returns_none_stop), + cmocka_unit_test(test__f_utf_seek_line__works), + + cmocka_unit_test(test__f_utf_seek_line_to__at_newline), + cmocka_unit_test(test__f_utf_seek_line_to__returns_data_not_stop), + cmocka_unit_test(test__f_utf_seek_line_to__returns_none_stop), + cmocka_unit_test(test__f_utf_seek_line_to__works), + + cmocka_unit_test(test__f_utf_seek_to__returns_data_not_stop), + cmocka_unit_test(test__f_utf_seek_to__returns_none_stop), + cmocka_unit_test(test__f_utf_seek_to__works), + + #ifndef _di_level_0_parameter_checking_ + cmocka_unit_test(test__f_utf_append__parameter_checking), + cmocka_unit_test(test__f_utf_append_assure__parameter_checking), + cmocka_unit_test(test__f_utf_append_assure_nulless__parameter_checking), + cmocka_unit_test(test__f_utf_append_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_adjust__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_append__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_append_assure__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_append_assure_nulless__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_append_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_increase__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_increase__returns_data_not), + cmocka_unit_test(test__f_utf_dynamic_increase_by__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_mash__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_mash_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_mish__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_mish_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_partial_append__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_partial_append_assure__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_partial_append_assure_nulless__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_partial_append_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_partial_mash__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_partial_mash_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_partial_mish__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_partial_mish_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_partial_prepend__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_partial_prepend_assure__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_partial_prepend_assure_nulless__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_partial_prepend_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_prepend__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_prepend_assure__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_prepend_assure_nulless__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_prepend_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_seek_line__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_seek_line_to__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_seek_to__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamic_terminate__parameter_checking), + cmocka_unit_test(test__f_utf_dynamic_terminate_after__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamics_adjust__parameter_checking), + cmocka_unit_test(test__f_utf_dynamics_append__parameter_checking), + cmocka_unit_test(test__f_utf_dynamics_append_all__parameter_checking), + cmocka_unit_test(test__f_utf_dynamics_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_dynamics_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_dynamics_increase__parameter_checking), + cmocka_unit_test(test__f_utf_dynamics_increase_by__parameter_checking), + cmocka_unit_test(test__f_utf_dynamics_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_dynamicss_adjust__parameter_checking), + cmocka_unit_test(test__f_utf_dynamicss_append__parameter_checking), + cmocka_unit_test(test__f_utf_dynamicss_append_all__parameter_checking), + cmocka_unit_test(test__f_utf_dynamicss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_dynamicss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_dynamicss_increase__parameter_checking), + cmocka_unit_test(test__f_utf_dynamicss_increase_by__parameter_checking), + cmocka_unit_test(test__f_utf_dynamicss_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_map_multis_adjust__parameter_checking), + cmocka_unit_test(test__f_utf_map_multis_append__parameter_checking), + cmocka_unit_test(test__f_utf_map_multis_append_all__parameter_checking), + cmocka_unit_test(test__f_utf_map_multis_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_map_multis_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_map_multis_increase__parameter_checking), + cmocka_unit_test(test__f_utf_map_multis_increase_by__parameter_checking), + cmocka_unit_test(test__f_utf_map_multis_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_map_multiss_adjust__parameter_checking), + cmocka_unit_test(test__f_utf_map_multiss_append__parameter_checking), + cmocka_unit_test(test__f_utf_map_multiss_append_all__parameter_checking), + cmocka_unit_test(test__f_utf_map_multiss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_map_multiss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_map_multiss_increase__parameter_checking), + cmocka_unit_test(test__f_utf_map_multiss_increase_by__parameter_checking), + cmocka_unit_test(test__f_utf_map_multiss_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_maps_adjust__parameter_checking), + cmocka_unit_test(test__f_utf_maps_append__parameter_checking), + cmocka_unit_test(test__f_utf_maps_append_all__parameter_checking), + cmocka_unit_test(test__f_utf_maps_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_maps_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_maps_increase__parameter_checking), + cmocka_unit_test(test__f_utf_maps_increase_by__parameter_checking), + cmocka_unit_test(test__f_utf_maps_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_mapss_adjust__parameter_checking), + cmocka_unit_test(test__f_utf_mapss_append__parameter_checking), + cmocka_unit_test(test__f_utf_mapss_append_all__parameter_checking), + cmocka_unit_test(test__f_utf_mapss_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_mapss_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_mapss_increase__parameter_checking), + cmocka_unit_test(test__f_utf_mapss_increase_by__parameter_checking), + cmocka_unit_test(test__f_utf_mapss_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_mash__parameter_checking), + cmocka_unit_test(test__f_utf_mash_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_mish__parameter_checking), + cmocka_unit_test(test__f_utf_mish_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_prepend__parameter_checking), + cmocka_unit_test(test__f_utf_prepend_assure__parameter_checking), + cmocka_unit_test(test__f_utf_prepend_assure_nulless__parameter_checking), + cmocka_unit_test(test__f_utf_prepend_nulless__parameter_checking), + + cmocka_unit_test(test__f_utf_triples_adjust__parameter_checking), + cmocka_unit_test(test__f_utf_triples_append__parameter_checking), + cmocka_unit_test(test__f_utf_triples_append_all__parameter_checking), + cmocka_unit_test(test__f_utf_triples_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_triples_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_triples_increase__parameter_checking), + cmocka_unit_test(test__f_utf_triples_increase_by__parameter_checking), + cmocka_unit_test(test__f_utf_triples_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_tripless_adjust__parameter_checking), + cmocka_unit_test(test__f_utf_tripless_append__parameter_checking), + cmocka_unit_test(test__f_utf_tripless_append_all__parameter_checking), + cmocka_unit_test(test__f_utf_tripless_decimate_by__parameter_checking), + cmocka_unit_test(test__f_utf_tripless_decrease_by__parameter_checking), + cmocka_unit_test(test__f_utf_tripless_increase__parameter_checking), + cmocka_unit_test(test__f_utf_tripless_increase_by__parameter_checking), + cmocka_unit_test(test__f_utf_tripless_resize__parameter_checking), + + cmocka_unit_test(test__f_utf_seek_line__parameter_checking), + + cmocka_unit_test(test__f_utf_seek_line_to__parameter_checking), + + cmocka_unit_test(test__f_utf_seek_to__parameter_checking), + #endif // _di_level_0_parameter_checking_ + }; + + return cmocka_run_group_tests(tests, setup, setdown); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf.h b/level_0/f_utf/tests/unit/c/test-utf.h new file mode 100644 index 0000000..750c5d7 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf.h @@ -0,0 +1,185 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the string project. + */ +#ifndef _TEST__F_utf_h +#define _TEST__F_utf_h + +// Libc includes. +#include +#include +#include +#include + +// cmocka includes. +#include + +// FLL-0 includes. +#include + +// Mock includes. +//#include "mock-string.h" + +// Test includes. +#include "test-utf-append.h" +#include "test-utf-append_assure.h" +#include "test-utf-append_assure_nulless.h" +#include "test-utf-append_nulless.h" +#include "test-utf-dynamic_adjust.h" +#include "test-utf-dynamic_append.h" +#include "test-utf-dynamic_append_assure.h" +#include "test-utf-dynamic_append_assure_nulless.h" +#include "test-utf-dynamic_append_nulless.h" +#include "test-utf-dynamic_decimate_by.h" +#include "test-utf-dynamic_decrease_by.h" +#include "test-utf-dynamic_increase.h" +#include "test-utf-dynamic_increase_by.h" +#include "test-utf-dynamic_mash.h" +#include "test-utf-dynamic_mash_nulless.h" +#include "test-utf-dynamic_mish.h" +#include "test-utf-dynamic_mish_nulless.h" +#include "test-utf-dynamic_partial_append.h" +#include "test-utf-dynamic_partial_append_assure.h" +#include "test-utf-dynamic_partial_append_assure_nulless.h" +#include "test-utf-dynamic_partial_append_nulless.h" +#include "test-utf-dynamic_partial_mash.h" +#include "test-utf-dynamic_partial_mash_nulless.h" +#include "test-utf-dynamic_partial_mish.h" +#include "test-utf-dynamic_partial_mish_nulless.h" +#include "test-utf-dynamic_partial_prepend.h" +#include "test-utf-dynamic_partial_prepend_assure.h" +#include "test-utf-dynamic_partial_prepend_assure_nulless.h" +#include "test-utf-dynamic_partial_prepend_nulless.h" +#include "test-utf-dynamic_prepend.h" +#include "test-utf-dynamic_prepend_assure.h" +#include "test-utf-dynamic_prepend_assure_nulless.h" +#include "test-utf-dynamic_prepend_nulless.h" +#include "test-utf-dynamic_resize.h" +#include "test-utf-dynamic_seek_line.h" +#include "test-utf-dynamic_seek_line_to.h" +#include "test-utf-dynamic_seek_to.h" +#include "test-utf-dynamic_terminate.h" +#include "test-utf-dynamic_terminate_after.h" +#include "test-utf-dynamics_adjust.h" +#include "test-utf-dynamics_append.h" +#include "test-utf-dynamics_append_all.h" +#include "test-utf-dynamics_decimate_by.h" +#include "test-utf-dynamics_decrease_by.h" +#include "test-utf-dynamics_increase.h" +#include "test-utf-dynamics_increase_by.h" +#include "test-utf-dynamics_resize.h" +#include "test-utf-dynamicss_adjust.h" +#include "test-utf-dynamicss_append.h" +#include "test-utf-dynamicss_append_all.h" +#include "test-utf-dynamicss_decimate_by.h" +#include "test-utf-dynamicss_decrease_by.h" +#include "test-utf-dynamicss_increase.h" +#include "test-utf-dynamicss_increase_by.h" +#include "test-utf-dynamicss_resize.h" +#include "test-utf-map_multis_adjust.h" +#include "test-utf-map_multis_append.h" +#include "test-utf-map_multis_append_all.h" +#include "test-utf-map_multis_decimate_by.h" +#include "test-utf-map_multis_decrease_by.h" +#include "test-utf-map_multis_increase.h" +#include "test-utf-map_multis_increase_by.h" +#include "test-utf-map_multis_resize.h" +#include "test-utf-map_multiss_adjust.h" +#include "test-utf-map_multiss_append.h" +#include "test-utf-map_multiss_append_all.h" +#include "test-utf-map_multiss_decimate_by.h" +#include "test-utf-map_multiss_decrease_by.h" +#include "test-utf-map_multiss_increase.h" +#include "test-utf-map_multiss_increase_by.h" +#include "test-utf-map_multiss_resize.h" +#include "test-utf-maps_adjust.h" +#include "test-utf-maps_append.h" +#include "test-utf-maps_append_all.h" +#include "test-utf-maps_decimate_by.h" +#include "test-utf-maps_decrease_by.h" +#include "test-utf-maps_increase.h" +#include "test-utf-maps_increase_by.h" +#include "test-utf-maps_resize.h" +#include "test-utf-mapss_adjust.h" +#include "test-utf-mapss_append.h" +#include "test-utf-mapss_append_all.h" +#include "test-utf-mapss_decimate_by.h" +#include "test-utf-mapss_decrease_by.h" +#include "test-utf-mapss_increase.h" +#include "test-utf-mapss_increase_by.h" +#include "test-utf-mapss_resize.h" +#include "test-utf-mash.h" +#include "test-utf-mash_nulless.h" +#include "test-utf-mish.h" +#include "test-utf-mish_nulless.h" +#include "test-utf-prepend.h" +#include "test-utf-prepend_assure.h" +#include "test-utf-prepend_assure_nulless.h" +#include "test-utf-prepend_nulless.h" +#include "test-utf-seek_line.h" +#include "test-utf-seek_line_to.h" +#include "test-utf-seek_to.h" +#include "test-utf-triples_adjust.h" +#include "test-utf-triples_append.h" +#include "test-utf-triples_append_all.h" +#include "test-utf-triples_decimate_by.h" +#include "test-utf-triples_decrease_by.h" +#include "test-utf-triples_increase.h" +#include "test-utf-triples_increase_by.h" +#include "test-utf-triples_resize.h" +#include "test-utf-tripless_adjust.h" +#include "test-utf-tripless_append.h" +#include "test-utf-tripless_append_all.h" +#include "test-utf-tripless_decimate_by.h" +#include "test-utf-tripless_decrease_by.h" +#include "test-utf-tripless_increase.h" +#include "test-utf-tripless_increase_by.h" +#include "test-utf-tripless_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Perform any setup operations. + * + * @param state + * The test state. + * + * @return + * The status of this function, where 0 means success. + */ +extern int setup(void **state); + +/** + * Peform any setdown operations. + * + * @param state + * The test state. + * + * @return + * The status of this function, where 0 means success. + */ +extern int setdown(void **state); + +/** + * Run all tests. + * + * @return + * The final result of the tests. + * + * @see cmocka_run_group_tests() + * @see cmocka_unit_test() + */ +extern int main(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _TEST__F_utf_h -- 1.8.3.1