make merge request sing with Eressea

added a missing file (move_test.c)
changing the way tests are included
making some lua code prettier (too many parens)
This commit is contained in:
Enno Rehling 2011-03-08 21:06:38 -08:00
parent 8714957a61
commit e01c6bb8b1
9 changed files with 33 additions and 36 deletions

View File

@ -9,8 +9,8 @@ local function _test_unique_btype()
local utype = nil
for i = 1, #config.buildings do
bt = config.buildings[i]
if (((config.get_building(bt).flags / 4) % 2) ~= 0) then -- #define BTF_UNIQUE 0x04
if (((config.get_building(bt).flags / 2) % 2) == 0) then -- #define BTF_NOBUILD 0x02
if ((config.get_building(bt).flags / 4) % 2) ~= 0 then -- #define BTF_UNIQUE 0x04
if ((config.get_building(bt).flags / 2) % 2) == 0 then -- #define BTF_NOBUILD 0x02
utype = bt
end
end
@ -89,7 +89,7 @@ function test_plane()
local r, x, y
for x = -3, 3 do for y = -3, 3 do
r = region.create(x, y, "plain")
if (x==y) then
if x==y then
local u = unit.create(f, r, 1)
end
end end
@ -752,7 +752,7 @@ function test_ride_with_horses_and_cart()
u:add_item("sword", capacity / sword_cfg.weight)
u:add_item("horse", 1)
if (cart_cfg~=nil) then
if cart_cfg~=nil then
-- we need 2 horses for a cart, so this should fail:
u:add_item("cart", 1)
u:clear_orders()
@ -965,7 +965,7 @@ function test_building_unique0()
local u2 = unit.create(f2, r, 20)
local utype = _test_unique_btype()
if (utype ~= nil) then
if utype ~= nil then
assert_equal("harbour", utype)
u:set_skill("building", 20)
u:add_item("log", 10000)
@ -988,7 +988,7 @@ function test_building_unique0()
bcount = 0
for bs in r.buildings do
assert_equal(1, string.find(bs.name, translate(utype)))
if (bs.size >= config.get_building(utype).maxsize) then
if bs.size >= config.get_building(utype).maxsize then
bcount = bcount + 1
end
end
@ -1006,7 +1006,7 @@ function test_building_unique()
local u2 = unit.create(f2, r, 20)
local utype = _test_unique_btype()
if (utype ~= nil) then
if utype ~= nil then
u:set_skill("building", 20)
u:add_item("log", 10000)
u:add_item("iron", 10000)
@ -1030,20 +1030,20 @@ function test_building_unique()
u2:clear_orders()
u2:add_order("MACHEN Hafen")
process_orders()
if (r.buildings() == nil) then
if r.buildings == nil then
process_orders()
end
assert_not_nil(r.buildings)
bcount = 0
local h1 = nil
for bs in r.buildings do
if (h1 == nil) then
if h1 == nil then
h1 = bs.name
else
assert_equal(h1, bs.name)
end
assert_equal(1, string.find(bs.name, "Hafen"))
if (bs.size >= 25) then
if bs.size >= 25 then
bcount = bcount + 1
end
end

View File

@ -656,17 +656,7 @@ void tolua_region_open(lua_State * L)
tolua_function(L, TOLUA_CAST "get_key", tolua_region_getkey);
tolua_function(L, TOLUA_CAST "set_key", tolua_region_setkey);
#if 0
.def("add_notice", &region_addnotice)
.def("add_direction", &region_adddirection)
.def("move", &region_move)
.def("get_road", &region_getroad)
.def("set_road", &region_setroad)
.def("next", &region_next)
.def("add_item", &region_additem)
.property("items", &region_items, return_stl_iterator)
.property("plane_id", &region_plane)
#endif
tolua_variable(L, TOLUA_CAST "objects", tolua_region_get_objects, 0);
}
tolua_endmodule(L);

View File

@ -105,6 +105,7 @@
<ClCompile Include="kernel\magic.c" />
<ClCompile Include="kernel\message.c" />
<ClCompile Include="kernel\move.c" />
<ClCompile Include="kernel\move_test.c" />
<ClCompile Include="kernel\names.c" />
<ClCompile Include="kernel\order.c" />
<ClCompile Include="kernel\pathfinder.c" />
@ -178,10 +179,7 @@
<ClCompile Include="attributes\reduceproduction.c" />
<ClCompile Include="attributes\targetregion.c" />
<ClCompile Include="attributes\viewrange.c" />
<ClCompile Include="kernel\curse_test.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="kernel\curse_test.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="kernel\alchemy.h" />

View File

@ -292,6 +292,9 @@
<Filter>attributes</Filter>
</ClCompile>
<ClCompile Include="kernel\curse_test.c" />
<ClCompile Include="kernel\move_test.c">
<Filter>kernel</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="kernel\alchemy.h">

View File

@ -808,7 +808,3 @@ double destr_curse(curse * c, int cast_level, double force)
}
return force;
}
#ifndef DISABLE_TESTS
#include "curse_test.c"
#endif

View File

@ -1,3 +1,9 @@
#include <platform.h>
#include "types.h"
#include "curse.h"
#include <util/attrib.h>
#include <cutest/CuTest.h>
static void test_curse(CuTest * tc)

View File

@ -2715,7 +2715,3 @@ void follow_unit(unit * u)
}
}
}
#ifndef DISABLE_TESTS
#include "move_test.c"
#endif

7
src/kernel/move_test.c Normal file
View File

@ -0,0 +1,7 @@
#include <cutest/CuTest.h>
CuSuite *get_move_suite(void)
{
CuSuite *suite = CuSuiteNew();
return suite;
}

View File

@ -6,10 +6,11 @@
#include <util/base36_test.c>
#include <util/quicklist_test.c>
#include <kernel/move_test.c>
#include <kernel/curse_test.c>
CuSuite *get_curse_suite(void);
CuSuite *get_market_suite(void);
CuSuite *get_move_suite(void);
CuSuite *get_laws_suite(void);
#include <kernel/region.h>