2012-05-23 21:42:14 +02:00
|
|
|
#include <platform.h>
|
|
|
|
|
|
|
|
#include <kernel/types.h>
|
|
|
|
#include <kernel/magic.h>
|
|
|
|
#include <kernel/spell.h>
|
|
|
|
#include <kernel/spellbook.h>
|
|
|
|
#include <util/quicklist.h>
|
|
|
|
#include <util/language.h>
|
|
|
|
|
|
|
|
#include <cutest/CuTest.h>
|
|
|
|
#include <tests.h>
|
|
|
|
|
|
|
|
|
|
|
|
int count_spell_cb(spellbook_entry * sbe, void * ptr)
|
|
|
|
{
|
|
|
|
int * counter = (int *)ptr;
|
|
|
|
++*counter;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-24 05:22:12 +02:00
|
|
|
void test_named_spellbooks(CuTest * tc)
|
2012-05-23 21:42:14 +02:00
|
|
|
{
|
|
|
|
spell * sp;
|
2012-05-24 05:22:12 +02:00
|
|
|
spellbook * sb;
|
2012-05-23 21:42:14 +02:00
|
|
|
int counter = 0;
|
|
|
|
|
2012-05-24 05:22:12 +02:00
|
|
|
sb = create_spellbook("spells");
|
2012-05-23 21:42:14 +02:00
|
|
|
CuAssertPtrNotNull(tc, sb);
|
2012-05-24 05:22:12 +02:00
|
|
|
CuAssertStrEquals(tc, "spells", sb->name);
|
|
|
|
|
|
|
|
sp = create_spell("testspell", 0);
|
|
|
|
spellbook_add(sb, sp, 1);
|
|
|
|
CuAssertPtrNotNull(tc, sb->spells);
|
|
|
|
|
|
|
|
spellbook_foreach(sb, count_spell_cb, &counter);
|
|
|
|
CuAssertIntEquals(tc, 1, counter);
|
|
|
|
|
|
|
|
#ifdef TODO
|
|
|
|
/* try adding the same spell twice. that should fail */
|
|
|
|
spellbook_add(sb, sp, 1);
|
2012-05-23 21:42:14 +02:00
|
|
|
spellbook_foreach(sb, count_spell_cb, &counter);
|
|
|
|
CuAssertIntEquals(tc, 1, counter);
|
2012-05-24 05:22:12 +02:00
|
|
|
#endif
|
2012-05-23 21:42:14 +02:00
|
|
|
spellbook_free(sb);
|
|
|
|
}
|
|
|
|
|
|
|
|
CuSuite *get_spellbook_suite(void)
|
|
|
|
{
|
|
|
|
CuSuite *suite = CuSuiteNew();
|
2012-05-24 05:22:12 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_named_spellbooks);
|
2012-05-23 21:42:14 +02:00
|
|
|
return suite;
|
|
|
|
}
|