]> Kevux Git Server - fll/commitdiff
Refactor: The fss extract functions to be fss decode functions.
authorKevin Day <thekevinday@gmail.com>
Thu, 14 Dec 2023 02:27:54 +0000 (20:27 -0600)
committerKevin Day <thekevinday@gmail.com>
Thu, 14 Dec 2023 02:27:54 +0000 (20:27 -0600)
The commit 4713c80244fe1bc00da097eb27987e77c98601f0 introduced f_fss_simple_packet_encode().
Rename the f_fss_simple_packet_extract() and similar functions to f_fss_simple_packet_decode().

This makes the language more consistent between the two different functions.

level_0/f_fss/c/fss/simple_packet.c
level_0/f_fss/c/fss/simple_packet.h
level_0/f_fss/data/build/settings-tests
level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode.c [moved from level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract.c with 75% similarity]
level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode.h [new file with mode: 0644]
level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode_range.c [moved from level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract_range.c with 74% similarity]
level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode_range.h [new file with mode: 0644]
level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract.h [deleted file]
level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract_range.h [deleted file]
level_0/f_fss/tests/unit/c/test-fss.c
level_0/f_fss/tests/unit/c/test-fss.h

index fe0366754833d7734d6e75f0157e16134d90c326..b4ba948a1b5f834a0e9c22ae3e20ae578da64e76 100644 (file)
@@ -4,87 +4,8 @@
 extern "C" {
 #endif
 
-#ifndef _di_f_fss_simple_packet_delete_
-  f_status_t f_fss_simple_packet_delete(f_fss_simple_packet_t * const simple_packet) {
-    #ifndef _di_level_0_parameter_checking_
-      if (!simple_packet) return F_status_set_error(F_parameter);
-    #endif // _di_level_0_parameter_checking_
-
-    if (simple_packet->payload.size && simple_packet->payload.string) {
-      const f_status_t status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &simple_packet->payload.string, &simple_packet->payload.used, &simple_packet->payload.size);
-      if (F_status_is_error(status)) return status;
-    }
-
-    return F_okay;
-  }
-#endif // _di_f_fss_simple_packet_delete_
-
-#ifndef _di_f_fss_simple_packet_destroy_
-  f_status_t f_fss_simple_packet_destroy(f_fss_simple_packet_t * const simple_packet) {
-    #ifndef _di_level_0_parameter_checking_
-      if (!simple_packet) return F_status_set_error(F_parameter);
-    #endif // _di_level_0_parameter_checking_
-
-    if (simple_packet->payload.size && simple_packet->payload.string) {
-      const f_status_t status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &simple_packet->payload.string, &simple_packet->payload.used, &simple_packet->payload.size);
-      if (F_status_is_error(status)) return status;
-    }
-
-    return F_okay;
-  }
-#endif // _di_f_fss_simple_packet_destroy_
-
-#ifndef _di_f_fss_simple_packet_encode_
-  f_status_t f_fss_simple_packet_encode(const uint8_t control, const uint32_t size, f_string_dynamic_t * const destination) {
-    #ifndef _di_level_0_parameter_checking_
-      if (!destination) return F_status_set_error(F_parameter);
-    #endif // _di_level_0_parameter_checking_
-
-    {
-      const f_status_t status = f_memory_array_increase_by(F_fss_simple_packet_block_header_size_d, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
-      if (F_status_is_error(status)) return status;
-    }
-
-    destination->string[destination->used++] = (uint8_t) control;
-
-    #ifdef _is_F_endian_little
-      // Big Endian.
-      if (control & F_fss_simple_packet_endian_d) {
-        destination->string[destination->used++] = ((uint8_t) size) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff;
-      }
-      // Little Endian.
-      else {
-        destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff;
-        destination->string[destination->used++] = ((uint8_t) size) & 0xff;
-      }
-    #else
-      // Big Endian.
-      if (control & F_fss_simple_packet_endian_d) {
-        destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff;
-        destination->string[destination->used++] = ((uint8_t) size) & 0xff;
-      }
-      // Little Endian.
-      else {
-        destination->string[destination->used++] = ((uint8_t) size)) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff;
-        destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff;
-      }
-    #endif // _is_F_endian_little
-
-    return F_okay;
-  }
-#endif // _di_f_fss_simple_packet_encode_
-
-#ifndef _di_f_fss_simple_packet_extract_
-  f_status_t f_fss_simple_packet_extract(const f_string_static_t buffer, f_fss_simple_packet_t * const packet) {
+#ifndef _di_f_fss_simple_packet_decode_
+  f_status_t f_fss_simple_packet_decode(const f_string_static_t buffer, f_fss_simple_packet_t * const packet) {
     #ifndef _di_level_0_parameter_checking_
       if (!packet) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
@@ -127,11 +48,11 @@ extern "C" {
 
     return F_okay;
   }
-#endif // _di_f_fss_simple_packet_extract_
+#endif // _di_f_fss_simple_packet_decode_
 
-#ifndef _di_f_fss_simple_packet_extract_range_
-  f_status_t f_fss_simple_packet_extract_range(const f_string_static_t buffer, f_fss_simple_packet_range_t * const packet) {
-    #ifndef _di_f_fss_simple_packet_extract_range_
+#ifndef _di_f_fss_simple_packet_decode_range_
+  f_status_t f_fss_simple_packet_decode_range(const f_string_static_t buffer, f_fss_simple_packet_range_t * const packet) {
+    #ifndef _di_f_fss_simple_packet_decode_range_
       if (!packet) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
 
@@ -176,7 +97,86 @@ extern "C" {
 
     return F_okay;
   }
-#endif // _di_f_fss_simple_packet_extract_range_
+#endif // _di_f_fss_simple_packet_decode_range_
+
+#ifndef _di_f_fss_simple_packet_delete_
+  f_status_t f_fss_simple_packet_delete(f_fss_simple_packet_t * const simple_packet) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!simple_packet) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    if (simple_packet->payload.size && simple_packet->payload.string) {
+      const f_status_t status = f_memory_array_resize(0, sizeof(f_char_t), (void **) &simple_packet->payload.string, &simple_packet->payload.used, &simple_packet->payload.size);
+      if (F_status_is_error(status)) return status;
+    }
+
+    return F_okay;
+  }
+#endif // _di_f_fss_simple_packet_delete_
+
+#ifndef _di_f_fss_simple_packet_destroy_
+  f_status_t f_fss_simple_packet_destroy(f_fss_simple_packet_t * const simple_packet) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!simple_packet) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    if (simple_packet->payload.size && simple_packet->payload.string) {
+      const f_status_t status = f_memory_array_adjust(0, sizeof(f_char_t), (void **) &simple_packet->payload.string, &simple_packet->payload.used, &simple_packet->payload.size);
+      if (F_status_is_error(status)) return status;
+    }
+
+    return F_okay;
+  }
+#endif // _di_f_fss_simple_packet_destroy_
+
+#ifndef _di_f_fss_simple_packet_encode_
+  f_status_t f_fss_simple_packet_encode(const uint8_t control, const uint32_t size, f_string_dynamic_t * const destination) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!destination) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    {
+      const f_status_t status = f_memory_array_increase_by(F_fss_simple_packet_block_header_size_d, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size);
+      if (F_status_is_error(status)) return status;
+    }
+
+    destination->string[destination->used++] = (uint8_t) control;
+
+    #ifdef _is_F_endian_little
+      // Big Endian.
+      if (control & F_fss_simple_packet_endian_d) {
+        destination->string[destination->used++] = ((uint8_t) size) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff;
+      }
+      // Little Endian.
+      else {
+        destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff;
+        destination->string[destination->used++] = ((uint8_t) size) & 0xff;
+      }
+    #else
+      // Big Endian.
+      if (control & F_fss_simple_packet_endian_d) {
+        destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff;
+        destination->string[destination->used++] = ((uint8_t) size) & 0xff;
+      }
+      // Little Endian.
+      else {
+        destination->string[destination->used++] = ((uint8_t) size)) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 8) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 16) & 0xff;
+        destination->string[destination->used++] = (((uint8_t) size) >> 24) & 0xff;
+      }
+    #endif // _is_F_endian_little
+
+    return F_okay;
+  }
+#endif // _di_f_fss_simple_packet_encode_
 
 #ifndef _di_f_fss_simple_packets_delete_callback_
   f_status_t f_fss_simple_packets_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) {
index 6f14c175caae2d48cb679a7928c5aae9221b452e..22bbf1fbbabcc6a921a764fb8d5782160d098b38 100644 (file)
@@ -200,6 +200,53 @@ extern "C" {
 #endif // _di_f_fss_simple_packet_rangess_t_
 
 /**
+ * Extract the different parts of the FSS-000F (Simple Packet) string into a packet structure.
+ *
+ * The buffer is processed as binary data, therefore, NULL and other control data are considered valid data and are not ignored.
+ *
+ * @param buffer
+ *   The string buffer to identify the packet ranges of.
+ *   This buffer is considered binary data and so any NULL found within is treated as a valid part of the buffer.
+ * @param packet
+ *   The packet extracted from the given buffer, without doing anything to the payload.
+ *   The caller can allocate the payload and extract it at any time by just selecting the string from F_fss_simple_packet_block_header_size_d until at most F_fss_simple_packet_block_payload_size_d.
+ *   Must not be NULL.
+ *
+ * @return
+ *   F_okay on success (The end of the Payload Block is assumed to be the remainder of the buffer or F_fss_simple_packet_block_payload_size_d, whichever is smaller).
+ *   F_packet_too_small if the buffer.used is smaller than the minimum size of the packet.
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *   F_valid_not (with error bit) if the data is invalid, which generally only happens when the value of the Size block is less than 5 (and when not returning F_partial).
+ */
+#ifndef _di_f_fss_simple_packet_decode_
+  extern f_status_t f_fss_simple_packet_decode(const f_string_static_t buffer, f_fss_simple_packet_t * const packet);
+#endif // _di_f_fss_simple_packet_decode_
+
+/**
+ * Extract the different parts of the FSS-000F (Simple Packet) string into a packet range structure.
+ *
+ * The buffer is processed as binary data, therefore, NULL and other control data are considered valid data and are not ignored.
+ *
+ * @param buffer
+ *   The string buffer to identify the packet ranges of.
+ *   This buffer is considered binary data and so any NULL found within is treated as a valid part of the buffer.
+ * @param packet
+ *   The packet range extracted from the given buffer, with the payload being represented by a range.
+ *   Must not be NULL.
+ *
+ * @return
+ *   F_okay on success (The end of the Payload Block is assumed to be the remainder of the buffer or F_fss_simple_packet_block_payload_size_d, whichever is smaller).
+ *   F_packet_too_small if the buffer.used is smaller than the minimum size of the packet.
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *   F_valid_not (with error bit) if the data is invalid, which generally only happens when the value of the Size block is less than 5 (and when not returning F_partial).
+ */
+#ifndef _di_f_fss_simple_packet_decode_range_
+  extern f_status_t f_fss_simple_packet_decode_range(const f_string_static_t buffer, f_fss_simple_packet_range_t * const packet);
+#endif // _di_f_fss_simple_packet_decode_range_
+
+/**
  * Delete a FSS-000F (Simple Packet).
  *
  * @param simple_packet
@@ -270,53 +317,6 @@ extern "C" {
 #endif // _di_f_fss_simple_packet_encode_
 
 /**
- * Extract the different parts of the FSS-000F (Simple Packet) string into a packet structure.
- *
- * The buffer is processed as binary data, therefore, NULL and other control data are considered valid data and are not ignored.
- *
- * @param buffer
- *   The string buffer to identify the packet ranges of.
- *   This buffer is considered binary data and so any NULL found within is treated as a valid part of the buffer.
- * @param packet
- *   The packet extracted from the given buffer, without doing anything to the payload.
- *   The caller can allocate the payload and extract it at any time by just selecting the string from F_fss_simple_packet_block_header_size_d until at most F_fss_simple_packet_block_payload_size_d.
- *   Must not be NULL.
- *
- * @return
- *   F_okay on success (The end of the Payload Block is assumed to be the remainder of the buffer or F_fss_simple_packet_block_payload_size_d, whichever is smaller).
- *   F_packet_too_small if the buffer.used is smaller than the minimum size of the packet.
- *
- *   F_parameter (with error bit) if a parameter is invalid.
- *   F_valid_not (with error bit) if the data is invalid, which generally only happens when the value of the Size block is less than 5 (and when not returning F_partial).
- */
-#ifndef _di_f_fss_simple_packet_extract_
-  extern f_status_t f_fss_simple_packet_extract(const f_string_static_t buffer, f_fss_simple_packet_t * const packet);
-#endif // _di_f_fss_simple_packet_extract_
-
-/**
- * Extract the different parts of the FSS-000F (Simple Packet) string into a packet range structure.
- *
- * The buffer is processed as binary data, therefore, NULL and other control data are considered valid data and are not ignored.
- *
- * @param buffer
- *   The string buffer to identify the packet ranges of.
- *   This buffer is considered binary data and so any NULL found within is treated as a valid part of the buffer.
- * @param packet
- *   The packet range extracted from the given buffer, with the payload being represented by a range.
- *   Must not be NULL.
- *
- * @return
- *   F_okay on success (The end of the Payload Block is assumed to be the remainder of the buffer or F_fss_simple_packet_block_payload_size_d, whichever is smaller).
- *   F_packet_too_small if the buffer.used is smaller than the minimum size of the packet.
- *
- *   F_parameter (with error bit) if a parameter is invalid.
- *   F_valid_not (with error bit) if the data is invalid, which generally only happens when the value of the Size block is less than 5 (and when not returning F_partial).
- */
-#ifndef _di_f_fss_simple_packet_extract_range_
-  extern f_status_t f_fss_simple_packet_extract_range(const f_string_static_t buffer, f_fss_simple_packet_range_t * const packet);
-#endif // _di_f_fss_simple_packet_extract_range_
-
-/**
  * A callback intended to be passed to f_memory_arrays_resize() for an f_fss_simple_packets_t structure.
  *
  * This is only called when shrinking the array and generally should perform deallocations.
index 3d3b51d02b1d9d24fdd71105938a8f77dfe0da79..b04aaf08f182ed73db95237635e76d4d2d2d2702 100644 (file)
@@ -36,7 +36,7 @@ build_sources_program test-fss-set_delete.c test-fss-set_destroy.c
 build_sources_program test-fss-sets_delete_callback.c test-fss-sets_destroy_callback.c test-fss-setss_delete_callback.c test-fss-setss_destroy_callback.c
 build_sources_program test-fss-set_quote_delete.c test-fss-set_quote_destroy.c
 build_sources_program test-fss-set_quotes_delete_callback.c test-fss-set_quotes_destroy_callback.c test-fss-set_quotess_delete_callback.c test-fss-set_quotess_destroy_callback.c
-build_sources_program test-fss-simple_packet_encode.c test-fss-simple_packet_extract.c test-fss-simple_packet_extract_range.c
+build_sources_program test-fss-simple_packet_decode.c test-fss-simple_packet_decode_range.c test-fss-simple_packet_encode.c
 build_sources_program test-fss-simple_packet_delete.c test-fss-simple_packet_destroy.c
 build_sources_program test-fss-simple_packets_delete_callback.c test-fss-simple_packets_destroy_callback.c test-fss-simple_packetss_delete_callback.c test-fss-simple_packetss_destroy_callback.c
 
similarity index 75%
rename from level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract.c
rename to level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode.c
index b9cab6e5145a102f63759d8f5f25ab498f817dcf..3285bfc8aad15fcf711b090864dfd469b5be1814 100644 (file)
@@ -1,20 +1,20 @@
 #include "test-fss.h"
-#include "test-fss-simple_packet_extract.h"
+#include "test-fss-simple_packet_decode.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void test__f_fss_simple_packet_extract__parameter_checking(void **state) {
+void test__f_fss_simple_packet_decode__parameter_checking(void **state) {
 
   {
-    const f_status_t status = f_fss_simple_packet_extract(f_string_empty_s, 0);
+    const f_status_t status = f_fss_simple_packet_decode(f_string_empty_s, 0);
 
     assert_int_equal(status, F_status_set_error(F_parameter));
   }
 }
 
-void test__f_fss_simple_packet_extract__returns_packet_too_small(void **state) {
+void test__f_fss_simple_packet_decode__returns_packet_too_small(void **state) {
 
   f_string_static_t test = macro_f_string_static_t_initialize_1("testing", 0, 0);
   f_fss_simple_packet_t packet = f_fss_simple_packet_t_initialize;
@@ -22,14 +22,14 @@ void test__f_fss_simple_packet_extract__returns_packet_too_small(void **state) {
   {
     for (test.used = 0; test.used < F_fss_simple_packet_block_header_size_d; ++test.used) {
 
-      const f_status_t status = f_fss_simple_packet_extract(f_string_empty_s, &packet);
+      const f_status_t status = f_fss_simple_packet_decode(f_string_empty_s, &packet);
 
       assert_int_equal(status, F_packet_too_small);
     } // for
   }
 }
 
-void test__f_fss_simple_packet_extract__works_big_endian(void **state) {
+void test__f_fss_simple_packet_decode__works_big_endian(void **state) {
 
   f_char_t string_1[] = { 0x80, 0x05, 0x00, 0x00, 0x00 };
   f_char_t string_2[] = { 0x80, 0x06, 0x00, 0x00, 0x00, 0x01 };
@@ -52,7 +52,7 @@ void test__f_fss_simple_packet_extract__works_big_endian(void **state) {
 
       f_fss_simple_packet_t packet = f_fss_simple_packet_t_initialize;
 
-      const f_status_t status = f_fss_simple_packet_extract(datas[i], &packet);
+      const f_status_t status = f_fss_simple_packet_decode(datas[i], &packet);
 
       assert_int_equal(status, F_okay);
       assert_int_equal(packet.control & F_fss_simple_packet_endian_d, F_fss_simple_packet_endian_d);
@@ -61,7 +61,7 @@ void test__f_fss_simple_packet_extract__works_big_endian(void **state) {
   }
 }
 
-void test__f_fss_simple_packet_extract__works_little_endian(void **state) {
+void test__f_fss_simple_packet_decode__works_little_endian(void **state) {
 
   f_char_t string_1[] = { 0x00, 0x00, 0x00, 0x00, 0x05 };
   f_char_t string_2[] = { 0x00, 0x00, 0x00, 0x00, 0x06, 0x01 };
@@ -84,7 +84,7 @@ void test__f_fss_simple_packet_extract__works_little_endian(void **state) {
 
       f_fss_simple_packet_t packet = f_fss_simple_packet_t_initialize;
 
-      const f_status_t status = f_fss_simple_packet_extract(datas[i], &packet);
+      const f_status_t status = f_fss_simple_packet_decode(datas[i], &packet);
 
       assert_int_equal(status, F_okay);
       assert_int_equal(packet.control & F_fss_simple_packet_endian_d, 0);
diff --git a/level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode.h b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode.h
new file mode 100644 (file)
index 0000000..e6a171c
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the array types in the FSS project.
+ */
+#ifndef _TEST__F_fss__simple_packet_decode
+#define _TEST__F_fss__simple_packet_decode
+
+/**
+ * Test that the function correctly fails on invalid parameter.
+ *
+ * @see f_fss_simple_packet_decode()
+ */
+extern void test__f_fss_simple_packet_decode__parameter_checking(void **state);
+
+/**
+ * Test that the function returns F_packet_too_small.
+ *
+ * @see f_fss_simple_packet_decode()
+ */
+extern void test__f_fss_simple_packet_decode__returns_packet_too_small(void **state);
+
+/**
+ * Test that the function works, with the control bit set to big endian.
+ *
+ * @see f_fss_simple_packet_decode()
+ */
+extern void test__f_fss_simple_packet_decode__works_big_endian(void **state);
+
+/**
+ * Test that the function works, with the control bit set to little endian.
+ *
+ * @see f_fss_simple_packet_decode()
+ */
+extern void test__f_fss_simple_packet_decode__works_little_endian(void **state);
+
+#endif // _TEST__F_fss__simple_packet_decode
similarity index 74%
rename from level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract_range.c
rename to level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode_range.c
index ebbda3a0f43652051e3f558d062da800e5794962..c0ee1eaf3b5e516052d1f40294f0b199cbfed37c 100644 (file)
@@ -1,20 +1,20 @@
 #include "test-fss.h"
-#include "test-fss-simple_packet_extract_range.h"
+#include "test-fss-simple_packet_decode_range.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void test__f_fss_simple_packet_extract_range__parameter_checking(void **state) {
+void test__f_fss_simple_packet_decode_range__parameter_checking(void **state) {
 
   {
-    const f_status_t status = f_fss_simple_packet_extract_range(f_string_empty_s, 0);
+    const f_status_t status = f_fss_simple_packet_decode_range(f_string_empty_s, 0);
 
     assert_int_equal(status, F_status_set_error(F_parameter));
   }
 }
 
-void test__f_fss_simple_packet_extract_range__returns_packet_too_small(void **state) {
+void test__f_fss_simple_packet_decode_range__returns_packet_too_small(void **state) {
 
   f_string_static_t test = macro_f_string_static_t_initialize_1("testing", 0, 0);
   f_fss_simple_packet_range_t packet = f_fss_simple_packet_range_t_initialize;
@@ -22,14 +22,14 @@ void test__f_fss_simple_packet_extract_range__returns_packet_too_small(void **st
   {
     for (test.used = 0; test.used < F_fss_simple_packet_block_header_size_d; ++test.used) {
 
-      const f_status_t status = f_fss_simple_packet_extract_range(f_string_empty_s, &packet);
+      const f_status_t status = f_fss_simple_packet_decode_range(f_string_empty_s, &packet);
 
       assert_int_equal(status, F_packet_too_small);
     } // for
   }
 }
 
-void test__f_fss_simple_packet_extract_range__works_big_endian(void **state) {
+void test__f_fss_simple_packet_decode_range__works_big_endian(void **state) {
 
   f_char_t string_1[] = { 0x80, 0x05, 0x00, 0x00, 0x00 };
   f_char_t string_2[] = { 0x80, 0x06, 0x00, 0x00, 0x00, 0x01 };
@@ -52,7 +52,7 @@ void test__f_fss_simple_packet_extract_range__works_big_endian(void **state) {
 
       f_fss_simple_packet_range_t packet = f_fss_simple_packet_range_t_initialize;
 
-      const f_status_t status = f_fss_simple_packet_extract_range(datas[i], &packet);
+      const f_status_t status = f_fss_simple_packet_decode_range(datas[i], &packet);
 
       assert_int_equal(status, F_okay);
       assert_int_equal(packet.control & F_fss_simple_packet_endian_d, F_fss_simple_packet_endian_d);
@@ -61,7 +61,7 @@ void test__f_fss_simple_packet_extract_range__works_big_endian(void **state) {
   }
 }
 
-void test__f_fss_simple_packet_extract_range__works_little_endian(void **state) {
+void test__f_fss_simple_packet_decode_range__works_little_endian(void **state) {
 
   f_char_t string_1[] = { 0x00, 0x00, 0x00, 0x00, 0x05 };
   f_char_t string_2[] = { 0x00, 0x00, 0x00, 0x00, 0x06, 0x01 };
@@ -84,7 +84,7 @@ void test__f_fss_simple_packet_extract_range__works_little_endian(void **state)
 
       f_fss_simple_packet_range_t packet = f_fss_simple_packet_range_t_initialize;
 
-      const f_status_t status = f_fss_simple_packet_extract_range(datas[i], &packet);
+      const f_status_t status = f_fss_simple_packet_decode_range(datas[i], &packet);
 
       assert_int_equal(status, F_okay);
       assert_int_equal(packet.control & F_fss_simple_packet_endian_d, 0);
diff --git a/level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode_range.h b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_decode_range.h
new file mode 100644 (file)
index 0000000..de9673b
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Test the array types in the FSS project.
+ */
+#ifndef _TEST__F_fss__simple_packet_decode_range
+#define _TEST__F_fss__simple_packet_decode_range
+
+/**
+ * Test that the function correctly fails on invalid parameter.
+ *
+ * @see f_fss_simple_packet_decode_range()
+ */
+extern void test__f_fss_simple_packet_decode_range__parameter_checking(void **state);
+
+/**
+ * Test that the function returns F_packet_too_small.
+ *
+ * @see f_fss_simple_packet_decode_range()
+ */
+extern void test__f_fss_simple_packet_decode_range__returns_packet_too_small(void **state);
+
+/**
+ * Test that the function works, with the control bit set to big endian.
+ *
+ * @see f_fss_simple_packet_decode_range()
+ */
+extern void test__f_fss_simple_packet_decode_range__works_big_endian(void **state);
+
+/**
+ * Test that the function works, with the control bit set to little endian.
+ *
+ * @see f_fss_simple_packet_decode_range()
+ */
+extern void test__f_fss_simple_packet_decode_range__works_little_endian(void **state);
+
+#endif // _TEST__F_fss__simple_packet_decode_range
diff --git a/level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract.h b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract.h
deleted file mode 100644 (file)
index 6a2e014..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * FLL - Level 0
- *
- * Project: FSS
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the FSS project.
- */
-#ifndef _TEST__F_fss__simple_packet_extract
-#define _TEST__F_fss__simple_packet_extract
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_fss_simple_packet_extract()
- */
-extern void test__f_fss_simple_packet_extract__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_packet_too_small.
- *
- * @see f_fss_simple_packet_extract()
- */
-extern void test__f_fss_simple_packet_extract__returns_packet_too_small(void **state);
-
-/**
- * Test that the function works, with the control bit set to big endian.
- *
- * @see f_fss_simple_packet_extract()
- */
-extern void test__f_fss_simple_packet_extract__works_big_endian(void **state);
-
-/**
- * Test that the function works, with the control bit set to little endian.
- *
- * @see f_fss_simple_packet_extract()
- */
-extern void test__f_fss_simple_packet_extract__works_little_endian(void **state);
-
-#endif // _TEST__F_fss__simple_packet_extract
diff --git a/level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract_range.h b/level_0/f_fss/tests/unit/c/test-fss-simple_packet_extract_range.h
deleted file mode 100644 (file)
index 25b1a16..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * FLL - Level 0
- *
- * Project: FSS
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the array types in the FSS project.
- */
-#ifndef _TEST__F_fss__simple_packet_extract_range
-#define _TEST__F_fss__simple_packet_extract_range
-
-/**
- * Test that the function correctly fails on invalid parameter.
- *
- * @see f_fss_simple_packet_extract_range()
- */
-extern void test__f_fss_simple_packet_extract_range__parameter_checking(void **state);
-
-/**
- * Test that the function returns F_packet_too_small.
- *
- * @see f_fss_simple_packet_extract_range()
- */
-extern void test__f_fss_simple_packet_extract_range__returns_packet_too_small(void **state);
-
-/**
- * Test that the function works, with the control bit set to big endian.
- *
- * @see f_fss_simple_packet_extract_range()
- */
-extern void test__f_fss_simple_packet_extract_range__works_big_endian(void **state);
-
-/**
- * Test that the function works, with the control bit set to little endian.
- *
- * @see f_fss_simple_packet_extract_range()
- */
-extern void test__f_fss_simple_packet_extract_range__works_little_endian(void **state);
-
-#endif // _TEST__F_fss__simple_packet_extract_range
index 950351b62c795c874a3bbdd29abe4eef0d518831..999dbb08baebe70da403e0fe5ff81bbc9ee9593b 100644 (file)
@@ -129,16 +129,16 @@ int main(void) {
     cmocka_unit_test(test__f_fss_simple_packetss_delete_callback__works),
     cmocka_unit_test(test__f_fss_simple_packetss_destroy_callback__works),
 
+    cmocka_unit_test(test__f_fss_simple_packet_decode__works_little_endian),
+    cmocka_unit_test(test__f_fss_simple_packet_decode_range__works_little_endian),
     cmocka_unit_test(test__f_fss_simple_packet_encode__works_little_endian),
-    cmocka_unit_test(test__f_fss_simple_packet_extract__works_little_endian),
-    cmocka_unit_test(test__f_fss_simple_packet_extract_range__works_little_endian),
 
-    cmocka_unit_test(test__f_fss_simple_packet_extract__works_big_endian),
-    cmocka_unit_test(test__f_fss_simple_packet_extract_range__works_big_endian),
+    cmocka_unit_test(test__f_fss_simple_packet_decode__works_big_endian),
+    cmocka_unit_test(test__f_fss_simple_packet_decode_range__works_big_endian),
     cmocka_unit_test(test__f_fss_simple_packet_encode__works_big_endian),
 
-    cmocka_unit_test(test__f_fss_simple_packet_extract__returns_packet_too_small),
-    cmocka_unit_test(test__f_fss_simple_packet_extract_range__returns_packet_too_small),
+    cmocka_unit_test(test__f_fss_simple_packet_decode__returns_packet_too_small),
+    cmocka_unit_test(test__f_fss_simple_packet_decode_range__returns_packet_too_small),
 
     #ifndef _di_level_0_parameter_checking_
       cmocka_unit_test(test__f_fss_apply_delimit__parameter_checking),
@@ -170,11 +170,11 @@ int main(void) {
       cmocka_unit_test(test__f_fss_set_quote_delete__parameter_checking),
       cmocka_unit_test(test__f_fss_set_quote_destroy__parameter_checking),
 
+      cmocka_unit_test(test__f_fss_simple_packet_decode__parameter_checking),
+      cmocka_unit_test(test__f_fss_simple_packet_decode_range__parameter_checking),
       cmocka_unit_test(test__f_fss_simple_packet_delete__parameter_checking),
       cmocka_unit_test(test__f_fss_simple_packet_destroy__parameter_checking),
       cmocka_unit_test(test__f_fss_simple_packet_encode__parameter_checking),
-      cmocka_unit_test(test__f_fss_simple_packet_extract__parameter_checking),
-      cmocka_unit_test(test__f_fss_simple_packet_extract_range__parameter_checking),
 
       // f_fss_items_delete_callback() doesn't use parameter checking.
       // f_fss_items_destroy_callback() doesn't use parameter checking.
index 5b7433acea2d450f2073ca33cf92f50c8eb77dfb..15945b3aa70c3d21d32a69fe8c03d5c07428c889 100644 (file)
 #include "test-fss-set_quotes_destroy_callback.h"
 #include "test-fss-set_quotess_delete_callback.h"
 #include "test-fss-set_quotess_destroy_callback.h"
-#include "test-fss-simple_packet_encode.h"
-#include "test-fss-simple_packet_extract.h"
-#include "test-fss-simple_packet_extract_range.h"
+#include "test-fss-simple_packet_decode.h"
+#include "test-fss-simple_packet_decode_range.h"
 #include "test-fss-simple_packet_delete.h"
 #include "test-fss-simple_packet_destroy.h"
+#include "test-fss-simple_packet_encode.h"
 #include "test-fss-simple_packets_delete_callback.h"
 #include "test-fss-simple_packets_destroy_callback.h"
 #include "test-fss-simple_packetss_delete_callback.h"