From 1f659327946ef73b70c1cbc839ec4f9c21a1943c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 18 Sep 2017 17:20:09 +0200 Subject: [PATCH] add a test for get_equipment with substrings. --- src/kernel/equipment.test.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/kernel/equipment.test.c b/src/kernel/equipment.test.c index 1e6bf1819..4ed077fb0 100644 --- a/src/kernel/equipment.test.c +++ b/src/kernel/equipment.test.c @@ -10,7 +10,7 @@ #include #include -void test_equipment(CuTest * tc) +static void test_equipment(CuTest * tc) { equipment * eq; unit * u; @@ -46,9 +46,33 @@ void test_equipment(CuTest * tc) test_cleanup(); } +static void test_get_equipment(CuTest * tc) +{ + equipment * eq; + + test_setup(); + eq = create_equipment("catapultammo"); + CuAssertPtrNotNull(tc, eq); + CuAssertStrEquals(tc, "catapultammo", eq->name); + eq = get_equipment("catapultammo"); + CuAssertPtrNotNull(tc, eq); + CuAssertStrEquals(tc, "catapultammo", eq->name); + eq = get_equipment("catapult"); + CuAssertPtrEquals(tc, NULL, eq); + eq = create_equipment("catapult"); + eq = get_equipment("catapult"); + CuAssertPtrNotNull(tc, eq); + CuAssertStrEquals(tc, "catapult", eq->name); + eq = get_equipment("catapultammo"); + CuAssertPtrNotNull(tc, eq); + CuAssertStrEquals(tc, "catapultammo", eq->name); + test_cleanup(); +} + CuSuite *get_equipment_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_equipment); + SUITE_ADD_TEST(suite, test_get_equipment); return suite; }