]> Kevux Git Server - fll/commitdiff
Update: Add parameter checking to unit tests, fix ordering, and other minor changes.
authorKevin Day <thekevinday@gmail.com>
Sun, 16 Jan 2022 20:58:57 +0000 (14:58 -0600)
committerKevin Day <thekevinday@gmail.com>
Sun, 16 Jan 2022 20:59:23 +0000 (14:59 -0600)
13 files changed:
level_0/f_account/tests/c/test-account-by_id.c
level_0/f_account/tests/c/test-account-by_id.h
level_0/f_account/tests/c/test-account-by_name.c
level_0/f_account/tests/c/test-account-by_name.h
level_0/f_account/tests/c/test-account-id_group_by_name.c
level_0/f_account/tests/c/test-account-id_group_by_name.h
level_0/f_account/tests/c/test-account-id_user_by_name.c
level_0/f_account/tests/c/test-account-id_user_by_name.h
level_0/f_account/tests/c/test-account-name_group_by_id.c
level_0/f_account/tests/c/test-account-name_group_by_id.h
level_0/f_account/tests/c/test-account-name_user_by_id.c
level_0/f_account/tests/c/test-account-name_user_by_id.h
level_0/f_account/tests/c/test-account.c

index 3c43894368d6ace1e8641d7585c72efda60a6f77..c4d7395a2c4c7b070b2c8f775c6fca0feb15f572 100644 (file)
@@ -5,6 +5,46 @@
 extern "C" {
 #endif
 
+void test__f_account_by_id__fails(void **state) {
+
+  const long size = 20;
+  uid_t uid = 0;
+  f_account_t account = f_account_t_initialize;
+
+  int errnos[] = {
+    EINTR,
+    EIO,
+    EMFILE,
+    ENFILE,
+    ENOMEM,
+    ERANGE,
+    mock_errno_generic,
+  };
+
+  f_status_t statuss[] = {
+    F_interrupt,
+    F_input_output,
+    F_file_descriptor_max,
+    F_file_open_max,
+    F_memory_not,
+    F_buffer_too_small,
+    F_failure,
+  };
+
+  for (int i = 0; i < 7; ++i) {
+
+    will_return(__wrap_sysconf, size);
+    will_return(__wrap_getpwuid_r, true);
+    will_return(__wrap_getpwuid_r, errnos[i]);
+
+    const f_status_t status = f_account_by_id(uid, &account);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
+  } // for
+
+  macro_f_account_t_delete_simple(account);
+}
+
 void test__f_account_by_id__not_found(void **state) {
 
   const long size = 20;
@@ -26,6 +66,17 @@ void test__f_account_by_id__not_found(void **state) {
   macro_f_account_t_delete_simple(account);
 }
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_account_by_id__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_account_by_id(0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_account_by_id__works(void **state) {
 
   const long size = 20;
@@ -63,46 +114,6 @@ void test__f_account_by_id__works(void **state) {
   macro_f_account_t_delete_simple(account);
 }
 
-void test__f_account_by_id__fails(void **state) {
-
-  const long size = 20;
-  uid_t uid = 0;
-  f_account_t account = f_account_t_initialize;
-
-  int errnos[] = {
-    EINTR,
-    EIO,
-    EMFILE,
-    ENFILE,
-    ENOMEM,
-    ERANGE,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_interrupt,
-    F_input_output,
-    F_file_descriptor_max,
-    F_file_open_max,
-    F_memory_not,
-    F_buffer_too_small,
-    F_failure,
-  };
-
-  for (int i = 0; i < 7; ++i) {
-
-    will_return(__wrap_sysconf, size);
-    will_return(__wrap_getpwuid_r, true);
-    will_return(__wrap_getpwuid_r, errnos[i]);
-
-    const f_status_t status = f_account_by_id(uid, &account);
-
-    assert_int_equal(F_status_set_fine(status), statuss[i]);
-  } // for
-
-  macro_f_account_t_delete_simple(account);
-}
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 00c9d31858ef0d7a0fc43c270b4508ea51acbb21..111eb12b6ff4e09b48b7858aa8dbcfe5e41d5379 100644 (file)
 #define _TEST__F_account_by_id_
 
 /**
+ * Test that function fails.
+ *
+ * @see f_account_by_id()
+ */
+extern void test__f_account_by_id__fails(void **state);
+
+/**
  * Test that function works but the account does not exist.
  *
  * @see f_account_by_id()
 extern void test__f_account_by_id__not_found(void **state);
 
 /**
- * Test that function works.
+ * Test that parameter checking works as expected.
  *
  * @see f_account_by_id()
  */
-extern void test__f_account_by_id__works(void **state);
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_account_by_id__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
 
 /**
- * Test that function fails.
+ * Test that function works.
  *
  * @see f_account_by_id()
  */
-extern void test__f_account_by_id__fails(void **state);
+extern void test__f_account_by_id__works(void **state);
 
 #endif // _TEST__F_account_by_id_
index d3a9075403ee7d83a9809a97031dd67f7eed67c0..e1faebf15748a17e675492b398be859580752c1c 100644 (file)
@@ -5,11 +5,51 @@
 extern "C" {
 #endif
 
+void test__f_account_by_name__fails(void **state) {
+
+  const long size = 20;
+  char *name = "name";
+  f_account_t account = f_account_t_initialize;
+
+  int errnos[] = {
+    EINTR,
+    EIO,
+    EMFILE,
+    ENFILE,
+    ENOMEM,
+    ERANGE,
+    mock_errno_generic,
+  };
+
+  f_status_t statuss[] = {
+    F_interrupt,
+    F_input_output,
+    F_file_descriptor_max,
+    F_file_open_max,
+    F_memory_not,
+    F_buffer_too_small,
+    F_failure,
+  };
+
+  for (int i = 0; i < 7; ++i) {
+
+    will_return(__wrap_sysconf, size);
+    will_return(__wrap_getpwnam_r, true);
+    will_return(__wrap_getpwnam_r, errnos[i]);
+
+    const f_status_t status = f_account_by_name(name, &account);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
+  } // for
+
+  macro_f_account_t_delete_simple(account);
+}
+
 void test__f_account_by_name__not_found(void **state) {
 
   const long size = 20;
   struct passwd password;
-  char *name = "the_name";
+  char *name = "name";
   f_account_t account = f_account_t_initialize;
 
   {
@@ -26,12 +66,25 @@ void test__f_account_by_name__not_found(void **state) {
   macro_f_account_t_delete_simple(account);
 }
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_account_by_name__parameter_checking(void **state) {
+
+    const f_string_t name = f_string_t_initialize;
+
+    {
+      const f_status_t status = f_account_by_name(name, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_account_by_name__works(void **state) {
 
   const long size = 20;
   struct passwd password;
   struct passwd pointer;
-  char *name = "the_name";
+  char *name = "name";
   f_account_t account = f_account_t_initialize;
 
   password.pw_uid = 1;
@@ -63,46 +116,6 @@ void test__f_account_by_name__works(void **state) {
   macro_f_account_t_delete_simple(account);
 }
 
-void test__f_account_by_name__fails(void **state) {
-
-  const long size = 20;
-  char *name = "the_name";
-  f_account_t account = f_account_t_initialize;
-
-  int errnos[] = {
-    EINTR,
-    EIO,
-    EMFILE,
-    ENFILE,
-    ENOMEM,
-    ERANGE,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_interrupt,
-    F_input_output,
-    F_file_descriptor_max,
-    F_file_open_max,
-    F_memory_not,
-    F_buffer_too_small,
-    F_failure,
-  };
-
-  for (int i = 0; i < 7; ++i) {
-
-    will_return(__wrap_sysconf, size);
-    will_return(__wrap_getpwnam_r, true);
-    will_return(__wrap_getpwnam_r, errnos[i]);
-
-    const f_status_t status = f_account_by_name(name, &account);
-
-    assert_int_equal(F_status_set_fine(status), statuss[i]);
-  } // for
-
-  macro_f_account_t_delete_simple(account);
-}
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 46532938822573fff6be4c38f1b4fb1830e6f2be..0c7812c9ac42c322b263f0607414e08224330c8f 100644 (file)
 #define _TEST__F_account_by_name_
 
 /**
+ * Test that function fails.
+ *
+ * @see f_account_by_name()
+ */
+extern void test__f_account_by_name__fails(void **state);
+
+/**
  * Test that function works but the account does not exist.
  *
  * @see f_account_by_name()
 extern void test__f_account_by_name__not_found(void **state);
 
 /**
- * Test that function works.
+ * Test that parameter checking works as expected.
  *
  * @see f_account_by_name()
  */
-extern void test__f_account_by_name__works(void **state);
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_account_by_name__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
 
 /**
- * Test that function fails.
+ * Test that function works.
  *
  * @see f_account_by_name()
  */
-extern void test__f_account_by_name__fails(void **state);
+extern void test__f_account_by_name__works(void **state);
 
 #endif // _TEST__F_account_by_name_
index b547d98f51e20f0a80764e686cc2416db5f8cc34..0d8900381849ef8a3ed3507edcca728d99927ec1 100644 (file)
@@ -5,11 +5,49 @@
 extern "C" {
 #endif
 
+void test__f_account_id_group_by_name__fails(void **state) {
+
+  const long size = 20;
+  char *name = "name";
+  gid_t gid = 0;
+
+  int errnos[] = {
+    EINTR,
+    EIO,
+    EMFILE,
+    ENFILE,
+    ENOMEM,
+    ERANGE,
+    mock_errno_generic,
+  };
+
+  f_status_t statuss[] = {
+    F_interrupt,
+    F_input_output,
+    F_file_descriptor_max,
+    F_file_open_max,
+    F_memory_not,
+    F_buffer_too_small,
+    F_failure,
+  };
+
+  for (int i = 0; i < 7; ++i) {
+
+    will_return(__wrap_sysconf, size);
+    will_return(__wrap_getgrnam_r, true);
+    will_return(__wrap_getgrnam_r, errnos[i]);
+
+    const f_status_t status = f_account_id_group_by_name(name, &gid);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
+  } // for
+}
+
 void test__f_account_id_group_by_name__not_found(void **state) {
 
   const long size = 20;
   struct group group_data;
-  char *name = "the_name";
+  char *name = "name";
   gid_t gid = 0;
 
   {
@@ -24,6 +62,19 @@ void test__f_account_id_group_by_name__not_found(void **state) {
   }
 }
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_account_id_group_by_name__parameter_checking(void **state) {
+
+    const f_string_t name = f_string_t_initialize;
+
+    {
+      const f_status_t status = f_account_id_group_by_name(name, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_account_id_group_by_name__works(void **state) {
 
   const long size = 20;
@@ -33,7 +84,7 @@ void test__f_account_id_group_by_name__works(void **state) {
   gid_t gid = 0;
 
   group_data.gr_gid = 1;
-  group_data.gr_name = "the_name";
+  group_data.gr_name = "gr_name";
   group_data.gr_passwd = "gr_passwd";
   group_data.gr_mem = pointers;
 
@@ -50,44 +101,6 @@ void test__f_account_id_group_by_name__works(void **state) {
   }
 }
 
-void test__f_account_id_group_by_name__fails(void **state) {
-
-  const long size = 20;
-  char *name = "the_name";
-  gid_t gid = 0;
-
-  int errnos[] = {
-    EINTR,
-    EIO,
-    EMFILE,
-    ENFILE,
-    ENOMEM,
-    ERANGE,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_interrupt,
-    F_input_output,
-    F_file_descriptor_max,
-    F_file_open_max,
-    F_memory_not,
-    F_buffer_too_small,
-    F_failure,
-  };
-
-  for (int i = 0; i < 7; ++i) {
-
-    will_return(__wrap_sysconf, size);
-    will_return(__wrap_getgrnam_r, true);
-    will_return(__wrap_getgrnam_r, errnos[i]);
-
-    const f_status_t status = f_account_id_group_by_name(name, &gid);
-
-    assert_int_equal(F_status_set_fine(status), statuss[i]);
-  } // for
-}
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 81f0c77a865b46fc2df4f80014246c1251d51990..e1fe41d61b1c0839db3598bfede5e8c69b7397da 100644 (file)
 #define _TEST__F_account_id_group_by_name_
 
 /**
+ * Test that function fails.
+ *
+ * @see f_account_id_group_by_name()
+ */
+extern void test__f_account_id_group_by_name__fails(void **state);
+
+/**
  * Test that function works but the group does not exist.
  *
  * @see f_account_id_group_by_name()
 extern void test__f_account_id_group_by_name__not_found(void **state);
 
 /**
- * Test that function works.
+ * Test that parameter checking works as expected.
  *
  * @see f_account_id_group_by_name()
  */
-extern void test__f_account_id_group_by_name__works(void **state);
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_account_id_group_by_name__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
 
 /**
- * Test that function fails.
+ * Test that function works.
  *
  * @see f_account_id_group_by_name()
  */
-extern void test__f_account_id_group_by_name__fails(void **state);
+extern void test__f_account_id_group_by_name__works(void **state);
 
 #endif // _TEST__F_account_id_group_by_name_
index 17811ed1bd3d794ca801863700291e7a791eed90..4549f82d0de0ec03a2b8557e78628f88a1ea69e6 100644 (file)
@@ -5,11 +5,49 @@
 extern "C" {
 #endif
 
+void test__f_account_id_user_by_name__fails(void **state) {
+
+  const long size = 20;
+  char *name = "name";
+  uid_t uid = 0;
+
+  int errnos[] = {
+    EINTR,
+    EIO,
+    EMFILE,
+    ENFILE,
+    ENOMEM,
+    ERANGE,
+    mock_errno_generic,
+  };
+
+  f_status_t statuss[] = {
+    F_interrupt,
+    F_input_output,
+    F_file_descriptor_max,
+    F_file_open_max,
+    F_memory_not,
+    F_buffer_too_small,
+    F_failure,
+  };
+
+  for (int i = 0; i < 7; ++i) {
+
+    will_return(__wrap_sysconf, size);
+    will_return(__wrap_getpwnam_r, true);
+    will_return(__wrap_getpwnam_r, errnos[i]);
+
+    const f_status_t status = f_account_id_user_by_name(name, &uid);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
+  } // for
+}
+
 void test__f_account_id_user_by_name__not_found(void **state) {
 
   const long size = 20;
   struct passwd password;
-  char *name = "the_name";
+  char *name = "name";
   uid_t uid = 0;
 
   {
@@ -24,6 +62,19 @@ void test__f_account_id_user_by_name__not_found(void **state) {
   }
 }
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_account_id_user_by_name__parameter_checking(void **state) {
+
+    const f_string_t name = f_string_t_initialize;
+
+    {
+      const f_status_t status = f_account_id_user_by_name(name, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_account_id_user_by_name__works(void **state) {
 
   const long size = 20;
@@ -52,44 +103,6 @@ void test__f_account_id_user_by_name__works(void **state) {
   }
 }
 
-void test__f_account_id_user_by_name__fails(void **state) {
-
-  const long size = 20;
-  char *name = "the_name";
-  uid_t uid = 0;
-
-  int errnos[] = {
-    EINTR,
-    EIO,
-    EMFILE,
-    ENFILE,
-    ENOMEM,
-    ERANGE,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_interrupt,
-    F_input_output,
-    F_file_descriptor_max,
-    F_file_open_max,
-    F_memory_not,
-    F_buffer_too_small,
-    F_failure,
-  };
-
-  for (int i = 0; i < 7; ++i) {
-
-    will_return(__wrap_sysconf, size);
-    will_return(__wrap_getpwnam_r, true);
-    will_return(__wrap_getpwnam_r, errnos[i]);
-
-    const f_status_t status = f_account_id_user_by_name(name, &uid);
-
-    assert_int_equal(F_status_set_fine(status), statuss[i]);
-  } // for
-}
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index d60904af7dd079ccce2b06e55f5012b001b4d1d2..77866627bf7efee79c398f4ae9572ba1fbb0803f 100644 (file)
 #define _TEST__F_account_id_user_by_name_
 
 /**
+ * Test that function fails.
+ *
+ * @see f_account_id_user_by_name()
+ */
+extern void test__f_account_id_user_by_name__fails(void **state);
+
+/**
  * Test that function works but the group does not exist.
  *
  * @see f_account_id_user_by_name()
 extern void test__f_account_id_user_by_name__not_found(void **state);
 
 /**
- * Test that function works.
+ * Test that parameter checking works as expected.
  *
  * @see f_account_id_user_by_name()
  */
-extern void test__f_account_id_user_by_name__works(void **state);
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_account_id_user_by_name__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
 
 /**
- * Test that function fails.
+ * Test that function works.
  *
  * @see f_account_id_user_by_name()
  */
-extern void test__f_account_id_user_by_name__fails(void **state);
+extern void test__f_account_id_user_by_name__works(void **state);
 
 #endif // _TEST__F_account_id_user_by_name_
index d1ff3436166ca7c476234211bdd6c7170ccbc3be..6103838a288bcbbf9798061ef82e4cca7955c1a1 100644 (file)
@@ -5,6 +5,46 @@
 extern "C" {
 #endif
 
+void test__f_account_name_group_by_id__fails(void **state) {
+
+  const long size = 20;
+  gid_t gid = 0;
+  f_string_dynamic_t name = f_string_dynamic_t_initialize;
+
+  int errnos[] = {
+    EINTR,
+    EIO,
+    EMFILE,
+    ENFILE,
+    ENOMEM,
+    ERANGE,
+    mock_errno_generic,
+  };
+
+  f_status_t statuss[] = {
+    F_interrupt,
+    F_input_output,
+    F_file_descriptor_max,
+    F_file_open_max,
+    F_memory_not,
+    F_buffer_too_small,
+    F_failure,
+  };
+
+  for (int i = 0; i < 7; ++i) {
+
+    will_return(__wrap_sysconf, size);
+    will_return(__wrap_getgrgid_r, true);
+    will_return(__wrap_getgrgid_r, errnos[i]);
+
+    const f_status_t status = f_account_name_group_by_id(gid, &name);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
+  } // for
+
+  f_string_dynamic_resize(0, &name);
+}
+
 void test__f_account_name_group_by_id__not_found(void **state) {
 
   const long size = 20;
@@ -26,6 +66,17 @@ void test__f_account_name_group_by_id__not_found(void **state) {
   f_string_dynamic_resize(0, &name);
 }
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_account_name_group_by_id__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_account_name_group_by_id(0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_account_name_group_by_id__works(void **state) {
 
   const long size = 20;
@@ -55,46 +106,6 @@ void test__f_account_name_group_by_id__works(void **state) {
   f_string_dynamic_resize(0, &name);
 }
 
-void test__f_account_name_group_by_id__fails(void **state) {
-
-  const long size = 20;
-  gid_t gid = 0;
-  f_string_dynamic_t name = f_string_dynamic_t_initialize;
-
-  int errnos[] = {
-    EINTR,
-    EIO,
-    EMFILE,
-    ENFILE,
-    ENOMEM,
-    ERANGE,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_interrupt,
-    F_input_output,
-    F_file_descriptor_max,
-    F_file_open_max,
-    F_memory_not,
-    F_buffer_too_small,
-    F_failure,
-  };
-
-  for (int i = 0; i < 7; ++i) {
-
-    will_return(__wrap_sysconf, size);
-    will_return(__wrap_getgrgid_r, true);
-    will_return(__wrap_getgrgid_r, errnos[i]);
-
-    const f_status_t status = f_account_name_group_by_id(gid, &name);
-
-    assert_int_equal(F_status_set_fine(status), statuss[i]);
-  } // for
-
-  f_string_dynamic_resize(0, &name);
-}
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 6d44b98343766d7ecc2c9fb55a2606835d33ce87..d4ff4a127a6e8b3eb1fa39bae1b8652356aea1a6 100644 (file)
 #define _TEST__F_account_name_group_by_id_
 
 /**
+ * Test that function fails.
+ *
+ * @see f_account_name_group_by_id()
+ */
+extern void test__f_account_name_group_by_id__fails(void **state);
+
+/**
  * Test that function works but the group does not exist.
  *
  * @see f_account_name_group_by_id()
 extern void test__f_account_name_group_by_id__not_found(void **state);
 
 /**
- * Test that function works.
+ * Test that parameter checking works as expected.
  *
  * @see f_account_name_group_by_id()
  */
-extern void test__f_account_name_group_by_id__works(void **state);
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_account_name_group_by_id__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
 
 /**
- * Test that function fails.
+ * Test that function works.
  *
  * @see f_account_name_group_by_id()
  */
-extern void test__f_account_name_group_by_id__fails(void **state);
+extern void test__f_account_name_group_by_id__works(void **state);
 
 #endif // _TEST__F_account_name_group_by_id_
index bf14520f2474fb370e4d196214647d58d910e525..80dcc6bdd3b9295bd3f56d7b864a03eec142d459 100644 (file)
@@ -5,6 +5,46 @@
 extern "C" {
 #endif
 
+void test__f_account_name_user_by_id__fails(void **state) {
+
+  const long size = 20;
+  uid_t uid = 0;
+  f_string_dynamic_t name = f_string_dynamic_t_initialize;
+
+  int errnos[] = {
+    EINTR,
+    EIO,
+    EMFILE,
+    ENFILE,
+    ENOMEM,
+    ERANGE,
+    mock_errno_generic,
+  };
+
+  f_status_t statuss[] = {
+    F_interrupt,
+    F_input_output,
+    F_file_descriptor_max,
+    F_file_open_max,
+    F_memory_not,
+    F_buffer_too_small,
+    F_failure,
+  };
+
+  for (int i = 0; i < 7; ++i) {
+
+    will_return(__wrap_sysconf, size);
+    will_return(__wrap_getpwuid_r, true);
+    will_return(__wrap_getpwuid_r, errnos[i]);
+
+    const f_status_t status = f_account_name_user_by_id(uid, &name);
+
+    assert_int_equal(F_status_set_fine(status), statuss[i]);
+  } // for
+
+  f_string_dynamic_resize(0, &name);
+}
+
 void test__f_account_name_user_by_id__not_found(void **state) {
 
   const long size = 20;
@@ -26,6 +66,17 @@ void test__f_account_name_user_by_id__not_found(void **state) {
   f_string_dynamic_resize(0, &name);
 }
 
+#ifndef _di_level_0_parameter_checking_
+  void test__f_account_name_user_by_id__parameter_checking(void **state) {
+
+    {
+      const f_status_t status = f_account_name_user_by_id(0, 0);
+
+      assert_int_equal(F_status_set_fine(status), F_parameter);
+    }
+  }
+#endif // _di_level_0_parameter_checking_
+
 void test__f_account_name_user_by_id__works(void **state) {
 
   const long size = 20;
@@ -57,46 +108,6 @@ void test__f_account_name_user_by_id__works(void **state) {
   f_string_dynamic_resize(0, &name);
 }
 
-void test__f_account_name_user_by_id__fails(void **state) {
-
-  const long size = 20;
-  uid_t uid = 0;
-  f_string_dynamic_t name = f_string_dynamic_t_initialize;
-
-  int errnos[] = {
-    EINTR,
-    EIO,
-    EMFILE,
-    ENFILE,
-    ENOMEM,
-    ERANGE,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_interrupt,
-    F_input_output,
-    F_file_descriptor_max,
-    F_file_open_max,
-    F_memory_not,
-    F_buffer_too_small,
-    F_failure,
-  };
-
-  for (int i = 0; i < 7; ++i) {
-
-    will_return(__wrap_sysconf, size);
-    will_return(__wrap_getpwuid_r, true);
-    will_return(__wrap_getpwuid_r, errnos[i]);
-
-    const f_status_t status = f_account_name_user_by_id(uid, &name);
-
-    assert_int_equal(F_status_set_fine(status), statuss[i]);
-  } // for
-
-  f_string_dynamic_resize(0, &name);
-}
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 5954e640355d145b2814e8c04a9de82515ee2c5c..e80814a3e04c83a8f392805b896bb2f0d822b40b 100644 (file)
 #define _TEST__F_account_name_user_by_id_
 
 /**
+ * Test that function fails.
+ *
+ * @see f_account_name_user_by_id()
+ */
+extern void test__f_account_name_user_by_id__fails(void **state);
+
+/**
  * Test that function works but the group does not exist.
  *
  * @see f_account_name_user_by_id()
 extern void test__f_account_name_user_by_id__not_found(void **state);
 
 /**
- * Test that function works.
+ * Test that parameter checking works as expected.
  *
  * @see f_account_name_user_by_id()
  */
-extern void test__f_account_name_user_by_id__works(void **state);
+#ifndef _di_level_0_parameter_checking_
+  extern void test__f_account_name_user_by_id__parameter_checking(void **state);
+#endif // _di_level_0_parameter_checking_
 
 /**
- * Test that function fails.
+ * Test that function works.
  *
  * @see f_account_name_user_by_id()
  */
-extern void test__f_account_name_user_by_id__fails(void **state);
+extern void test__f_account_name_user_by_id__works(void **state);
 
 #endif // _TEST__F_account_name_user_by_id_
index 534c6cfabf99aa0f25f90c3e9e0a823f93357d26..74bbc837ac4ecb471eeebbefe9d7382e5be28e01 100644 (file)
@@ -19,29 +19,38 @@ int setdown(void **state) {
 int main(void) {
 
   const struct CMUnitTest tests[] = {
+    cmocka_unit_test(test__f_account_by_id__fails),
     cmocka_unit_test(test__f_account_by_id__not_found),
     cmocka_unit_test(test__f_account_by_id__works),
-    cmocka_unit_test(test__f_account_by_id__fails),
 
+    cmocka_unit_test(test__f_account_by_name__fails),
     cmocka_unit_test(test__f_account_by_name__not_found),
     cmocka_unit_test(test__f_account_by_name__works),
-    cmocka_unit_test(test__f_account_by_name__fails),
 
-    cmocka_unit_test(test__f_account_id_group_by_name__not_found),
-    cmocka_unit_test(test__f_account_id_group_by_name__works),
     cmocka_unit_test(test__f_account_id_group_by_name__fails),
-
-    cmocka_unit_test(test__f_account_id_user_by_name__not_found),
-    cmocka_unit_test(test__f_account_id_user_by_name__works),
-    cmocka_unit_test(test__f_account_id_user_by_name__fails),
-
     cmocka_unit_test(test__f_account_id_group_by_name__not_found),
     cmocka_unit_test(test__f_account_id_group_by_name__works),
-    cmocka_unit_test(test__f_account_id_group_by_name__fails),
 
+    cmocka_unit_test(test__f_account_id_user_by_name__fails),
     cmocka_unit_test(test__f_account_id_user_by_name__not_found),
     cmocka_unit_test(test__f_account_id_user_by_name__works),
-    cmocka_unit_test(test__f_account_id_user_by_name__fails),
+
+    cmocka_unit_test(test__f_account_name_group_by_id__fails),
+    cmocka_unit_test(test__f_account_name_group_by_id__not_found),
+    cmocka_unit_test(test__f_account_name_group_by_id__works),
+
+    cmocka_unit_test(test__f_account_name_user_by_id__fails),
+    cmocka_unit_test(test__f_account_name_user_by_id__not_found),
+    cmocka_unit_test(test__f_account_name_user_by_id__works),
+
+    #ifndef _di_level_0_parameter_checking_
+      cmocka_unit_test(test__f_account_by_id__parameter_checking),
+      cmocka_unit_test(test__f_account_by_name__parameter_checking),
+      cmocka_unit_test(test__f_account_id_group_by_name__parameter_checking),
+      cmocka_unit_test(test__f_account_id_user_by_name__parameter_checking),
+      cmocka_unit_test(test__f_account_name_group_by_id__parameter_checking),
+      cmocka_unit_test(test__f_account_name_user_by_id__parameter_checking),
+    #endif // _di_level_0_parameter_checking_
   };
 
   return cmocka_run_group_tests(tests, setup, setdown);