]> granicus.if.org Git - check/commitdiff
Add tests for ck_assert_ptr_null and ck_assert_ptr_nonnull macros
authorDotsenko Andrey <cnconlinux@gmail.com>
Mon, 12 Dec 2016 19:15:22 +0000 (22:15 +0300)
committerDotsenko Andrey <cnconlinux@gmail.com>
Tue, 13 Dec 2016 17:42:37 +0000 (20:42 +0300)
tests/check_check_master.c
tests/check_check_sub.c

index 5ac5f8ce27f75ab0615de9862beac11baf6ee2e4..e61361cb4de7a7c12774dd52937d59df6b521e35 100644 (file)
@@ -230,6 +230,8 @@ static master_test_t master_tests[] = {
   { "Simple Tests", "test_ck_assert_pstr_ne_with_null", CK_FAILURE, "Assertion 't != s' failed: t == (null), s == (null)" },
   { "Simple Tests", "test_ck_assert_ptr_eq", CK_FAILURE, "Assertion 'x == y' failed: x == 0x1, y == 0x2" },
   { "Simple Tests", "test_ck_assert_ptr_ne", CK_FAILURE, "Assertion 'x != z' failed: x == 0x1, z == 0x1" },
+  { "Simple Tests", "test_ck_assert_ptr_null", CK_FAILURE, "Assertion 'x == NULL' failed: x == 0x1" },
+  { "Simple Tests", "test_ck_assert_ptr_nonnull", CK_FAILURE, "Assertion 'x != NULL' failed: x == 0" },
   { "Simple Tests", "test_ck_assert_mem_eq", CK_FAILURE, "Assertion '\"\\x00\\x00\\x00\\x00\\x01\" == s' failed: \"\\x00\\x00\\x00\\x00\\x01\" == \"0000000001\", s == \"0000000002\"" },
   { "Simple Tests", "test_ck_assert_mem_ne", CK_FAILURE, "Assertion 't != s' failed: t == \"0000000002\", s == \"0000000002\"" },
   { "Simple Tests", "test_ck_assert_mem_lt", CK_FAILURE, "Assertion 's < s' failed: s == \"0000000001\", s == \"0000000001\"" },
index 77de05a79b95e630b18dd75edddec99e5ec08047..b5aac1d247631f9b0be201060acfe9d133978b9a 100644 (file)
@@ -2131,6 +2131,30 @@ START_TEST(test_ck_assert_ptr_ne)
 }
 END_TEST
 
+START_TEST(test_ck_assert_ptr_null)
+{
+  record_test_name(tcase_name());
+
+  void* x = (void*)0x1;
+  void* y = NULL;
+  ck_assert_ptr_null(y);
+  record_failure_line_num(__LINE__);
+  ck_assert_ptr_null(x);
+}
+END_TEST
+
+START_TEST(test_ck_assert_ptr_nonnull)
+{
+  record_test_name(tcase_name());
+
+  void* x = NULL;
+  void* y = (void*)0x1;
+  ck_assert_ptr_nonnull(y);
+  record_failure_line_num(__LINE__);
+  ck_assert_ptr_nonnull(x);
+}
+END_TEST
+
 START_TEST(test_ck_assert_mem_eq)
 {
   const char *s = "\x00\x00\x00\x00\x02";
@@ -2917,6 +2941,8 @@ Suite *make_sub_suite(void)
   tcase_add_test (tc_simple, test_ck_assert_pstr_ne_with_null);
   tcase_add_test (tc_simple, test_ck_assert_ptr_eq);
   tcase_add_test (tc_simple, test_ck_assert_ptr_ne);
+  tcase_add_test (tc_simple, test_ck_assert_ptr_null);
+  tcase_add_test (tc_simple, test_ck_assert_ptr_nonnull);
   tcase_add_test (tc_simple, test_ck_assert_mem_eq);
   tcase_add_test (tc_simple, test_ck_assert_mem_ne);
   tcase_add_test (tc_simple, test_ck_assert_mem_lt);