Added a test for the set_email function.

I'm hoping to trigger bug 2354 in a unit test.
This commit is contained in:
Enno Rehling 2017-08-06 19:02:57 +02:00
parent 9110d01229
commit 78f8ec0173
1 changed files with 17 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/unit.h> #include <kernel/unit.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <util/goodies.h>
#include <util/language.h> #include <util/language.h>
#include <util/password.h> #include <util/password.h>
@ -223,6 +224,21 @@ static void test_valid_race(CuTest *tc) {
test_cleanup(); 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 *get_faction_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); 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_set_origin_bug);
SUITE_ADD_TEST(suite, test_check_passwd); SUITE_ADD_TEST(suite, test_check_passwd);
SUITE_ADD_TEST(suite, test_valid_race); SUITE_ADD_TEST(suite, test_valid_race);
SUITE_ADD_TEST(suite, test_set_email);
return suite; return suite;
} }