]> granicus.if.org Git - neomutt/commitdiff
test: add parse 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)
15 files changed:
test/parse/mutt_auto_subscribe.c
test/parse/mutt_check_encoding.c
test/parse/mutt_check_mime_type.c
test/parse/mutt_extract_message_id.c
test/parse/mutt_is_message_type.c
test/parse/mutt_matches_ignore.c
test/parse/mutt_parse_content_type.c
test/parse/mutt_parse_mailto.c
test/parse/mutt_parse_multipart.c
test/parse/mutt_parse_part.c
test/parse/mutt_read_mime_header.c
test/parse/mutt_rfc822_parse_line.c
test/parse/mutt_rfc822_parse_message.c
test/parse/mutt_rfc822_read_header.c
test/parse/mutt_rfc822_read_line.c

index 296f9c0a1ea6c06556e024c46c8546dd6a20f5a0..b8d7b010cf2f0dfdcc293f40d839f209d7ae7801 100644 (file)
@@ -30,4 +30,9 @@
 void test_mutt_auto_subscribe(void)
 {
   // void mutt_auto_subscribe(const char *mailto);
+
+  {
+    mutt_auto_subscribe(NULL);
+    TEST_CHECK_(1, "mutt_auto_subscribe(NULL)");
+  }
 }
index e02a972af3ad04eedae8173c2ea0bad9dba44307..6c4bde5121778d709e6b4821ba46edced6909c69 100644 (file)
@@ -30,4 +30,8 @@
 void test_mutt_check_encoding(void)
 {
   // int mutt_check_encoding(const char *c);
+
+  {
+    TEST_CHECK(mutt_check_encoding(NULL) == 0);
+  }
 }
index 925569ad0ca4d8f1c265af577a2a6976cd30ea15..f42b56ae1cc54f36b3267ad539ec76cdacda076c 100644 (file)
@@ -30,4 +30,8 @@
 void test_mutt_check_mime_type(void)
 {
   // int mutt_check_mime_type(const char *s);
+
+  {
+    TEST_CHECK(mutt_check_mime_type(NULL) == 0);
+  }
 }
index 0f244ac4d417be17118d8666ad97e483e8d67dd5..078ae44e8b0ea83cbe12c5e60fa85c78457f4c88 100644 (file)
 void test_mutt_extract_message_id(void)
 {
   // char *mutt_extract_message_id(const char *s, const char **saveptr);
+
+  {
+    const char *saveptr = NULL;
+    TEST_CHECK(!mutt_extract_message_id(NULL, &saveptr));
+  }
+
+  {
+    TEST_CHECK(!mutt_extract_message_id("apple", NULL));
+  }
 }
index 5271d1c40c16a831e3b8b681905c954a04aae58a..a34967e034d96cda8b6eded066cd91390d1e8561 100644 (file)
@@ -30,4 +30,8 @@
 void test_mutt_is_message_type(void)
 {
   // bool mutt_is_message_type(int type, const char *subtype);
+
+  {
+    TEST_CHECK(!mutt_is_message_type(0, NULL));
+  }
 }
index dcf63cfac9793b13d587e62fd7240525627f6fd8..44755a86561117b5581dc541656334ba9e810431 100644 (file)
@@ -30,4 +30,8 @@
 void test_mutt_matches_ignore(void)
 {
   // bool mutt_matches_ignore(const char *s);
+
+  {
+    TEST_CHECK(!mutt_matches_ignore(NULL));
+  }
 }
index c675b332c4712676c867eb1b3c55997bd1a8285c..66820a740b2bcd265be59799b67ad55bf1525b59 100644 (file)
 void test_mutt_parse_content_type(void)
 {
   // void mutt_parse_content_type(const char *s, struct Body *ct);
+
+  {
+    struct Body body = { 0 };
+    mutt_parse_content_type(NULL, &body);
+    TEST_CHECK_(1, "mutt_parse_content_type(NULL, &body)");
+  }
+
+  {
+    mutt_parse_content_type("apple", NULL);
+    TEST_CHECK_(1, "mutt_parse_content_type(\"apple\", NULL)");
+  }
 }
index 44b534afbdea43d9d1deea841fdbee3ccc694eb0..27b5daccdf16a9e022d999ac08277879a8ed450c 100644 (file)
 void test_mutt_parse_mailto(void)
 {
   // int mutt_parse_mailto(struct Envelope *e, char **body, const char *src);
+
+  {
+    char *body = NULL;
+    TEST_CHECK(mutt_parse_mailto(NULL, &body, "apple") != 0);
+  }
+
+  {
+    struct Envelope envelope = { 0 };
+    TEST_CHECK(mutt_parse_mailto(&envelope, NULL, "apple") != 0);
+  }
+
+  {
+    struct Envelope envelope = { 0 };
+    char *body = NULL;
+    TEST_CHECK(mutt_parse_mailto(&envelope, &body, NULL) != 0);
+  }
 }
index 5dceffbcf8c18dd029f038fc5699ae1b5d0e382e..2fede96913b70c231f32efec4675a59a134c2856 100644 (file)
 void test_mutt_parse_multipart(void)
 {
   // struct Body *mutt_parse_multipart(FILE *fp, const char *boundary, off_t end_off, bool digest);
+
+  {
+    TEST_CHECK(!mutt_parse_multipart(NULL, "apple", 0, false));
+  }
+
+  {
+    FILE fp = { 0 };
+    TEST_CHECK(!mutt_parse_multipart(&fp, NULL, 0, false));
+  }
 }
index 4941208d0f332b26c9944fbbdf6b675556af52c2..0340c7ca2d0fba87681a8e16feba19612b9026b4 100644 (file)
 void test_mutt_parse_part(void)
 {
   // void mutt_parse_part(FILE *fp, struct Body *b);
+
+  {
+    struct Body body = { 0 };
+    mutt_parse_part(NULL, &body);
+    TEST_CHECK_(1, "mutt_parse_part(NULL, &body)");
+  }
+
+  {
+    FILE fp = { 0 };
+    mutt_parse_part(&fp, NULL);
+    TEST_CHECK_(1, "mutt_parse_part(&fp, NULL)");
+  }
 }
index 8c1f3065044903e12c49235e9cad7273780dbdce..5d46e20f90d91a3b5d3026b1b7b0fae09ad3135a 100644 (file)
@@ -30,4 +30,8 @@
 void test_mutt_read_mime_header(void)
 {
   // struct Body *mutt_read_mime_header(FILE *fp, bool digest);
+
+  {
+    TEST_CHECK(!mutt_read_mime_header(NULL, false));
+  }
 }
index d470841560ee9e6922362385293112b7b1b2c145..d3040c39c1ee2a85670fd34b5a237646fede09d5 100644 (file)
 void test_mutt_rfc822_parse_line(void)
 {
   // int mutt_rfc822_parse_line(struct Envelope *env, struct Email *e, char *line, char *p, bool user_hdrs, bool weed, bool do_2047);
+
+  {
+    struct Email email = { 0 };
+    TEST_CHECK(mutt_rfc822_parse_line(NULL, &email, "apple", "banana", false, false, false) == 0);
+  }
+
+  {
+    struct Envelope envelope = { 0 };
+    TEST_CHECK(mutt_rfc822_parse_line(&envelope, NULL, "apple", "banana", false, false, false) == 0);
+  }
+
+  {
+    struct Envelope envelope = { 0 };
+    struct Email email = { 0 };
+    TEST_CHECK(mutt_rfc822_parse_line(&envelope, &email, NULL, "banana", false, false, false) == 0);
+  }
+
+  {
+    struct Envelope envelope = { 0 };
+    struct Email email = { 0 };
+    TEST_CHECK(mutt_rfc822_parse_line(&envelope, &email, "apple", NULL, false, false, false) == 0);
+  }
 }
index 3b6b6ae0a3a379591582123c5edf2dfc78f10160..f71e8c2606180848be9e33e05a7d59843889e671 100644 (file)
 void test_mutt_rfc822_parse_message(void)
 {
   // struct Body *mutt_rfc822_parse_message(FILE *fp, struct Body *parent);
+
+  {
+    struct Body body = { 0 };
+    TEST_CHECK(!mutt_rfc822_parse_message(NULL, &body));
+  }
+
+  {
+    FILE fp = { 0 };
+    TEST_CHECK(!mutt_rfc822_parse_message(&fp, NULL));
+  }
 }
index ed744990af223d3e32b61f8fb48396921ecee4cd..59a8406c8135bb9c77d3fd84987191b915256a0e 100644 (file)
 void test_mutt_rfc822_read_header(void)
 {
   // struct Envelope *mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed);
+
+  {
+    struct Email email = { 0 };
+    TEST_CHECK(!mutt_rfc822_read_header(NULL, &email, false, false));
+  }
+
+  {
+    FILE *fp = fopen("/dev/null", "r");
+    TEST_CHECK(mutt_rfc822_read_header(fp, NULL, false, false) != NULL);
+    fclose(fp);
+  }
 }
index 8bdb5a521b369f1aa81d2072bfb9b25021f6fd2f..da6455087a387a0ec30a62aaa279bcaac35d3e0c 100644 (file)
 void test_mutt_rfc822_read_line(void)
 {
   // char *mutt_rfc822_read_line(FILE *fp, char *line, size_t *linelen);
+
+  {
+    size_t linelen = 0;
+    TEST_CHECK(!mutt_rfc822_read_line(NULL, "apple", &linelen));
+  }
+
+  {
+    FILE fp = { 0 };
+    size_t linelen = 0;
+    TEST_CHECK(!mutt_rfc822_read_line(&fp, NULL, &linelen));
+  }
+
+  {
+    FILE fp = { 0 };
+    TEST_CHECK(!mutt_rfc822_read_line(&fp, "apple", NULL));
+  }
 }