2012-06-04 03:41:07 +02:00
|
|
|
#include <platform.h>
|
|
|
|
|
|
|
|
#include <kernel/types.h>
|
2012-05-19 20:26:46 +02:00
|
|
|
#include <kernel/item.h>
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
2012-06-04 03:41:07 +02:00
|
|
|
#include <util/language.h>
|
|
|
|
|
2012-05-31 04:17:08 +02:00
|
|
|
#include <CuTest.h>
|
2012-06-04 08:36:40 +02:00
|
|
|
#include <tests.h>
|
2012-05-19 20:26:46 +02:00
|
|
|
|
2014-06-25 04:51:06 +02:00
|
|
|
static void test_resources(CuTest *tc) {
|
|
|
|
resource_type *rtype;
|
|
|
|
test_cleanup();
|
2014-06-30 02:02:45 +02:00
|
|
|
CuAssertPtrNotNull(tc, rt_find("hp"));
|
|
|
|
CuAssertPtrEquals(tc, rt_find("hp"), (void *)get_resourcetype(R_LIFE));
|
|
|
|
CuAssertPtrNotNull(tc, rt_find("peasant"));
|
|
|
|
CuAssertPtrEquals(tc, rt_find("peasant"), (void *)get_resourcetype(R_PEASANT));
|
|
|
|
CuAssertPtrNotNull(tc, rt_find("aura"));
|
|
|
|
CuAssertPtrEquals(tc, rt_find("aura"), (void *)get_resourcetype(R_AURA));
|
|
|
|
CuAssertPtrNotNull(tc, rt_find("permaura"));
|
|
|
|
CuAssertPtrEquals(tc, rt_find("permaura"), (void *)get_resourcetype(R_PERMAURA));
|
|
|
|
CuAssertPtrNotNull(tc, rt_find("unit"));
|
|
|
|
CuAssertPtrEquals(tc, rt_find("unit"), (void *)get_resourcetype(R_UNIT));
|
|
|
|
|
|
|
|
CuAssertPtrEquals(tc, 0, rt_find("stone"));
|
|
|
|
rtype = rt_get_or_create("stone");
|
|
|
|
CuAssertPtrEquals(tc, (void *)rtype, (void *)rt_find("stone"));
|
|
|
|
CuAssertPtrEquals(tc, (void *)rtype, (void *)get_resourcetype(R_STONE));
|
2014-06-25 04:51:06 +02:00
|
|
|
test_cleanup();
|
2014-06-30 02:02:45 +02:00
|
|
|
CuAssertPtrEquals(tc, 0, rt_find("stone"));
|
|
|
|
rtype = rt_get_or_create("stone");
|
|
|
|
CuAssertPtrEquals(tc, (void *)rtype, (void *)get_resourcetype(R_STONE));
|
2014-06-25 04:51:06 +02:00
|
|
|
}
|
|
|
|
|
2012-05-19 20:26:46 +02:00
|
|
|
static void test_recreate_world(CuTest * tc)
|
|
|
|
{
|
|
|
|
test_cleanup();
|
2014-06-16 07:17:08 +02:00
|
|
|
CuAssertPtrEquals(tc, 0, get_locale("de"));
|
2014-06-25 07:44:05 +02:00
|
|
|
CuAssertPtrEquals(tc, 0, (void *)rt_find("horse"));
|
2014-06-24 17:19:11 +02:00
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_LIFE));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_AURA));
|
2014-06-25 07:44:05 +02:00
|
|
|
CuAssertPtrNotNull(tc, (void *)rt_find("money"));
|
2012-05-22 06:39:18 +02:00
|
|
|
|
2012-05-19 20:26:46 +02:00
|
|
|
test_create_world();
|
2014-06-16 07:17:08 +02:00
|
|
|
CuAssertPtrEquals(tc, default_locale, get_locale("de"));
|
2012-05-19 20:49:47 +02:00
|
|
|
CuAssertPtrNotNull(tc, default_locale);
|
2012-05-22 06:39:18 +02:00
|
|
|
CuAssertPtrNotNull(tc, findregion(0, 0));
|
2014-06-25 07:44:05 +02:00
|
|
|
CuAssertPtrNotNull(tc, (void *)rt_find("horse"));
|
2014-06-24 17:19:11 +02:00
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_HORSE));
|
2014-06-25 07:44:05 +02:00
|
|
|
CuAssertPtrNotNull(tc, (void *)rt_find("money"));
|
2014-06-24 17:19:11 +02:00
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_LIFE));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_SILVER));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_AURA));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_PEASANT));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_UNIT));
|
2012-05-22 06:39:18 +02:00
|
|
|
|
2012-05-19 20:26:46 +02:00
|
|
|
test_cleanup();
|
2014-06-16 07:17:08 +02:00
|
|
|
CuAssertPtrEquals(tc, 0, get_locale("de"));
|
2014-06-25 07:44:05 +02:00
|
|
|
CuAssertPtrEquals(tc, 0, (void*)rt_find("horse"));
|
2014-06-24 17:19:11 +02:00
|
|
|
CuAssertPtrEquals(tc, 0, (void*)get_resourcetype(R_HORSE));
|
2014-06-25 07:44:05 +02:00
|
|
|
CuAssertPtrNotNull(tc, (void *)rt_find("money"));
|
2014-06-24 17:19:11 +02:00
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_LIFE));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_SILVER));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_AURA));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_PEASANT));
|
|
|
|
CuAssertPtrNotNull(tc, get_resourcetype(R_UNIT));
|
2012-05-19 20:26:46 +02:00
|
|
|
CuAssertPtrEquals(tc, 0, findregion(0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
CuSuite *get_tests_suite(void)
|
|
|
|
{
|
|
|
|
CuSuite *suite = CuSuiteNew();
|
2014-06-25 04:51:06 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_resources);
|
2012-05-19 20:26:46 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_recreate_world);
|
|
|
|
return suite;
|
|
|
|
}
|