From 6235d05d6b2115be994a0f25751637cce74d4438 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 27 Apr 2019 21:26:07 +0100 Subject: [PATCH] test: add group tests for degenerate cases --- test/group/mutt_group_match.c | 9 +++++++++ test/group/mutt_grouplist_add.c | 12 ++++++++++++ test/group/mutt_grouplist_add_addrlist.c | 12 ++++++++++++ test/group/mutt_grouplist_add_regex.c | 16 ++++++++++++++++ test/group/mutt_grouplist_clear.c | 5 +++++ test/group/mutt_grouplist_destroy.c | 5 +++++ test/group/mutt_grouplist_remove_addrlist.c | 10 ++++++++++ test/group/mutt_grouplist_remove_regex.c | 9 +++++++++ test/group/mutt_pattern_group.c | 4 ++++ 9 files changed, 82 insertions(+) diff --git a/test/group/mutt_group_match.c b/test/group/mutt_group_match.c index 5d32ddd8b..af616bf6e 100644 --- a/test/group/mutt_group_match.c +++ b/test/group/mutt_group_match.c @@ -29,4 +29,13 @@ void test_mutt_group_match(void) { // bool mutt_group_match(struct Group *g, const char *s); + + { + TEST_CHECK(!mutt_group_match(NULL, "apple")); + } + + { + struct Group group = { 0 }; + TEST_CHECK(!mutt_group_match(&group, NULL)); + } } diff --git a/test/group/mutt_grouplist_add.c b/test/group/mutt_grouplist_add.c index 8d3733641..b8b63208d 100644 --- a/test/group/mutt_grouplist_add.c +++ b/test/group/mutt_grouplist_add.c @@ -29,4 +29,16 @@ void test_mutt_grouplist_add(void) { // void mutt_grouplist_add(struct GroupList *head, struct Group *group); + + { + struct Group group = { 0 }; + mutt_grouplist_add(NULL, &group); + TEST_CHECK_(1, "mutt_grouplist_add(NULL, &group)"); + } + + { + struct GroupList head = { 0 }; + mutt_grouplist_add(&head, NULL); + TEST_CHECK_(1, "mutt_grouplist_add(&head, NULL)"); + } } diff --git a/test/group/mutt_grouplist_add_addrlist.c b/test/group/mutt_grouplist_add_addrlist.c index 34d73aa8c..35ae21a7f 100644 --- a/test/group/mutt_grouplist_add_addrlist.c +++ b/test/group/mutt_grouplist_add_addrlist.c @@ -29,4 +29,16 @@ void test_mutt_grouplist_add_addrlist(void) { // void mutt_grouplist_add_addrlist(struct GroupList *head, struct Address *a); + + { + struct Address addr = { 0 }; + mutt_grouplist_add_addrlist(NULL, &addr); + TEST_CHECK_(1, "mutt_grouplist_add_addrlist(NULL, &addr)"); + } + + { + struct GroupList head = { 0 }; + mutt_grouplist_add_addrlist(&head, NULL); + TEST_CHECK_(1, "mutt_grouplist_add_addrlist(&head, NULL)"); + } } diff --git a/test/group/mutt_grouplist_add_regex.c b/test/group/mutt_grouplist_add_regex.c index 12f381429..84cce9193 100644 --- a/test/group/mutt_grouplist_add_regex.c +++ b/test/group/mutt_grouplist_add_regex.c @@ -29,4 +29,20 @@ void test_mutt_grouplist_add_regex(void) { // int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err); + + { + struct Buffer err = { 0 }; + TEST_CHECK(mutt_grouplist_add_regex(NULL, "apple", 0, &err) == -1); + } + + { + struct GroupList head = { 0 }; + struct Buffer err = { 0 }; + TEST_CHECK(mutt_grouplist_add_regex(&head, NULL, 0, &err) == -1); + } + + { + struct GroupList head = { 0 }; + TEST_CHECK(mutt_grouplist_add_regex(&head, "apple", 0, NULL) == 0); + } } diff --git a/test/group/mutt_grouplist_clear.c b/test/group/mutt_grouplist_clear.c index 4080e0e77..00d54e9a6 100644 --- a/test/group/mutt_grouplist_clear.c +++ b/test/group/mutt_grouplist_clear.c @@ -29,4 +29,9 @@ void test_mutt_grouplist_clear(void) { // void mutt_grouplist_clear(struct GroupList *head); + + { + mutt_grouplist_clear(NULL); + TEST_CHECK_(1, "mutt_grouplist_clear(NULL)"); + } } diff --git a/test/group/mutt_grouplist_destroy.c b/test/group/mutt_grouplist_destroy.c index 8c8acabe4..83d62a01e 100644 --- a/test/group/mutt_grouplist_destroy.c +++ b/test/group/mutt_grouplist_destroy.c @@ -29,4 +29,9 @@ void test_mutt_grouplist_destroy(void) { // void mutt_grouplist_destroy(struct GroupList *head); + + { + mutt_grouplist_destroy(NULL); + TEST_CHECK_(1, "mutt_grouplist_destroy(NULL)"); + } } diff --git a/test/group/mutt_grouplist_remove_addrlist.c b/test/group/mutt_grouplist_remove_addrlist.c index 6909e07e7..cf8de46af 100644 --- a/test/group/mutt_grouplist_remove_addrlist.c +++ b/test/group/mutt_grouplist_remove_addrlist.c @@ -29,4 +29,14 @@ void test_mutt_grouplist_remove_addrlist(void) { // int mutt_grouplist_remove_addrlist(struct GroupList *head, struct Address *a); + + { + struct Address addr = { 0 }; + TEST_CHECK(mutt_grouplist_remove_addrlist(NULL, &addr) == -1); + } + + { + struct GroupList head = { 0 }; + TEST_CHECK(mutt_grouplist_remove_addrlist(&head, NULL) == -1); + } } diff --git a/test/group/mutt_grouplist_remove_regex.c b/test/group/mutt_grouplist_remove_regex.c index edd986271..276810d9c 100644 --- a/test/group/mutt_grouplist_remove_regex.c +++ b/test/group/mutt_grouplist_remove_regex.c @@ -29,4 +29,13 @@ void test_mutt_grouplist_remove_regex(void) { // int mutt_grouplist_remove_regex(struct GroupList *head, const char *s); + + { + TEST_CHECK(mutt_grouplist_remove_regex(NULL, "apple") == -1); + } + + { + struct GroupList head = { 0 }; + TEST_CHECK(mutt_grouplist_remove_regex(&head, NULL) == -1); + } } diff --git a/test/group/mutt_pattern_group.c b/test/group/mutt_pattern_group.c index 5541a709d..734d463a8 100644 --- a/test/group/mutt_pattern_group.c +++ b/test/group/mutt_pattern_group.c @@ -29,4 +29,8 @@ void test_mutt_pattern_group(void) { // struct Group *mutt_pattern_group(const char *k); + + { + TEST_CHECK(!mutt_pattern_group(NULL)); + } } -- 2.40.0