From 42bfc43e4f51c7292c90a5e76f01371e1603b1d5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Sep 2016 13:01:08 +0200 Subject: [PATCH] test lighthouse preparation --- src/reports.test.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/reports.test.c b/src/reports.test.c index b8df6792c..1a8b35190 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -2,6 +2,7 @@ #include #include "reports.h" #include "move.h" +#include "lighthouse.h" #include "travelthru.h" #include "keyword.h" @@ -222,6 +223,34 @@ static void test_arg_resources(CuTest *tc) { test_cleanup(); } +static void test_prepare_lighthouse(CuTest *tc) { + report_context ctx; + faction *f; + region *r1, *r2, *r3; + unit *u; + building *b; + building_type *btype; + + test_setup(); + f = test_create_faction(0); + r1 = test_create_region(0, 0, 0); + r2 = test_create_region(1, 0, 0); + r3 = test_create_region(2, 0, 0); + btype = test_create_buildingtype("lighthouse"); + b = test_create_building(r1, btype); + b->size = 10; + u = test_create_unit(f, r1); + u->building = b; + update_lighthouse(b); + prepare_report(&ctx, f); + CuAssertPtrEquals(tc, r1, ctx.first); + CuAssertPtrEquals(tc, r3, ctx.last); + CuAssertIntEquals(tc, seen_unit, r1->seen.mode); + CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode); + CuAssertIntEquals(tc, seen_none, r3->seen.mode); + test_cleanup(); +} + static void test_prepare_report(CuTest *tc) { report_context ctx; faction *f; @@ -260,6 +289,7 @@ CuSuite *get_reports_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_prepare_report); + SUITE_ADD_TEST(suite, test_prepare_lighthouse); SUITE_ADD_TEST(suite, test_reorder_units); SUITE_ADD_TEST(suite, test_seen_faction); SUITE_ADD_TEST(suite, test_regionid);