]> Kevux Git Server - fll/commitdiff
Update: Add parameter checking to unit tests and fix ordering.
authorKevin Day <thekevinday@gmail.com>
Sun, 16 Jan 2022 22:49:43 +0000 (16:49 -0600)
committerKevin Day <thekevinday@gmail.com>
Sun, 16 Jan 2022 22:49:43 +0000 (16:49 -0600)
13 files changed:
level_0/f_memory/tests/c/test-memory-adjust.c
level_0/f_memory/tests/c/test-memory-adjust.h
level_0/f_memory/tests/c/test-memory-delete.c
level_0/f_memory/tests/c/test-memory-delete.h
level_0/f_memory/tests/c/test-memory-destroy.c
level_0/f_memory/tests/c/test-memory-destroy.h
level_0/f_memory/tests/c/test-memory-new.c
level_0/f_memory/tests/c/test-memory-new.h
level_0/f_memory/tests/c/test-memory-new_aligned.c
level_0/f_memory/tests/c/test-memory-new_aligned.h
level_0/f_memory/tests/c/test-memory-resize.c
level_0/f_memory/tests/c/test-memory-resize.h
level_0/f_memory/tests/c/test-memory.c

index fa6bb47ad0a02623a2cbbc7ccad2f580d6f98b8d..892e2d5d0b6dbdf45ee641fce2e88834f004e77b 100644 (file)
@@ -5,6 +5,23 @@
 extern "C" {
 #endif
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_memory_adjust__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_memory_adjust(1, 4, 0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+
+    {
+      const f_status_t status = f_memory_adjust(1, 4, 1, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_memory_adjust__works(void **state) {
 
   uint16_t *data = 0;
index 63532d953f65ee291e51254c2c6cbac3c0d45959..534080e82347e99397d20dc0a325412b6080be05 100644 (file)
 #define _TEST__F_memory__adjust
 
 /**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_memory_adjust()
+ */
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_memory_adjust__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
  * Test that reallocation works.
  *
  * @see f_memory_new()
index f2e538cc3488b83d666eec62e24d082985041cab..85ddd6aa5f4af323d577881d962dc4e44311c4f3 100644 (file)
@@ -95,6 +95,17 @@ void test__f_memory_delete__frees_resized_memory(void **state) {
   }
 }
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_memory_delete__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_memory_delete(4, 0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index c78a5b19f727eb861c225e361a8b9d0ce6c9d7c3..fe9626ca657ec7ac4a842016b7209b6316b73176 100644 (file)
@@ -44,4 +44,13 @@ extern void test__f_memory_delete__frees_memory(void **state);
  */
 extern void test__f_memory_delete__frees_resized_memory(void **state);
 
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_memory_delete()
+ */
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_memory_delete__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
 #endif // _TEST__F_memory__delete
index cc6732fdf35a5502c8c2ce1a9c5f5dd37bd16dfa..75c30460e49e01276fcc92b4536eefc27b7f4f6a 100644 (file)
@@ -95,6 +95,17 @@ void test__f_memory_destroy__frees_resized_memory(void **state) {
   }
 }
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_memory_destroy__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_memory_destroy(4, 0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 4a57ce6df1ca36efe1789c5e2955f0c279628780..561aec2f755843d6d468fa9df7a591604dc4c4f3 100644 (file)
@@ -44,4 +44,13 @@ extern void test__f_memory_destroy__frees_memory(void **state);
  */
 extern void test__f_memory_destroy__frees_resized_memory(void **state);
 
+/**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_memory_destroy()
+ */
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_memory_destroy__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
 #endif // _TEST__F_memory__destroy
index c52f195a0b152ad6abcb2aa9f4a02a07f4197bee..257500e162f833ebe4b02aae66380c215caa0547 100644 (file)
@@ -5,6 +5,17 @@
 extern "C" {
 #endif
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_memory_new__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_memory_new(1, 0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_memory_new__works(void **state) {
 
   uint16_t *data = 0;
index 08a2807e4296b5b45e2a4d4da9f2ca06c7ed15fc..a3ab86709a48f9e068a5bb6095034ea4ffebb42f 100644 (file)
 #define _TEST__F_memory__new
 
 /**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_memory_new()
+ */
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_memory_new__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
  * Test that allocation works.
  *
  * @see f_memory_new()
index 784982387bf3f159e0a15185f4fb88771b459849..859727bf97fbf71036e8b596b21301b827183649 100644 (file)
@@ -5,6 +5,17 @@
 extern "C" {
 #endif
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_memory_new_aligned__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_memory_new_aligned(1, 0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_memory_new_aligned__works(void **state) {
 
   uint16_t *data = 0;
index a819b5a49772d29d37d105f2d071ba1b67cf52ca..9b520f69a276b40a51510d14fbb443c7a3cc0170 100644 (file)
 #define _TEST__F_memory__new_aligned
 
 /**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_memory_new_aligned()
+ */
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_memory_new_aligned__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
  * Test that allocation works.
  *
  * @see f_memory_new_aligned()
index a0d77dc373d6696049c2762059370a7b8903f248..8070bf0bcf492e236167af79e65568c0cf43d53b 100644 (file)
@@ -5,6 +5,23 @@
 extern "C" {
 #endif
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_memory_resize__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_memory_resize(1, 4, 0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+
+    {
+      const f_status_t status = f_memory_resize(1, 4, 1, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_memory_resize__works(void **state) {
 
   uint16_t *data = 0;
index fc91c53e35e80eff5081920b6b1e18a08742732a..58efe233d1c434a76ed0b30aa5bbe5a351e03b32 100644 (file)
 #define _TEST__F_memory__resize
 
 /**
+ * Test that parameter checking works as expected.
+ *
+ * @see f_memory_resize()
+ */
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_memory_resize__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
+
+/**
  * Test that reallocation works.
  *
  * @see f_memory_new()
index 9d868c63e4553df51d048f1053b80a0e375fb6f0..e45960ed1bde8a8043b9e698b072d3f3253f5d1a 100644 (file)
@@ -33,6 +33,14 @@ int main(void) {
     cmocka_unit_test(test__f_memory_new_aligned__works),
 
     cmocka_unit_test(test__f_memory_resize__works),
+
+    #ifndef _di_level_0_parameter_checking_
+      cmocka_unit_test(test__f_memory_adjust__parameter_checking),
+      cmocka_unit_test(test__f_memory_delete__parameter_checking),
+      cmocka_unit_test(test__f_memory_destroy__parameter_checking),
+      cmocka_unit_test(test__f_memory_new__parameter_checking),
+      cmocka_unit_test(test__f_memory_resize__parameter_checking),
+    #endif // _di_level_0_parameter_checking_
   };
 
   return cmocka_run_group_tests(tests, setup, setdown);