diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df92085db..b4e600e0d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,6 +192,7 @@ set(TESTS_SRC donations.test.c wormhole.test.c alchemy.test.c + guard.test.c test_eressea.c tests.c battle.test.c diff --git a/src/guard.test.c b/src/guard.test.c new file mode 100644 index 000000000..b00f50b49 --- /dev/null +++ b/src/guard.test.c @@ -0,0 +1,37 @@ +#include + +#include "guard.h" +#include "monster.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include "tests.h" + +static void test_guard_monsters(CuTest * tc) +{ + unit *u, *ug; + region *r; + + test_setup(); + r = test_create_region(0, 0, 0); + u = test_create_unit(test_create_faction(0), r); + ug = test_create_unit(get_monsters(), r); + setguard(ug, GUARD_ALL); + CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); + test_cleanup(); +} + +CuSuite *get_guard_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_guard_monsters); + return suite; +} diff --git a/src/test_eressea.c b/src/test_eressea.c index 002d9a0cb..39ec90be6 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -111,6 +111,7 @@ int RunAllTests(int argc, char *argv[]) ADD_SUITE(ally); ADD_SUITE(messages); /* gamecode */ + ADD_SUITE(guard); ADD_SUITE(report); ADD_SUITE(creport); ADD_SUITE(prefix);