From: Kevin Day Date: Mon, 11 Mar 2024 00:00:41 +0000 (-0500) Subject: Update: Wrap up unit tests for fl_fss_payload_header_map() and fix observed problems. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=74005e58543df1a3244a3c3a1d29512e2d32d3bd;p=fll Update: Wrap up unit tests for fl_fss_payload_header_map() and fix observed problems. The unit tests for fl_fss_payload_header_map() are lacking significant combinations and permutations. This, however, is being considered good enough for a first pass. More complex and broader cases will hopefully be handled in some likely relatively distant future. The null_quantity flag does not make any sense as the variable "total" can be 0 and that should not logically be considered NULL. Make sure strings are NULL terminated for the cases where the code adds an extra space and then unassigned the used length of that space. Handle cases where range.start > range.stop, aka NULL range. Various other fixes. --- diff --git a/level_0/f_abstruse/c/abstruse/private-abstruse.c b/level_0/f_abstruse/c/abstruse/private-abstruse.c index afe0ac0..b37e918 100644 --- a/level_0/f_abstruse/c/abstruse/private-abstruse.c +++ b/level_0/f_abstruse/c/abstruse/private-abstruse.c @@ -147,15 +147,18 @@ extern "C" { case f_abstruse_triple_e: if (abstruse->is.a_triple.a.size) { - return f_memory_array_resize(0, sizeof(f_char_t), (void **) &abstruse->is.a_triple.a.string, &abstruse->is.a_triple.a.used, &abstruse->is.a_triple.a.size); + const f_status_t status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &abstruse->is.a_triple.a.string, &abstruse->is.a_triple.a.used, &abstruse->is.a_triple.a.size); + if (F_status_is_error(status)) return status; } if (abstruse->is.a_triple.b.size) { - return f_memory_array_resize(0, sizeof(f_char_t), (void **) &abstruse->is.a_triple.b.string, &abstruse->is.a_triple.b.used, &abstruse->is.a_triple.b.size); + const f_status_t status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &abstruse->is.a_triple.b.string, &abstruse->is.a_triple.b.used, &abstruse->is.a_triple.b.size); + if (F_status_is_error(status)) return status; } if (abstruse->is.a_triple.c.size) { - return f_memory_array_resize(0, sizeof(f_char_t), (void **) &abstruse->is.a_triple.c.string, &abstruse->is.a_triple.c.used, &abstruse->is.a_triple.c.size); + const f_status_t status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &abstruse->is.a_triple.c.string, &abstruse->is.a_triple.c.used, &abstruse->is.a_triple.c.size); + if (F_status_is_error(status)) return status; } break; diff --git a/level_0/f_fss/c/fss/payload.h b/level_0/f_fss/c/fss/payload.h index 359f732..6d06679 100644 --- a/level_0/f_fss/c/fss/payload.h +++ b/level_0/f_fss/c/fss/payload.h @@ -50,7 +50,6 @@ extern "C" { * - null_map_value: Types of map and maps has empty strings (such as "") added for NULL values (used is 0) for the map value. * - null_map_value_name: An enumeration value representing both null_map_name and null_map_value keys being set. * - null_maps: Types of map and maps have empty strings added (such as "") added for when null_map_key and null_map_value are not set and both map key and map value have NULL values (used is 0). - * - null_quantity: Types of quantity and quantitys have empty strings added (such as "") for when start > stop, aka NULL quantitys. * - null_quantitys: Types of quantitys have empty strings added (such as "") added for when the array is empty. * - null_range: Types of range and ranges have empty strings added (such as "") for when start > stop, aka NULL ranges. * - null_ranges: Types of ranges have empty strings added (such as "") added for when the array is empty. @@ -93,18 +92,17 @@ extern "C" { f_fss_payload_header_map_flag_null_map_value_e = 0x100000, f_fss_payload_header_map_flag_null_map_value_name_e = 0x180000, f_fss_payload_header_map_flag_null_maps_e = 0x200000, - f_fss_payload_header_map_flag_null_quantity_e = 0x400000, - f_fss_payload_header_map_flag_null_quantitys_e = 0x800000, - f_fss_payload_header_map_flag_null_range_e = 0x1000000, - f_fss_payload_header_map_flag_null_ranges_e = 0x2000000, - f_fss_payload_header_map_flag_null_string_e = 0x4000000, - f_fss_payload_header_map_flag_null_strings_e = 0x8000000, - f_fss_payload_header_map_flag_null_triple_e = 0x10000000, - f_fss_payload_header_map_flag_null_triples_e = 0x20000000, - f_fss_payload_header_map_flag_quote_double_e = 0x40000000, - f_fss_payload_header_map_flag_quote_grave_e = 0x80000000, - f_fss_payload_header_map_flag_quote_single_e = 0x10000000, - f_fss_payload_header_map_flag_last_e = 0x20000000, + f_fss_payload_header_map_flag_null_quantitys_e = 0x400000, + f_fss_payload_header_map_flag_null_range_e = 0x800000, + f_fss_payload_header_map_flag_null_ranges_e = 0x1000000, + f_fss_payload_header_map_flag_null_string_e = 0x2000000, + f_fss_payload_header_map_flag_null_strings_e = 0x4000000, + f_fss_payload_header_map_flag_null_triple_e = 0x8000000, + f_fss_payload_header_map_flag_null_triples_e = 0x10000000, + f_fss_payload_header_map_flag_quote_double_e = 0x20000000, + f_fss_payload_header_map_flag_quote_grave_e = 0x40000000, + f_fss_payload_header_map_flag_quote_single_e = 0x80000000, + f_fss_payload_header_map_flag_last_e = 0x100000000, }; // enum #endif // _di_f_fss_payload_header_map_flag_e_ diff --git a/level_1/fl_fss/c/fss/payload.c b/level_1/fl_fss/c/fss/payload.c index 77a0c87..f96d165 100644 --- a/level_1/fl_fss/c/fss/payload.c +++ b/level_1/fl_fss/c/fss/payload.c @@ -270,12 +270,7 @@ extern "C" { break; case f_abstruse_quantity_e: - if (!headers.array[internal.i].value.is.a_quantity.total || (data->flag & f_fss_payload_header_map_flag_null_quantity_e)) { - if (private_fl_payload_header_map_quantity(data, state, &internal, headers.array[internal.i].value.is.a_quantity, destinations) == F_false) { - ++destinations->used; - } - } - else if (data->flag & f_fss_payload_header_map_flag_null_e) { + if (private_fl_payload_header_map_quantity(data, state, &internal, headers.array[internal.i].value.is.a_quantity, destinations) == F_false) { ++destinations->used; } diff --git a/level_1/fl_fss/c/fss/private-payload.c b/level_1/fl_fss/c/fss/private-payload.c index cc37641..7ce936d 100644 --- a/level_1/fl_fss/c/fss/private-payload.c +++ b/level_1/fl_fss/c/fss/private-payload.c @@ -77,6 +77,7 @@ extern "C" { // Remove the always added trailing extended next. destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + destinations->array[destinations->used].value.string[destinations->array[destinations->used].value.used] = 0; } } else { @@ -186,6 +187,7 @@ extern "C" { // Remove the always added trailing space. if (destinations->array[destinations->used].value.used) { destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + destinations->array[destinations->used].value.string[destinations->array[destinations->used].value.used] = 0; } } @@ -342,6 +344,7 @@ extern "C" { // Remove the always added trailing space. if (destinations->array[destinations->used].value.used) { destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + destinations->array[destinations->used].value.string[destinations->array[destinations->used].value.used] = 0; } } @@ -544,6 +547,7 @@ extern "C" { // Remove the always added trailing space. if (destinations->array[destinations->used].value.used) { destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + destinations->array[destinations->used].value.string[destinations->array[destinations->used].value.used] = 0; } } else { @@ -600,6 +604,7 @@ extern "C" { // Remove the always added trailing space. if (destinations->array[destinations->used].value.used) { destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + destinations->array[destinations->used].value.string[destinations->array[destinations->used].value.used] = 0; } } @@ -953,39 +958,27 @@ extern "C" { #if !defined(_di_fl_fss_payload_header_map_) uint8_t private_fl_payload_header_map_quantity(fl_fss_payload_header_state_t * const data, f_state_t * const state, fl_fss_payload_header_internal_t * const internal, const f_quantity_t quantity, f_string_maps_t * const destinations) { - if (quantity.total) { - data->cache->used = 0; - - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.start) == F_true) return F_true; - - if (data->flag & f_fss_payload_header_map_flag_join_quantity_e) { - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.total) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - } - else { - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; + data->cache->used = 0; - 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; + state->status = f_memory_array_increase_by(FL_payload_digit_size_2_d, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; - data->cache->used = 0; + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.start) == F_true) return F_true; - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.total) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - } + if (data->flag & f_fss_payload_header_map_flag_join_quantity_e) { + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.total) == F_true) return F_true; + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; } else { - if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { - if (data->flag & f_fss_payload_header_map_flag_join_quantity_e) { - data->cache->used = 0; + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, data->cache, f_fss_space_s) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - } - else { - if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, &destinations->array[destinations->used].value, f_fss_extended_next_s) == F_true) 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; + + data->cache->used = 0; + + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.total) == F_true) return F_true; + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; } state->status = F_okay; @@ -1007,25 +1000,15 @@ extern "C" { if (F_status_set_fine(state->status) == F_interrupt) return F_true; } - if (quantitys.array[internal->l].total) { - internal->k += FL_payload_digit_size_2_d + f_fss_extended_next_s.used + internal->quote_null.used * 2; - } - else if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { - internal->k += f_fss_extended_next_s.used + internal->quote_null.used * 2; - } + internal->k += FL_payload_digit_size_2_d + f_fss_extended_next_s.used + internal->quote_null.used * 2 + f_fss_placeholder_s.used * 2; } // for - // Add additional characters for the standard placeholders. - if (internal->k) { - internal->k += f_fss_placeholder_s.used * 2; - } + data->cache->used = 0; state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); if (F_status_is_error(state->status)) return F_true; if (data->flag & f_fss_payload_header_map_flag_join_quantitys_e) { - data->cache->used = 0; - state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; @@ -1036,28 +1019,13 @@ extern "C" { if (F_status_set_fine(state->status) == F_interrupt) return F_true; } - if (quantitys.array[internal->l].total) { - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; - - continue; - } - - if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { - if (data->cache->used) { - state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); - if (F_status_is_error(state->status)) return F_true; - } - - if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, data->cache, f_fss_space_s) == F_true) return F_true; - } + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; } // for if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; } else { - data->cache->used = 0; - if (data->flag & f_fss_payload_header_map_flag_join_quantity_e) { state->status = f_memory_array_increase_by(FL_payload_digit_size_2_d, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; @@ -1069,22 +1037,11 @@ extern "C" { if (F_status_set_fine(state->status) == F_interrupt) return F_true; } - if (quantitys.array[internal->l].total) { - data->cache->used = 0; - - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - - continue; - } - - if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { - data->cache->used = 0; + data->cache->used = 0; - if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, data->cache, f_fss_space_s) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - } + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; } // for } else { @@ -1098,30 +1055,18 @@ extern "C" { if (F_status_set_fine(state->status) == F_interrupt) return F_true; } - if (quantitys.array[internal->l].total) { - data->cache->used = 0; - - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - - data->cache->used = 0; - - 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; + data->cache->used = 0; - if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) 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; + data->cache->used = 0; - continue; - } + 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; - if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { - state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; - } + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) 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; @@ -1130,6 +1075,7 @@ extern "C" { // Remove the always added trailing space (except when all quantitys are NULL and f_fss_payload_header_map_flag_null_quantity_e is not set). if (destinations->array[destinations->used].value.used) { destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + destinations->array[destinations->used].value.string[destinations->array[destinations->used].value.used] = 0; } } } @@ -1157,10 +1103,11 @@ extern "C" { #if !defined(_di_fl_fss_payload_header_map_) uint8_t private_fl_payload_header_map_range(fl_fss_payload_header_state_t * const data, f_state_t * const state, fl_fss_payload_header_internal_t * const internal, const f_range_t range, f_string_maps_t * const destinations) { + data->cache->used = 0; + if (range.start > range.stop) { if (data->flag & f_fss_payload_header_map_flag_null_range_e) { if (data->flag & f_fss_payload_header_map_flag_join_range_e) { - data->cache->used = 0; if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, data->cache, f_fss_space_s) == F_true) return F_true; if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; @@ -1171,7 +1118,8 @@ extern "C" { } } else { - data->cache->used = 0; + state->status = f_memory_array_increase_by(FL_payload_digit_size_2_d, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; if (private_fl_payload_header_map_number_unsigned(data, state, internal, range.start) == F_true) return F_true; @@ -1257,7 +1205,14 @@ extern "C" { if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.array[internal->l].stop) == F_true) return F_true; } // for - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; + if (data->cache->used) { + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; + } + else if (!(data->flag & f_fss_payload_header_map_flag_null_range_e)) { + + // Let caller know to not increment when not allowing NULL ranges. + return F_true; + } } else { data->cache->used = 0; @@ -1266,6 +1221,8 @@ extern "C" { state->status = f_memory_array_increase_by(FL_payload_digit_size_2_d, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; + uint8_t no_data = F_true; + for (internal->l = 0; internal->l < ranges.used; ++internal->l) { if (state->interrupt) { @@ -1276,6 +1233,7 @@ extern "C" { if (ranges.array[internal->l].start > ranges.array[internal->l].stop) { if (data->flag & f_fss_payload_header_map_flag_null_range_e) { data->cache->used = 0; + no_data = F_false; if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, data->cache, f_fss_space_s) == F_true) return F_true; if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; @@ -1285,16 +1243,22 @@ extern "C" { } data->cache->used = 0; + no_data = F_false; if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.array[internal->l].start) == F_true) return F_true; if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.array[internal->l].stop) == F_true) return F_true; if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; } // for + + // Let caller know to not increment when not allowing NULL ranges. + if (no_data) return F_true; } else { state->status = f_memory_array_increase_by(FL_payload_digit_size_1_d, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; + uint8_t no_data = F_true; + for (internal->l = 0; internal->l < ranges.used; ++internal->l) { if (state->interrupt) { @@ -1304,16 +1268,19 @@ extern "C" { if (ranges.array[internal->l].start > ranges.array[internal->l].stop) { if (data->flag & f_fss_payload_header_map_flag_null_range_e) { + no_data = F_false; + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); 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; + 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; + } continue; } + no_data = F_false; data->cache->used = 0; if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.array[internal->l].start) == F_true) return F_true; @@ -1331,26 +1298,33 @@ extern "C" { if (F_status_is_error(state->status)) return F_true; } // for + // Let caller know to not increment when not allowing NULL ranges. + if (no_data) return F_true; + // Remove the always added trailing space (except when all ranges are NULL and f_fss_payload_header_map_flag_null_range_e is not set). if (destinations->array[destinations->used].value.used) { destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + destinations->array[destinations->used].value.string[destinations->array[destinations->used].value.used] = 0; } } } } - else { - if (data->flag & f_fss_payload_header_map_flag_null_ranges_e) { - if (data->flag & f_fss_payload_header_map_flag_join_ranges_range_e) { - data->cache->used = 0; + else if (data->flag & f_fss_payload_header_map_flag_null_ranges_e) { + if (data->flag & f_fss_payload_header_map_flag_join_ranges_range_e) { + data->cache->used = 0; - if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, data->cache, f_fss_space_s) == F_true) return F_true; - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - } - else { - if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, &destinations->array[destinations->used].value, f_fss_extended_next_s) == F_true) return F_true; - } + if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, data->cache, f_fss_space_s) == F_true) return F_true; + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; + } + else { + if (private_fl_payload_helper_header_map_destination_write_empty_two(data, state, internal, &destinations->array[destinations->used].value, f_fss_extended_next_s) == F_true) return F_true; } } + else { + + // Let caller know to not increment when not allowing NULL ranges. + return F_true; + } state->status = F_okay; @@ -1469,65 +1443,107 @@ extern "C" { f_string_dynamic_t * const destination = (data->flag & f_fss_payload_header_map_flag_join_triple_e) ? data->cache : &destinations->array[destinations->used].value; const f_string_static_t separator = (data->flag & f_fss_payload_header_map_flag_join_triple_e) ? f_string_space_s : f_fss_extended_next_s; - const f_string_static_t a = triple.a.used ? triple.a : internal->quote_null; - const f_string_static_t b = triple.b.used ? triple.b : internal->quote_null; - const f_string_static_t c = triple.c.used ? triple.c : internal->quote_null; data->cache->used = 0; - state->status = f_memory_array_increase_by(a.used + b.used + c.used + separator.used * 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); - if (F_status_is_error(state->status)) return F_true; + { + f_number_unsigned_t length = separator.used * 2 + f_fss_placeholder_s.used * 6; - if (triple.a.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { - if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { - state->status = f_string_dynamic_append(a, destination); + if (triple.a.used) { + length += triple.a.used; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + length += internal->quote_null.used; } - else { - internal->range.start = 0; - internal->range.stop = a.used - 1; - private_fl_fss_basic_write(F_false, a, internal->quote, &internal->range, destination, state, (void * const) internal); + if (triple.b.used) { + length += triple.b.used; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + length += internal->quote_null.used; } - if (F_status_is_error(state->status)) return F_true; + if (triple.c.used) { + length += triple.c.used; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + length += internal->quote_null.used; + } - if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { - state->status = f_string_dynamic_append(separator, destination); + if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { + state->status = f_memory_array_increase_by(length, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); if (F_status_is_error(state->status)) return F_true; } } - if (triple.b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { - if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { - state->status = f_string_dynamic_append(b, destination); + if (triple.a.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triple.a.used) { + if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { + state->status = f_string_dynamic_append(triple.a, destination); + } + else { + internal->range.start = 0; + internal->range.stop = triple.a.used - 1; + + private_fl_fss_basic_write(F_false, triple.a, internal->quote, &internal->range, destination, state, (void * const) internal); + } + + if (F_status_is_error(state->status)) return F_true; } else { - internal->range.start = 0; - internal->range.stop = b.used - 1; + state->status = f_string_dynamic_append(internal->quote_null, destination); + if (F_status_is_error(state->status)) return F_true; + } + } - private_fl_fss_basic_write(F_false, b, internal->quote, &internal->range, destination, state, (void * const) internal); + if (triple.b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triple.a.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + state->status = f_string_dynamic_append_assure(separator, destination); + if (F_status_is_error(state->status)) return F_true; } - if (F_status_is_error(state->status)) return F_true; + if (triple.b.used) { + if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { + state->status = f_string_dynamic_append(triple.b, destination); + } + else { + internal->range.start = 0; + internal->range.stop = triple.b.used - 1; + + private_fl_fss_basic_write(F_false, triple.b, internal->quote, &internal->range, destination, state, (void * const) internal); + } - if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { - state->status = f_string_dynamic_append(separator, destination); + if (F_status_is_error(state->status)) return F_true; + } + else { + state->status = f_string_dynamic_append(internal->quote_null, destination); if (F_status_is_error(state->status)) return F_true; } } if (triple.c.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { - if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { - state->status = f_string_dynamic_append(c, destination); + if (triple.a.used || triple.b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + state->status = f_string_dynamic_append_assure(separator, destination); + if (F_status_is_error(state->status)) return F_true; } - else { - internal->range.start = 0; - internal->range.stop = c.used - 1; - private_fl_fss_basic_write(F_false, c, internal->quote, &internal->range, destination, state, (void * const) internal); - } + if (triple.c.used) { + if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { + state->status = f_string_dynamic_append(triple.c, destination); + } + else { + internal->range.start = 0; + internal->range.stop = triple.c.used - 1; - if (F_status_is_error(state->status)) return F_true; + private_fl_fss_basic_write(F_false, triple.c, internal->quote, &internal->range, destination, state, (void * const) internal); + } + + if (F_status_is_error(state->status)) return F_true; + } + else { + state->status = f_string_dynamic_append(internal->quote_null, destination); + if (F_status_is_error(state->status)) return F_true; + } } if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { @@ -1561,19 +1577,15 @@ extern "C" { internal->k += (triples.array[internal->l].b.used) ? triples.array[internal->l].b.used : internal->quote_null.used; internal->k += (triples.array[internal->l].c.used) ? triples.array[internal->l].c.used : internal->quote_null.used; internal->k += (data->flag & f_fss_payload_header_map_flag_join_triple_e) ? f_fss_space_s.used * 2 : f_fss_extended_next_s.used * 2; + internal->k += f_fss_placeholder_s.used * 6; } // for - // Add additional characters for the standard placeholders. - if (internal->k) { - internal->k += f_fss_placeholder_s.used * 4; - } - state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); if (F_status_is_error(state->status)) return F_true; - if (data->flag & f_fss_payload_header_map_flag_join_triples_triple_e) { - data->cache->used = 0; + data->cache->used = 0; + if (data->flag & f_fss_payload_header_map_flag_join_triples_triple_e) { state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; @@ -1584,62 +1596,34 @@ extern "C" { if (F_status_set_fine(state->status) == F_interrupt) return F_true; } - if (!(data->flag & f_fss_payload_header_map_flag_join_triples_e)) { - if (data->cache->used) { - 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; - } - - data->cache->used = 0; - } - else { - if (data->cache->used) { - state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); - if (F_status_is_error(state->status)) return F_true; - } + if (data->cache->used) { + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; } if (triples.array[internal->l].a.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { - if (triples.array[internal->l].a.used) { - state->status = f_string_dynamic_append(triples.array[internal->l].a, data->cache); - if (F_status_is_error(state->status)) return F_true; - } - else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { - state->status = f_string_dynamic_append(internal->quote_null, data->cache); - if (F_status_is_error(state->status)) return F_true; - } - - if (triples.array[internal->l].b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { - state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); - if (F_status_is_error(state->status)) return F_true; - } + state->status = f_string_dynamic_append((triples.array[internal->l].a.used) ? triples.array[internal->l].a : internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; } if (triples.array[internal->l].b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { - if (triples.array[internal->l].b.used) { - state->status = f_string_dynamic_append(triples.array[internal->l].b, data->cache); - if (F_status_is_error(state->status)) return F_true; - } - else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { - state->status = f_string_dynamic_append(internal->quote_null, data->cache); - if (F_status_is_error(state->status)) return F_true; - } - - if (triples.array[internal->l].c.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triples.array[internal->l].a.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); if (F_status_is_error(state->status)) return F_true; } + + state->status = f_string_dynamic_append((triples.array[internal->l].b.used) ? triples.array[internal->l].b : internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; } if (triples.array[internal->l].c.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { - if (triples.array[internal->l].c.used) { - state->status = f_string_dynamic_append(triples.array[internal->l].c, data->cache); - if (F_status_is_error(state->status)) return F_true; - } - else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { - state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (triples.array[internal->l].a.used || triples.array[internal->l].b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); if (F_status_is_error(state->status)) return F_true; } + + state->status = f_string_dynamic_append((triples.array[internal->l].c.used) ? triples.array[internal->l].c : internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; } if (!(data->flag & f_fss_payload_header_map_flag_join_triples_e)) { @@ -1647,13 +1631,9 @@ extern "C" { } } // for - if (data->flag & f_fss_payload_header_map_flag_join_triples_e) { - if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; - } + if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, internal, data->cache, destinations) == F_true) return F_true; } else { - data->cache->used = 0; - for (internal->l = 0; internal->l < triples.used; ++internal->l) { if (state->interrupt) { @@ -1666,10 +1646,10 @@ extern "C" { internal->range.start = 0; internal->range.stop = triples.array[internal->l].a.used - 1; - private_fl_fss_basic_write(F_false, triples.array[internal->l].a, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + private_fl_fss_basic_write(F_false, triples.array[internal->l].a, internal->quote, &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_null_triple_e) { + else { state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; } @@ -1683,7 +1663,7 @@ extern "C" { internal->range.start = 0; internal->range.stop = triples.array[internal->l].b.used - 1; - private_fl_fss_basic_write(F_false, triples.array[internal->l].b, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + private_fl_fss_basic_write(F_false, triples.array[internal->l].b, internal->quote, &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_null_triple_e) { @@ -1700,7 +1680,7 @@ extern "C" { internal->range.start = 0; internal->range.stop = triples.array[internal->l].c.used - 1; - private_fl_fss_basic_write(F_false, triples.array[internal->l].c, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + private_fl_fss_basic_write(F_false, triples.array[internal->l].c, internal->quote, &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_null_triple_e) { @@ -1716,7 +1696,11 @@ extern "C" { // Remove the always added trailing space (except when all triples are NULL and f_fss_payload_header_map_flag_null_triple_e is not set). if (destinations->array[destinations->used].value.used) { destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + destinations->array[destinations->used].value.string[destinations->array[destinations->used].value.used] = 0; } + + state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; } } else { diff --git a/level_1/fl_fss/data/build/settings-tests b/level_1/fl_fss/data/build/settings-tests index 95600f9..624511b 100644 --- a/level_1/fl_fss/data/build/settings-tests +++ b/level_1/fl_fss/data/build/settings-tests @@ -45,11 +45,17 @@ build_sources_program test-fss-payload_header_map-abstruse_map-join.c test-fss-p build_sources_program test-fss-payload_header_map-abstruse_map_multi-join.c test-fss-payload_header_map-abstruse_map_multi-split.c build_sources_program test-fss-payload_header_map-abstruse_map_multis-join.c test-fss-payload_header_map-abstruse_map_multis-split.c build_sources_program test-fss-payload_header_map-abstruse_maps-join.c test-fss-payload_header_map-abstruse_maps-split.c +build_sources_program test-fss-payload_header_map-abstruse_quantity-join.c test-fss-payload_header_map-abstruse_quantity-split.c +build_sources_program test-fss-payload_header_map-abstruse_quantitys-join.c test-fss-payload_header_map-abstruse_quantitys-split.c +build_sources_program test-fss-payload_header_map-abstruse_range-join.c test-fss-payload_header_map-abstruse_range-split.c +build_sources_program test-fss-payload_header_map-abstruse_ranges-join.c test-fss-payload_header_map-abstruse_ranges-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 build_sources_program test-fss-payload_header_map-abstruse_string-join.c build_sources_program test-fss-payload_header_map-abstruse_strings-join.c test-fss-payload_header_map-abstruse_strings-split.c +build_sources_program test-fss-payload_header_map-abstruse_triple-join.c test-fss-payload_header_map-abstruse_triple-split.c +build_sources_program test-fss-payload_header_map-abstruse_triples-join.c test-fss-payload_header_map-abstruse_triples-split.c build_sources_program test-fss.c data-fss.c help-fss.c help-fss-payload.c diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-0.txt new file mode 100644 index 0000000..91939e4 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-0.txt @@ -0,0 +1,3 @@ +a +1 +"0 1" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-1.txt new file mode 100644 index 0000000..edb5950 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-1.txt @@ -0,0 +1,3 @@ +b +1 +"55555 77777777" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-2.txt new file mode 100644 index 0000000..055589c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantity-2.txt @@ -0,0 +1,3 @@ +c +1 +"123456789 9876543210" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-0.txt new file mode 100644 index 0000000..91939e4 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-0.txt @@ -0,0 +1,3 @@ +a +1 +"0 1" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-1.txt new file mode 100644 index 0000000..edb5950 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-1.txt @@ -0,0 +1,3 @@ +b +1 +"55555 77777777" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-2.txt new file mode 100644 index 0000000..055589c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_quantitys-2.txt @@ -0,0 +1,3 @@ +c +1 +"123456789 9876543210" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-0.txt new file mode 100644 index 0000000..91939e4 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-0.txt @@ -0,0 +1,3 @@ +a +1 +"0 1" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-1.txt new file mode 100644 index 0000000..edb5950 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-1.txt @@ -0,0 +1,3 @@ +b +1 +"55555 77777777" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-2.txt new file mode 100644 index 0000000..055589c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-2.txt @@ -0,0 +1,3 @@ +c +1 +"123456789 9876543210" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-3.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-3.txt new file mode 100644 index 0000000..d4b81ee --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_range-3.txt @@ -0,0 +1,2 @@ +d +0 diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-0.txt new file mode 100644 index 0000000..91939e4 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-0.txt @@ -0,0 +1,3 @@ +a +1 +"0 1" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-1.txt new file mode 100644 index 0000000..edb5950 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-1.txt @@ -0,0 +1,3 @@ +b +1 +"55555 77777777" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-2.txt new file mode 100644 index 0000000..055589c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-2.txt @@ -0,0 +1,3 @@ +c +1 +"123456789 9876543210" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-3.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-3.txt new file mode 100644 index 0000000..d4b81ee --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_ranges-3.txt @@ -0,0 +1,2 @@ +d +0 diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-0.txt new file mode 100644 index 0000000..ee90c50 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-0.txt @@ -0,0 +1,3 @@ +a-0 +1 +"0 hello world" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-1.txt new file mode 100644 index 0000000..3f9d8f4 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-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_triple-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-2.txt new file mode 100644 index 0000000..26bcdbd --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-2.txt @@ -0,0 +1,3 @@ +a-2 +1 +""\" ''" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-3.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-3.txt new file mode 100644 index 0000000..cdc6a2d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-3.txt @@ -0,0 +1,3 @@ +b-0 +1 +"全 ⸙" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-4.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-4.txt new file mode 100644 index 0000000..babfa63 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-4.txt @@ -0,0 +1,3 @@ +b-1 +1 +"␂␂␂ ␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-5.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-5.txt new file mode 100644 index 0000000..576b709 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-5.txt @@ -0,0 +1,3 @@ +b-2 +1 +"' '" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-6.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-6.txt new file mode 100644 index 0000000..e9d783e --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triple-6.txt @@ -0,0 +1,3 @@ +c-0 +1 +"� "a b \" c" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-0.txt new file mode 100644 index 0000000..ee90c50 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-0.txt @@ -0,0 +1,3 @@ +a-0 +1 +"0 hello world" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-1.txt new file mode 100644 index 0000000..3f9d8f4 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-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_triples-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-2.txt new file mode 100644 index 0000000..26bcdbd --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-2.txt @@ -0,0 +1,3 @@ +a-2 +1 +""\" ''" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-3.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-3.txt new file mode 100644 index 0000000..cdc6a2d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-3.txt @@ -0,0 +1,3 @@ +b-0 +1 +"全 ⸙" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-4.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-4.txt new file mode 100644 index 0000000..babfa63 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-4.txt @@ -0,0 +1,3 @@ +b-1 +1 +"␂␂␂ ␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-5.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-5.txt new file mode 100644 index 0000000..576b709 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-5.txt @@ -0,0 +1,3 @@ +b-2 +1 +"' '" diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-6.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-6.txt new file mode 100644 index 0000000..e9d783e --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_triples-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_quantity-0.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantity-0.txt new file mode 100644 index 0000000..1561ae6 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantity-0.txt @@ -0,0 +1,3 @@ +a +1 +0 1 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantity-1.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantity-1.txt new file mode 100644 index 0000000..83a56f3 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantity-1.txt @@ -0,0 +1,3 @@ +b +1 +55555 77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantity-2.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantity-2.txt new file mode 100644 index 0000000..f88707b --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantity-2.txt @@ -0,0 +1,3 @@ +c +1 +123456789 9876543210 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-0.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-0.txt new file mode 100644 index 0000000..1561ae6 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-0.txt @@ -0,0 +1,3 @@ +a +1 +0 1 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-1.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-1.txt new file mode 100644 index 0000000..83a56f3 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-1.txt @@ -0,0 +1,3 @@ +b +1 +55555 77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-2.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-2.txt new file mode 100644 index 0000000..f88707b --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_quantitys-2.txt @@ -0,0 +1,3 @@ +c +1 +123456789 9876543210 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-0.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-0.txt new file mode 100644 index 0000000..1561ae6 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-0.txt @@ -0,0 +1,3 @@ +a +1 +0 1 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-1.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-1.txt new file mode 100644 index 0000000..83a56f3 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-1.txt @@ -0,0 +1,3 @@ +b +1 +55555 77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-2.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-2.txt new file mode 100644 index 0000000..f88707b --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-2.txt @@ -0,0 +1,3 @@ +c +1 +123456789 9876543210 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-3.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-3.txt new file mode 100644 index 0000000..d4b81ee --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_range-3.txt @@ -0,0 +1,2 @@ +d +0 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-0.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-0.txt new file mode 100644 index 0000000..1561ae6 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-0.txt @@ -0,0 +1,3 @@ +a +1 +0 1 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-1.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-1.txt new file mode 100644 index 0000000..83a56f3 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-1.txt @@ -0,0 +1,3 @@ +b +1 +55555 77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-2.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-2.txt new file mode 100644 index 0000000..f88707b --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-2.txt @@ -0,0 +1,3 @@ +c +1 +123456789 9876543210 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-3.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-3.txt new file mode 100644 index 0000000..d4b81ee --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_ranges-3.txt @@ -0,0 +1,2 @@ +d +0 diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-0.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-0.txt new file mode 100644 index 0000000..017b988 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-0.txt @@ -0,0 +1,3 @@ +a-0 +1 +0 hello world diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-1.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-1.txt new file mode 100644 index 0000000..2490950 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-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_triple-2.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-2.txt new file mode 100644 index 0000000..7e91d24 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-2.txt @@ -0,0 +1,3 @@ +a-2 +1 +"""" "''" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-3.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-3.txt new file mode 100644 index 0000000..6a55e8c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-3.txt @@ -0,0 +1,3 @@ +b-0 +1 +全 ⸙ diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-4.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-4.txt new file mode 100644 index 0000000..2df9bf9 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-4.txt @@ -0,0 +1,3 @@ +b-1 +1 +␂␂␂ "␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-5.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-5.txt new file mode 100644 index 0000000..7f046f2 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-5.txt @@ -0,0 +1,3 @@ +b-2 +1 +"'" "'" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-6.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-6.txt new file mode 100644 index 0000000..946471d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triple-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_triples-0.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-0.txt new file mode 100644 index 0000000..017b988 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-0.txt @@ -0,0 +1,3 @@ +a-0 +1 +0 hello world diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-1.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-1.txt new file mode 100644 index 0000000..2490950 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-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_triples-2.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-2.txt new file mode 100644 index 0000000..7e91d24 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-2.txt @@ -0,0 +1,3 @@ +a-2 +1 +"""" "''" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-3.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-3.txt new file mode 100644 index 0000000..6a55e8c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-3.txt @@ -0,0 +1,3 @@ +b-0 +1 +全 ⸙ diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-4.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-4.txt new file mode 100644 index 0000000..2df9bf9 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-4.txt @@ -0,0 +1,3 @@ +b-1 +1 +␂␂␂ "␀ ␀ ␀ ␀ ␀ ␀" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-5.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-5.txt new file mode 100644 index 0000000..7f046f2 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-5.txt @@ -0,0 +1,3 @@ +b-2 +1 +"'" "'" diff --git a/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-6.txt b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-6.txt new file mode 100644 index 0000000..946471d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-split-abstruse_triples-6.txt @@ -0,0 +1,3 @@ +c-0 +1 +� ""a b \" c" diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_quantity.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_quantity.txt new file mode 100644 index 0000000..6560241 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_quantity.txt @@ -0,0 +1,12 @@ +a +2 +0 +1 +b +2 +55555 +77777777 +c +2 +0123456789 +9876543210 diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_quantitys.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_quantitys.txt new file mode 100644 index 0000000..6560241 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_quantitys.txt @@ -0,0 +1,12 @@ +a +2 +0 +1 +b +2 +55555 +77777777 +c +2 +0123456789 +9876543210 diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_range.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_range.txt new file mode 100644 index 0000000..2a4e0f1 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_range.txt @@ -0,0 +1,16 @@ +a +2 +0 +1 +b +2 +55555 +77777777 +c +2 +0123456789 +9876543210 +d +2 +5 +3 diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_ranges.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_ranges.txt new file mode 100644 index 0000000..2a4e0f1 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_ranges.txt @@ -0,0 +1,16 @@ +a +2 +0 +1 +b +2 +55555 +77777777 +c +2 +0123456789 +9876543210 +d +2 +5 +3 diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_triple.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_triple.txt new file mode 100644 index 0000000..0d948d3 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_triple.txt @@ -0,0 +1,29 @@ +a-0 +3 +0 +hello +world +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/data/tests/variables/payload-abstruse_triples.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_triples.txt new file mode 100644 index 0000000..0d948d3 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-abstruse_triples.txt @@ -0,0 +1,29 @@ +a-0 +3 +0 +hello +world +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 a48a985..9f2f648 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 @@ -71,6 +71,11 @@ void help_payload__test(const f_string_t context_variables, const f_string_t con } // for fl_fss_payload_header_map(headers, &destinations, &state); + + if (state.status != F_okay || destinations.used != expects.used) { + printf("[ ERROR ] --- Failure mapping: headers/payload-%s-%d.txt.\n", context_headers, at); + } + assert_int_equal(state.status, F_okay); assert_int_equal(destinations.used, expects.used); diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-join.c new file mode 100644 index 0000000..9dc2004 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-join.c @@ -0,0 +1,47 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_quantity__works_join(void **void_state) { + + help_payload__test("abstruse_quantity", "join-abstruse_quantity", f_fss_payload_header_map_flag_join_quantity_e, test__fl_fss_payload_header_map__abstruse_quantity__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_quantity__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].key.used = 0; + headers->array[0].value.is.a_quantity.start = 0; + headers->array[0].value.is.a_quantity.total = 0; + headers->array[0].value.type = f_abstruse_quantity_e; + + f_quantity_t * const quantity = &headers->array[0].value.is.a_quantity; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + if (contents.used) { + f_number_signed_t number = atoll(contents.array[0].string); + + if (!number) { + assert_int_equal(contents.array[0].string[0], '0'); + } + + quantity->start = number; + + if (contents.used > 1) { + number = atoll(contents.array[1].string); + + if (!number) { + assert_int_equal(contents.array[1].string[0], '0'); + } + + quantity->total = number; + } + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-join.h new file mode 100644 index 0000000..77488ae --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-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_quantity_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_quantity_join_h + +/** + * Test that the function works for abstruse_quantity type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_quantity__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_quantity__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_quantity_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-split.c new file mode 100644 index 0000000..126a73d --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-split.c @@ -0,0 +1,47 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_quantity__works_split(void **void_state) { + + help_payload__test("abstruse_quantity", "split-abstruse_quantity", 0, test__fl_fss_payload_header_map__abstruse_quantity__split_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_quantity__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].key.used = 0; + headers->array[0].value.is.a_quantity.start = 0; + headers->array[0].value.is.a_quantity.total = 0; + headers->array[0].value.type = f_abstruse_quantity_e; + + f_quantity_t * const quantity = &headers->array[0].value.is.a_quantity; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + if (contents.used) { + f_number_signed_t number = atoll(contents.array[0].string); + + if (!number) { + assert_int_equal(contents.array[0].string[0], '0'); + } + + quantity->start = number; + + if (contents.used > 1) { + number = atoll(contents.array[1].string); + + if (!number) { + assert_int_equal(contents.array[1].string[0], '0'); + } + + quantity->total = number; + } + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-split.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-split.h new file mode 100644 index 0000000..e6e48ae --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantity-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_quantity_split_h +#define _TEST__FL_fss_payload_header_map__abstruse_quantity_split_h + +/** + * Test that the function works for abstruse_quantity type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_quantity__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_quantity__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_quantity_split_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-join.c new file mode 100644 index 0000000..031f743 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-join.c @@ -0,0 +1,53 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_quantitys__works_join(void **void_state) { + + help_payload__test("abstruse_quantitys", "join-abstruse_quantitys", f_fss_payload_header_map_flag_join_quantitys_e, test__fl_fss_payload_header_map__abstruse_quantitys__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_quantitys__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].key.used = 0; + headers->array[0].value.is.a_quantitys.used = 0; + headers->array[0].value.type = f_abstruse_quantitys_e; + + f_quantitys_t * const quantitys = &headers->array[0].value.is.a_quantitys; + + 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_quantity_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); + assert_int_equal(state->status, F_okay); + + f_number_signed_t number = 0; + + for (f_number_unsigned_t i = 0; i < contents.used; i += 2, ++quantitys->used) { + + number = atoll(contents.array[i].string); + + if (!number) { + assert_int_equal(contents.array[i].string[0], '0'); + } + + quantitys->array[quantitys->used].start = number; + quantitys->array[quantitys->used].total = 0; + + if (i + 1 < contents.used) { + number = atoll(contents.array[i + 1].string); + + if (!number) { + assert_int_equal(contents.array[i + 1].string[0], '0'); + } + + quantitys->array[quantitys->used].total = number; + } + } // for +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-join.h new file mode 100644 index 0000000..4c67b26 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-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_quantitys_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_quantitys_join_h + +/** + * Test that the function works for abstruse_quantitys type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_quantitys__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_quantitys__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_quantitys_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-split.c new file mode 100644 index 0000000..69ce209 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-split.c @@ -0,0 +1,53 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_quantitys__works_split(void **void_state) { + + help_payload__test("abstruse_quantitys", "split-abstruse_quantitys", 0, test__fl_fss_payload_header_map__abstruse_quantitys__split_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_quantitys__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].key.used = 0; + headers->array[0].value.is.a_quantitys.used = 0; + headers->array[0].value.type = f_abstruse_quantitys_e; + + f_quantitys_t * const quantitys = &headers->array[0].value.is.a_quantitys; + + 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_quantity_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); + assert_int_equal(state->status, F_okay); + + f_number_signed_t number = 0; + + for (f_number_unsigned_t i = 0; i < contents.used; i += 2, ++quantitys->used) { + + number = atoll(contents.array[i].string); + + if (!number) { + assert_int_equal(contents.array[i].string[0], '0'); + } + + quantitys->array[quantitys->used].start = number; + quantitys->array[quantitys->used].total = 0; + + if (i + 1 < contents.used) { + number = atoll(contents.array[i + 1].string); + + if (!number) { + assert_int_equal(contents.array[i + 1].string[0], '0'); + } + + quantitys->array[quantitys->used].total = number; + } + } // for +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-split.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-split.h new file mode 100644 index 0000000..86494f7 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_quantitys-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_quantitys_split_h +#define _TEST__FL_fss_payload_header_map__abstruse_quantitys_split_h + +/** + * Test that the function works for abstruse_quantitys type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_quantitys__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_quantitys__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_quantitys_split_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-join.c new file mode 100644 index 0000000..8d54743 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-join.c @@ -0,0 +1,49 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_range__works_join(void **void_state) { + + help_payload__test("abstruse_range", "join-abstruse_range", f_fss_payload_header_map_flag_join_range_e, test__fl_fss_payload_header_map__abstruse_range__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_range__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].key.used = 0; + headers->array[0].value.is.a_range.start = 0; + headers->array[0].value.is.a_range.stop = 0; + headers->array[0].value.type = f_abstruse_range_e; + + f_range_t * const quantity = &headers->array[0].value.is.a_range; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + if (contents.used > 1) { + f_number_signed_t number = atoll(contents.array[0].string); + + if (!number) { + assert_int_equal(contents.array[0].string[0], '0'); + } + + quantity->start = number; + + number = atoll(contents.array[1].string); + + if (!number) { + assert_int_equal(contents.array[1].string[0], '0'); + } + + quantity->stop = number; + } + else { + quantity->start = 1; + quantity->stop = 0; + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-join.h new file mode 100644 index 0000000..704fc70 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-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_range_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_range_join_h + +/** + * Test that the function works for abstruse_range type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_range__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_range__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_range_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-split.c new file mode 100644 index 0000000..9ab5077 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-split.c @@ -0,0 +1,49 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_range__works_split(void **void_state) { + + help_payload__test("abstruse_range", "split-abstruse_range", 0, test__fl_fss_payload_header_map__abstruse_range__split_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_range__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].key.used = 0; + headers->array[0].value.is.a_range.start = 0; + headers->array[0].value.is.a_range.stop = 0; + headers->array[0].value.type = f_abstruse_range_e; + + f_range_t * const quantity = &headers->array[0].value.is.a_range; + + state->status = f_string_dynamic_append(object, &headers->array[headers->used].key); + assert_int_equal(state->status, F_okay); + + if (contents.used > 1) { + f_number_signed_t number = atoll(contents.array[0].string); + + if (!number) { + assert_int_equal(contents.array[0].string[0], '0'); + } + + quantity->start = number; + + number = atoll(contents.array[1].string); + + if (!number) { + assert_int_equal(contents.array[1].string[0], '0'); + } + + quantity->stop = number; + } + else { + quantity->start = 1; + quantity->stop = 0; + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-split.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-split.h new file mode 100644 index 0000000..f5d465d --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_range-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_range_split_h +#define _TEST__FL_fss_payload_header_map__abstruse_range_split_h + +/** + * Test that the function works for abstruse_range type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_range__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_range__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_range_split_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-join.c new file mode 100644 index 0000000..ab876e8 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-join.c @@ -0,0 +1,57 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_ranges__works_join(void **void_state) { + + help_payload__test("abstruse_ranges", "join-abstruse_ranges", f_fss_payload_header_map_flag_join_ranges_e, test__fl_fss_payload_header_map__abstruse_ranges__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_ranges__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].key.used = 0; + headers->array[0].value.is.a_ranges.used = 0; + headers->array[0].value.type = f_abstruse_ranges_e; + + f_ranges_t * const quantitys = &headers->array[0].value.is.a_ranges; + + 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_range_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); + assert_int_equal(state->status, F_okay); + + f_number_signed_t number = 0; + + for (f_number_unsigned_t i = 0; i < contents.used; i += 2, ++quantitys->used) { + + if (i + 1 < contents.used) { + number = atoll(contents.array[i].string); + + if (!number) { + assert_int_equal(contents.array[i].string[0], '0'); + } + + quantitys->array[quantitys->used].start = number; + quantitys->array[quantitys->used].stop = 0; + + number = atoll(contents.array[i + 1].string); + + if (!number) { + assert_int_equal(contents.array[i + 1].string[0], '0'); + } + + quantitys->array[quantitys->used].stop = number; + } + else { + quantitys->array[quantitys->used].start = 1; + quantitys->array[quantitys->used].stop = 0; + } + } // for +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-join.h new file mode 100644 index 0000000..a5a90ca --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-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_ranges_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_ranges_join_h + +/** + * Test that the function works for abstruse_ranges type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_ranges__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_ranges__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_ranges_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-split.c new file mode 100644 index 0000000..8ecf602 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-split.c @@ -0,0 +1,57 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_ranges__works_split(void **void_state) { + + help_payload__test("abstruse_ranges", "split-abstruse_ranges", 0, test__fl_fss_payload_header_map__abstruse_ranges__split_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_ranges__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].key.used = 0; + headers->array[0].value.is.a_ranges.used = 0; + headers->array[0].value.type = f_abstruse_ranges_e; + + f_ranges_t * const quantitys = &headers->array[0].value.is.a_ranges; + + 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_range_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); + assert_int_equal(state->status, F_okay); + + f_number_signed_t number = 0; + + for (f_number_unsigned_t i = 0; i < contents.used; i += 2, ++quantitys->used) { + + if (i + 1 < contents.used) { + number = atoll(contents.array[i].string); + + if (!number) { + assert_int_equal(contents.array[i].string[0], '0'); + } + + quantitys->array[quantitys->used].start = number; + quantitys->array[quantitys->used].stop = 0; + + number = atoll(contents.array[i + 1].string); + + if (!number) { + assert_int_equal(contents.array[i + 1].string[0], '0'); + } + + quantitys->array[quantitys->used].stop = number; + } + else { + quantitys->array[quantitys->used].start = 1; + quantitys->array[quantitys->used].stop = 0; + } + } // for +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-split.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-split.h new file mode 100644 index 0000000..1c62245 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_ranges-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_ranges_split_h +#define _TEST__FL_fss_payload_header_map__abstruse_ranges_split_h + +/** + * Test that the function works for abstruse_ranges type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_ranges__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_ranges__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_ranges_split_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-join.c new file mode 100644 index 0000000..37a6676 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-join.c @@ -0,0 +1,43 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_triple__works_join(void **void_state) { + + help_payload__test("abstruse_triple", "join-abstruse_triple", f_fss_payload_header_map_flag_join_triple_e, test__fl_fss_payload_header_map__abstruse_triple__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_triple__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_triple_e; + headers->array[0].value.is.a_triple.a.used = 0; + headers->array[0].value.is.a_triple.b.used = 0; + headers->array[0].value.is.a_triple.c.used = 0; + headers->array[0].key.used = 0; + + f_string_triple_t * const triple = &headers->array[0].value.is.a_triple; + + 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], &triple->a); + assert_int_equal(state->status, F_okay); + + if (contents.used > 1) { + state->status = f_string_dynamic_append(contents.array[1], &triple->b); + assert_int_equal(state->status, F_okay); + + if (contents.used > 2) { + state->status = f_string_dynamic_append(contents.array[2], &triple->c); + 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_triple-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-join.h new file mode 100644 index 0000000..ee5ae39 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-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_triple_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_triple_join_h + +/** + * Test that the function works for abstruse_triple type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_triple__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_triple__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_triple_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-split.c new file mode 100644 index 0000000..4090d38 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-split.c @@ -0,0 +1,43 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_triple__works_split(void **void_state) { + + help_payload__test("abstruse_triple", "split-abstruse_triple", 0, test__fl_fss_payload_header_map__abstruse_triple__split_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_triple__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_triple_e; + headers->array[0].value.is.a_triple.a.used = 0; + headers->array[0].value.is.a_triple.b.used = 0; + headers->array[0].value.is.a_triple.c.used = 0; + headers->array[0].key.used = 0; + + f_string_triple_t * const triple = &headers->array[0].value.is.a_triple; + + 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], &triple->a); + assert_int_equal(state->status, F_okay); + + if (contents.used > 1) { + state->status = f_string_dynamic_append(contents.array[1], &triple->b); + assert_int_equal(state->status, F_okay); + + if (contents.used > 2) { + state->status = f_string_dynamic_append(contents.array[2], &triple->c); + 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_triple-split.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-split.h new file mode 100644 index 0000000..66d11d3 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triple-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_triple_split_h +#define _TEST__FL_fss_payload_header_map__abstruse_triple_split_h + +/** + * Test that the function works for abstruse_triple type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_triple__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_triple__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_triple_split_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-join.c new file mode 100644 index 0000000..3f52272 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-join.c @@ -0,0 +1,51 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_triples__works_join(void **void_state) { + + help_payload__test("abstruse_triples", "join-abstruse_triples", f_fss_payload_header_map_flag_join_triples_e, test__fl_fss_payload_header_map__abstruse_triples__join_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_triples__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_triples_e; + headers->array[0].value.is.a_triples.used = 0; + headers->array[0].key.used = 0; + + f_string_triples_t * const triples = &headers->array[0].value.is.a_triples; + + 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_memory_array_increase_by(contents.used, sizeof(f_string_triple_t), (void **) &triples->array, &triples->used, &triples->size); + assert_int_equal(state->status, F_okay); + + for (f_number_unsigned_t i = 0; i < contents.used; i += 3, ++triples->used) { + + triples->array[triples->used].a.used = 0; + triples->array[triples->used].b.used = 0; + triples->array[triples->used].c.used = 0; + + state->status = f_string_dynamic_append(contents.array[i], &triples->array[triples->used].a); + assert_int_equal(state->status, F_okay); + + if (i + 1 < contents.used) { + state->status = f_string_dynamic_append(contents.array[i + 1], &triples->array[triples->used].b); + assert_int_equal(state->status, F_okay); + + if (i + 2 < contents.used) { + state->status = f_string_dynamic_append(contents.array[i + 2], &triples->array[triples->used].c); + 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_triples-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-join.h new file mode 100644 index 0000000..76fc240 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-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_triples_join_h +#define _TEST__FL_fss_payload_header_map__abstruse_triples_join_h + +/** + * Test that the function works for abstruse_triples type. + * + * @see fl_fss_payload_header_maps() + */ +extern void test__fl_fss_payload_header_map__abstruse_triples__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_triples__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_triples_join_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-split.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-split.c new file mode 100644 index 0000000..0644d29 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-split.c @@ -0,0 +1,51 @@ +#include "test-fss.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_triples__works_split(void **void_state) { + + help_payload__test("abstruse_triples", "split-abstruse_triples", 0, test__fl_fss_payload_header_map__abstruse_triples__split_load_contents, 0); +} + +void test__fl_fss_payload_header_map__abstruse_triples__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_triples_e; + headers->array[0].value.is.a_triples.used = 0; + headers->array[0].key.used = 0; + + f_string_triples_t * const triples = &headers->array[0].value.is.a_triples; + + 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_memory_array_increase_by(contents.used, sizeof(f_string_triple_t), (void **) &triples->array, &triples->used, &triples->size); + assert_int_equal(state->status, F_okay); + + for (f_number_unsigned_t i = 0; i < contents.used; i += 3, ++triples->used) { + + triples->array[triples->used].a.used = 0; + triples->array[triples->used].b.used = 0; + triples->array[triples->used].c.used = 0; + + state->status = f_string_dynamic_append(contents.array[i], &triples->array[triples->used].a); + assert_int_equal(state->status, F_okay); + + if (i + 1 < contents.used) { + state->status = f_string_dynamic_append(contents.array[i + 1], &triples->array[triples->used].b); + assert_int_equal(state->status, F_okay); + + if (i + 2 < contents.used) { + state->status = f_string_dynamic_append(contents.array[i + 2], &triples->array[triples->used].c); + 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_triples-split.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-split.h new file mode 100644 index 0000000..6f856ae --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_triples-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_triples_split_h +#define _TEST__FL_fss_payload_header_map__abstruse_triples_split_h + +/** + * Test that the function works for abstruse_triples type. + * + * @see fl_fss_payload_header_maps() + */ +extern void test__fl_fss_payload_header_map__abstruse_triples__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_triples__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_triples_split_h 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 5685825..4302d40 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss.c +++ b/level_1/fl_fss/tests/unit/c/test-fss.c @@ -79,12 +79,24 @@ int main(void) { cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_map_multis__works_split), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_maps__works_join), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_maps__works_split), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_quantity__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_quantity__works_split), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_quantitys__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_quantitys__works_split), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_range__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_range__works_split), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_ranges__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_ranges__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), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_string__works_join), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_strings__works_join), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_strings__works_split), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_triple__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_triple__works_split), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_triples__works_join), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_triples__works_split), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint8s__works_join), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint8s__works_split), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint16s__works_join), 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 78fe05b..1b9b7c6 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss.h +++ b/level_1/fl_fss/tests/unit/c/test-fss.h @@ -81,12 +81,24 @@ #include "test-fss-payload_header_map-abstruse_map_multis-split.h" #include "test-fss-payload_header_map-abstruse_maps-join.h" #include "test-fss-payload_header_map-abstruse_maps-split.h" +#include "test-fss-payload_header_map-abstruse_quantity-join.h" +#include "test-fss-payload_header_map-abstruse_quantity-split.h" +#include "test-fss-payload_header_map-abstruse_quantitys-join.h" +#include "test-fss-payload_header_map-abstruse_quantitys-split.h" +#include "test-fss-payload_header_map-abstruse_range-join.h" +#include "test-fss-payload_header_map-abstruse_range-split.h" +#include "test-fss-payload_header_map-abstruse_ranges-join.h" +#include "test-fss-payload_header_map-abstruse_ranges-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" #include "test-fss-payload_header_map-abstruse_string-join.h" #include "test-fss-payload_header_map-abstruse_strings-join.h" #include "test-fss-payload_header_map-abstruse_strings-split.h" +#include "test-fss-payload_header_map-abstruse_triple-join.h" +#include "test-fss-payload_header_map-abstruse_triple-split.h" +#include "test-fss-payload_header_map-abstruse_triples-join.h" +#include "test-fss-payload_header_map-abstruse_triples-split.h" #include "test-fss-payload_header_map-abstruse_uint8s-join.h" #include "test-fss-payload_header_map-abstruse_uint8s-split.h" #include "test-fss-payload_header_map-abstruse_uint16s-join.h"