Let tests clean up after/before themselves, so terrains can be created by each.

This commit is contained in:
Enno Rehling 2011-03-12 16:59:32 -08:00
parent 315066309a
commit 5afb83c193
2 changed files with 18 additions and 1 deletions

View File

@ -63,6 +63,19 @@ const char *terraindata[MAXTERRAINS] = {
static terrain_type *registered_terrains;
#ifndef DISABLE_TESTS
void test_clear_terrains(void)
{
while (registered_terrains) {
terrain_type * t = registered_terrains;
registered_terrains = t->next;
free(t->_name);
free(t->production);
free(t);
}
}
#endif
const terrain_type *terrains(void)
{
return registered_terrains;

View File

@ -67,7 +67,7 @@ extern "C" {
struct terrain_production *production;
const struct item_type **herbs; /* zero-terminated array of herbs */
const char *(*name) (const struct region * r);
const struct terrain_type *next;
struct terrain_type *next;
} terrain_type;
extern const terrain_type *terrains(void);
@ -77,6 +77,10 @@ extern "C" {
extern void init_terrains(void);
#ifndef DISABLE_TESTS
void test_clear_terrains(void);
#endif
#ifdef __cplusplus
}
#endif