- new test case (recruiting)

- logging and compilation fixes
This commit is contained in:
Enno Rehling 2008-12-31 11:30:44 +00:00
parent 5ea74d8bd8
commit 24182c4d06
6 changed files with 119 additions and 104 deletions

View file

@ -4,7 +4,7 @@
#include "eressea/server.cpp"
#ifndef BINDINGS_TOLUA
#ifdef BINDINGS_LUABIND
#include "eressea/lua/alliance.cpp"
#include "eressea/lua/building.cpp"
#include "eressea/lua/eressea.cpp"

View file

@ -837,7 +837,7 @@ demographics(void)
free(free_migrants);
free_migrants = m;
};
putchar('\n');
if (verbosity>=1) putchar('\n');
remove_empty_units();
@ -3930,7 +3930,7 @@ update_subscriptions(void)
strcat(strcpy(zText, basepath()), "/subscriptions");
F = fopen(zText, "r");
if (F==NULL) {
log_info((0, "could not open %s.\n", zText));
log_warning((0, "could not open %s.\n", zText));
return;
}
for (;;) {

View file

@ -357,10 +357,6 @@ extern void reorder_units(struct region * r);
extern const char *localenames[];
#ifdef _MSC_VER
#include <stdafx.h>
#endif
/** compatibility: **/
extern race_t old_race(const struct race *);
extern const struct race * new_race[];

View file

@ -258,7 +258,6 @@ _log_info(unsigned int level, const char * format, ...)
va_start(marker, format);
vfprintf(logfile, format, marker);
va_end(marker);
}
if (logfile!=stderr) {
if (stderr_level>=level) {
fprintf(stderr, "INFO[%u]: ", level);
@ -285,4 +284,5 @@ _log_info(unsigned int level, const char * format, ...)
log_flush();
}
}
}
}

View file

@ -122,11 +122,11 @@
#ifdef _MSC_VER
#pragma warning (pop)
#endif // _MSC_VER
#endif // BINDINGS_LUABIND
#include "lua/script.h"
#include <boost/version.hpp>
#endif // BINDINGS_LUABIND
#include <libxml/encoding.h>
/* stdc++ includes */

View file

@ -185,7 +185,7 @@ function test_events()
str = evt:get(0)
u2 = evt:get(1)
assert(u2~=nil)
print(str=="Du Elf stinken")
assert(str=="Du Elf stinken")
message_unit(u, u2, "thanks unit, i got your message: " .. str)
message_faction(u, u2.faction, "thanks faction, i got your message: " .. str)
message_region(u, "thanks region, i got your message: " .. str)
@ -218,18 +218,37 @@ function test_events()
assert(fail==0)
end
local function test_recruit()
free_game()
local r = region.create(0, 0, "plain")
local f = faction.create("enno@eressea.de", "human", "de")
local u = unit.create(f, r)
u.number = 1
local n = 3
r:set_resource("peasant", 200)
u:clear_orders()
u:add_item("money", 85*n+20)
u:add_order("REKRUTIERE " .. n)
process_orders()
assert(u.number == n+1)
local p = r:get_resource("peasant")
assert(p<200 and p>=200-n)
assert(u:get_item("money")==10)
end
loadscript("extensions.lua")
tests = {
["test_pure"] = test_pure,
["test_read_write"] = test_read_write,
["test_faction"] = test_faction,
["test_region"] = test_region,
["test_building"] = test_building,
["test_unit"] = test_unit,
["test_message"] = test_message,
["test_hashtable"] = test_hashtable,
["test_gmtool"] = test_gmtool,
["test_events"] = test_events
["pure"] = test_pure,
["read_write"] = test_read_write,
["faction"] = test_faction,
["region"] = test_region,
["building"] = test_building,
["unit"] = test_unit,
["message"] = test_message,
["hashtable"] = test_hashtable,
["gmtool"] = test_gmtool,
["events"] = test_events,
["recruit"] = test_recruit
}
fail = 0