Switch character width loops with memcpy().
Add cases where trailing string should be removed.
Make sure private_fl_fss_basic_write() is only called when the cache is not empty.
Make sue the internal.range is properly set when calling private_fl_fss_basic_write().
Ensure that when any quote is used that they get quoted where appropriate.
Ensure that when key has used of 0, the start range is greater than the stop range to designate a NULL range.
Add dynamic, dynamics, and map unit tests.
Make the tests test the string first rather than the used so that when there is an error it is easier to debug.
Remove unused/stale commented out code.
Switch fss_write flag from 16-bit into 32-bit.
This is necessary because more bits than 16 are in use.
}
const f_number_unsigned_t destination_used = destination->used;
-
- f_number_unsigned_t i = 0;
f_number_unsigned_t slash_count = 0;
uint8_t width = 0;
state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
}
state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
state->status = f_utf_buffer_increment(object, range, 1);
if (F_status_is_error(state->status)) return;
const f_number_unsigned_t destination_used = destination->used;
-
- f_number_unsigned_t i = 0;
f_number_unsigned_t slash_count = 0;
bool ends_on_space = F_false;
state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
}
state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
state->status = f_utf_buffer_increment(object, range, 1);
bool has_graph = F_false;
bool do_prepend = prepend ? F_true : F_false;
- f_number_unsigned_t i = 0;
f_number_unsigned_t r = 0;
f_number_unsigned_t slash_count = 0;
f_number_unsigned_t start = 0;
state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = content.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, content.string + range->start, width);
+
+ destination->used += width;
}
state->status = f_utf_buffer_increment(content, range, 1);
const f_number_unsigned_t destination_used = destination->used;
- f_number_unsigned_t i = 0;
f_number_unsigned_t slash_count = 0;
bool ends_on_space = F_false;
state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
}
state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
state->status = f_utf_buffer_increment(object, range, 1);
destinations->array[destinations->used].key.used = 0;
destinations->array[destinations->used].value.used = 0;
- internal.range.start = 0;
+ internal.range.start = headers.array[internal.i].key.used ? 0 : 1;
internal.range.stop = headers.array[internal.i].key.used ? headers.array[internal.i].key.used - 1 : 0;
private_fl_fss_basic_write(F_true, headers.array[internal.i].key, internal.quote, &internal.range, &destinations->array[destinations->used].key, state, (void * const) &internal);
}
}
}
+ else if (destinations->array[destinations->used].value.used) {
+
+ // Remove the always added trailing extended next.
+ destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used;
+ }
}
else {
if (data->flag & f_fss_payload_header_map_flag_null_dynamic_e) {
data->cache->used -= f_fss_space_s.used;
}
- private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
- if (F_status_is_error(state->status)) return F_true;
+ if (data->cache->used) {
+ internal->range.start = 0;
+ internal->range.stop = data->cache->used - 1;
+
+ private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
+ if (F_status_is_error(state->status)) return F_true;
+ }
}
else {
if (map->key.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) {
data->cache->used -= f_fss_space_s.used;
}
- private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
- if (F_status_is_error(state->status)) return F_true;
+ if (data->cache->used) {
+ internal->range.start = 0;
+ internal->range.stop = data->cache->used - 1;
+
+ private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
+ if (F_status_is_error(state->status)) return F_true;
+ }
}
else {
if (map->key.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e)) {
data->cache->used -= f_fss_space_s.used;
}
- private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
- if (F_status_is_error(state->status)) return F_true;
+ if (data->cache->used) {
+ internal->range.start = 0;
+ internal->range.stop = data->cache->used - 1;
+
+ private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
+ if (F_status_is_error(state->status)) return F_true;
+ }
}
else if (data->flag & f_fss_payload_header_map_flag_join_map_multi_e) {
data->cache->used = 0;
data->cache->used -= f_fss_space_s.used;
}
- private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
- if (F_status_is_error(state->status)) return F_true;
+ if (data->cache->used) {
+ internal->range.start = 0;
+ internal->range.stop = data->cache->used - 1;
- state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
+ private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value);
+ if (F_status_is_error(state->status)) return F_true;
+ }
} // for
// Remove the always added trailing space.
data->cache->used -= f_fss_space_s.used;
}
- private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
- if (F_status_is_error(state->status)) return F_true;
+ if (data->cache->used) {
+ internal->range.start = 0;
+ internal->range.stop = data->cache->used - 1;
+
+ private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
+ if (F_status_is_error(state->status)) return F_true;
+ }
}
else if (data->flag & f_fss_payload_header_map_flag_join_map_e) {
data->cache->used = 0;
data->cache->used -= f_fss_space_s.used;
}
- private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
- if (F_status_is_error(state->status)) return F_true;
+ if (data->cache->used) {
+ internal->range.start = 0;
+ internal->range.stop = data->cache->used - 1;
- state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value);
- if (F_status_is_error(state->status)) return F_true;
+ private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal);
+ if (F_status_is_error(state->status)) return F_true;
+
+ state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value);
+ if (F_status_is_error(state->status)) return F_true;
+ }
} // for
// Remove the always added trailing space.
destination->string[destination->used++] = quote_char;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
else if ((flag & 0x1) && object.string[range->start] == f_fss_comment_s.string[0]) {
destination->string[destination->used++] = f_fss_slash_s.string[0];
} // for
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
}
else if (object.string[range->start] == quote_char) {
if (F_status_is_error(state->status)) return;
if (range->start > range->stop || range->start >= object.used) {
-
state->status = f_memory_array_increase(state->step_large, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
destination->string[destination->used++] = quote_char;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
else if (object.string[range->start] == f_fss_eol_s.string[0]) {
state->status = F_status_set_error(F_okay_eol);
}
else if (object.string[range->start] != f_fss_placeholder_s.string[0]) {
if (!quoted_is) {
+ if (object.string[range->start] == f_string_ascii_quote_double_s.string[0] || object.string[range->start] == f_string_ascii_quote_single_s.string[0] || object.string[range->start] == f_string_ascii_grave_s.string[0]) {
+ item_first = range->start++;
+
+ f_fss_skip_past_delimit(object, range, state);
+ if (F_status_is_error(state->status)) return;
+
+ if (range->start > range->stop || range->start >= object.used) {
+ quoted_is = F_true;
+ }
+ else if (object.string[range->start] == object.string[item_first]) {
+ quoted_is = F_true;
+ }
+ else if (f_fss_is_space(object, *range, state) == F_true) {
+ quoted_is = F_true;
+ }
+ else if (F_status_is_error(state->status)) {
+ break;
+ }
+
+ range->start = item_first;
+ }
+
if (f_fss_is_space(object, *range, state) == F_false) {
if (F_status_is_error(state->status)) break;
}
state->status = f_memory_array_increase_by(width, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
if (F_status_is_error(state->status)) break;
- for (i = 0; i < width; ++i) {
- destination->string[destination->used++] = object.string[range->start + i];
- } // for
+ memcpy(destination->string + destination->used, object.string + range->start, width);
+
+ destination->used += width;
}
state->status = f_utf_buffer_increment(object, range, 1);
build_sources_program test-fss-extended_content_read.c test-fss-extended_content_write.c test-fss-extended_object_read.c test-fss-extended_object_write.c
build_sources_program test-fss-extended_list_content_read.c test-fss-extended_list_content_write.c test-fss-extended_list_object_read.c test-fss-extended_list_object_write.c
build_sources_program test-fss-payload_header_map.c
+build_sources_program test-fss-payload_header_map-abstruse_dynamic-join.c
+build_sources_program test-fss-payload_header_map-abstruse_dynamics-join.c test-fss-payload_header_map-abstruse_dynamics-split.c
build_sources_program test-fss-payload_header_map-abstruse_int8s-join.c test-fss-payload_header_map-abstruse_uint8s-join.c
build_sources_program test-fss-payload_header_map-abstruse_int8s-split.c test-fss-payload_header_map-abstruse_uint8s-split.c
build_sources_program test-fss-payload_header_map-abstruse_int16s-join.c test-fss-payload_header_map-abstruse_uint16s-join.c
build_sources_program test-fss-payload_header_map-abstruse_int32s-split.c test-fss-payload_header_map-abstruse_uint32s-split.c
build_sources_program test-fss-payload_header_map-abstruse_int64s-join.c test-fss-payload_header_map-abstruse_uint64s-join.c
build_sources_program test-fss-payload_header_map-abstruse_int64s-split.c test-fss-payload_header_map-abstruse_uint64s-split.c
+build_sources_program test-fss-payload_header_map-abstruse_map-join.c test-fss-payload_header_map-abstruse_map-split.c
build_sources_program test-fss-payload_header_map-abstruse_signed-join.c test-fss-payload_header_map-abstruse_unsigned-join.c
build_sources_program test-fss-payload_header_map-abstruse_signeds-join.c test-fss-payload_header_map-abstruse_unsigneds-join.c
build_sources_program test-fss-payload_header_map-abstruse_signeds-split.c test-fss-payload_header_map-abstruse_unsigneds-split.c
--- /dev/null
+a
+4
+0
+hello
+"some thing"
+3全#$⸙
--- /dev/null
+b
+3
+全
+⸙
+"␀ ␀ ␀ ␀ ␀ ␀"
--- /dev/null
+c
+2
+�
+""a b \" c"
--- /dev/null
+a
+1
+"0 hello some thing 3全#$⸙ """
--- /dev/null
+b
+1
+"全 ⸙ ␀ ␀ ␀ ␀ ␀ ␀"
--- /dev/null
+c
+1
+"� "a b \" c"
--- /dev/null
+a-0
+1
+"0 hello"
--- /dev/null
+a-1
+1
+"some thing 3全#$⸙"
--- /dev/null
+a-2
+1
+""\" ''"
--- /dev/null
+b-0
+1
+"全 ⸙"
--- /dev/null
+b-1
+1
+"␂␂␂ ␀ ␀ ␀ ␀ ␀ ␀"
--- /dev/null
+b-2
+1
+"' '"
--- /dev/null
+c-0
+1
+"� "a b \" c"
--- /dev/null
+a
+1
+0 hello "some thing" 3全#$⸙ """"
--- /dev/null
+b
+1
+全 ⸙ "␀ ␀ ␀ ␀ ␀ ␀"
--- /dev/null
+c
+1
+� ""a b \" c"
--- /dev/null
+a-0
+1
+0 hello
--- /dev/null
+a-1
+1
+"some thing" 3全#$⸙
--- /dev/null
+a-2
+1
+"""" "''"
--- /dev/null
+b-0
+1
+全 ⸙
--- /dev/null
+b-1
+1
+␂␂␂ "␀ ␀ ␀ ␀ ␀ ␀"
--- /dev/null
+b-2
+1
+"'" "'"
--- /dev/null
+c-0
+1
+� ""a b \" c"
--- /dev/null
+a
+4
+0
+hello
+some thing
+3全#$⸙
+b
+3
+全
+⸙
+␀ ␀ ␀ ␀ ␀ ␀
+c
+2
+�
+"a b " c
--- /dev/null
+a
+5
+0
+hello
+some thing
+3全#$⸙
+""
+b
+3
+全
+⸙
+␀ ␀ ␀ ␀ ␀ ␀
+c
+2
+�
+"a b " c
--- /dev/null
+a-0
+2
+0
+hello
+a-1
+2
+some thing
+3全#$⸙
+a-2
+2
+""
+''
+b-0
+2
+全
+⸙
+b-1
+2
+␂␂␂
+␀ ␀ ␀ ␀ ␀ ␀
+b-2
+2
+'
+'
+c-0
+2
+�
+"a b " c
for (f_number_unsigned_t i = 0; i < destinations.used; ++i) {
- assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used);
- assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used);
-
assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string);
assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string);
+
+ assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used);
+ assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used);
} // for
if (object.string) free(object.string);
--- /dev/null
+#include "test-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__fl_fss_payload_header_map__abstruse_dynamic__works_join(void **void_state) {
+
+ help_payload__test("abstruse_dynamic", "join-abstruse_dynamic", 0, test__fl_fss_payload_header_map__abstruse_dynamic__join_load_contents, 0);
+}
+
+void test__fl_fss_payload_header_map__abstruse_dynamic__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) {
+
+ for (f_number_unsigned_t i = 0; i < contents.used; ++i, ++headers->used) {
+
+ headers->array[headers->used].key.used = 0;
+
+ state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+ assert_int_equal(state->status, F_okay);
+
+ headers->array[headers->used].value.type = f_abstruse_dynamic_e;
+ headers->array[headers->used].value.is.a_dynamic.used = 0;
+
+ state->status = f_string_dynamic_append(contents.array[i], &headers->array[headers->used].value.is.a_dynamic);
+ assert_int_equal(state->status, F_okay);
+ } // for
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /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_dynamic_join_h
+#define _TEST__FL_fss_payload_header_map__abstruse_dynamic_join_h
+
+/**
+ * Test that the function works for abstruse_dynamic type.
+ *
+ * @see fl_fss_payload_header_map()
+ */
+extern void test__fl_fss_payload_header_map__abstruse_dynamic__works_join(void **state);
+
+/**
+ * Callback to load the contents for the test.
+ *
+ * @param object
+ * The object parameter.
+ * @param contents
+ * The contents parameter.
+ * @param headers
+ * The headers parameter.
+* @param state
+ * The state parameter.
+ * @param extra
+ * (optional) The extra parameter.
+ * Set to NULL to not use.
+ */
+extern void test__fl_fss_payload_header_map__abstruse_dynamic__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra);
+
+#endif // _TEST__FL_fss_payload_header_map__abstruse_dynamic_join_h
--- /dev/null
+#include "test-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__fl_fss_payload_header_map__abstruse_dynamics__works_join(void **void_state) {
+
+ help_payload__test("abstruse_dynamics", "join-abstruse_dynamics", f_fss_payload_header_map_flag_join_dynamics_e, test__fl_fss_payload_header_map__abstruse_dynamics__join_load_contents, 0);
+}
+
+void test__fl_fss_payload_header_map__abstruse_dynamics__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) {
+
+ headers->array[0].value.type = f_abstruse_dynamics_e;
+ headers->array[0].value.is.a_dynamics.used = 0;
+ headers->array[0].key.used = 0;
+
+ f_string_dynamics_t * const dynamics = &headers->array[0].value.is.a_dynamics;
+
+ state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+ assert_int_equal(state->status, F_okay);
+
+ state->status = f_memory_array_increase_by(contents.used, sizeof(f_string_dynamic_t), (void **) &dynamics->array, &dynamics->used, &dynamics->size);
+ assert_int_equal(state->status, F_okay);
+
+ for (f_number_unsigned_t i = 0; i < contents.used; ++i) {
+
+ dynamics->array[i].used = 0;
+
+ state->status = f_string_dynamic_append(contents.array[i], &dynamics->array[i]);
+ assert_int_equal(state->status, F_okay);
+ } // for
+
+ dynamics->used = contents.used;
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /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_dynamics_join_h
+#define _TEST__FL_fss_payload_header_map__abstruse_dynamics_join_h
+
+/**
+ * Test that the function works for abstruse_dynamics type.
+ *
+ * @see fl_fss_payload_header_map()
+ */
+extern void test__fl_fss_payload_header_map__abstruse_dynamics__works_join(void **state);
+
+/**
+ * Callback to load the contents for the test.
+ *
+ * @param object
+ * The object parameter.
+ * @param contents
+ * The contents parameter.
+ * @param headers
+ * The headers parameter.
+* @param state
+ * The state parameter.
+ * @param extra
+ * (optional) The extra parameter.
+ * Set to NULL to not use.
+ */
+extern void test__fl_fss_payload_header_map__abstruse_dynamics__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra);
+
+#endif // _TEST__FL_fss_payload_header_map__abstruse_dynamics_join_h
--- /dev/null
+#include "test-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__fl_fss_payload_header_map__abstruse_dynamics__works_split(void **void_state) {
+
+ help_payload__test("abstruse_dynamics", "split-abstruse_dynamics", 0, test__fl_fss_payload_header_map__abstruse_dynamics__split_load_contents, 0);
+}
+
+void test__fl_fss_payload_header_map__abstruse_dynamics__split_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) {
+
+ headers->array[0].value.type = f_abstruse_dynamics_e;
+ headers->array[0].value.is.a_dynamics.used = 0;
+ headers->array[0].key.used = 0;
+
+ f_string_dynamics_t * const dynamics = &headers->array[0].value.is.a_dynamics;
+
+ state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+ assert_int_equal(state->status, F_okay);
+
+ state->status = f_memory_array_increase_by(contents.used, sizeof(f_string_dynamic_t), (void **) &dynamics->array, &dynamics->used, &dynamics->size);
+ assert_int_equal(state->status, F_okay);
+
+ for (f_number_unsigned_t i = 0; i < contents.used; ++i) {
+
+ dynamics->array[i].used = 0;
+
+ state->status = f_string_dynamic_append(contents.array[i], &dynamics->array[i]);
+ assert_int_equal(state->status, F_okay);
+ } // for
+
+ dynamics->used = contents.used;
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /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_dynamics_split_h
+#define _TEST__FL_fss_payload_header_map__abstruse_dynamics_split_h
+
+/**
+ * Test that the function works for abstruse_dynamics type.
+ *
+ * @see fl_fss_payload_header_map()
+ */
+extern void test__fl_fss_payload_header_map__abstruse_dynamics__works_split(void **state);
+
+/**
+ * Callback to load the contents for the test.
+ *
+ * @param object
+ * The object parameter.
+ * @param contents
+ * The contents parameter.
+ * @param headers
+ * The headers parameter.
+* @param state
+ * The state parameter.
+ * @param extra
+ * (optional) The extra parameter.
+ * Set to NULL to not use.
+ */
+extern void test__fl_fss_payload_header_map__abstruse_dynamics__split_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra);
+
+#endif // _TEST__FL_fss_payload_header_map__abstruse_dynamics_split_h
--- /dev/null
+#include "test-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__fl_fss_payload_header_map__abstruse_map__works_join(void **void_state) {
+
+ help_payload__test("abstruse_map", "join-abstruse_map", f_fss_payload_header_map_flag_join_map_e, test__fl_fss_payload_header_map__abstruse_map__join_load_contents, 0);
+}
+
+void test__fl_fss_payload_header_map__abstruse_map__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) {
+
+ headers->array[0].value.type = f_abstruse_map_e;
+ headers->array[0].value.is.a_map.key.used = 0;
+ headers->array[0].value.is.a_map.value.used = 0;
+ headers->array[0].key.used = 0;
+
+ f_string_map_t * const map = &headers->array[0].value.is.a_map;
+
+ state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+ assert_int_equal(state->status, F_okay);
+
+ if (contents.used) {
+ state->status = f_string_dynamic_append(contents.array[0], &map->key);
+ assert_int_equal(state->status, F_okay);
+
+ if (contents.used > 1) {
+ state->status = f_string_dynamic_append(contents.array[1], &map->value);
+ assert_int_equal(state->status, F_okay);
+ }
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /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_map_join_h
+#define _TEST__FL_fss_payload_header_map__abstruse_map_join_h
+
+/**
+ * Test that the function works for abstruse_map type.
+ *
+ * @see fl_fss_payload_header_map()
+ */
+extern void test__fl_fss_payload_header_map__abstruse_map__works_join(void **state);
+
+/**
+ * Callback to load the contents for the test.
+ *
+ * @param object
+ * The object parameter.
+ * @param contents
+ * The contents parameter.
+ * @param headers
+ * The headers parameter.
+* @param state
+ * The state parameter.
+ * @param extra
+ * (optional) The extra parameter.
+ * Set to NULL to not use.
+ */
+extern void test__fl_fss_payload_header_map__abstruse_map__join_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra);
+
+#endif // _TEST__FL_fss_payload_header_map__abstruse_map_join_h
--- /dev/null
+#include "test-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__fl_fss_payload_header_map__abstruse_map__works_split(void **void_state) {
+
+ help_payload__test("abstruse_map", "split-abstruse_map", 0, test__fl_fss_payload_header_map__abstruse_map__split_load_contents, 0);
+}
+
+void test__fl_fss_payload_header_map__abstruse_map__split_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra) {
+
+ headers->array[0].value.type = f_abstruse_map_e;
+ headers->array[0].value.is.a_map.key.used = 0;
+ headers->array[0].value.is.a_map.value.used = 0;
+ headers->array[0].key.used = 0;
+
+ f_string_map_t * const map = &headers->array[0].value.is.a_map;
+
+ state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+ assert_int_equal(state->status, F_okay);
+
+ if (contents.used) {
+ state->status = f_string_dynamic_append(contents.array[0], &map->key);
+ assert_int_equal(state->status, F_okay);
+
+ if (contents.used > 1) {
+ state->status = f_string_dynamic_append(contents.array[1], &map->value);
+ assert_int_equal(state->status, F_okay);
+ }
+ }
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /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_map_split_h
+#define _TEST__FL_fss_payload_header_map__abstruse_map_split_h
+
+/**
+ * Test that the function works for abstruse_map type.
+ *
+ * @see fl_fss_payload_header_map()
+ */
+extern void test__fl_fss_payload_header_map__abstruse_map__works_split(void **state);
+
+/**
+ * Callback to load the contents for the test.
+ *
+ * @param object
+ * The object parameter.
+ * @param contents
+ * The contents parameter.
+ * @param headers
+ * The headers parameter.
+* @param state
+ * The state parameter.
+ * @param extra
+ * (optional) The extra parameter.
+ * Set to NULL to not use.
+ */
+extern void test__fl_fss_payload_header_map__abstruse_map__split_load_contents(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state, void * extra);
+
+#endif // _TEST__FL_fss_payload_header_map__abstruse_map_split_h
if (*strings) free(*strings);
- //headers->array[0].value.is.a_strings = calloc(contents.used + 1, sizeof(f_string_t *));
- //assert_int_not_equal(headers->array[0].value.is.a_strings, 0);
*strings = calloc(contents.used + 1, sizeof(f_string_t *));
assert_int_not_equal(*strings, 0);
if (*strings) free(*strings);
- //headers->array[0].value.is.a_strings = calloc(contents.used + 1, sizeof(f_string_t *));
- //assert_int_not_equal(headers->array[0].value.is.a_strings, 0);
*strings = calloc(contents.used + 1, sizeof(f_string_t *));
assert_int_not_equal(*strings, 0);
cmocka_unit_test(test__fl_fss_extended_list_object_read__works),
cmocka_unit_test(test__fl_fss_payload_header_map__returns_data_not),
+ cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_dynamic__works_join),
+ cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_dynamics__works_join),
+ cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_dynamics__works_split),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int8s__works_join),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int8s__works_split),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int16s__works_join),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int32s__works_split),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int64s__works_join),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int64s__works_split),
+ cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_map__works_join),
+ cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_map__works_split),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signed__works_join),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signeds__works_join),
cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signeds__works_split),
#include "test-fss-extended_list_object_read.h"
#include "test-fss-extended_list_object_write.h"
#include "test-fss-payload_header_map.h"
+#include "test-fss-payload_header_map-abstruse_dynamic-join.h"
+#include "test-fss-payload_header_map-abstruse_dynamics-join.h"
+#include "test-fss-payload_header_map-abstruse_dynamics-split.h"
#include "test-fss-payload_header_map-abstruse_int8s-join.h"
#include "test-fss-payload_header_map-abstruse_int8s-split.h"
#include "test-fss-payload_header_map-abstruse_int16s-join.h"
#include "test-fss-payload_header_map-abstruse_int32s-split.h"
#include "test-fss-payload_header_map-abstruse_int64s-join.h"
#include "test-fss-payload_header_map-abstruse_int64s-split.h"
+#include "test-fss-payload_header_map-abstruse_map-join.h"
+#include "test-fss-payload_header_map-abstruse_map-split.h"
#include "test-fss-payload_header_map-abstruse_signed-join.h"
#include "test-fss-payload_header_map-abstruse_signeds-join.h"
#include "test-fss-payload_header_map-abstruse_signeds-split.h"
*/
#ifndef _di_fss_write_setting_t_
typedef struct {
- uint16_t flag;
+ uint32_t flag;
f_status_t status_signal;
f_state_t state;