]> Kevux Git Server - fll/commitdiff
Progress: Add string unit tests for fl_fss_payload_header_map(), and reduce redundanc...
authorKevin Day <kevin@kevux.org>
Sat, 2 Mar 2024 17:36:45 +0000 (11:36 -0600)
committerKevin Day <kevin@kevux.org>
Sat, 2 Mar 2024 17:36:45 +0000 (11:36 -0600)
This adds unit tests for the string abstruse type.

The numbers tests are all almost identical.
Abstract their design out into a helper function and a callback.

The string tests will likely need similar helper functions as the number tests.

57 files changed:
level_1/fl_fss/data/build/settings-tests
level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-0.txt [new file with mode: 0644]
level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-1.txt [new file with mode: 0644]
level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-2.txt [new file with mode: 0644]
level_1/fl_fss/data/tests/variables/payload-abstruse_string.txt [new file with mode: 0644]
level_1/fl_fss/tests/unit/c/help-fss-number.c [new file with mode: 0644]
level_1/fl_fss/tests/unit/c/help-fss-number.h [new file with mode: 0644]
level_1/fl_fss/tests/unit/c/help-fss.c
level_1/fl_fss/tests/unit/c/help-fss.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signed-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signed-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_string-join.c [new file with mode: 0644]
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_string-join.h [new file with mode: 0644]
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s-split.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigned-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigned-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds-join.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds-join.h
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds-split.c
level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds-split.h
level_1/fl_fss/tests/unit/c/test-fss.c
level_1/fl_fss/tests/unit/c/test-fss.h

index 8accf6cc5e304eaa4129f3502b752e500f3e7857..7adf13406cf374658d8064210c6b35c78de5fc8b 100644 (file)
@@ -42,8 +42,9 @@ build_sources_program test-fss-payload_header_map-abstruse_int64s-split.c test-f
 build_sources_program test-fss-payload_header_map-abstruse_signed-join.c test-fss-payload_header_map-abstruse_unsigned-join.c
 build_sources_program test-fss-payload_header_map-abstruse_signeds-join.c test-fss-payload_header_map-abstruse_unsigneds-join.c
 build_sources_program test-fss-payload_header_map-abstruse_signeds-split.c test-fss-payload_header_map-abstruse_unsigneds-split.c
+build_sources_program test-fss-payload_header_map-abstruse_string-join.c
 
-build_sources_program test-fss.c data-fss.c help-fss.c
+build_sources_program test-fss.c data-fss.c help-fss.c help-fss-number.c
 
 build_script no
 build_shared yes
diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-0.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-0.txt
new file mode 100644 (file)
index 0000000..7b06942
--- /dev/null
@@ -0,0 +1,6 @@
+a
+4
+0
+hello
+"some thing"
+3全#$⸙
diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-1.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-1.txt
new file mode 100644 (file)
index 0000000..50e859f
--- /dev/null
@@ -0,0 +1,5 @@
+b
+3
+全
+⸙
+"␀ ␀ ␀ ␀ ␀ ␀"
diff --git a/level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-2.txt b/level_1/fl_fss/data/tests/headers/payload-join-abstruse_string-2.txt
new file mode 100644 (file)
index 0000000..41f6980
--- /dev/null
@@ -0,0 +1,4 @@
+c
+2
+�
+""a b \" c"
diff --git a/level_1/fl_fss/data/tests/variables/payload-abstruse_string.txt b/level_1/fl_fss/data/tests/variables/payload-abstruse_string.txt
new file mode 100644 (file)
index 0000000..d64b7e9
--- /dev/null
@@ -0,0 +1,15 @@
+a
+4
+0
+hello
+some thing
+3全#$⸙
+b
+3
+全
+⸙
+␀ ␀ ␀ ␀ ␀ ␀
+c
+2
+�
+"a b " c
diff --git a/level_1/fl_fss/tests/unit/c/help-fss-number.c b/level_1/fl_fss/tests/unit/c/help-fss-number.c
new file mode 100644 (file)
index 0000000..4f6adaa
--- /dev/null
@@ -0,0 +1,128 @@
+#include "test-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void help_number__test_payload(const f_string_t context_variables, const f_string_t context_headers, const uint64_t flag, void (*load_contents_at)(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const 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", context_variables);
+  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;
+    data.flag = flag;
+
+    for (uint16_t at = 0; ; ++at) {
+
+      if (help__read_line_object(file_variables, &object)) break;
+      if (help__read_line_contents__single(file_variables, &contents, F_true)) break;
+
+      state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
+      assert_true(F_status_is_error_not(state.status));
+
+      load_contents_at(object, contents, &headers, &state);
+
+      if (object.string) free(object.string);
+
+      object.string = 0;
+      object.used = 0;
+      object.size = 0;
+
+      ++headers.used;
+
+      file_headers = data__file_open__named_at("headers", "payload", context_headers, 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].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);
+      } // 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
diff --git a/level_1/fl_fss/tests/unit/c/help-fss-number.h b/level_1/fl_fss/tests/unit/c/help-fss-number.h
new file mode 100644 (file)
index 0000000..da90da0
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * 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_number_h
+#define _HELP__FL_fss_number_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Perform the unit test for a number.
+ *
+ * @param context_variables
+ *   The context name of the variables file for data__file_open__named().
+ * @param context_headers
+ *   The context name of the headers file for data__file_open__named_at().
+ * @param flag
+ *   The payload header state data flag.
+ * @param load_contents_at
+ *   A callback to perform the type-specific content loading translation of the number.
+ */
+void help_number__test_payload(const f_string_t context_variables, const f_string_t context_headers, const uint64_t flag, void (*load_contents_at)(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state));
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _HELP__FL_fss_number_h
index 447e7eb027cc07f462d5f2b0f20143564819e30f..090121ca61bbb1f4113f1732b05c115986c33a9f 100644 (file)
@@ -4,7 +4,7 @@
 extern "C" {
 #endif
 
-uint8_t help__read_line_contents__single(FILE *file, f_string_dynamics_t * const contents) {
+uint8_t help__read_line_contents__single(FILE *file, f_string_dynamics_t * const contents, const uint8_t as_number) {
 
   size_t max = 255;
   char *line_string = 0;
@@ -22,7 +22,7 @@ uint8_t help__read_line_contents__single(FILE *file, f_string_dynamics_t * const
 
   const f_number_unsigned_t count = (f_number_unsigned_t) atoi(line_string);
 
-  if (!count) {
+  if (!count && as_number) {
     assert_int_equal(line_string[0], '0');
   }
 
index 977bfb0f8f3d785e7fe70c92ef3f8a8218614c0b..9d670e50098459e7e59de90a8abee2d3168eb3bc 100644 (file)
@@ -27,12 +27,14 @@ extern "C" {
  * @param contents
  *   The array of contents to use.
  *   Must not be NULL.
+ * @param as_number
+ *   Operate as a number, performing a check if the first character is '0' (the character and not 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);
+uint8_t help__read_line_contents__single(FILE *file, f_string_dynamics_t * const contents, const uint8_t as_number);
 
 /**
  * Load the expect lines from the given file.
index c4697a4ff7269171d06ba9176a43d0291480af88..279402d4eea3272b966a541a625f7fd7a9989b65 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_int16s__works_join(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", "abstruse_int16s");
-  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;
-  f_int16s_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_i16s.used = 0;
-      headers.array[0].value.type = f_abstruse_int16s_e;
-      is_a = &headers.array[0].value.is.a_i16s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_int16s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_int16s", "join-abstruse_int16s", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_int16s__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_int16s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_int16s_t * const is_a = &headers->array[0].value.is.a_i16s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i16s.used = 0;
+  headers->array[0].value.type = f_abstruse_int16s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 8b73f45231a390af2789bb84cff4f87f8c21f91d..cac38e8f451202c7c723dc0c470f2833c0aa5232 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_int16s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_int16s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_int16s_join_h
index f8626feaf22027ff034e4246904f8cfadab03b78..344fa496959e5df7e18086d9a29c1349a3e83f27 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_int16s__works_split(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", "abstruse_int16s");
-  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;
-  f_int16s_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_i16s.used = 0;
-      headers.array[0].value.type = f_abstruse_int16s_e;
-      is_a = &headers.array[0].value.is.a_i16s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_int16s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_int16s", "split-abstruse_int16s", 0, test__fl_fss_payload_header_map__abstruse_int16s__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_int16s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_int16s_t * const is_a = &headers->array[0].value.is.a_i16s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i16s.used = 0;
+  headers->array[0].value.type = f_abstruse_int16s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 0f8482ddec7c65fe70218e15f7dc31f6e71fbd4b..9558b2148640c93a9cb969e084bde82aaa33b24f 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_int16s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_int16s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_int16s_split_h
index 794aa38330a093d253fcdb90c8611f62c2d82177..b15d3381b6aebb50c1166e172a06bbb7d12983b4 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_int32s__works_join(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", "abstruse_int32s");
-  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;
-  f_int32s_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_i32s.used = 0;
-      headers.array[0].value.type = f_abstruse_int32s_e;
-      is_a = &headers.array[0].value.is.a_i32s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_int32s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_int32s", "join-abstruse_int32s", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_int32s__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_int32s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_int32s_t * const is_a = &headers->array[0].value.is.a_i32s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i32s.used = 0;
+  headers->array[0].value.type = f_abstruse_int32s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index feb4dd858ee3753e46477398011a873243655927..7c15758114a7a67c8cac573655ef8b4e19de971b 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_int32s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_int32s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_int32s_join_h
index 7b851799d45e3012d5abf95b4ddd8eeb0ccec2ac..675b3815bfe868411d9103ea9eb0dc65940246dc 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_int32s__works_split(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", "abstruse_int32s");
-  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;
-  f_int32s_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_i32s.used = 0;
-      headers.array[0].value.type = f_abstruse_int32s_e;
-      is_a = &headers.array[0].value.is.a_i32s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_int32s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_int32s", "split-abstruse_int32s", 0, test__fl_fss_payload_header_map__abstruse_int32s__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_int32s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_int32s_t * const is_a = &headers->array[0].value.is.a_i32s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i32s.used = 0;
+  headers->array[0].value.type = f_abstruse_int32s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index edbfc1028d203f6f4647f0f533775aaddb10d4a1..828dbd7c02c7f55690d17849c9b65b9fc32b644b 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_int32s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_int32s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_int32s_split_h
index 5af5ed0bc0956ca2213cdc0118474387893c7526..262064783db86f4b7568533378501f3dcebd9cb9 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_int64s__works_join(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", "abstruse_int64s");
-  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;
-  f_int64s_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_i64s.used = 0;
-      headers.array[0].value.type = f_abstruse_int64s_e;
-      is_a = &headers.array[0].value.is.a_i64s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_int64s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_int64s", "join-abstruse_int64s", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_int64s__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_int64s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_int64s_t * const is_a = &headers->array[0].value.is.a_i64s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i64s.used = 0;
+  headers->array[0].value.type = f_abstruse_int64s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index cc74c0453b4849e7b8e40718db36c413ee07edf4..9a50ac9cc33e6df951b6bb7da55c1a3edec80453 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_int64s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_int64s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_int64s_join_h
index bd4d9c13a073d61415b2d164321dc70351f43774..41b14160be9ef2f63b4824a232207cdfdc177749 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_int64s__works_split(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", "abstruse_int64s");
-  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;
-  f_int64s_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_i64s.used = 0;
-      headers.array[0].value.type = f_abstruse_int64s_e;
-      is_a = &headers.array[0].value.is.a_i64s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_int64s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_int64s", "split-abstruse_int64s", 0, test__fl_fss_payload_header_map__abstruse_int64s__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_int64s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_int64s_t * const is_a = &headers->array[0].value.is.a_i64s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i64s.used = 0;
+  headers->array[0].value.type = f_abstruse_int64s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 7ebabf193fe81a1f8c83959832e7ca5badd14d5e..ec5113190ceb278c70dcb6adec40e9e368e9ef7a 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_int64s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_int64s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_int64s_split_h
index f304a2a3c67750ac6fc1aac5231f1d4bc83fe112..ff45ab56d3a181ebe1ca0cec7907894179497c1a 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_int8s__works_join(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", "abstruse_int8s");
-  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;
-  f_int8s_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_i8s.used = 0;
-      headers.array[0].value.type = f_abstruse_int8s_e;
-      is_a = &headers.array[0].value.is.a_i8s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_int8s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_int8s", "join-abstruse_int8s", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_int8s__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_int8s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_int8s_t * const is_a = &headers->array[0].value.is.a_i8s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i8s.used = 0;
+  headers->array[0].value.type = f_abstruse_int8s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index eb0cf4d4bf64ea9d00efa984ffdac2bb228697ce..a610d1a5e3358e42aca7694a986d452967c4d407 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_int8s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_int8s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_int8s_join_h
index 8d4be14692a072675dcee9b62c86b20c0d03b596..bfca9a3d18d031ecb4e862e3feaa91358d843a18 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_int8s__works_split(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", "abstruse_int8s");
-  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;
-  f_int8s_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_i8s.used = 0;
-      headers.array[0].value.type = f_abstruse_int8s_e;
-      is_a = &headers.array[0].value.is.a_i8s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_int8s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_int8s", "split-abstruse_int8s", 0, test__fl_fss_payload_header_map__abstruse_int8s__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_int8s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_int8s_t * const is_a = &headers->array[0].value.is.a_i8s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i8s.used = 0;
+  headers->array[0].value.type = f_abstruse_int8s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index ee11e6001a8801fd256d37d1805228d48eebe76d..7172c7f21cf8ca12335ae6383786e7ecc5835ea2 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_int8s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_int8s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_int8s_split_h
index 73cd6773879c84afa6b620eff0ddb1c748299dfd..876687b0ea5eb9c0adeb311879ad09751f33534c 100644 (file)
@@ -6,133 +6,27 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_signed__works_join(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", "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", "join-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].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);
-      } // 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;
+  help_number__test_payload("abstruse_signed", "join-abstruse_signed", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_signed__join_load_contents_at);
+}
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+void test__fl_fss_payload_header_map__abstruse_signed__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  for (f_number_unsigned_t i = 0; i < contents.used; ++i, ++headers->used) {
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+    const f_number_signed_t number = atoll(contents.array[i].string);
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+    if (!number) {
+      assert_int_equal(contents.array[i].string[0], '0');
+    }
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    headers->array[headers->used].key.used = 0;
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+    assert_int_equal(state->status, F_okay);
 
-  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);
+    headers->array[headers->used].value.type = f_abstruse_signed_e;
+    headers->array[headers->used].value.is.a_signed = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 25cbf105bb298df30db41f2702f428692f16f366..617cbe5df29b8e6101226cd84caa7f0d642d2739 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_signed__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_signed__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_signed_join_h
index 278f7cc201f2080ad315f8c122d95c5f61f16b8f..728a0a635bb8a5b6267c9c2283461da6b60d5505 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_signeds__works_join(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", "abstruse_signeds");
-  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;
-  f_number_signeds_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_signeds.used = 0;
-      headers.array[0].value.type = f_abstruse_signeds_e;
-      is_a = &headers.array[0].value.is.a_signeds;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_signeds", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_signeds", "join-abstruse_signeds", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_signeds__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_signeds__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_number_signeds_t * const is_a = &headers->array[0].value.is.a_signeds;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_signeds.used = 0;
+  headers->array[0].value.type = f_abstruse_signeds_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 3f5469ea6d3644c8d1aa5f3419266615a15924ab..53cb59fe00c64a47853c7b2347c5bdf8aad23188 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_signeds__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_signeds__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_signeds_join_h
index f680d9c77b61aff9abe26ce82a64d5c8e5a3b990..50bbd82b7c071242698c913b87dc393aec5f6a68 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_signeds__works_split(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", "abstruse_signeds");
-  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;
-  f_number_signeds_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_signeds.used = 0;
-      headers.array[0].value.type = f_abstruse_signeds_e;
-      is_a = &headers.array[0].value.is.a_signeds;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_signeds", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_signeds", "split-abstruse_signeds", 0, test__fl_fss_payload_header_map__abstruse_signeds__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_signeds__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_number_signeds_t * const is_a = &headers->array[0].value.is.a_signeds;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_signeds.used = 0;
+  headers->array[0].value.type = f_abstruse_signeds_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index fff05e1d86038cd6c39a48a8ebfbe3a7cd199baa..7171f7b3b26274c7a0cd6ff8604e979d5b07f1f1 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_signeds__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_signeds__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_signeds_split_h
diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_string-join.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_string-join.c
new file mode 100644 (file)
index 0000000..c1e7429
--- /dev/null
@@ -0,0 +1,134 @@
+#include "test-fss.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void test__fl_fss_payload_header_map__abstruse_string__works_join(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", "abstruse_string");
+  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, F_false)) 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) {
+
+        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_string_e;
+        headers.array[headers.used].value.is.a_string = contents.array[i].string;
+      } // 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", "join-abstruse_string", 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].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);
+      } // 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
diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_string-join.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_string-join.h
new file mode 100644 (file)
index 0000000..cc19eba
--- /dev/null
@@ -0,0 +1,20 @@
+/**
+ * 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_string_join_h
+#define _TEST__FL_fss_payload_header_map__abstruse_string_join_h
+
+/**
+ * Test that the function works for abstruse_string type.
+ *
+ * @see fl_fss_payload_header_map()
+ */
+extern void test__fl_fss_payload_header_map__abstruse_string__works_join(void **state);
+
+#endif // _TEST__FL_fss_payload_header_map__abstruse_string_join_h
index bc2fc4e6f3ecec2e74b15e1793ff83eb49abd8c9..820b06211a97c0687b10b213e9f7d84844315849 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_uint16s__works_join(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", "abstruse_uint16s");
-  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;
-  f_uint16s_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_u16s.used = 0;
-      headers.array[0].value.type = f_abstruse_uint16s_e;
-      is_a = &headers.array[0].value.is.a_u16s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_uint16s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_uint16s", "join-abstruse_uint16s", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_uint16s__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_uint16s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_uint16s_t * const is_a = &headers->array[0].value.is.a_u16s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i16s.used = 0;
+  headers->array[0].value.type = f_abstruse_uint16s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 1b2b7abdf0be96783ea6a4908a7d5d7780d9c259..68209af231291c689eb97a801a1afced6acc73c2 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_uint16s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_uint16s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_uint16s_join_h
index 25a98c7f13936ac994a16c3667245b3cd94eae9e..f1c084ad913a95dcb69238c55eac5928073b63f8 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_uint16s__works_split(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", "abstruse_uint16s");
-  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;
-  f_uint16s_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_u16s.used = 0;
-      headers.array[0].value.type = f_abstruse_uint16s_e;
-      is_a = &headers.array[0].value.is.a_u16s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_uint16s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_uint16s", "split-abstruse_uint16s", 0, test__fl_fss_payload_header_map__abstruse_uint16s__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_uint16s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_uint16s_t * const is_a = &headers->array[0].value.is.a_u16s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_u16s.used = 0;
+  headers->array[0].value.type = f_abstruse_uint16s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 7d7009077ff7fdaa39f4c2237231a03c74d00e03..7cfeeebe3f780296fbddc738ae000c8c973fea0e 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_uint16s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_uint16s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_uint16s_split_h
index 876256ea8037be726e804aac2f594be7a2be150b..6ba40486779496c763d10d0e93de6594f9e31f9b 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_uint32s__works_join(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", "abstruse_uint32s");
-  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;
-  f_uint32s_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_u32s.used = 0;
-      headers.array[0].value.type = f_abstruse_uint32s_e;
-      is_a = &headers.array[0].value.is.a_u32s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_uint32s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_uint32s", "join-abstruse_uint32s", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_uint32s__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_uint32s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_uint32s_t * const is_a = &headers->array[0].value.is.a_u32s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i32s.used = 0;
+  headers->array[0].value.type = f_abstruse_uint32s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 781a09c8360a444a139d9ce7c6d3b96c8e4846f2..87f8f8d29b2b137d7a88beefa1f95e1b89b0989b 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_uint32s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_uint32s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_uint32s_join_h
index 1d65e3192117466f569b1053d6713373013e9c8b..2316bbc8f8a15c6c83bdb1fdc52f6857ad81d86e 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_uint32s__works_split(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", "abstruse_uint32s");
-  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;
-  f_uint32s_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_u32s.used = 0;
-      headers.array[0].value.type = f_abstruse_uint32s_e;
-      is_a = &headers.array[0].value.is.a_u32s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_uint32s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_uint32s", "split-abstruse_uint32s", 0, test__fl_fss_payload_header_map__abstruse_uint32s__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_uint32s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_uint32s_t * const is_a = &headers->array[0].value.is.a_u32s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_u32s.used = 0;
+  headers->array[0].value.type = f_abstruse_uint32s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index d34f5ff50b7cd91fa0596d24da84ba9bfd15cba5..958de22d965acfbe8afc24d0e6ef565ecc63ac70 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_uint32s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_uint32s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_uint32s_split_h
index 38622b47c9ffbabb56fe71ac94b2d1037aa45044..628cc3e40f4d205f96638c5b31f8c1a5703dcfe1 100644 (file)
@@ -6,143 +6,34 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_uint64s__works_join(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", "abstruse_uint64s");
-  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;
-  f_uint64s_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_u64s.used = 0;
-      headers.array[0].value.type = f_abstruse_uint64s_e;
-      is_a = &headers.array[0].value.is.a_u64s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        // atoll() cannot be used here due to needing an unsigned 64-bit and atoll() returns a signed 64-bit.
-        const f_number_signed_t number = strtoull(contents.array[is_a->used].string, 0, 10);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_uint64s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_uint64s", "join-abstruse_uint64s", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_uint64s__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_uint64s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_uint64s_t * const is_a = &headers->array[0].value.is.a_u64s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i64s.used = 0;
+  headers->array[0].value.type = f_abstruse_uint64s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    // atoll() cannot be used here due to needing an unsigned 64-bit and atoll() returns a signed 64-bit.
+    const f_number_signed_t number = strtoull(contents.array[is_a->used].string, 0, 10);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index ba2e935f86df9a9c01d1be2fc22eaff6e3b4e597..8bef6392d3233e3085519358a6e94e647630b240 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_uint64s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_uint64s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_uint64s_join_h
index 3a739dfcd8dea3695bac769ddcb3aa2e783e14d6..655434c4c60fbf8fc5481a82d587f7156f37ce54 100644 (file)
@@ -6,142 +6,34 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_uint64s__works_split(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", "abstruse_uint64s");
-  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;
-  f_uint64s_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_u64s.used = 0;
-      headers.array[0].value.type = f_abstruse_uint64s_e;
-      is_a = &headers.array[0].value.is.a_u64s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        // atoll() cannot be used here due to needing an unsigned 64-bit and atoll() returns a signed 64-bit.
-        const f_number_signed_t number = strtoull(contents.array[is_a->used].string, 0, 10);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_uint64s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_uint64s", "split-abstruse_uint64s", 0, test__fl_fss_payload_header_map__abstruse_uint64s__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_uint64s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_uint64s_t * const is_a = &headers->array[0].value.is.a_u64s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i64s.used = 0;
+  headers->array[0].value.type = f_abstruse_uint64s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    // atoll() cannot be used here due to needing an unsigned 64-bit and atoll() returns a signed 64-bit.
+    const f_number_signed_t number = strtoull(contents.array[is_a->used].string, 0, 10);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index f1fdec9863f7d86b571b41a073bf01c06bc42319..dc063f747b74a0e38e41a7515fe5375212cc1987 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_uint64s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_uint64s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_uint64s_split_h
index 081e883800298a6e33a4b2d5a0fe795fc75e3207..ff04243c673b6468db14c09ab97016f4ca22932f 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_uint8s__works_join(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", "abstruse_uint8s");
-  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;
-  f_uint8s_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_u8s.used = 0;
-      headers.array[0].value.type = f_abstruse_uint8s_e;
-      is_a = &headers.array[0].value.is.a_u8s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_uint8s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_uint8s", "join-abstruse_uint8s", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_uint8s__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_uint8s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_uint8s_t * const is_a = &headers->array[0].value.is.a_u8s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_i8s.used = 0;
+  headers->array[0].value.type = f_abstruse_uint8s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 0001a843f5d7166cee50eda06f298a51b3a489e4..8339589b8b61bb64d65522b6b7b4a28e0f40c23e 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_uint8s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_uint8s__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_uint8s_join_h
index bf46673e2f28096145a157e5a5331dbdb73331cd..9a0b7966b593cd150713319d1f396e75a9ffc45b 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_uint8s__works_split(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", "abstruse_uint8s");
-  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;
-  f_uint8s_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_u8s.used = 0;
-      headers.array[0].value.type = f_abstruse_uint8s_e;
-      is_a = &headers.array[0].value.is.a_u8s;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_uint8s", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_uint8s", "split-abstruse_uint8s", 0, test__fl_fss_payload_header_map__abstruse_uint8s__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_uint8s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_uint8s_t * const is_a = &headers->array[0].value.is.a_u8s;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_u8s.used = 0;
+  headers->array[0].value.type = f_abstruse_uint8s_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 47b882673fab21f264800e3013e5059550210cf7..7fe85cdcd122783e2fcd0a4924adc943596d748e 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_uint8s__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_uint8s__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_uint8s_split_h
index fe54e695b7961daf5ea4adcf45306c1bb838e772..dae916ff70a16844e9606efb6c5d815460eb3470 100644 (file)
@@ -6,133 +6,27 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_unsigned__works_join(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", "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", "join-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].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);
-      } // 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;
+  help_number__test_payload("abstruse_unsigned", "join-abstruse_unsigned", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_unsigned__join_load_contents_at);
+}
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+void test__fl_fss_payload_header_map__abstruse_unsigned__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  for (f_number_unsigned_t i = 0; i < contents.used; ++i, ++headers->used) {
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+    const f_number_unsigned_t number = atoll(contents.array[i].string);
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+    if (!number) {
+      assert_int_equal(contents.array[i].string[0], '0');
+    }
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    headers->array[headers->used].key.used = 0;
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+    assert_int_equal(state->status, F_okay);
 
-  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);
+    headers->array[headers->used].value.type = f_abstruse_unsigned_e;
+    headers->array[headers->used].value.is.a_unsigned = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 533756afb7e50dfcdcae80b969a4720ccf3a780e..cf0c5ef3c8c6e30bf3e654d7d10270cebe0b96b9 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_unsigned__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_unsigned__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_unsigned_join_h
index 3e09ee42b93c6cf12bbc86e24e8ceadb3cb11f2c..13ddc811057509ed9fb403e1f464de07f734a065 100644 (file)
@@ -6,142 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_unsigneds__works_join(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", "abstruse_unsigneds");
-  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;
-  f_number_unsigneds_t *is_a = 0;
-
-  {
-    state.status = F_none;
-    state.data = &data;
-    data.cache = &cache;
-    data.flag |= f_fss_payload_header_map_flag_join_digits_e;
-
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_unsigneds.used = 0;
-      headers.array[0].value.type = f_abstruse_unsigneds_e;
-      is_a = &headers.array[0].value.is.a_unsigneds;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "join-abstruse_unsigneds", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_unsigneds", "join-abstruse_unsigneds", f_fss_payload_header_map_flag_join_digits_e, test__fl_fss_payload_header_map__abstruse_unsigneds__join_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_unsigneds__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_number_unsigneds_t * const is_a = &headers->array[0].value.is.a_unsigneds;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_unsigneds.used = 0;
+  headers->array[0].value.type = f_abstruse_unsigneds_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index e9b96be890e8c8e6c92336e0b5e536ca05a5b6c6..580477d64e5dc208475e180af5345cfb2ff80be9 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_unsigneds__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_unsigneds__join_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_unsigneds_join_h
index 7258e460cd8d92450f6f62b3fa73b910b5afdac8..a8be2d11fdb3b379507be3ddafe81aab6411fa8a 100644 (file)
@@ -6,141 +6,33 @@ extern "C" {
 
 void test__fl_fss_payload_header_map__abstruse_unsigneds__works_split(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", "abstruse_unsigneds");
-  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;
-  f_number_unsigneds_t *is_a = 0;
-
-  {
-    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(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size);
-      assert_true(F_status_is_error_not(state.status));
-
-      headers.array[0].key.used = 0;
-      headers.array[0].value.is.a_unsigneds.used = 0;
-      headers.array[0].value.type = f_abstruse_unsigneds_e;
-      is_a = &headers.array[0].value.is.a_unsigneds;
-
-      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_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
-      assert_true(F_status_is_error_not(state.status));
-
-      for (is_a->used = 0; is_a->used < contents.used; ) {
-
-        const f_number_signed_t number = atoll(contents.array[is_a->used].string);
-
-        if (!number) {
-          assert_int_equal(contents.array[is_a->used].string[0], '0');
-        }
-
-        is_a->array[is_a->used++] = number;
-      } // for
-
-      if (object.string) free(object.string);
-
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
-
-      ++headers.used;
-
-      file_headers = data__file_open__named_at("headers", "payload", "split-abstruse_unsigneds", 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].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);
-      } // 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;
+  help_number__test_payload("abstruse_unsigneds", "split-abstruse_unsigneds", 0, test__fl_fss_payload_header_map__abstruse_unsigneds__split_load_contents_at);
+}
 
-      object.string = 0;
-      object.used = 0;
-      object.size = 0;
+void test__fl_fss_payload_header_map__abstruse_unsigneds__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state) {
 
-      cache.string = 0;
-      cache.used = 0;
-      cache.size = 0;
+  f_number_unsigneds_t * const is_a = &headers->array[0].value.is.a_unsigneds;
 
-      contents.array = 0;
-      contents.used = 0;
-      contents.size = 0;
+  headers->array[0].key.used = 0;
+  headers->array[0].value.is.a_unsigneds.used = 0;
+  headers->array[0].value.type = f_abstruse_unsigneds_e;
 
-      headers.array = 0;
-      headers.used = 0;
-      headers.size = 0;
+  state->status = f_string_dynamic_append(object, &headers->array[headers->used].key);
+  assert_int_equal(state->status, F_okay);
 
-      destinations.array = 0;
-      destinations.used = 0;
-      destinations.size = 0;
+  state->status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size);
+  assert_true(F_status_is_error_not(state->status));
 
-      expects.array = 0;
-      expects.used = 0;
-      expects.size = 0;
-    } // for
-  }
+  for (is_a->used = 0; is_a->used < contents.used; ) {
 
-  if (file_variables) fclose(file_variables);
-  if (file_headers) fclose(file_headers);
+    const f_number_signed_t number = atoll(contents.array[is_a->used].string);
 
-  if (object.string) free(object.string);
-  if (cache.string) free(cache.string);
+    if (!number) {
+      assert_int_equal(contents.array[is_a->used].string[0], '0');
+    }
 
-  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);
+    is_a->array[is_a->used++] = number;
+  } // for
 }
 
 #ifdef __cplusplus
index 0787c3ef7220c69053fbaeffb9c0463991e79fbd..bd431cf0df27f18b5c72a53a491348c4c2a49a02 100644 (file)
  */
 extern void test__fl_fss_payload_header_map__abstruse_unsigneds__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.
+ */
+void test__fl_fss_payload_header_map__abstruse_unsigneds__split_load_contents_at(const f_string_static_t object, const f_string_dynamics_t contents, f_abstruse_maps_t * const headers, f_state_t * const state);
+
 #endif // _TEST__FL_fss_payload_header_map__abstruse_unsigneds_split_h
index dccb40f21f39e42300bb3bf3049177e5a7bcfba9..329815cdaa76c9152e46d1d2036e860b77630c05 100644 (file)
@@ -71,6 +71,8 @@ int main(void) {
     cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signed__works_join),
     cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signeds__works_join),
     cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signeds__works_split),
+    cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_string__works_join),
+    //cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_strings__works_join),
     cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint8s__works_join),
     cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint8s__works_split),
     cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint16s__works_join),
index be718e57596174fbdc5629be71404c78641a8571..d0e0e5ada01ea9249de7bbddb01500e4f56c9741 100644 (file)
@@ -38,6 +38,7 @@
 // Data includes.
 #include "data-fss.h"
 #include "help-fss.h"
+#include "help-fss-number.h"
 
 // Test includes.
 #include "test-fss-basic_content_read.h"
@@ -72,6 +73,7 @@
 #include "test-fss-payload_header_map-abstruse_signed-join.h"
 #include "test-fss-payload_header_map-abstruse_signeds-join.h"
 #include "test-fss-payload_header_map-abstruse_signeds-split.h"
+#include "test-fss-payload_header_map-abstruse_string-join.h"
 #include "test-fss-payload_header_map-abstruse_uint8s-join.h"
 #include "test-fss-payload_header_map-abstruse_uint8s-split.h"
 #include "test-fss-payload_header_map-abstruse_uint16s-join.h"