2012-05-23 03:44:54 +02:00
|
|
|
#include <platform.h>
|
|
|
|
|
2012-05-31 04:55:17 +02:00
|
|
|
#include <quicklist.h>
|
2012-05-09 12:14:54 +02:00
|
|
|
#include <kernel/spell.h>
|
2016-01-29 17:49:27 +01:00
|
|
|
#include <util/log.h>
|
2012-05-09 12:14:54 +02:00
|
|
|
|
2012-05-31 04:17:08 +02:00
|
|
|
#include <CuTest.h>
|
2012-05-09 12:14:54 +02:00
|
|
|
#include <tests.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2015-11-12 19:34:25 +01:00
|
|
|
static void test_create_a_spell(CuTest * tc)
|
2012-05-09 12:14:54 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
spell * sp;
|
2012-05-09 12:14:54 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
test_cleanup();
|
|
|
|
CuAssertPtrEquals(tc, 0, spells);
|
|
|
|
CuAssertPtrEquals(tc, 0, find_spell("testspell"));
|
2012-05-23 03:44:54 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
sp = create_spell("testspell", 0);
|
|
|
|
CuAssertPtrEquals(tc, sp, find_spell("testspell"));
|
|
|
|
CuAssertPtrNotNull(tc, spells);
|
2012-05-23 03:44:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_create_duplicate_spell(CuTest * tc)
|
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
spell *sp;
|
2016-01-29 17:49:27 +01:00
|
|
|
/* FIXME: this test emits ERROR messages (duplicate spells), inject a logger to verify that */
|
2012-05-23 03:44:54 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
test_cleanup();
|
|
|
|
CuAssertPtrEquals(tc, 0, find_spell("testspell"));
|
2012-05-09 12:14:54 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
sp = create_spell("testspell", 0);
|
|
|
|
CuAssertPtrEquals(tc, 0, create_spell("testspell", 0));
|
|
|
|
CuAssertPtrEquals(tc, sp, find_spell("testspell"));
|
2012-05-09 12:14:54 +02:00
|
|
|
}
|
|
|
|
|
2012-05-23 03:44:54 +02:00
|
|
|
static void test_create_spell_with_id(CuTest * tc)
|
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
spell *sp;
|
2016-01-29 17:49:27 +01:00
|
|
|
/* FIXME: this test emits ERROR messages (duplicate spells), inject a logger to verify that */
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
test_cleanup();
|
|
|
|
CuAssertPtrEquals(tc, 0, find_spellbyid(42));
|
|
|
|
sp = create_spell("testspell", 42);
|
|
|
|
CuAssertPtrEquals(tc, sp, find_spellbyid(42));
|
|
|
|
CuAssertPtrEquals(tc, 0, create_spell("testspell", 47));
|
|
|
|
CuAssertPtrEquals(tc, 0, find_spellbyid(47));
|
2012-05-23 03:44:54 +02:00
|
|
|
}
|
|
|
|
|
2012-05-09 12:14:54 +02:00
|
|
|
CuSuite *get_spell_suite(void)
|
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
CuSuite *suite = CuSuiteNew();
|
2015-11-12 19:34:25 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_create_a_spell);
|
2015-01-30 20:37:14 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_create_duplicate_spell);
|
|
|
|
SUITE_ADD_TEST(suite, test_create_spell_with_id);
|
|
|
|
return suite;
|
2012-05-09 12:14:54 +02:00
|
|
|
}
|