]> granicus.if.org Git - neomutt/commitdiff
test: add md5 tests for degenerate cases
authorRichard Russon <rich@flatcap.org>
Mon, 29 Apr 2019 13:46:56 +0000 (14:46 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 30 Apr 2019 10:22:04 +0000 (11:22 +0100)
test/md5/mutt_md5.c
test/md5/mutt_md5_bytes.c
test/md5/mutt_md5_finish_ctx.c
test/md5/mutt_md5_init_ctx.c
test/md5/mutt_md5_process.c
test/md5/mutt_md5_process_bytes.c
test/md5/mutt_md5_toascii.c

index 979313adff2cb963488be2428edf38daa131d503..4b77845f5395f94d37d2ba7255a307697d5324b5 100644 (file)
 void test_mutt_md5(void)
 {
   // void *mutt_md5(const char *str, void *buf);
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(!mutt_md5(NULL, &buf));
+  }
+
+  {
+    TEST_CHECK(!mutt_md5("apple", NULL));
+  }
 }
index 902aa8b053a0d851df6a62bd569f484fd1f5132f..e93ed72478a52ddaf5cedbe9d189eb3c3afe4c92 100644 (file)
 void test_mutt_md5_bytes(void)
 {
   // void *mutt_md5_bytes(const void *buffer, size_t len, void *resbuf);
+
+  {
+    char buf[32] = { 0 };
+    mutt_md5_bytes(NULL, 10, &buf);
+    TEST_CHECK_(1, "mutt_md5_bytes(NULL, 10, &buf)");
+  }
+
+  {
+    char buf[32] = { 0 };
+    mutt_md5_bytes(&buf, 10, NULL);
+    TEST_CHECK_(1, "mutt_md5_bytes(&buf, 10, NULL)");
+  }
 }
index 171cce54c8ad398254e278bfdbdfc1f88b29a42e..d05e9ecfbe59816d33e271cefc93c92dfa58c2c7 100644 (file)
 void test_mutt_md5_finish_ctx(void)
 {
   // void *mutt_md5_finish_ctx(struct Md5Ctx *md5ctx, void *resbuf);
+
+  {
+    char buf[32] = { 0 };
+    mutt_md5_finish_ctx(NULL, &buf);
+    TEST_CHECK_(1, "mutt_md5_finish_ctx(NULL, &buf)");
+  }
+
+  {
+    struct Md5Ctx md5ctx = { 0 };
+    mutt_md5_finish_ctx(&md5ctx, NULL);
+    TEST_CHECK_(1, "mutt_md5_finish_ctx(&md5ctx, NULL)");
+  }
 }
index 899bab6c996055c0bb400150914e027ba8e364b7..efd233837958d16449635e7307f3302dd1f3b693 100644 (file)
@@ -28,4 +28,9 @@
 void test_mutt_md5_init_ctx(void)
 {
   // void mutt_md5_init_ctx(struct Md5Ctx *md5ctx);
+
+  {
+    mutt_md5_init_ctx(NULL);
+    TEST_CHECK_(1, "mutt_md5_init_ctx(NULL)");
+  }
 }
index 5b4a74c5ab9bec5f32603dbb96dca25961de6b7d..93fd56bbd82cfcce7f524b6fb51889ed40180020 100644 (file)
 void test_mutt_md5_process(void)
 {
   // void mutt_md5_process(const char *str, struct Md5Ctx *md5ctx);
+
+  {
+    struct Md5Ctx md5ctx = { 0 };
+    mutt_md5_process(NULL, &md5ctx);
+    TEST_CHECK_(1, "mutt_md5_process(NULL, &md5ctx)");
+  }
+
+  {
+    mutt_md5_process("apple", NULL);
+    TEST_CHECK_(1, "mutt_md5_process(\"apple\", NULL)");
+  }
 }
index 342c2688b87f48f12f25104f4124586881956441..06e75c2949e556a0a6b0b52aed8a972b6c9ca1cc 100644 (file)
 void test_mutt_md5_process_bytes(void)
 {
   // void mutt_md5_process_bytes(const void *buffer, size_t len, struct Md5Ctx *md5ctx);
+
+  {
+    struct Md5Ctx md5ctx = { 0 };
+    mutt_md5_process_bytes(NULL, 10, &md5ctx);
+    TEST_CHECK_(1, "mutt_md5_process_bytes(NULL, 10, &md5ctx)");
+  }
+
+  {
+    char buf[32] = { 0 };
+    mutt_md5_process_bytes(&buf, sizeof(buf), NULL);
+    TEST_CHECK_(1, "mutt_md5_process_bytes(&buf, sizeof(buf), NULL)");
+  }
 }
index 7dbaf006c2de2fc8121c3d198c4f8769f82f4eaa..50b06994b446a7080115515dd64f9240793253c8 100644 (file)
 void test_mutt_md5_toascii(void)
 {
   // void mutt_md5_toascii(const void *digest, char *resbuf);
+
+  {
+    char buf[32] = { 0 };
+    mutt_md5_toascii(NULL, buf);
+    TEST_CHECK_(1, "mutt_md5_toascii(NULL, &buf)");
+  }
+
+  {
+    mutt_md5_toascii("apple", NULL);
+    TEST_CHECK_(1, "mutt_md5_toascii(\"apple\", NULL)");
+  }
 }