From 78f8ec0173c35555a13c38e9dfa3626cb22e7d75 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 6 Aug 2017 19:02:57 +0200 Subject: [PATCH] Added a test for the set_email function. I'm hoping to trigger bug 2354 in a unit test. --- src/kernel/faction.test.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 80faba3c1..7eda676f7 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -223,6 +224,21 @@ static void test_valid_race(CuTest *tc) { test_cleanup(); } +static void test_set_email(CuTest *tc) { + char * email = NULL; + test_setup(); + CuAssertIntEquals(tc, 0, set_email(&email, "enno@eressea.de")); + CuAssertStrEquals(tc, "enno@eressea.de", email); + CuAssertIntEquals(tc, 0, set_email(&email, "bugs@eressea.de")); + CuAssertStrEquals(tc, "bugs@eressea.de", email); + CuAssertIntEquals(tc, -1, set_email(&email, "bad@@eressea.de")); + CuAssertStrEquals(tc, "bugs@eressea.de", email); + CuAssertIntEquals(tc, -1, set_email(&email, "eressea.de")); + CuAssertStrEquals(tc, "bugs@eressea.de", email); + free(email); + test_cleanup(); +} + CuSuite *get_faction_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -237,5 +253,6 @@ CuSuite *get_faction_suite(void) SUITE_ADD_TEST(suite, test_set_origin_bug); SUITE_ADD_TEST(suite, test_check_passwd); SUITE_ADD_TEST(suite, test_valid_race); + SUITE_ADD_TEST(suite, test_set_email); return suite; }