I added the single digit unit tests for signed and unsigned.
I started to add uint8_t with the test files but then I realized that I actually should implement uint8s_t.
I am leaving those test files currently but I will change them at a later date.
This adds a helper file for the payload header map private functions to simplify some of the code.
build_sources_library conversion.c private-conversion.c conversion/common.c
build_sources_library directory.c private-directory.c
build_sources_library environment.c
-build_sources_library private-fss.c fss/basic.c fss/basic_list.c fss/embedded_list.c fss/extended.c fss/extended_list.c fss/payload.c fss/private-payload.c
+build_sources_library private-fss.c fss/basic.c fss/basic_list.c fss/embedded_list.c fss/extended.c fss/extended_list.c fss/payload.c fss/private-payload.c fss/private-payload-helper.c
build_sources_library iki.c
build_sources_library path.c
build_sources_library print.c private-print.c print/common.c
build_sources_library level_1/conversion.c level_1/private-conversion.c level_1/conversion/common.c
build_sources_library level_1/directory.c level_1/private-directory.c
build_sources_library level_1/environment.c
-build_sources_library level_1/private-fss.c level_1/fss/basic.c level_1/fss/basic_list.c level_1/fss/embedded_list.c level_1/fss/extended.c level_1/fss/extended_list.c level_1/fss/payload.c level_1/fss/private-payload.c
+build_sources_library level_1/private-fss.c level_1/fss/basic.c level_1/fss/basic_list.c level_1/fss/embedded_list.c level_1/fss/extended.c level_1/fss/extended_list.c level_1/fss/payload.c level_1/fss/private-payload.c level_1/fss/private-payload-helper.c
build_sources_library level_1/iki.c
build_sources_library level_1/path.c
build_sources_library level_1/print.c level_1/private-print.c level_1/print/common.c
#include "payload.h"
#include "../private-fss.h"
#include "private-payload.h"
+#include "private-payload-helper.h"
#ifdef __cplusplus
extern "C" {
destinations->array[destinations->used].name.used = 0;
destinations->array[destinations->used].value.used = 0;
- if (!headers.array[internal.i].key.used) continue;
-
internal.range.start = 0;
- internal.range.stop = headers.array[internal.i].key.used - 1;
+ internal.range.stop = headers.array[internal.i].key.used ? headers.array[internal.i].key.used - 1 : 0;
private_fl_fss_basic_write(F_true, headers.array[internal.i].key, internal.quote, &internal.range, &destinations->array[destinations->used].name, state, (void * const) &internal);
data->cache->used = 0;
if (private_fl_payload_header_map_number_signed(data, state, &internal, headers.array[internal.i].value.is.a_signed) == F_false) {
- if (private_fl_payload_header_map_cache_write(data, state, &internal) == F_false) {
+ if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, &internal, data->cache, destinations) == F_false) {
++destinations->used;
}
}
data->cache->used = 0;
if (private_fl_payload_header_map_number_unsigned(data, state, &internal, headers.array[internal.i].value.is.a_unsigned) == F_false) {
- if (private_fl_payload_header_map_cache_write(data, state, &internal) == F_false) {
+ if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, &internal, data->cache, destinations) == F_false) {
++destinations->used;
}
}
string_static.used = string_static.string ? strnlen(string_static.string, F_string_t_size_d) : 0;
if (string_static.used || (data->flag & f_fss_payload_header_map_flag_null_string_e)) {
- if (private_fl_payload_header_map_dynamic(data, state, &internal, &string_static, destinations) == F_false) {
+ if (private_fl_payload_helper_header_map_destination_write_buffer_or_empty(data, state, &internal, &string_static, destinations, f_fss_payload_header_map_flag_null_string_e) == F_false) {
++destinations->used;
}
}
case f_abstruse_dynamic_e:
if (headers.array[internal.i].value.is.a_dynamic.used || (data->flag & f_fss_payload_header_map_flag_null_dynamic_e)) {
- if (private_fl_payload_header_map_dynamic(data, state, &internal, &headers.array[internal.i].value.is.a_dynamic, destinations) == F_false) {
+ if (private_fl_payload_helper_header_map_destination_write_buffer_or_empty(data, state, &internal, &headers.array[internal.i].value.is.a_dynamic, destinations, f_fss_payload_header_map_flag_null_dynamic_e) == F_false) {
++destinations->used;
}
}
} /* for */ \
\
if (data->cache->used && (data->flag & f_fss_payload_header_map_flag_join_digits_e)) { \
- private_fl_payload_header_map_cache_write(data, state, &internal); \
- \
- if (F_status_is_error_not(state->status)) { \
+ if (private_fl_payload_helper_header_map_destination_write_buffer(data, state, &internal, data->cache, destinations) == F_false) { \
++destinations->used; \
} \
}
--- /dev/null
+#include "payload.h"
+#include "../private-fss.h"
+#include "private-payload-helper.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_di_fl_fss_payload_header_map_)
+ uint8_t private_fl_payload_helper_header_map_destination_write_buffer(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const buffer, f_string_maps_t * const destinations) {
+
+ if (buffer->used) {
+ internal->range.start = 0;
+ internal->range.stop = buffer->used - 1;
+
+ private_fl_fss_basic_write(F_false, *buffer, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value);
+ if (F_status_is_error(state->status)) return F_true;
+ }
+
+ state->status = F_okay;
+
+ return F_false;
+ }
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+#if !defined(_di_fl_fss_payload_header_map_)
+ uint8_t private_fl_payload_helper_header_map_destination_write_buffer_or_empty(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const buffer, f_string_maps_t * const destinations, const uint64_t append_on_empty) {
+
+ if (buffer->used) {
+ internal->range.start = 0;
+ internal->range.stop = buffer->used - 1;
+
+ private_fl_fss_basic_write(F_false, *buffer, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value);
+ if (F_status_is_error(state->status)) return F_true;
+ }
+ else if (data->flag & append_on_empty) {
+ 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_okay;
+
+ return F_false;
+ }
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+#if !defined(_di_fl_fss_payload_header_map_)
+ uint8_t private_fl_payload_helper_header_map_destination_write_empty_three(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const destination, const f_string_static_t separator) {
+
+ state->status = f_memory_array_increase_by(internal->quote_null.used * 3 + separator.used * 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append(internal->quote_null, destination);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append_assure(separator, destination);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append(internal->quote_null, destination);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append_assure(separator, destination);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append(internal->quote_null, destination);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = F_okay;
+
+ return F_false;
+ }
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+#if !defined(_di_fl_fss_payload_header_map_)
+ uint8_t private_fl_payload_helper_header_map_destination_write_empty_two(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const destination, const f_string_static_t separator) {
+
+ state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + separator.used, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append(internal->quote_null, destination);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append_assure(separator, destination);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append(internal->quote_null, destination);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = F_okay;
+
+ return F_false;
+ }
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 1
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * These are provided for internal reduction in redundant code.
+ * These should not be exposed/used outside of this project.
+ */
+#ifndef _PRIVATE_FL_fss_payload_helper_h
+#define _PRIVATE_FL_fss_payload_helper_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Write to the next destinations value, doing nothing on empty buffer.
+ *
+ * @param data
+ * The f_fss_payload_header_state_t pointer.
+ * Must not be NULL.
+ * @param state
+ * The state passed directly from the fl_fss_payload_header_map() parameters.
+ *
+ * This alters state.status:
+ * F_okay on success.
+ *
+ * Errors (with error bit) from: private_fl_fss_basic_write().
+ * Errors (with error bit) from: f_string_dynamic_strip_null().
+ *
+ * Must not be NULL.
+ * @param internal
+ * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map().
+ * The internal.range is modified.
+ * Must not be NULL.
+ * @param buffer
+ * The buffer to write using the FLL Extended (FSS-0001) format.
+ * Must not be NULL.
+ *
+ * @return
+ * F_true if the caller should break or exit due to an error or something similar.
+ * F_false, otherwise.
+ *
+ * @see private_fl_fss_basic_write()
+ * @see f_string_dynamic_strip_null()
+ *
+ * @see fl_fss_payload_header_map()
+ */
+#if !defined(_di_fl_fss_payload_header_map_)
+ extern uint8_t private_fl_payload_helper_header_map_destination_write_buffer(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const buffer, f_string_maps_t * const destinations) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+/**
+ * Write to the next destinations value, and if empty adding the quotes on NULL if needed.
+ *
+ * @param data
+ * The f_fss_payload_header_state_t pointer.
+ * Must not be NULL.
+ * @param state
+ * The state passed directly from the fl_fss_payload_header_map() parameters.
+ *
+ * This alters state.status:
+ * F_okay on success.
+ *
+ * Errors (with error bit) from: private_fl_fss_basic_write().
+ * Errors (with error bit) from: f_string_dynamic_append().
+ * Errors (with error bit) from: f_string_dynamic_strip_null().
+ *
+ * Must not be NULL.
+ * @param internal
+ * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map().
+ * The internal.range is modified.
+ * Must not be NULL.
+ * @param buffer
+ * The buffer to write using the FLL Extended (FSS-0001) format.
+ * Must not be NULL.
+ * @param append_on_empty
+ * Append the quoted empty string when the this flag is set.
+ *
+ * @return
+ * F_true if the caller should break or exit due to an error or something similar.
+ * F_false, otherwise.
+ *
+ * @see private_fl_fss_basic_write()
+ * @see f_string_dynamic_append()
+ * @see f_string_dynamic_strip_null()
+ *
+ * @see fl_fss_payload_header_map()
+ */
+#if !defined(_di_fl_fss_payload_header_map_)
+ extern uint8_t private_fl_payload_helper_header_map_destination_write_buffer_or_empty(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const buffer, f_string_maps_t * const destinations, const uint64_t append_on_empty) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+/**
+ * Write three quoted empty strings to the destination.
+ *
+ * @param data
+ * The f_fss_payload_header_state_t pointer.
+ * Must not be NULL.
+ * @param state
+ * The state passed directly from the fl_fss_payload_header_map() parameters.
+ *
+ * This alters state.status:
+ * F_okay on success.
+ *
+ * Errors (with error bit) from: private_fl_fss_basic_write().
+ * Errors (with error bit) from: f_string_dynamic_append().
+ * Errors (with error bit) from: f_string_dynamic_append_assure().
+ *
+ * Must not be NULL.
+ * @param internal
+ * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map().
+ * The internal.range is modified.
+ * Must not be NULL.
+ * @param destination
+ * The buffer to append to.
+ * Must not be NULL.
+ * @param separator
+ * The separate to use between each quoted empty string.
+ *
+ * @return
+ * F_true if the caller should break or exit due to an error or something similar.
+ * F_false, otherwise.
+ *
+ * @see private_fl_fss_basic_write()
+ * @see f_string_dynamic_append()
+ * @see f_string_dynamic_append_assure()
+ *
+ * @see fl_fss_payload_header_map()
+ */
+#if !defined(_di_fl_fss_payload_header_map_)
+ extern uint8_t private_fl_payload_helper_header_map_destination_write_empty_three(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const destination, const f_string_static_t separator) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+/**
+ * Write two quoted empty strings to the destination.
+ *
+ * @param data
+ * The f_fss_payload_header_state_t pointer.
+ * Must not be NULL.
+ * @param state
+ * The state passed directly from the fl_fss_payload_header_map() parameters.
+ *
+ * This alters state.status:
+ * F_okay on success.
+ *
+ * Errors (with error bit) from: private_fl_fss_basic_write().
+ * Errors (with error bit) from: f_string_dynamic_append().
+ * Errors (with error bit) from: f_string_dynamic_append_assure().
+ *
+ * Must not be NULL.
+ * @param internal
+ * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map().
+ * The internal.range is modified.
+ * Must not be NULL.
+ * @param destination
+ * The buffer to append to.
+ * Must not be NULL.
+ * @param separator
+ * The separate to use between each quoted empty string.
+ *
+ * @return
+ * F_true if the caller should break or exit due to an error or something similar.
+ * F_false, otherwise.
+ *
+ * @see private_fl_fss_basic_write()
+ * @see f_string_dynamic_append()
+ * @see f_string_dynamic_append_assure()
+ *
+ * @see fl_fss_payload_header_map()
+ */
+#if !defined(_di_fl_fss_payload_header_map_)
+ extern uint8_t private_fl_payload_helper_header_map_destination_write_empty_two(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const destination, const f_string_static_t separator) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_FL_fss_payload_helper_h
#include "payload.h"
#include "../private-fss.h"
#include "private-payload.h"
+#include "private-payload-helper.h"
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(_di_fl_fss_payload_header_map_)
- uint8_t private_fl_payload_header_map_cache_write(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal) {
-
- if (!data->cache->used) return F_false;
-
- internal->range.start = 0;
- internal->range.stop = data->cache->used - 1;
-
- private_fl_fss_basic_write(F_false, *data->cache, internal->quote, &internal->range, &internal->destinations->array[internal->destinations->used].value, state, (void * const) internal);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_strip_null(&internal->destinations->array[internal->destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = F_okay;
-
- return F_false;
- }
-#endif // !defined(_di_fl_fss_payload_header_map_)
-
-#if !defined(_di_fl_fss_payload_header_map_)
- uint8_t private_fl_payload_header_map_dynamic(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const buffer, f_string_maps_t * const destinations) {
-
- if (buffer->used) {
- internal->range.start = 0;
- internal->range.stop = buffer->used - 1;
-
- private_fl_fss_basic_write(F_false, *buffer, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value);
- }
- 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;
-
- state->status = F_okay;
-
- return F_false;
- }
-#endif // !defined(_di_fl_fss_payload_header_map_)
-
-#if !defined(_di_fl_fss_payload_header_map_)
uint8_t private_fl_payload_header_map_dynamics(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_statics_t * const buffers, f_string_maps_t * const destinations) {
if (buffers->used) {
if (F_status_is_error(state->status)) return F_true;
}
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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_map_multi_values_name_e) == f_fss_payload_header_map_flag_null_map_multi_values_name_e) {
if (F_status_is_error(state->status)) return F_true;
}
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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_map_value_name_e) == f_fss_payload_header_map_flag_null_map_value_name_e) {
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_header_map_cache_write(data, state, internal) == 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_header_map_cache_write(data, state, internal) == 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;
if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.total) == F_true) return F_true;
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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_join_quantity_e) {
data->cache->used = 0;
- state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- 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(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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 {
- state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, 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;
-
- 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(internal->quote_null, &destinations->array[destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
+ 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 (F_status_is_error(state->status)) return F_true;
}
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- 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(internal->quote_null, 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;
}
} // for
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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;
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_header_map_cache_write(data, state, internal) == 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;
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- 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(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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;
}
} // for
}
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_cache_write(data, state, internal) == 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;
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_header_map_cache_write(data, state, internal) == 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;
if (data->flag & f_fss_payload_header_map_flag_join_quantitys_quantity_e) {
data->cache->used = 0;
- state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_space_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(f_fss_space_s, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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 {
- state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, 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;
-
- 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(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(internal->quote_null, &destinations->array[destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
+ 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 (data->flag & f_fss_payload_header_map_flag_join_range_e) {
data->cache->used = 0;
- state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- 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(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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 {
- state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, 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;
-
- 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(internal->quote_null, &destinations->array[destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
+ 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 (data->flag & f_fss_payload_header_map_flag_join_range_e) {
if (private_fl_payload_header_map_number_unsigned(data, state, internal, range.stop) == F_true) return F_true;
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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_header_map_cache_write(data, state, internal) == 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;
if (private_fl_payload_header_map_number_unsigned(data, state, internal, range.stop) == F_true) return F_true;
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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 (F_status_is_error(state->status)) return F_true;
}
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- 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(internal->quote_null, 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;
}
continue;
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_header_map_cache_write(data, state, internal) == 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;
if (data->flag & f_fss_payload_header_map_flag_null_range_e) {
data->cache->used = 0;
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- 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(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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;
}
continue;
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_header_map_cache_write(data, state, internal) == 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 {
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;
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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;
if (F_status_is_error(state->status)) 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_header_map_cache_write(data, state, internal) == 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;
if (data->flag & f_fss_payload_header_map_flag_join_ranges_range_e) {
data->cache->used = 0;
- state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_space_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(f_fss_space_s, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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 {
- state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, 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;
-
- 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(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(internal->quote_null, &destinations->array[destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
+ 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 (data->flag & f_fss_payload_header_map_flag_join_triple_e) {
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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 {
state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value);
}
if (!(data->flag & f_fss_payload_header_map_flag_join_triples_e)) {
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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
if (data->flag & f_fss_payload_header_map_flag_join_triples_e) {
- if (private_fl_payload_header_map_cache_write(data, state, internal) == 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_join_triples_triple_e) {
data->cache->used = 0;
- state->status = f_memory_array_increase_by(internal->quote_null.used * 3 + f_fss_space_s.used * 2, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(f_fss_space_s, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(f_fss_space_s, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(internal->quote_null, data->cache);
- if (F_status_is_error(state->status)) return F_true;
-
- if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true;
+ if (private_fl_payload_helper_header_map_destination_write_empty_three(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 {
- state->status = f_memory_array_increase_by(internal->quote_null.used * 3 + f_fss_extended_next_s.used * 2, 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;
-
- 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(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(internal->quote_null, &destinations->array[destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
-
- state->status = f_string_dynamic_append(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(internal->quote_null, &destinations->array[destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
+ if (private_fl_payload_helper_header_map_destination_write_empty_three(data, state, internal, &destinations->array[destinations->used].value, f_fss_extended_next_s) == F_true) return F_true;
}
}
}
#endif
/**
- * Write the cache to the destination.
- *
- * @param data
- * The f_fss_payload_header_state_t pointer.
- * This caller must reset data.cache.used as needed.
- * if data.cache.used is not 0, then this will append a space before adding the converted number.
- * Must not be NULL.
- * @param state
- * The state passed directly from the fl_fss_payload_header_map() parameters.
- *
- * This alters state.status:
- * F_okay on success.
- *
- * Errors (with error bit) from: private_fl_fss_basic_write().
- * Errors (with error bit) from: f_string_dynamic_strip_null().
- *
- * Must not be NULL.
- * @param internal
- * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map().
- * The internal.range is modified.
- * Must not be NULL.
- *
- * @return
- * F_true if the caller should break or exit due to an error or something similar.
- * F_false, otherwise.
- *
- * @see private_fl_fss_basic_write()
- * @see f_string_dynamic_strip_null()
- *
- * @see fl_fss_payload_header_map()
- */
-#if !defined(_di_fl_fss_payload_header_map_)
- extern uint8_t private_fl_payload_header_map_cache_write(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal) F_attribute_visibility_internal_d;
-#endif // !defined(_di_fl_fss_payload_header_map_)
-
-/**
- * Process the dynamic string, writing it into the packet with the appropriate escaping as necessary.
- *
- * This expects that the appropriate used and flag checks are performed prior to calling this.
- *
- * @param data
- * The f_fss_payload_header_state_t pointer.
- * Must not be NULL.
- * @param state
- * The state passed directly from the fl_fss_payload_header_map() parameters.
- *
- * This alters state.status:
- * F_okay on success.
- *
- * Errors (with error bit) from: f_string_dynamic_strip_null().
- * Errors (with error bit) from: private_fl_fss_basic_write().
- *
- * Must not be NULL.
- * @param internal
- * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map().
- * Must not be NULL.
- * @param buffer
- * The dynamic string to read from.
- * Must not be NULL.
- * @param destinations
- * A map of strings representing the header names and values after being safely converted into the valid payload header format.
- * This built header names and values are appended onto this.
- * This is updated as appropriate.
- * Must not be NULL.
- *
- * @return
- * F_true if the caller should break or exit due to an error or something similar.
- * F_false, otherwise.
- *
- * @see f_string_dynamic_append()
- * @see f_string_dynamic_strip_null()
- *
- * @see private_fl_fss_basic_write()
- *
- * @see fl_fss_payload_header_map()
- */
-#if !defined(_di_fl_fss_payload_header_map_)
- extern uint8_t private_fl_payload_header_map_dynamic(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_static_t * const buffer, f_string_maps_t * const destinations) F_attribute_visibility_internal_d;
-#endif // !defined(_di_fl_fss_payload_header_map_)
-
-/**
* Process the array of dynamic strings, writing it into the packet with the appropriate escaping as necessary.
*
* This expects that the appropriate used and flag checks are performed prior to calling this.
/**
* Process the signed number, converting it to a string and appending that string onto data->cache.
+ *
* The resulting data->cache is then appended onto the destination value on success.
* If the number is not appended to data->cache, then nothing is appended to the destination value.
*
/**
* Process the unsigned number, converting it to a string and appending that string onto data->cache.
+ *
* The resulting data->cache is then appended onto the destination value on success.
* If the number is not appended to data->cache, then nothing is appended to the destination value.
*
* Errors (with error bit) from: f_string_dynamic_append().
* Errors (with error bit) from: f_string_dynamic_append_assure().
* Errors (with error bit) from: private_fl_fss_basic_write().
- * Errors (with error bit) from: private_fl_payload_header_map_cache_write().
* Errors (with error bit) from: private_fl_payload_header_map_number_unsigned().
+ * Errors (with error bit) from: private_fl_payload_helper_header_map_destination_write_buffer().
*
* Must not be NULL.
* @param internal
* Errors (with error bit) from: f_string_dynamic_append().
* Errors (with error bit) from: f_string_dynamic_append_assure().
* Errors (with error bit) from: private_fl_fss_basic_write().
- * Errors (with error bit) from: private_fl_payload_header_map_cache_write().
* Errors (with error bit) from: private_fl_payload_header_map_number_unsigned().
+ * Errors (with error bit) from: private_fl_payload_helper_header_map_destination_write_buffer().
*
* Must not be NULL.
* @param internal
* Errors (with error bit) from: f_string_dynamic_append().
* Errors (with error bit) from: f_string_dynamic_append_assure().
* Errors (with error bit) from: private_fl_fss_basic_write().
- * Errors (with error bit) from: private_fl_payload_header_map_cache_write().
* Errors (with error bit) from: private_fl_payload_header_map_number_unsigned().
+ * Errors (with error bit) from: private_fl_payload_helper_header_map_destination_write_buffer().
*
* Must not be NULL.
* @param internal
build_libraries -lc
build_libraries-individual -lf_abstruse -lf_conversion -lf_file -lf_fss -lf_memory -lf_string -lf_type_array -lf_utf
-build_sources_library private-fss.c fss/basic.c fss/basic_list.c fss/embedded_list.c fss/extended.c fss/extended_list.c fss/payload.c fss/private-payload.c
+build_sources_library private-fss.c fss/basic.c fss/basic_list.c fss/embedded_list.c fss/extended.c fss/extended_list.c fss/payload.c fss/private-payload.c fss/private-payload-helper.c
build_sources_headers fss.h fss/basic.h fss/basic_list.h fss/embedded_list.h fss/extended.h fss/extended_list.h fss/payload.h fss/payload/define.h fss/payload/type.h
build_sources_program test-fss-extended_content_read.c test-fss-extended_content_write.c test-fss-extended_object_read.c test-fss-extended_object_write.c
build_sources_program test-fss-extended_list_content_read.c test-fss-extended_list_content_write.c test-fss-extended_list_object_read.c test-fss-extended_list_object_write.c
build_sources_program test-fss-payload_header_map.c
+build_sources_program test-fss-payload_header_map-abstruse_signed.c test-fss-payload_header_map-abstruse_unsigned.c
-build_sources_program test-fss.c data-fss.c
+build_sources_program test-fss.c data-fss.c help-fss.c
build_script no
build_shared yes
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+555
+1
+7777
--- /dev/null
+c
+1
+012345
+1
+-32700
+1
+-1
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55555
+1
+77777777
--- /dev/null
+c
+1
+123456789
+1
+-2147483600
+1
+-1
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55555
+1
+77777777
--- /dev/null
+c
+1
+123456789
+1
+-9876543210
+1
+-1
+1
+-9223372036854775000
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55
+1
+77
--- /dev/null
+c
+1
+12
+1
+-120
+1
+-1
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55555
+1
+77777777
--- /dev/null
+c
+1
+123456789
+1
+-9876543210
+1
+-1
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55555
+1
+7777
--- /dev/null
+c
+1
+1234
+1
+65500
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55555
+1
+77777777
--- /dev/null
+c
+1
+123456789
+1
+4294967200
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55555
+1
+77777777
--- /dev/null
+c
+1
+123456789
+1
+9876543210
+1
+18446744073709550000
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55
+1
+77
--- /dev/null
+c
+1
+25
+1
+250
--- /dev/null
+a
+1
+0
+1
+1
+1
+2
+1
+3
--- /dev/null
+b
+1
+44
+1
+55555
+1
+77777777
--- /dev/null
+c
+1
+123456789
+1
+9876543210
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+555
+7777
+c
+3
+012345
+-32700
+-1
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55555
+77777777
+c
+3
+0123456789
+-2147483600
+-1
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55555
+77777777
+c
+4
+0123456789
+-9876543210
+-1
+-9223372036854775000
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55
+77
+c
+3
+012
+-120
+-1
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55555
+77777777
+c
+3
+0123456789
+-9876543210
+-1
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55555
+7777
+c
+2
+01234
+65500
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55555
+77777777
+c
+2
+0123456789
+4294967200
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55555
+77777777
+c
+3
+0123456789
+9876543210
+18446744073709550000
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55
+77
+c
+2
+025
+250
--- /dev/null
+a
+4
+0
+1
+2
+3
+b
+3
+44
+55555
+77777777
+c
+2
+0123456789
+9876543210
-#include "data-fss.h"
+#include "test-fss.h"
#ifdef __cplusplus
extern "C" {
#endif
-FILE *data__file_open__named__all_read(const f_string_t set, const f_string_t name) {
+FILE *data__file_open__named(const f_string_t set, const f_string_t name, const f_string_t context) {
+
char path[255];
memset(path, 0, 255);
- snprintf(path, 254, "./data/tests/%s/%s-all_read.txt", set, name);
+ snprintf(path, 254, "./data/tests/%s/%s-%s.txt", set, name, context);
return fopen(path, "r");
}
-FILE *data__file_open__named_at__all_read(const f_string_t set, const f_string_t name, const uint8_t at) {
+FILE *data__file_open__named_at(const f_string_t set, const f_string_t name, const f_string_t context, const uint16_t at) {
+
char path[255];
memset(path, 0, 255);
- snprintf(path, 254, "./data/tests/%s/%s-all_read-%d.txt", set, name, at);
+ snprintf(path, 254, "./data/tests/%s/%s-%s-%d.txt", set, name, context, at);
return fopen(path, "r");
}
#include <stdint.h>
#include <stdio.h>
-// FLL-0 includes.
-
-// FLL-1 includes.
-#include <fll/level_1/fss.h>
-#include <fll/level_1/fss/basic.h>
-#include <fll/level_1/fss/basic_list.h>
-#include <fll/level_1/fss/embedded_list.h>
-#include <fll/level_1/fss/extended.h>
-#include <fll/level_1/fss/extended_list.h>
-#include <fll/level_1/fss/payload.h>
-
#ifdef __cplusplus
extern "C" {
#endif
*
* This requires the following:
* - The file path is relative to the current working directory (tests are run from project root).
- * - The file path is "data/tests/${set}/${name}-all_read.txt".
+ * - The file path is "data/tests/${set}/${name}-${context}.txt".
* - Where "${set}" represents the directory set, like "contents", "objects", or "strings".
* - Where "${name}" represents the standard name, such as "basic" or "extended".
+ * - Where "${context}" represents the test context, such as "all_read" or "header_map".
*
+ * @param set
+ * The name of the test set, representing the directory the the files are stored within.
+ * @param context
+ * The test file directory set.
+ * @param name
+ * The test file standard name.
* @param at
* A number representing the specific content index position.
*
*
* @see fopen()
*/
-extern FILE *data__file_open__named__all_read(const f_string_t set, const f_string_t name);
+extern FILE *data__file_open__named(const f_string_t set, const f_string_t name, const f_string_t context);
/**
* Open the test data file for the given set with the given name and the given at index.
*
* This requires the following:
* - The file path is relative to the current working directory (tests are run from project root).
- * - The file path is "data/tests/${set}/${name}-all_read-${at}.txt".
+ * - The file path is "data/tests/${set}/${name}-${context}-${at}.txt".
+ * - Where "${set}" represents the directory set, like "contents", "headers", "objects", "strings", or "variables".
+ * - Where "${name}" represents the standard name, such as "basic", "extended", or "payload".
+ * - Where "${context}" represents the test context, such as "all_read" or "abstruse_signed".
* - Where "${at}" represents the index.
- * - Where "${set}" represents the directory set, like "contents", "objects", or "strings".
- * - Where "${name}" represents the standard name, such as "basic" or "extended".
*
+ * @param set
+ * The name of the test set, representing the directory the the files are stored within.
+ * @param context
+ * The test file directory set.
+ * @param name
+ * The test file standard name.
* @param at
* A number representing the specific content index position.
*
*
* @see fopen()
*/
-extern FILE *data__file_open__named_at__all_read(const f_string_t set, const f_string_t name, const uint8_t at);
+extern FILE *data__file_open__named_at(const f_string_t set, const f_string_t name, const f_string_t context, const uint16_t at);
#ifdef __cplusplus
} // extern "C"
--- /dev/null
+#include "test-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+uint8_t help__read_line_contents__single(FILE *file, f_string_dynamics_t * const contents) {
+
+ size_t max = 255;
+ char *line_string = 0;
+
+ ssize_t result = getline(&line_string, &max, file);
+
+ if (result == -1) {
+ if (line_string) free(line_string);
+
+ return F_true;
+ }
+
+ assert_int_not_equal(result, 0);
+ assert_int_not_equal(line_string[0], 0);
+
+ const f_number_unsigned_t count = (f_number_unsigned_t) atoi(line_string);
+
+ if (!count) {
+ assert_int_equal(line_string[0], '0');
+ }
+
+ contents->used = 0;
+
+ {
+ const f_status_t status = f_memory_array_increase_by(count, sizeof(f_string_dynamic_t), (void **) &contents->array, &contents->used, &contents->size);
+ assert_true(F_status_is_error_not(status));
+ }
+
+ for (; contents->used < count; ++contents->used) {
+
+ max = 255;
+ contents->array[contents->used].used = 0;
+
+ const f_status_t status = f_memory_array_increase_by(max, sizeof(f_string_t), (void **) &contents->array[contents->used].string, &contents->array[contents->used].used, &contents->array[contents->used].size);
+ assert_true(F_status_is_error_not(status));
+
+ result = getline(&contents->array[contents->used].string, &max, file);
+ assert_int_not_equal(result, -1);
+ assert_int_not_equal(result, 0);
+
+ contents->array[contents->used].used = ((f_number_unsigned_t) result) - 1;
+ contents->array[contents->used].string[contents->array[contents->used].used] = 0;
+ } // for
+
+ if (line_string) free(line_string);
+
+ return F_false;
+}
+
+uint8_t help__read_line_expects__single(FILE *file, const f_string_static_t object, f_string_maps_t * const expects) {
+
+ size_t max = 255;
+ char *line_string = 0;
+ f_status_t status = F_okay;
+
+ ssize_t result = getline(&line_string, &max, file);
+
+ if (result == -1) {
+ if (line_string) free(line_string);
+
+ return F_true;
+ }
+
+ assert_int_not_equal(result, 0);
+ assert_int_not_equal(line_string[0], 0);
+
+ const f_number_unsigned_t count = (f_number_unsigned_t) atoi(line_string);
+
+ if (!count) {
+ assert_int_equal(line_string[0], '0');
+ }
+
+ status = f_memory_array_increase_by(count, sizeof(f_string_map_t), (void **) &expects->array, &expects->used, &expects->size);
+ assert_true(F_status_is_error_not(status));
+
+ for (f_number_unsigned_t i = 0; i < count; ++i, ++expects->used) {
+
+ max = 255;
+ expects->array[expects->used].name.used = 0;
+ expects->array[expects->used].value.used = 0;
+
+ status = f_string_dynamic_append(object, &expects->array[expects->used].name);
+ assert_true(F_status_is_error_not(status));
+
+ status = f_string_dynamic_terminate_after(&expects->array[expects->used].name);
+ assert_true(F_status_is_error_not(status));
+
+ status = f_memory_array_increase_by(max, sizeof(f_string_t), (void **) &expects->array[expects->used].value.string, &expects->array[expects->used].value.used, &expects->array[expects->used].value.size);
+ assert_true(F_status_is_error_not(status));
+
+ result = getline(&expects->array[expects->used].value.string, &max, file);
+ assert_int_not_equal(result, -1);
+ assert_int_not_equal(result, 0);
+
+ expects->array[expects->used].value.used = ((f_number_unsigned_t) result) - 1;
+ expects->array[expects->used].value.string[expects->array[expects->used].value.used] = 0;
+ } // for
+
+ if (line_string) free(line_string);
+
+ return F_false;
+}
+
+uint8_t help__read_line_object(FILE *file, f_string_dynamic_t * const object) {
+
+ size_t max = 255;
+
+ object->used = 0;
+
+ const f_status_t status = f_memory_array_increase_by(max, sizeof(f_string_t), (void **) &object->string, &object->used, &object->size);
+ assert_true(F_status_is_error_not(status));
+
+ const ssize_t result = getline(&object->string, &max, file);
+ if (result == -1) return F_true;
+
+ assert_int_not_equal(result, 0);
+
+ object->used = ((f_number_unsigned_t) result) - 1;
+ object->string[object->used] = 0;
+
+ return F_false;
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 1
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Helper for the fss project tests.
+ */
+#ifndef _HELP__FL_fss_h
+#define _HELP__FL_fss_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Load the content lines from the given file.
+ *
+ * This first loads the content line total followed by each content line according to that total.
+ *
+ * The content read is treated each as a single, separate, map value.
+ *
+ * @param file
+ * The file to use.
+ * Must not be NULL.
+ * @param contents
+ * The array of contents to use.
+ * Must not be NULL.
+ *
+ * @return
+ * F_true if there is no content left to read in the file.
+ * F_false otherwise.
+ */
+uint8_t help__read_line_contents__single(FILE *file, f_string_dynamics_t * const contents);
+
+/**
+ * Load the expect lines from the given file.
+ *
+ * This first loads the expect line total followed by each expect line according to that total.
+ *
+ * The expect read is treated each as a single, separate, map value.
+ *
+ * @param file
+ * The file to use.
+ * Must not be NULL.
+ * @param object
+ * The object name to associate with each expected content.
+ * @param expects
+ * The array of expects to use.
+ * Must not be NULL.
+ *
+ * @return
+ * F_true if there is no expect left to read in the file.
+ * F_false otherwise.
+ */
+uint8_t help__read_line_expects__single(FILE *file, const f_string_static_t object, f_string_maps_t * const expects);
+
+/**
+ * Load the object line from the given file.
+ *
+ * The object line is required to exist in the file.
+ *
+ * @param file
+ * The file to use.
+ * Must not be NULL.
+ * @param object
+ * The string to use.
+ * The used is set to the size of the string read, without the EOL.
+ * Must not be NULL.
+ *
+ * @return
+ * F_true if there is no object left to read in the file.
+ * F_false otherwise.
+ */
+uint8_t help__read_line_object(FILE *file, f_string_dynamic_t * const object);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _HELP__FL_fss_h
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__file_open__named__all_read("strings", "basic");
- FILE *file_contents = data__file_open__named__all_read("contents", "basic");
+ FILE *file_strings = data__file_open__named("strings", "basic", "all_read");
+ FILE *file_contents = data__file_open__named("contents", "basic", "all_read");
assert_non_null(file_strings);
assert_non_null(file_contents);
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__file_open__named__all_read("strings", "basic_list");
+ FILE *file_strings = data__file_open__named("strings", "basic_list", "all_read");
FILE *file_contents[] = {
- data__file_open__named_at__all_read("contents", "basic_list", 0),
- data__file_open__named_at__all_read("contents", "basic_list", 1),
- data__file_open__named_at__all_read("contents", "basic_list", 2),
- data__file_open__named_at__all_read("contents", "basic_list", 3),
- data__file_open__named_at__all_read("contents", "basic_list", 4),
- data__file_open__named_at__all_read("contents", "basic_list", 5),
- data__file_open__named_at__all_read("contents", "basic_list", 6),
- data__file_open__named_at__all_read("contents", "basic_list", 7),
- data__file_open__named_at__all_read("contents", "basic_list", 8),
- data__file_open__named_at__all_read("contents", "basic_list", 9),
- data__file_open__named_at__all_read("contents", "basic_list", 10),
- data__file_open__named_at__all_read("contents", "basic_list", 11),
+ data__file_open__named_at("contents", "basic_list", "all_read", 0),
+ data__file_open__named_at("contents", "basic_list", "all_read", 1),
+ data__file_open__named_at("contents", "basic_list", "all_read", 2),
+ data__file_open__named_at("contents", "basic_list", "all_read", 3),
+ data__file_open__named_at("contents", "basic_list", "all_read", 4),
+ data__file_open__named_at("contents", "basic_list", "all_read", 5),
+ data__file_open__named_at("contents", "basic_list", "all_read", 6),
+ data__file_open__named_at("contents", "basic_list", "all_read", 7),
+ data__file_open__named_at("contents", "basic_list", "all_read", 8),
+ data__file_open__named_at("contents", "basic_list", "all_read", 9),
+ data__file_open__named_at("contents", "basic_list", "all_read", 10),
+ data__file_open__named_at("contents", "basic_list", "all_read", 11),
};
assert_non_null(file_strings);
void test__fl_fss_basic_list_object_read__works(void **void_state) {
{
- FILE *file_strings = data__file_open__named__all_read("strings", "basic_list");
- FILE *file_objects = data__file_open__named__all_read("objects", "basic_list");
+ FILE *file_strings = data__file_open__named("strings", "basic_list", "all_read");
+ FILE *file_objects = data__file_open__named("objects", "basic_list", "all_read");
assert_non_null(file_strings);
assert_non_null(file_objects);
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__file_open__named__all_read("strings", "basic");
- FILE *file_objects = data__file_open__named__all_read("objects", "basic");
+ FILE *file_strings = data__file_open__named("strings", "basic", "all_read");
+ FILE *file_objects = data__file_open__named("objects", "basic", "all_read");
assert_non_null(file_strings);
assert_non_null(file_objects);
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__file_open__named__all_read("strings", "embedded_list");
+ FILE *file_strings = data__file_open__named("strings", "embedded_list", "all_read");
FILE *file_contents[] = {
- data__file_open__named_at__all_read("contents", "embedded_list", 0),
- data__file_open__named_at__all_read("contents", "embedded_list", 1),
- data__file_open__named_at__all_read("contents", "embedded_list", 2),
- data__file_open__named_at__all_read("contents", "embedded_list", 3),
- data__file_open__named_at__all_read("contents", "embedded_list", 4),
- data__file_open__named_at__all_read("contents", "embedded_list", 5),
- data__file_open__named_at__all_read("contents", "embedded_list", 6),
- data__file_open__named_at__all_read("contents", "embedded_list", 7),
- data__file_open__named_at__all_read("contents", "embedded_list", 8),
- data__file_open__named_at__all_read("contents", "embedded_list", 9),
- data__file_open__named_at__all_read("contents", "embedded_list", 10),
- data__file_open__named_at__all_read("contents", "embedded_list", 11),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 0),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 1),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 2),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 3),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 4),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 5),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 6),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 7),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 8),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 9),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 10),
+ data__file_open__named_at("contents", "embedded_list", "all_read", 11),
};
assert_non_null(file_strings);
void test__fl_fss_embedded_list_object_read__works(void **void_state) {
{
- FILE *file_strings = data__file_open__named__all_read("strings", "embedded_list");
- FILE *file_objects = data__file_open__named__all_read("objects", "embedded_list");
+ FILE *file_strings = data__file_open__named("strings", "embedded_list", "all_read");
+ FILE *file_objects = data__file_open__named("objects", "embedded_list", "all_read");
assert_non_null(file_strings);
assert_non_null(file_objects);
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__file_open__named__all_read("strings", "extended");
+ FILE *file_strings = data__file_open__named("strings", "extended", "all_read");
FILE *file_contents[] = {
- data__file_open__named_at__all_read("contents", "extended", 0),
- data__file_open__named_at__all_read("contents", "extended", 1),
- data__file_open__named_at__all_read("contents", "extended", 2),
- data__file_open__named_at__all_read("contents", "extended", 3),
- data__file_open__named_at__all_read("contents", "extended", 4),
- data__file_open__named_at__all_read("contents", "extended", 5),
- data__file_open__named_at__all_read("contents", "extended", 6),
- data__file_open__named_at__all_read("contents", "extended", 7),
+ data__file_open__named_at("contents", "extended", "all_read", 0),
+ data__file_open__named_at("contents", "extended", "all_read", 1),
+ data__file_open__named_at("contents", "extended", "all_read", 2),
+ data__file_open__named_at("contents", "extended", "all_read", 3),
+ data__file_open__named_at("contents", "extended", "all_read", 4),
+ data__file_open__named_at("contents", "extended", "all_read", 5),
+ data__file_open__named_at("contents", "extended", "all_read", 6),
+ data__file_open__named_at("contents", "extended", "all_read", 7),
};
assert_non_null(file_strings);
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__file_open__named__all_read("strings", "extended_list");
+ FILE *file_strings = data__file_open__named("strings", "extended_list", "all_read");
FILE *file_contents[] = {
- data__file_open__named_at__all_read("contents", "extended_list", 0),
- data__file_open__named_at__all_read("contents", "extended_list", 1),
- data__file_open__named_at__all_read("contents", "extended_list", 2),
- data__file_open__named_at__all_read("contents", "extended_list", 3),
- data__file_open__named_at__all_read("contents", "extended_list", 4),
- data__file_open__named_at__all_read("contents", "extended_list", 5),
- data__file_open__named_at__all_read("contents", "extended_list", 6),
- data__file_open__named_at__all_read("contents", "extended_list", 7),
- data__file_open__named_at__all_read("contents", "extended_list", 8),
- data__file_open__named_at__all_read("contents", "extended_list", 9),
- data__file_open__named_at__all_read("contents", "extended_list", 10),
- data__file_open__named_at__all_read("contents", "extended_list", 11),
+ data__file_open__named_at("contents", "extended_list", "all_read", 0),
+ data__file_open__named_at("contents", "extended_list", "all_read", 1),
+ data__file_open__named_at("contents", "extended_list", "all_read", 2),
+ data__file_open__named_at("contents", "extended_list", "all_read", 3),
+ data__file_open__named_at("contents", "extended_list", "all_read", 4),
+ data__file_open__named_at("contents", "extended_list", "all_read", 5),
+ data__file_open__named_at("contents", "extended_list", "all_read", 6),
+ data__file_open__named_at("contents", "extended_list", "all_read", 7),
+ data__file_open__named_at("contents", "extended_list", "all_read", 8),
+ data__file_open__named_at("contents", "extended_list", "all_read", 9),
+ data__file_open__named_at("contents", "extended_list", "all_read", 10),
+ data__file_open__named_at("contents", "extended_list", "all_read", 11),
};
assert_non_null(file_strings);
void test__fl_fss_extended_list_object_read__works(void **void_state) {
{
- FILE *file_strings = data__file_open__named__all_read("strings", "extended_list");
- FILE *file_objects = data__file_open__named__all_read("objects", "extended_list");
+ FILE *file_strings = data__file_open__named("strings", "extended_list", "all_read");
+ FILE *file_objects = data__file_open__named("objects", "extended_list", "all_read");
assert_non_null(file_strings);
assert_non_null(file_objects);
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__file_open__named__all_read("strings", "extended");
- FILE *file_objects = data__file_open__named__all_read("objects", "extended");
+ FILE *file_strings = data__file_open__named("strings", "extended", "all_read");
+ FILE *file_objects = data__file_open__named("objects", "extended", "all_read");
assert_non_null(file_strings);
assert_non_null(file_objects);
f_string_dynamic_t result_string = f_string_dynamic_t_initialize;
f_string_dynamic_t delimit_string = f_string_dynamic_t_initialize;
- for (int line = 0; ; ++line) {
+ for (;;) {
max = 255;
--- /dev/null
+#include "test-fss.h"
+#include "test-fss-payload_header_map-abstruse_signed.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__fl_fss_payload_header_map__abstruse_signed__works_combined(void **void_state) {
+
+ // Note: Each line should probably be at max 255 characters.
+ // The payload begins with a digit on the first line representing the number of Content lines following the Object line.
+ // Following the digit is a single Object line.
+ // Following the Object line is a line for each Content designated by the first line (can be 0).
+ // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file.
+ FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_signed");
+ FILE *file_headers = 0;
+
+ assert_non_null(file_variables);
+
+ f_abstruse_maps_t headers = f_abstruse_maps_t_initialize;
+ f_state_t state = f_state_t_initialize;
+ f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize;
+ f_string_dynamic_t object = f_string_dynamic_t_initialize;
+ f_string_dynamics_t contents = f_string_dynamics_t_initialize;
+ f_string_dynamic_t cache = f_string_dynamic_t_initialize;
+ f_string_maps_t destinations = f_string_maps_t_initialize;
+ f_string_maps_t expects = f_string_maps_t_initialize;
+
+ {
+ state.status = F_none;
+ state.data = &data;
+ data.cache = &cache;
+
+ for (uint16_t at = 0; ; ++at) {
+
+ if (help__read_line_object(file_variables, &object)) break;
+ if (help__read_line_contents__single(file_variables, &contents)) break;
+
+ state.status = f_memory_array_increase_by(contents.used, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
+ assert_true(F_status_is_error_not(state.status));
+
+ for (f_number_unsigned_t i = 0; i < contents.used; ++i, ++headers.used) {
+
+ const f_number_signed_t number = atoll(contents.array[i].string);
+
+ if (!number) {
+ assert_int_equal(contents.array[i].string[0], '0');
+ }
+
+ headers.array[headers.used].key.used = 0;
+
+ state.status = f_string_dynamic_append(object, &headers.array[headers.used].key);
+ assert_int_equal(state.status, F_okay);
+
+ headers.array[headers.used].value.type = f_abstruse_signed_e;
+ headers.array[headers.used].value.is.a_signed = number;
+ } // for
+
+ if (object.string) free(object.string);
+
+ object.string = 0;
+ object.used = 0;
+ object.size = 0;
+
+ file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_signed", at);
+ assert_non_null(file_headers);
+
+ help__read_line_object(file_headers, &object);
+
+ for (;;) {
+ state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size);
+ assert_true(F_status_is_error_not(state.status));
+
+ if (help__read_line_expects__single(file_headers, object, &expects)) break;
+ } // for
+
+ fl_fss_payload_header_map(headers, &destinations, &state);
+ assert_int_equal(state.status, F_okay);
+ assert_int_equal(destinations.used, expects.used);
+
+ for (f_number_unsigned_t i = 0; i < destinations.used; ++i) {
+
+ assert_int_equal(destinations.array[i].name.used, expects.array[i].name.used);
+ assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used);
+
+ assert_string_equal(destinations.array[i].name.string, expects.array[i].name.string);
+ assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string);
+ } // for
+
+ if (object.string) free(object.string);
+ if (cache.string) free(cache.string);
+ if (file_headers) fclose(file_headers);
+
+ f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback);
+
+ file_headers = 0;
+
+ object.string = 0;
+ object.used = 0;
+ object.size = 0;
+
+ cache.string = 0;
+ cache.used = 0;
+ cache.size = 0;
+
+ contents.array = 0;
+ contents.used = 0;
+ contents.size = 0;
+
+ headers.array = 0;
+ headers.used = 0;
+ headers.size = 0;
+
+ destinations.array = 0;
+ destinations.used = 0;
+ destinations.size = 0;
+
+ expects.array = 0;
+ expects.used = 0;
+ expects.size = 0;
+ } // for
+ }
+
+ if (file_variables) fclose(file_variables);
+ if (file_headers) fclose(file_headers);
+
+ if (object.string) free(object.string);
+ if (cache.string) free(cache.string);
+
+ f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * 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_signed_h
+#define _TEST__FL_fss_payload_header_map__abstruse_signed_h
+
+/**
+ * Test that the function works for abstruse_signed type.
+ *
+ * @see fl_fss_payload_header_map()
+ */
+extern void test__fl_fss_payload_header_map__abstruse_signed__works_combined(void **state);
+
+#endif // _TEST__FL_fss_payload_header_map__abstruse_signed_h
--- /dev/null
+#include "test-fss.h"
+#include "test-fss-payload_header_map-abstruse_unsigned.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__fl_fss_payload_header_map__abstruse_unsigned__works_combined(void **void_state) {
+
+ // Note: Each line should probably be at max 255 characters.
+ // The payload begins with a digit on the first line representing the number of Content lines following the Object line.
+ // Following the digit is a single Object line.
+ // Following the Object line is a line for each Content designated by the first line (can be 0).
+ // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file.
+ FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_unsigned");
+ FILE *file_headers = 0;
+
+ assert_non_null(file_variables);
+
+ f_abstruse_maps_t headers = f_abstruse_maps_t_initialize;
+ f_state_t state = f_state_t_initialize;
+ f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize;
+ f_string_dynamic_t object = f_string_dynamic_t_initialize;
+ f_string_dynamics_t contents = f_string_dynamics_t_initialize;
+ f_string_dynamic_t cache = f_string_dynamic_t_initialize;
+ f_string_maps_t destinations = f_string_maps_t_initialize;
+ f_string_maps_t expects = f_string_maps_t_initialize;
+
+ {
+ state.status = F_none;
+ state.data = &data;
+ data.cache = &cache;
+
+ for (uint16_t at = 0; ; ++at) {
+
+ if (help__read_line_object(file_variables, &object)) break;
+ if (help__read_line_contents__single(file_variables, &contents)) break;
+
+ state.status = f_memory_array_increase_by(contents.used, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
+ assert_true(F_status_is_error_not(state.status));
+
+ for (f_number_unsigned_t i = 0; i < contents.used; ++i, ++headers.used) {
+
+ const f_number_unsigned_t number = atoll(contents.array[i].string);
+
+ if (!number) {
+ assert_int_equal(contents.array[i].string[0], '0');
+ }
+
+ headers.array[headers.used].key.used = 0;
+
+ state.status = f_string_dynamic_append(object, &headers.array[headers.used].key);
+ assert_int_equal(state.status, F_okay);
+
+ headers.array[headers.used].value.type = f_abstruse_unsigned_e;
+ headers.array[headers.used].value.is.a_unsigned = number;
+ } // for
+
+ if (object.string) free(object.string);
+
+ object.string = 0;
+ object.used = 0;
+ object.size = 0;
+
+ file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_unsigned", at);
+ assert_non_null(file_headers);
+
+ help__read_line_object(file_headers, &object);
+
+ for (;;) {
+ state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size);
+ assert_true(F_status_is_error_not(state.status));
+
+ if (help__read_line_expects__single(file_headers, object, &expects)) break;
+ } // for
+
+ fl_fss_payload_header_map(headers, &destinations, &state);
+ assert_int_equal(state.status, F_okay);
+ assert_int_equal(destinations.used, expects.used);
+
+ for (f_number_unsigned_t i = 0; i < destinations.used; ++i) {
+
+ assert_int_equal(destinations.array[i].name.used, expects.array[i].name.used);
+ assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used);
+
+ assert_string_equal(destinations.array[i].name.string, expects.array[i].name.string);
+ assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string);
+ } // for
+
+ if (object.string) free(object.string);
+ if (cache.string) free(cache.string);
+ if (file_headers) fclose(file_headers);
+
+ f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback);
+
+ file_headers = 0;
+
+ object.string = 0;
+ object.used = 0;
+ object.size = 0;
+
+ cache.string = 0;
+ cache.used = 0;
+ cache.size = 0;
+
+ contents.array = 0;
+ contents.used = 0;
+ contents.size = 0;
+
+ headers.array = 0;
+ headers.used = 0;
+ headers.size = 0;
+
+ destinations.array = 0;
+ destinations.used = 0;
+ destinations.size = 0;
+
+ expects.array = 0;
+ expects.used = 0;
+ expects.size = 0;
+ } // for
+ }
+
+ if (file_variables) fclose(file_variables);
+ if (file_headers) fclose(file_headers);
+
+ if (object.string) free(object.string);
+ if (cache.string) free(cache.string);
+
+ f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback);
+ f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback);
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * 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_unsigned_h
+#define _TEST__FL_fss_payload_header_map__abstruse_unsigned_h
+
+/**
+ * Test that the function works for abstruse_unsigned type.
+ *
+ * @see fl_fss_payload_header_map()
+ */
+extern void test__fl_fss_payload_header_map__abstruse_unsigned__works_combined(void **state);
+
+#endif // _TEST__FL_fss_payload_header_map__abstruse_unsigned_h
cmocka_unit_test(test__fl_fss_extended_list_object_read__works),
cmocka_unit_test(test__fl_fss_payload_header_map__returns_data_not),
+ cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signed__works_combined),
+ cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_unsigned__works_combined),
#ifndef _di_level_0_parameter_checking_
cmocka_unit_test(test__fl_fss_basic_content_read__parameter_checking),
#include <setjmp.h>
#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
// Data includes.
#include "data-fss.h"
+#include "help-fss.h"
// Test includes.
#include "test-fss-basic_content_read.h"
#include "test-fss-extended_list_object_read.h"
#include "test-fss-extended_list_object_write.h"
#include "test-fss-payload_header_map.h"
+#include "test-fss-payload_header_map-abstruse_signed.h"
+#include "test-fss-payload_header_map-abstruse_unsigned.h"
#ifdef __cplusplus
extern "C" {