From 7fdbb1b939c8ccbb2392d6d261a45bf7c69e40d6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 18 Sep 2017 17:26:34 +0200 Subject: [PATCH] add a test for rt_find to flush out substring matches. --- src/kernel/item.test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c index c1c64bf62..c6113ec5d 100644 --- a/src/kernel/item.test.c +++ b/src/kernel/item.test.c @@ -173,12 +173,31 @@ static void test_core_resources(CuTest *tc) { test_cleanup(); } +static void test_get_resource(CuTest *tc) { + resource_type *rtype; + + test_setup(); + + CuAssertPtrEquals(tc, NULL, rt_find("catapultammo")); + rtype = rt_get_or_create("catapultammo"); + CuAssertPtrNotNull(tc, rtype); + CuAssertPtrEquals(tc, rtype, rt_find("catapultammo")); + CuAssertStrEquals(tc, "catapultammo", rtype->_name); + + CuAssertPtrEquals(tc, NULL, rt_find("catapult")); + rtype = rt_get_or_create("catapult"); + CuAssertPtrEquals(tc, rtype, rt_find("catapult")); + CuAssertStrEquals(tc, "catapult", rtype->_name); + test_cleanup(); +} + CuSuite *get_item_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_resourcename_no_appearance); SUITE_ADD_TEST(suite, test_resourcename_with_appearance); SUITE_ADD_TEST(suite, test_change_item); + SUITE_ADD_TEST(suite, test_get_resource); SUITE_ADD_TEST(suite, test_resource_type); SUITE_ADD_TEST(suite, test_finditemtype); SUITE_ADD_TEST(suite, test_findresourcetype);