From 391a123a3ed3a1eeac5885b9dda7c762e9c58d88 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 7 Jul 2015 14:42:07 +0200 Subject: [PATCH] test that correct messages are sent to correct factions. --- src/kernel/ship.c | 5 +---- src/spy.test.c | 6 ++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kernel/ship.c b/src/kernel/ship.c index c5aded3cd..a01326bdd 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -435,10 +435,7 @@ void write_ship_reference(const struct ship *sh, struct storage *store) void ship_setname(ship * self, const char *name) { free(self->name); - if (name) - self->name = _strdup(name); - else - self->name = NULL; + self->name = name ? _strdup(name) : 0; } const char *ship_getname(const ship * self) diff --git a/src/spy.test.c b/src/spy.test.c index 7f97eb171..085cc5675 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -136,6 +136,7 @@ static void test_sabotage_other_fail(CuTest *tc) { unit *u, *u2; region *r; order *ord; + message *msg; setup_sabotage(); r = test_create_region(0, 0, NULL); @@ -151,6 +152,10 @@ static void test_sabotage_other_fail(CuTest *tc) { ord = create_order(K_SABOTAGE, u->faction->locale, "SCHIFF"); assert(ord); CuAssertIntEquals(tc, 0, sabotage_cmd(u2, ord)); + msg = test_get_last_message(u2->faction->msgs); + CuAssertStrEquals(tc, "destroy_ship_1", test_get_messagetype(msg)); + msg = test_get_last_message(u->faction->msgs); + CuAssertStrEquals(tc, "destroy_ship_3", test_get_messagetype(msg)); CuAssertPtrNotNull(tc, r->ships); test_cleanup(); } @@ -179,6 +184,7 @@ static void test_sabotage_other_success(CuTest *tc) { CuAssertPtrEquals(tc, 0, r->ships); test_cleanup(); } + CuSuite *get_spy_suite(void) { CuSuite *suite = CuSuiteNew();