make laws_tests more stand-alone

This commit is contained in:
Enno Rehling 2011-03-08 21:16:47 -08:00
parent e01c6bb8b1
commit 5bf42bd8e9
5 changed files with 30 additions and 17 deletions

View File

@ -97,10 +97,7 @@
<ClCompile Include="gmtool.c" />
<ClCompile Include="gamecode\items.c" />
<ClCompile Include="gamecode\laws.c" />
<ClCompile Include="gamecode\laws_test.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gamecode\laws_test.c" />
<ClCompile Include="gamecode\market.c" />
<ClCompile Include="gamecode\market_test.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>

View File

@ -205,7 +205,7 @@ enum {
FOOD_IS_FREE = 4
};
static void get_food(region * r)
void get_food(region * r)
{
plane *pl = rplane(r);
unit *u;
@ -1614,7 +1614,7 @@ static int display_cmd(unit * u, struct order *ord)
return 0;
}
static boolean renamed_building(const building * b)
boolean renamed_building(const building * b)
{
const struct locale *lang = locales;
for (; lang; lang = nextlocale(lang)) {
@ -1645,7 +1645,7 @@ static int rename_cmd(unit * u, order * ord, char **s, const char *s2)
return 0;
}
static int
int
rename_building(unit * u, order * ord, building * b, const char *name)
{
unit *owner = b ? building_owner(b) : 0;
@ -4410,7 +4410,3 @@ int init_data(const char *filename, const char *catalog)
}
return 0;
}
#ifndef DISABLE_TESTS
#include "laws_test.c"
#endif

View File

@ -34,6 +34,10 @@ extern "C" {
const char *s, struct unit *receiver);
int init_data(const char *filename, const char *catalog);
boolean renamed_building(const struct building * b);
int rename_building(struct unit * u, struct order * ord, struct building * b, const char *name);
void get_food(struct region * r);
/* eressea-specific. put somewhere else, please. */
void processorders(void);
extern struct attrib_type at_germs;

View File

@ -1,7 +1,24 @@
/* this file should only be included by laws.c, never compiled on its own
* (it does not even include all the headers needed to do so).
**/
#include <platform.h>
#include <kernel/types.h>
#include "laws.h"
#include <kernel/config.h>
#include <kernel/building.h>
#include <kernel/faction.h>
#include <kernel/item.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/ship.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
#include <util/language.h>
#include <cutest/CuTest.h>
#include <tests.h>
static void test_new_building_can_be_renamed(CuTest * tc)
{

View File

@ -8,10 +8,9 @@
#include <util/quicklist_test.c>
#include <kernel/move_test.c>
#include <kernel/curse_test.c>
#include <gamecode/laws_test.c>
CuSuite *get_curse_suite(void);
CuSuite *get_market_suite(void);
CuSuite *get_laws_suite(void);
#include <kernel/region.h>
#include <kernel/terrain.h>
@ -102,12 +101,12 @@ void test_create_world(void)
building_type *btype;
ship_type *stype;
t_plain = calloc(1, sizeof(terrain_type));
t_plain = (terrain_type*)calloc(1, sizeof(terrain_type));
t_plain->_name = strdup("plain");
t_plain->flags = LAND_REGION | FOREST_REGION | WALK_INTO;
register_terrain(t_plain);
t_ocean = calloc(1, sizeof(terrain_type));
t_ocean = (terrain_type*)calloc(1, sizeof(terrain_type));
t_ocean->_name = strdup("ocean");
t_ocean->flags = SEA_REGION | SAIL_INTO | SWIM_INTO;
register_terrain(t_ocean);
@ -115,10 +114,10 @@ void test_create_world(void)
island[0] = test_create_region(0, 0, t_plain);
island[1] = test_create_region(1, 0, t_plain);
for (i = 0; i != 2; ++i) {
direction_t j;
int j;
region *r = island[i];
for (j = 0; j != MAXDIRECTIONS; ++j) {
region *rn = r_connect(r, j);
region *rn = r_connect(r, (direction_t)j);
if (!rn) {
rn = test_create_region(r->x + delta_x[j], r->y + delta_y[j], t_ocean);
}