From b2e69c1f0ad28593f550f557928802bcafe78b58 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 5 Mar 2024 21:57:35 -0600 Subject: [PATCH] Progress: Add dynamic, dynamics, and map unit tests for fl_fss_payload_header_map() and fix several problems. Switch character width loops with memcpy(). Add cases where trailing string should be removed. Make sure private_fl_fss_basic_write() is only called when the cache is not empty. Make sue the internal.range is properly set when calling private_fl_fss_basic_write(). Ensure that when any quote is used that they get quoted where appropriate. Ensure that when key has used of 0, the start range is greater than the stop range to designate a NULL range. Add dynamic, dynamics, and map unit tests. Make the tests test the string first rather than the used so that when there is an error it is easier to debug. Remove unused/stale commented out code. Switch fss_write flag from 16-bit into 32-bit. This is necessary because more bits than 16 are in use. --- level_1/fl_fss/c/fss/basic_list.c | 14 ++--- level_1/fl_fss/c/fss/embedded_list.c | 14 ++--- level_1/fl_fss/c/fss/extended_list.c | 20 +++---- level_1/fl_fss/c/fss/payload.c | 2 +- level_1/fl_fss/c/fss/private-payload.c | 67 ++++++++++++++++------ level_1/fl_fss/c/private-fss.c | 47 ++++++++++----- level_1/fl_fss/data/build/settings-tests | 3 + .../headers/payload-join-abstruse_dynamic-0.txt | 6 ++ .../headers/payload-join-abstruse_dynamic-1.txt | 5 ++ .../headers/payload-join-abstruse_dynamic-2.txt | 4 ++ .../headers/payload-join-abstruse_dynamics-0.txt | 3 + .../headers/payload-join-abstruse_dynamics-1.txt | 3 + .../headers/payload-join-abstruse_dynamics-2.txt | 3 + .../tests/headers/payload-join-abstruse_map-0.txt | 3 + .../tests/headers/payload-join-abstruse_map-1.txt | 3 + .../tests/headers/payload-join-abstruse_map-2.txt | 3 + .../tests/headers/payload-join-abstruse_map-3.txt | 3 + .../tests/headers/payload-join-abstruse_map-4.txt | 3 + .../tests/headers/payload-join-abstruse_map-5.txt | 3 + .../tests/headers/payload-join-abstruse_map-6.txt | 3 + .../headers/payload-split-abstruse_dynamics-0.txt | 3 + .../headers/payload-split-abstruse_dynamics-1.txt | 3 + .../headers/payload-split-abstruse_dynamics-2.txt | 3 + .../tests/headers/payload-split-abstruse_map-0.txt | 3 + .../tests/headers/payload-split-abstruse_map-1.txt | 3 + .../tests/headers/payload-split-abstruse_map-2.txt | 3 + .../tests/headers/payload-split-abstruse_map-3.txt | 3 + .../tests/headers/payload-split-abstruse_map-4.txt | 3 + .../tests/headers/payload-split-abstruse_map-5.txt | 3 + .../tests/headers/payload-split-abstruse_map-6.txt | 3 + .../tests/variables/payload-abstruse_dynamic.txt | 15 +++++ .../tests/variables/payload-abstruse_dynamics.txt | 16 ++++++ .../data/tests/variables/payload-abstruse_map.txt | 28 +++++++++ level_1/fl_fss/tests/unit/c/help-fss-payload.c | 6 +- ...-fss-payload_header_map-abstruse_dynamic-join.c | 31 ++++++++++ ...-fss-payload_header_map-abstruse_dynamic-join.h | 37 ++++++++++++ ...fss-payload_header_map-abstruse_dynamics-join.c | 39 +++++++++++++ ...fss-payload_header_map-abstruse_dynamics-join.h | 37 ++++++++++++ ...ss-payload_header_map-abstruse_dynamics-split.c | 39 +++++++++++++ ...ss-payload_header_map-abstruse_dynamics-split.h | 37 ++++++++++++ ...test-fss-payload_header_map-abstruse_map-join.c | 37 ++++++++++++ ...test-fss-payload_header_map-abstruse_map-join.h | 37 ++++++++++++ ...est-fss-payload_header_map-abstruse_map-split.c | 37 ++++++++++++ ...est-fss-payload_header_map-abstruse_map-split.h | 37 ++++++++++++ ...-fss-payload_header_map-abstruse_strings-join.c | 2 - ...fss-payload_header_map-abstruse_strings-split.c | 2 - level_1/fl_fss/tests/unit/c/test-fss.c | 5 ++ level_1/fl_fss/tests/unit/c/test-fss.h | 5 ++ level_3/fss_write/c/main/common/type.h | 2 +- 49 files changed, 626 insertions(+), 65 deletions(-) create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-3.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-4.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-5.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-6.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-3.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-4.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-5.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-6.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-abstruse_dynamic.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-abstruse_dynamics.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-abstruse_map.txt create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamic-join.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamic-join.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-join.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-join.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-split.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-split.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-join.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-join.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-split.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-split.h diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index b818035..24b00fc 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -915,8 +915,6 @@ extern "C" { } const f_number_unsigned_t destination_used = destination->used; - - f_number_unsigned_t i = 0; f_number_unsigned_t slash_count = 0; uint8_t width = 0; @@ -970,9 +968,9 @@ extern "C" { state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } } @@ -1039,9 +1037,9 @@ extern "C" { state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } state->status = f_utf_buffer_increment(object, range, 1); diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index 0f21132..34b20e8 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -1492,8 +1492,6 @@ extern "C" { if (F_status_is_error(state->status)) return; const f_number_unsigned_t destination_used = destination->used; - - f_number_unsigned_t i = 0; f_number_unsigned_t slash_count = 0; bool ends_on_space = F_false; @@ -1549,9 +1547,9 @@ extern "C" { state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } } @@ -1638,9 +1636,9 @@ extern "C" { state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } state->status = f_utf_buffer_increment(object, range, 1); diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 1777a8e..3c0e393 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -284,7 +284,6 @@ extern "C" { bool has_graph = F_false; bool do_prepend = prepend ? F_true : F_false; - f_number_unsigned_t i = 0; f_number_unsigned_t r = 0; f_number_unsigned_t slash_count = 0; f_number_unsigned_t start = 0; @@ -490,9 +489,9 @@ extern "C" { state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = content.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, content.string + range->start, width); + + destination->used += width; } state->status = f_utf_buffer_increment(content, range, 1); @@ -947,7 +946,6 @@ extern "C" { const f_number_unsigned_t destination_used = destination->used; - f_number_unsigned_t i = 0; f_number_unsigned_t slash_count = 0; bool ends_on_space = F_false; @@ -1003,9 +1001,9 @@ extern "C" { state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } } @@ -1092,9 +1090,9 @@ extern "C" { state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } state->status = f_utf_buffer_increment(object, range, 1); diff --git a/level_1/fl_fss/c/fss/payload.c b/level_1/fl_fss/c/fss/payload.c index 995b0be..0114562 100644 --- a/level_1/fl_fss/c/fss/payload.c +++ b/level_1/fl_fss/c/fss/payload.c @@ -81,7 +81,7 @@ extern "C" { destinations->array[destinations->used].key.used = 0; destinations->array[destinations->used].value.used = 0; - internal.range.start = 0; + internal.range.start = headers.array[internal.i].key.used ? 0 : 1; internal.range.stop = headers.array[internal.i].key.used ? headers.array[internal.i].key.used - 1 : 0; private_fl_fss_basic_write(F_true, headers.array[internal.i].key, internal.quote, &internal.range, &destinations->array[destinations->used].key, state, (void * const) &internal); diff --git a/level_1/fl_fss/c/fss/private-payload.c b/level_1/fl_fss/c/fss/private-payload.c index d29e84f..ba71dd8 100644 --- a/level_1/fl_fss/c/fss/private-payload.c +++ b/level_1/fl_fss/c/fss/private-payload.c @@ -73,6 +73,11 @@ extern "C" { } } } + else if (destinations->array[destinations->used].value.used) { + + // Remove the always added trailing extended next. + destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + } } else { if (data->flag & f_fss_payload_header_map_flag_null_dynamic_e) { @@ -135,8 +140,13 @@ extern "C" { data->cache->used -= f_fss_space_s.used; } - private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; + if (data->cache->used) { + internal->range.start = 0; + internal->range.stop = data->cache->used - 1; + + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } } else { if (map->key.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { @@ -266,8 +276,13 @@ extern "C" { data->cache->used -= f_fss_space_s.used; } - private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; + if (data->cache->used) { + internal->range.start = 0; + internal->range.stop = data->cache->used - 1; + + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } } else { if (map->key.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e)) { @@ -434,8 +449,13 @@ extern "C" { data->cache->used -= f_fss_space_s.used; } - private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; + if (data->cache->used) { + internal->range.start = 0; + internal->range.stop = data->cache->used - 1; + + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } } else if (data->flag & f_fss_payload_header_map_flag_join_map_multi_e) { data->cache->used = 0; @@ -500,11 +520,16 @@ extern "C" { data->cache->used -= f_fss_space_s.used; } - private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; + if (data->cache->used) { + internal->range.start = 0; + internal->range.stop = data->cache->used - 1; - state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } } // for // Remove the always added trailing space. @@ -703,8 +728,13 @@ extern "C" { data->cache->used -= f_fss_space_s.used; } - private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; + if (data->cache->used) { + internal->range.start = 0; + internal->range.stop = data->cache->used - 1; + + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } } else if (data->flag & f_fss_payload_header_map_flag_join_map_e) { data->cache->used = 0; @@ -754,11 +784,16 @@ extern "C" { data->cache->used -= f_fss_space_s.used; } - private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; + if (data->cache->used) { + internal->range.start = 0; + internal->range.stop = data->cache->used - 1; - state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } } // for // Remove the always added trailing space. diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 841bc0a..d7b7b2e 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -936,9 +936,9 @@ extern "C" { destination->string[destination->used++] = quote_char; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } else if ((flag & 0x1) && object.string[range->start] == f_fss_comment_s.string[0]) { @@ -984,9 +984,9 @@ extern "C" { destination->string[destination->used++] = f_fss_slash_s.string[0]; } // for - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } } else if (object.string[range->start] == quote_char) { @@ -996,7 +996,6 @@ extern "C" { if (F_status_is_error(state->status)) return; if (range->start > range->stop || range->start >= object.used) { - state->status = f_memory_array_increase(state->step_large, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; @@ -1041,9 +1040,9 @@ extern "C" { destination->string[destination->used++] = quote_char; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } else if (object.string[range->start] == f_fss_eol_s.string[0]) { state->status = F_status_set_error(F_okay_eol); @@ -1052,6 +1051,28 @@ extern "C" { } else if (object.string[range->start] != f_fss_placeholder_s.string[0]) { if (!quoted_is) { + if (object.string[range->start] == f_string_ascii_quote_double_s.string[0] || object.string[range->start] == f_string_ascii_quote_single_s.string[0] || object.string[range->start] == f_string_ascii_grave_s.string[0]) { + item_first = range->start++; + + f_fss_skip_past_delimit(object, range, state); + if (F_status_is_error(state->status)) return; + + if (range->start > range->stop || range->start >= object.used) { + quoted_is = F_true; + } + else if (object.string[range->start] == object.string[item_first]) { + quoted_is = F_true; + } + else if (f_fss_is_space(object, *range, state) == F_true) { + quoted_is = F_true; + } + else if (F_status_is_error(state->status)) { + break; + } + + range->start = item_first; + } + if (f_fss_is_space(object, *range, state) == F_false) { if (F_status_is_error(state->status)) break; } @@ -1065,9 +1086,9 @@ extern "C" { state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; - for (i = 0; i < width; ++i) { - destination->string[destination->used++] = object.string[range->start + i]; - } // for + memcpy(destination->string + destination->used, object.string + range->start, width); + + destination->used += width; } state->status = f_utf_buffer_increment(object, range, 1); diff --git a/level_1/fl_fss/data/build/settings-tests b/level_1/fl_fss/data/build/settings-tests index 096964d..af11560 100644 --- a/level_1/fl_fss/data/build/settings-tests +++ b/level_1/fl_fss/data/build/settings-tests @@ -31,6 +31,8 @@ build_sources_program test-fss-embedded_list_content_read.c test-fss-embedded_li build_sources_program test-fss-extended_content_read.c test-fss-extended_content_write.c test-fss-extended_object_read.c test-fss-extended_object_write.c build_sources_program test-fss-extended_list_content_read.c test-fss-extended_list_content_write.c test-fss-extended_list_object_read.c test-fss-extended_list_object_write.c build_sources_program test-fss-payload_header_map.c +build_sources_program test-fss-payload_header_map-abstruse_dynamic-join.c +build_sources_program test-fss-payload_header_map-abstruse_dynamics-join.c test-fss-payload_header_map-abstruse_dynamics-split.c build_sources_program test-fss-payload_header_map-abstruse_int8s-join.c test-fss-payload_header_map-abstruse_uint8s-join.c build_sources_program test-fss-payload_header_map-abstruse_int8s-split.c test-fss-payload_header_map-abstruse_uint8s-split.c build_sources_program test-fss-payload_header_map-abstruse_int16s-join.c test-fss-payload_header_map-abstruse_uint16s-join.c @@ -39,6 +41,7 @@ build_sources_program test-fss-payload_header_map-abstruse_int32s-join.c test-fs build_sources_program test-fss-payload_header_map-abstruse_int32s-split.c test-fss-payload_header_map-abstruse_uint32s-split.c build_sources_program test-fss-payload_header_map-abstruse_int64s-join.c test-fss-payload_header_map-abstruse_uint64s-join.c build_sources_program test-fss-payload_header_map-abstruse_int64s-split.c test-fss-payload_header_map-abstruse_uint64s-split.c +build_sources_program test-fss-payload_header_map-abstruse_map-join.c test-fss-payload_header_map-abstruse_map-split.c build_sources_program test-fss-payload_header_map-abstruse_signed-join.c test-fss-payload_header_map-abstruse_unsigned-join.c build_sources_program test-fss-payload_header_map-abstruse_signeds-join.c test-fss-payload_header_map-abstruse_unsigneds-join.c build_sources_program test-fss-payload_header_map-abstruse_signeds-split.c test-fss-payload_header_map-abstruse_unsigneds-split.c diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-0.txt new file mode 100644 index 0000000..7b06942 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +hello +"some thing" +3全#$⸙ diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-1.txt new file mode 100644 index 0000000..50e859f --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-1.txt @@ -0,0 +1,5 @@ +b +3 +全 +⸙ +"␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-2.txt new file mode 100644 index 0000000..41f6980 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamic-2.txt @@ -0,0 +1,4 @@ +c +2 +� +""a b \" c" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-0.txt new file mode 100644 index 0000000..2547b5e --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-0.txt @@ -0,0 +1,3 @@ +a +1 +"0 hello some thing 3全#$⸙ """ diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-1.txt new file mode 100644 index 0000000..1cee3a3 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-1.txt @@ -0,0 +1,3 @@ +b +1 +"全 ⸙ ␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-2.txt new file mode 100644 index 0000000..f53932f --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_dynamics-2.txt @@ -0,0 +1,3 @@ +c +1 +"� "a b \" c" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-0.txt new file mode 100644 index 0000000..003eb20 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-0.txt @@ -0,0 +1,3 @@ +a-0 +1 +"0 hello" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-1.txt new file mode 100644 index 0000000..3f9d8f4 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-1.txt @@ -0,0 +1,3 @@ +a-1 +1 +"some thing 3全#$⸙" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-2.txt new file mode 100644 index 0000000..26bcdbd --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-2.txt @@ -0,0 +1,3 @@ +a-2 +1 +""\" ''" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-3.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-3.txt new file mode 100644 index 0000000..cdc6a2d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-3.txt @@ -0,0 +1,3 @@ +b-0 +1 +"全 ⸙" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-4.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-4.txt new file mode 100644 index 0000000..babfa63 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-4.txt @@ -0,0 +1,3 @@ +b-1 +1 +"␂␂␂ ␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-5.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-5.txt new file mode 100644 index 0000000..576b709 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-5.txt @@ -0,0 +1,3 @@ +b-2 +1 +"' '" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-6.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-6.txt new file mode 100644 index 0000000..e9d783e --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_map-6.txt @@ -0,0 +1,3 @@ +c-0 +1 +"� "a b \" c" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-0.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-0.txt new file mode 100644 index 0000000..3cdfa1f --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-0.txt @@ -0,0 +1,3 @@ +a +1 +0 hello "some thing" 3全#$⸙ """" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-1.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-1.txt new file mode 100644 index 0000000..044ed3e --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-1.txt @@ -0,0 +1,3 @@ +b +1 +全 ⸙ "␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-2.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-2.txt new file mode 100644 index 0000000..64fa96d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_dynamics-2.txt @@ -0,0 +1,3 @@ +c +1 +� ""a b \" c" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-0.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-0.txt new file mode 100644 index 0000000..3a0f995 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-0.txt @@ -0,0 +1,3 @@ +a-0 +1 +0 hello diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-1.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-1.txt new file mode 100644 index 0000000..2490950 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-1.txt @@ -0,0 +1,3 @@ +a-1 +1 +"some thing" 3全#$⸙ diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-2.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-2.txt new file mode 100644 index 0000000..7e91d24 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-2.txt @@ -0,0 +1,3 @@ +a-2 +1 +"""" "''" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-3.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-3.txt new file mode 100644 index 0000000..6a55e8c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-3.txt @@ -0,0 +1,3 @@ +b-0 +1 +全 ⸙ diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-4.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-4.txt new file mode 100644 index 0000000..2df9bf9 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-4.txt @@ -0,0 +1,3 @@ +b-1 +1 +␂␂␂ "␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-5.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-5.txt new file mode 100644 index 0000000..7f046f2 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-5.txt @@ -0,0 +1,3 @@ +b-2 +1 +"'" "'" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-6.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-6.txt new file mode 100644 index 0000000..946471d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_map-6.txt @@ -0,0 +1,3 @@ +c-0 +1 +� ""a b \" c" diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_dynamic.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_dynamic.txt new file mode 100644 index 0000000..d64b7e9 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_dynamic.txt @@ -0,0 +1,15 @@ +a +4 +0 +hello +some thing +3全#$⸙ +b +3 +全 +⸙ +␀ ␀ ␀ ␀ ␀ ␀ +c +2 +� +"a b " c diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_dynamics.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_dynamics.txt new file mode 100644 index 0000000..f4cdddb --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_dynamics.txt @@ -0,0 +1,16 @@ +a +5 +0 +hello +some thing +3全#$⸙ +"" +b +3 +全 +⸙ +␀ ␀ ␀ ␀ ␀ ␀ +c +2 +� +"a b " c diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_map.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_map.txt new file mode 100644 index 0000000..f3bf3e3 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_map.txt @@ -0,0 +1,28 @@ +a-0 +2 +0 +hello +a-1 +2 +some thing +3全#$⸙ +a-2 +2 +"" +'' +b-0 +2 +全 +⸙ +b-1 +2 +␂␂␂ +␀ ␀ ␀ ␀ ␀ ␀ +b-2 +2 +' +' +c-0 +2 +� +"a b " c diff --git a/level_1/fl_fss/tests/unit/c/help-fss-payload.c b/level_1/fl_fss/tests/unit/c/help-fss-payload.c index d99f675..65f9cb1 100644 --- a/level_1/fl_fss/tests/unit/c/help-fss-payload.c +++ b/level_1/fl_fss/tests/unit/c/help-fss-payload.c @@ -67,11 +67,11 @@ void help_payload__test(const f_string_t context_variables, const f_string_t con for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { - assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); - assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); - assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); } // for if (object.string) free(object.string); diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamic-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamic-join.c new file mode 100644 index 0000000..78763f1 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamic-join.c @@ -0,0 +1,31 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_dynamic__works_join(void **void_state) { + + help_payload__test("abstruse_dynamic", "join-abstruse_dynamic", 0, test__fl_fss_payload_header_map__abstruse_dynamic__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_dynamic__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) { + + for (f_number_unsigned_t i = 0; i < contents.used; ++i, ++headers->used) { + + headers->array[headers->used].key.used = 0; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + headers->array[headers->used].value.type = f_abstruse_dynamic_e; + headers->array[headers->used].value.is.a_dynamic.used = 0; + + state->status = f_string_dynamic_append(contents.array[i], &headers->array[headers->used].value.is.a_dynamic); + assert_int_equal(state->status, F_okay); + } // for +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamic-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamic-join.h new file mode 100644 index 0000000..f506569 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamic-join.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_dynamic_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_dynamic_join_h + +/** + * Test that the function works for abstruse_dynamic type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_dynamic__works_join(void **state); + +/** + * Callback to load the contents for the test. + * + * @param object + * The object parameter. + * @param contents + * The contents parameter. + * @param headers + * The headers parameter. +* @param state + * The state parameter. + * @param extra + * (optional) The extra parameter. + * Set to NULL to not use. + */ +extern void test__fl_fss_payload_header_map__abstruse_dynamic__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_dynamic_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-join.c new file mode 100644 index 0000000..41e7a22 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-join.c @@ -0,0 +1,39 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_dynamics__works_join(void **void_state) { + + help_payload__test("abstruse_dynamics", "join-abstruse_dynamics", f_fss_payload_header_map_flag_join_dynamics_e, test__fl_fss_payload_header_map__abstruse_dynamics__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_dynamics__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) { + + headers->array[0].value.type = f_abstruse_dynamics_e; + headers->array[0].value.is.a_dynamics.used = 0; + headers->array[0].key.used = 0; + + f_string_dynamics_t * const dynamics = &headers->array[0].value.is.a_dynamics; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + state->status = f_memory_array_increase_by(contents.used, sizeof(f_string_dynamic_t), (void **) &dynamics->array, &dynamics->used, &dynamics->size); + assert_int_equal(state->status, F_okay); + + for (f_number_unsigned_t i = 0; i < contents.used; ++i) { + + dynamics->array[i].used = 0; + + state->status = f_string_dynamic_append(contents.array[i], &dynamics->array[i]); + assert_int_equal(state->status, F_okay); + } // for + + dynamics->used = contents.used; +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-join.h new file mode 100644 index 0000000..6207321 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-join.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_dynamics_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_dynamics_join_h + +/** + * Test that the function works for abstruse_dynamics type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_dynamics__works_join(void **state); + +/** + * Callback to load the contents for the test. + * + * @param object + * The object parameter. + * @param contents + * The contents parameter. + * @param headers + * The headers parameter. +* @param state + * The state parameter. + * @param extra + * (optional) The extra parameter. + * Set to NULL to not use. + */ +extern void test__fl_fss_payload_header_map__abstruse_dynamics__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_dynamics_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-split.c new file mode 100644 index 0000000..7007ed1 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-split.c @@ -0,0 +1,39 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_dynamics__works_split(void **void_state) { + + help_payload__test("abstruse_dynamics", "split-abstruse_dynamics", 0, test__fl_fss_payload_header_map__abstruse_dynamics__split_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_dynamics__split_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) { + + headers->array[0].value.type = f_abstruse_dynamics_e; + headers->array[0].value.is.a_dynamics.used = 0; + headers->array[0].key.used = 0; + + f_string_dynamics_t * const dynamics = &headers->array[0].value.is.a_dynamics; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + state->status = f_memory_array_increase_by(contents.used, sizeof(f_string_dynamic_t), (void **) &dynamics->array, &dynamics->used, &dynamics->size); + assert_int_equal(state->status, F_okay); + + for (f_number_unsigned_t i = 0; i < contents.used; ++i) { + + dynamics->array[i].used = 0; + + state->status = f_string_dynamic_append(contents.array[i], &dynamics->array[i]); + assert_int_equal(state->status, F_okay); + } // for + + dynamics->used = contents.used; +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-split.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-split.h new file mode 100644 index 0000000..6f3b913 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_dynamics-split.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_dynamics_split_h +#define _TEST__FL_fss_payload_header_map__abstruse_dynamics_split_h + +/** + * Test that the function works for abstruse_dynamics type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_dynamics__works_split(void **state); + +/** + * Callback to load the contents for the test. + * + * @param object + * The object parameter. + * @param contents + * The contents parameter. + * @param headers + * The headers parameter. +* @param state + * The state parameter. + * @param extra + * (optional) The extra parameter. + * Set to NULL to not use. + */ +extern void test__fl_fss_payload_header_map__abstruse_dynamics__split_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_dynamics_split_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-join.c new file mode 100644 index 0000000..cfab941 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-join.c @@ -0,0 +1,37 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_map__works_join(void **void_state) { + + help_payload__test("abstruse_map", "join-abstruse_map", f_fss_payload_header_map_flag_join_map_e, test__fl_fss_payload_header_map__abstruse_map__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_map__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) { + + headers->array[0].value.type = f_abstruse_map_e; + headers->array[0].value.is.a_map.key.used = 0; + headers->array[0].value.is.a_map.value.used = 0; + headers->array[0].key.used = 0; + + f_string_map_t * const map = &headers->array[0].value.is.a_map; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + if (contents.used) { + state->status = f_string_dynamic_append(contents.array[0], &map->key); + assert_int_equal(state->status, F_okay); + + if (contents.used > 1) { + state->status = f_string_dynamic_append(contents.array[1], &map->value); + assert_int_equal(state->status, F_okay); + } + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-join.h new file mode 100644 index 0000000..3638088 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-join.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_map_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_map_join_h + +/** + * Test that the function works for abstruse_map type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_map__works_join(void **state); + +/** + * Callback to load the contents for the test. + * + * @param object + * The object parameter. + * @param contents + * The contents parameter. + * @param headers + * The headers parameter. +* @param state + * The state parameter. + * @param extra + * (optional) The extra parameter. + * Set to NULL to not use. + */ +extern void test__fl_fss_payload_header_map__abstruse_map__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_map_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-split.c new file mode 100644 index 0000000..a03bfb9 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-split.c @@ -0,0 +1,37 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_map__works_split(void **void_state) { + + help_payload__test("abstruse_map", "split-abstruse_map", 0, test__fl_fss_payload_header_map__abstruse_map__split_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_map__split_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) { + + headers->array[0].value.type = f_abstruse_map_e; + headers->array[0].value.is.a_map.key.used = 0; + headers->array[0].value.is.a_map.value.used = 0; + headers->array[0].key.used = 0; + + f_string_map_t * const map = &headers->array[0].value.is.a_map; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + if (contents.used) { + state->status = f_string_dynamic_append(contents.array[0], &map->key); + assert_int_equal(state->status, F_okay); + + if (contents.used > 1) { + state->status = f_string_dynamic_append(contents.array[1], &map->value); + assert_int_equal(state->status, F_okay); + } + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-split.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-split.h new file mode 100644 index 0000000..9288e06 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_map-split.h @@ -0,0 +1,37 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_map_split_h +#define _TEST__FL_fss_payload_header_map__abstruse_map_split_h + +/** + * Test that the function works for abstruse_map type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_map__works_split(void **state); + +/** + * Callback to load the contents for the test. + * + * @param object + * The object parameter. + * @param contents + * The contents parameter. + * @param headers + * The headers parameter. +* @param state + * The state parameter. + * @param extra + * (optional) The extra parameter. + * Set to NULL to not use. + */ +extern void test__fl_fss_payload_header_map__abstruse_map__split_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_map_split_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_strings-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_strings-join.c index 07c3ed3..df1c3e5 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_strings-join.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_strings-join.c @@ -19,8 +19,6 @@ void test__fl_fss_payload_header_map__abstruse_strings__join_load_contents(const if (*strings) free(*strings); - //headers->array[0].value.is.a_strings = calloc(contents.used + 1, sizeof(f_string_t *)); - //assert_int_not_equal(headers->array[0].value.is.a_strings, 0); *strings = calloc(contents.used + 1, sizeof(f_string_t *)); assert_int_not_equal(*strings, 0); diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_strings-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_strings-split.c index 1c6d91c..7d01747 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_strings-split.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_strings-split.c @@ -19,8 +19,6 @@ void test__fl_fss_payload_header_map__abstruse_strings__split_load_contents(cons if (*strings) free(*strings); - //headers->array[0].value.is.a_strings = calloc(contents.used + 1, sizeof(f_string_t *)); - //assert_int_not_equal(headers->array[0].value.is.a_strings, 0); *strings = calloc(contents.used + 1, sizeof(f_string_t *)); assert_int_not_equal(*strings, 0); diff --git a/level_1/fl_fss/tests/unit/c/test-fss.c b/level_1/fl_fss/tests/unit/c/test-fss.c index 703e254..5e3934f 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss.c +++ b/level_1/fl_fss/tests/unit/c/test-fss.c @@ -60,6 +60,9 @@ int main(void) { cmocka_unit_test(test__fl_fss_extended_list_object_read__works), cmocka_unit_test(test__fl_fss_payload_header_map__returns_data_not), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_dynamic__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_dynamics__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_dynamics__works_split), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int8s__works_join), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int8s__works_split), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int16s__works_join), @@ -68,6 +71,8 @@ int main(void) { cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int32s__works_split), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int64s__works_join), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int64s__works_split), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_map__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_map__works_split), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signed__works_join), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signeds__works_join), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signeds__works_split), diff --git a/level_1/fl_fss/tests/unit/c/test-fss.h b/level_1/fl_fss/tests/unit/c/test-fss.h index cac7fad..b6b0516 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss.h +++ b/level_1/fl_fss/tests/unit/c/test-fss.h @@ -62,6 +62,9 @@ #include "test-fss-extended_list_object_read.h" #include "test-fss-extended_list_object_write.h" #include "test-fss-payload_header_map.h" +#include "test-fss-payload_header_map-abstruse_dynamic-join.h" +#include "test-fss-payload_header_map-abstruse_dynamics-join.h" +#include "test-fss-payload_header_map-abstruse_dynamics-split.h" #include "test-fss-payload_header_map-abstruse_int8s-join.h" #include "test-fss-payload_header_map-abstruse_int8s-split.h" #include "test-fss-payload_header_map-abstruse_int16s-join.h" @@ -70,6 +73,8 @@ #include "test-fss-payload_header_map-abstruse_int32s-split.h" #include "test-fss-payload_header_map-abstruse_int64s-join.h" #include "test-fss-payload_header_map-abstruse_int64s-split.h" +#include "test-fss-payload_header_map-abstruse_map-join.h" +#include "test-fss-payload_header_map-abstruse_map-split.h" #include "test-fss-payload_header_map-abstruse_signed-join.h" #include "test-fss-payload_header_map-abstruse_signeds-join.h" #include "test-fss-payload_header_map-abstruse_signeds-split.h" diff --git a/level_3/fss_write/c/main/common/type.h b/level_3/fss_write/c/main/common/type.h index 5753584..4622ecd 100644 --- a/level_3/fss_write/c/main/common/type.h +++ b/level_3/fss_write/c/main/common/type.h @@ -81,7 +81,7 @@ extern "C" { */ #ifndef _di_fss_write_setting_t_ typedef struct { - uint16_t flag; + uint32_t flag; f_status_t status_signal; f_state_t state; -- 1.8.3.1