2015-01-12 22:53:21 +01:00
|
|
|
#include <platform.h>
|
2014-08-27 06:40:18 +02:00
|
|
|
#include <config.h>
|
|
|
|
#include "reports.h"
|
2015-05-19 08:26:44 +02:00
|
|
|
#include "report.h"
|
2015-08-05 14:45:46 +02:00
|
|
|
#include "creport.h"
|
2015-08-18 17:08:02 +02:00
|
|
|
#include "move.h"
|
2015-09-08 09:56:56 +02:00
|
|
|
#include "seen.h"
|
2015-08-18 18:57:04 +02:00
|
|
|
#include "travelthru.h"
|
2015-11-12 19:34:25 +01:00
|
|
|
#include "keyword.h"
|
2012-05-17 21:23:25 +02:00
|
|
|
|
|
|
|
#include <kernel/building.h>
|
2014-08-24 23:36:06 +02:00
|
|
|
#include <kernel/faction.h>
|
|
|
|
#include <kernel/race.h>
|
2012-05-17 21:23:25 +02:00
|
|
|
#include <kernel/region.h>
|
|
|
|
#include <kernel/ship.h>
|
|
|
|
#include <kernel/unit.h>
|
2015-11-12 19:34:25 +01:00
|
|
|
#include <kernel/spell.h>
|
|
|
|
#include <kernel/spellbook.h>
|
2012-05-17 21:23:25 +02:00
|
|
|
|
2015-08-19 14:37:51 +02:00
|
|
|
#include <util/language.h>
|
|
|
|
|
2014-08-24 23:36:06 +02:00
|
|
|
#include <quicklist.h>
|
2015-05-19 08:26:44 +02:00
|
|
|
#include <stream.h>
|
|
|
|
#include <memstream.h>
|
2014-08-24 23:36:06 +02:00
|
|
|
|
2012-05-31 04:17:08 +02:00
|
|
|
#include <CuTest.h>
|
2012-05-17 21:23:25 +02:00
|
|
|
#include <tests.h>
|
|
|
|
|
2014-03-15 19:29:11 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-05-17 21:23:25 +02:00
|
|
|
static void test_reorder_units(CuTest * tc)
|
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
region *r;
|
|
|
|
building *b;
|
|
|
|
ship * s;
|
|
|
|
unit *u0, *u1, *u2, *u3, *u4;
|
|
|
|
struct faction * f;
|
|
|
|
const building_type *btype;
|
|
|
|
const ship_type *stype;
|
|
|
|
|
|
|
|
test_cleanup();
|
|
|
|
test_create_world();
|
|
|
|
|
|
|
|
btype = bt_find("castle");
|
|
|
|
stype = st_find("boat");
|
|
|
|
|
|
|
|
r = findregion(-1, 0);
|
|
|
|
b = test_create_building(r, btype);
|
|
|
|
s = test_create_ship(r, stype);
|
|
|
|
f = test_create_faction(0);
|
|
|
|
|
|
|
|
u0 = test_create_unit(f, r);
|
|
|
|
u_set_ship(u0, s);
|
|
|
|
u1 = test_create_unit(f, r);
|
|
|
|
u_set_ship(u1, s);
|
|
|
|
ship_set_owner(u1);
|
|
|
|
u2 = test_create_unit(f, r);
|
|
|
|
u3 = test_create_unit(f, r);
|
|
|
|
u_set_building(u3, b);
|
|
|
|
u4 = test_create_unit(f, r);
|
|
|
|
u_set_building(u4, b);
|
|
|
|
building_set_owner(u4);
|
|
|
|
|
|
|
|
reorder_units(r);
|
|
|
|
|
|
|
|
CuAssertPtrEquals(tc, u4, r->units);
|
|
|
|
CuAssertPtrEquals(tc, u3, u4->next);
|
|
|
|
CuAssertPtrEquals(tc, u2, u3->next);
|
|
|
|
CuAssertPtrEquals(tc, u1, u2->next);
|
|
|
|
CuAssertPtrEquals(tc, u0, u1->next);
|
|
|
|
CuAssertPtrEquals(tc, 0, u0->next);
|
2015-10-13 22:11:45 +02:00
|
|
|
test_cleanup();
|
2012-05-17 21:23:25 +02:00
|
|
|
}
|
|
|
|
|
2012-05-29 08:31:46 +02:00
|
|
|
static void test_regionid(CuTest * tc) {
|
2015-01-30 20:37:14 +01:00
|
|
|
size_t len;
|
|
|
|
const struct terrain_type * plain;
|
|
|
|
struct region * r;
|
|
|
|
char buffer[64];
|
|
|
|
|
|
|
|
test_cleanup();
|
|
|
|
plain = test_create_terrain("plain", 0);
|
|
|
|
r = test_create_region(0, 0, plain);
|
|
|
|
|
|
|
|
memset(buffer, 0x7d, sizeof(buffer));
|
|
|
|
len = f_regionid(r, 0, buffer, sizeof(buffer));
|
2015-05-15 20:35:36 +02:00
|
|
|
CuAssertIntEquals(tc, 11, (int)len);
|
2015-01-30 20:37:14 +01:00
|
|
|
CuAssertStrEquals(tc, "plain (0,0)", buffer);
|
|
|
|
|
|
|
|
memset(buffer, 0x7d, sizeof(buffer));
|
|
|
|
len = f_regionid(r, 0, buffer, 11);
|
2015-05-15 20:35:36 +02:00
|
|
|
CuAssertIntEquals(tc, 10, (int)len);
|
2015-01-30 20:37:14 +01:00
|
|
|
CuAssertStrEquals(tc, "plain (0,0", buffer);
|
|
|
|
CuAssertIntEquals(tc, 0x7d, buffer[11]);
|
2015-10-13 22:11:45 +02:00
|
|
|
test_cleanup();
|
2012-05-29 08:31:46 +02:00
|
|
|
}
|
|
|
|
|
2014-08-24 23:36:06 +02:00
|
|
|
static void test_seen_faction(CuTest *tc) {
|
|
|
|
faction *f1, *f2;
|
2015-10-13 22:11:45 +02:00
|
|
|
race *rc;
|
|
|
|
|
|
|
|
test_cleanup();
|
|
|
|
rc = test_create_race("human");
|
2014-08-24 23:36:06 +02:00
|
|
|
f1 = test_create_faction(rc);
|
|
|
|
f2 = test_create_faction(rc);
|
|
|
|
add_seen_faction(f1, f2);
|
|
|
|
CuAssertPtrEquals(tc, f2, ql_get(f1->seen_factions, 0));
|
|
|
|
CuAssertIntEquals(tc, 1, ql_length(f1->seen_factions));
|
|
|
|
add_seen_faction(f1, f2);
|
|
|
|
CuAssertIntEquals(tc, 1, ql_length(f1->seen_factions));
|
|
|
|
add_seen_faction(f1, f1);
|
|
|
|
CuAssertIntEquals(tc, 2, ql_length(f1->seen_factions));
|
|
|
|
f2 = (faction *)ql_get(f1->seen_factions, 1);
|
|
|
|
f1 = (faction *)ql_get(f1->seen_factions, 0);
|
2015-01-30 20:37:14 +01:00
|
|
|
CuAssertTrue(tc, f1->no < f2->no);
|
2015-10-13 22:11:45 +02:00
|
|
|
test_cleanup();
|
2014-08-24 23:36:06 +02:00
|
|
|
}
|
|
|
|
|
2015-05-19 08:26:44 +02:00
|
|
|
static void test_write_spaces(CuTest *tc) {
|
|
|
|
stream out = { 0 };
|
|
|
|
char buf[1024];
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
mstream_init(&out);
|
|
|
|
write_spaces(&out, 4);
|
|
|
|
out.api->rewind(out.handle);
|
|
|
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
|
|
|
buf[len] = '\0';
|
|
|
|
CuAssertStrEquals(tc, " ", buf);
|
|
|
|
CuAssertIntEquals(tc, ' ', buf[3]);
|
|
|
|
mstream_done(&out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_write_many_spaces(CuTest *tc) {
|
|
|
|
stream out = { 0 };
|
|
|
|
char buf[1024];
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
mstream_init(&out);
|
|
|
|
write_spaces(&out, 100);
|
|
|
|
out.api->rewind(out.handle);
|
|
|
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
|
|
|
buf[len] = '\0';
|
|
|
|
CuAssertIntEquals(tc, 100, (int)len);
|
|
|
|
CuAssertIntEquals(tc, ' ', buf[99]);
|
|
|
|
mstream_done(&out);
|
|
|
|
}
|
|
|
|
|
2015-05-20 18:05:25 +02:00
|
|
|
static void test_sparagraph(CuTest *tc) {
|
|
|
|
strlist *sp = 0;
|
2015-10-13 23:06:33 +02:00
|
|
|
|
2015-05-20 18:05:25 +02:00
|
|
|
split_paragraph(&sp, "Hello World", 0, 16, 0);
|
|
|
|
CuAssertPtrNotNull(tc, sp);
|
|
|
|
CuAssertStrEquals(tc, "Hello World", sp->s);
|
|
|
|
CuAssertPtrEquals(tc, 0, sp->next);
|
2015-10-13 23:06:33 +02:00
|
|
|
freestrlist(sp);
|
|
|
|
|
2015-05-20 18:05:25 +02:00
|
|
|
split_paragraph(&sp, "Hello World", 4, 16, 0);
|
|
|
|
CuAssertPtrNotNull(tc, sp);
|
|
|
|
CuAssertStrEquals(tc, " Hello World", sp->s);
|
|
|
|
CuAssertPtrEquals(tc, 0, sp->next);
|
2015-10-13 23:06:33 +02:00
|
|
|
freestrlist(sp);
|
|
|
|
|
2015-05-20 18:05:25 +02:00
|
|
|
split_paragraph(&sp, "Hello World", 4, 16, '*');
|
|
|
|
CuAssertPtrNotNull(tc, sp);
|
|
|
|
CuAssertStrEquals(tc, " * Hello World", sp->s);
|
|
|
|
CuAssertPtrEquals(tc, 0, sp->next);
|
2015-10-13 23:06:33 +02:00
|
|
|
freestrlist(sp);
|
|
|
|
|
2015-05-20 18:05:25 +02:00
|
|
|
split_paragraph(&sp, "12345678 90 12345678", 0, 8, '*');
|
|
|
|
CuAssertPtrNotNull(tc, sp);
|
|
|
|
CuAssertStrEquals(tc, "12345678", sp->s);
|
|
|
|
CuAssertPtrNotNull(tc, sp->next);
|
|
|
|
CuAssertStrEquals(tc, "90", sp->next->s);
|
|
|
|
CuAssertPtrNotNull(tc, sp->next->next);
|
|
|
|
CuAssertStrEquals(tc, "12345678", sp->next->next->s);
|
|
|
|
CuAssertPtrEquals(tc, 0, sp->next->next->next);
|
2015-10-13 22:21:05 +02:00
|
|
|
freestrlist(sp);
|
2015-05-20 18:05:25 +02:00
|
|
|
}
|
|
|
|
|
2015-08-05 14:45:46 +02:00
|
|
|
static void test_cr_unit(CuTest *tc) {
|
|
|
|
stream strm;
|
|
|
|
char line[1024];
|
|
|
|
faction *f;
|
|
|
|
region *r;
|
|
|
|
unit *u;
|
|
|
|
|
|
|
|
test_cleanup();
|
|
|
|
f = test_create_faction(0);
|
|
|
|
r = test_create_region(0, 0, 0);
|
|
|
|
u = test_create_unit(f, r);
|
|
|
|
renumber_unit(u, 1234);
|
|
|
|
|
|
|
|
mstream_init(&strm);
|
|
|
|
cr_output_unit(&strm, r, f, u, see_unit);
|
|
|
|
strm.api->rewind(strm.handle);
|
|
|
|
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
|
|
|
CuAssertStrEquals(tc, line, "EINHEIT 1234");
|
|
|
|
mstream_done(&strm);
|
|
|
|
test_cleanup();
|
|
|
|
}
|
|
|
|
|
2015-08-18 17:08:02 +02:00
|
|
|
static void test_write_travelthru(CuTest *tc) {
|
|
|
|
stream out = { 0 };
|
|
|
|
char buf[1024];
|
|
|
|
size_t len;
|
|
|
|
region *r;
|
|
|
|
faction *f;
|
|
|
|
unit *u;
|
2015-08-19 14:37:51 +02:00
|
|
|
struct locale *lang;
|
2015-08-18 17:08:02 +02:00
|
|
|
|
|
|
|
test_cleanup();
|
2015-08-19 14:37:51 +02:00
|
|
|
lang = get_or_create_locale("de");
|
|
|
|
locale_setstring(lang, "travelthru_header", "Durchreise: ");
|
2015-08-18 17:08:02 +02:00
|
|
|
mstream_init(&out);
|
|
|
|
r = test_create_region(0, 0, 0);
|
|
|
|
r->flags |= RF_TRAVELUNIT;
|
|
|
|
f = test_create_faction(0);
|
2015-08-19 14:37:51 +02:00
|
|
|
f->locale = lang;
|
2015-08-18 17:08:02 +02:00
|
|
|
u = test_create_unit(f, 0);
|
2015-08-19 14:37:51 +02:00
|
|
|
unit_setname(u, "Hodor");
|
|
|
|
unit_setid(u, 1);
|
2015-08-18 17:08:02 +02:00
|
|
|
|
|
|
|
write_travelthru(&out, r, f);
|
|
|
|
out.api->rewind(out.handle);
|
|
|
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
|
|
|
CuAssertIntEquals_Msg(tc, "no travelers, no report", 0, (int)len);
|
2015-08-19 14:50:19 +02:00
|
|
|
mstream_done(&out);
|
|
|
|
|
|
|
|
mstream_init(&out);
|
2015-08-19 14:37:51 +02:00
|
|
|
travelthru_add(r, u);
|
2015-08-18 17:08:02 +02:00
|
|
|
write_travelthru(&out, r, f);
|
2015-08-19 14:37:51 +02:00
|
|
|
out.api->rewind(out.handle);
|
2015-08-18 17:08:02 +02:00
|
|
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
2015-08-19 14:37:51 +02:00
|
|
|
buf[len] = '\0';
|
|
|
|
CuAssertStrEquals_Msg(tc, "list one unit", "Durchreise: Hodor (1).\n", buf);
|
2015-08-19 14:50:19 +02:00
|
|
|
mstream_done(&out);
|
2015-08-18 17:08:02 +02:00
|
|
|
|
2015-08-19 14:50:19 +02:00
|
|
|
mstream_init(&out);
|
2015-08-18 17:08:02 +02:00
|
|
|
move_unit(u, r, 0);
|
|
|
|
write_travelthru(&out, r, f);
|
2015-08-19 14:37:51 +02:00
|
|
|
out.api->rewind(out.handle);
|
2015-08-18 17:08:02 +02:00
|
|
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
2015-08-19 14:50:19 +02:00
|
|
|
CuAssertIntEquals_Msg(tc, "do not list units that stopped in the region", 0, (int)len);
|
2015-08-18 17:08:02 +02:00
|
|
|
|
|
|
|
mstream_done(&out);
|
|
|
|
test_cleanup();
|
|
|
|
}
|
|
|
|
|
2015-08-26 21:19:14 +02:00
|
|
|
static void test_write_unit(CuTest *tc) {
|
|
|
|
unit *u;
|
|
|
|
faction *f;
|
|
|
|
race *rc;
|
|
|
|
struct locale *lang;
|
|
|
|
char buffer[1024];
|
2016-01-29 17:49:27 +01:00
|
|
|
/* FIXME: test emits ERROR: no translation for combat status status_aggressive in locale de */
|
2015-08-26 21:19:14 +02:00
|
|
|
|
|
|
|
test_cleanup();
|
|
|
|
rc = rc_get_or_create("human");
|
|
|
|
rc->bonus[SK_ALCHEMY] = 1;
|
|
|
|
lang = get_or_create_locale("de");
|
|
|
|
locale_setstring(lang, "nr_skills", "Talente");
|
|
|
|
locale_setstring(lang, "skill::sailing", "Segeln");
|
|
|
|
locale_setstring(lang, "skill::alchemy", "Alchemie");
|
2016-02-01 14:06:56 +01:00
|
|
|
locale_setstring(lang, "status_aggressive", "aggressiv");
|
2015-08-26 21:19:14 +02:00
|
|
|
init_skills(lang);
|
|
|
|
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
|
|
|
|
u->faction->locale = lang;
|
|
|
|
faction_setname(u->faction, "UFO");
|
|
|
|
renumber_faction(u->faction, 1);
|
|
|
|
unit_setname(u, "Hodor");
|
|
|
|
unit_setid(u, 1);
|
|
|
|
|
|
|
|
bufunit(u->faction, u, 0, 0, buffer, sizeof(buffer));
|
2016-02-01 14:06:56 +01:00
|
|
|
CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv.", buffer);
|
2015-08-26 21:19:14 +02:00
|
|
|
|
|
|
|
set_level(u, SK_SAILING, 1);
|
|
|
|
bufunit(u->faction, u, 0, 0, buffer, sizeof(buffer));
|
2016-02-01 14:06:56 +01:00
|
|
|
CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv, Talente: Segeln 1.", buffer);
|
2015-08-26 21:19:14 +02:00
|
|
|
|
|
|
|
set_level(u, SK_ALCHEMY, 1);
|
|
|
|
bufunit(u->faction, u, 0, 0, buffer, sizeof(buffer));
|
2016-02-01 14:06:56 +01:00
|
|
|
CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv, Talente: Segeln 1, Alchemie 2.", buffer);
|
2015-08-26 21:19:14 +02:00
|
|
|
|
|
|
|
f = test_create_faction(0);
|
|
|
|
f->locale = get_or_create_locale("de");
|
|
|
|
bufunit(f, u, 0, 0, buffer, sizeof(buffer));
|
|
|
|
CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buffer);
|
|
|
|
test_cleanup();
|
|
|
|
}
|
|
|
|
|
2015-11-12 22:29:56 +01:00
|
|
|
typedef struct {
|
|
|
|
struct locale *lang;
|
2015-11-12 19:34:25 +01:00
|
|
|
spell *sp;
|
|
|
|
spellbook *spb;
|
|
|
|
spellbook_entry * sbe;
|
2015-11-12 22:29:56 +01:00
|
|
|
} spell_fixture;
|
|
|
|
|
|
|
|
static void setup_spell_fixture(spell_fixture * spf) {
|
|
|
|
spf->lang = get_or_create_locale("de");
|
|
|
|
locale_setstring(spf->lang, mkname("spell", "testspell"), "Testzauber");
|
|
|
|
locale_setstring(spf->lang, "nr_spell_type", "Typ:");
|
|
|
|
locale_setstring(spf->lang, "sptype_normal", "Normal");
|
|
|
|
locale_setstring(spf->lang, "nr_spell_modifiers", "Modifier:");
|
|
|
|
locale_setstring(spf->lang, "smod_none", "Keine");
|
|
|
|
locale_setstring(spf->lang, keyword(K_CAST), "ZAUBERE");
|
|
|
|
locale_setstring(spf->lang, parameters[P_REGION], "REGION");
|
|
|
|
locale_setstring(spf->lang, parameters[P_LEVEL], "STUFE");
|
|
|
|
locale_setstring(spf->lang, "par_unit", "enr");
|
|
|
|
locale_setstring(spf->lang, "par_ship", "snr");
|
|
|
|
locale_setstring(spf->lang, "par_building", "bnr");
|
|
|
|
locale_setstring(spf->lang, "spellpar::hodor", "Hodor");
|
|
|
|
|
|
|
|
spf->spb = create_spellbook("testbook");
|
|
|
|
spf->sp = test_create_spell();
|
|
|
|
spellbook_add(spf->spb, spf->sp, 1);
|
|
|
|
spf->sbe = spellbook_get(spf->spb, spf->sp);
|
|
|
|
}
|
2015-11-12 19:34:25 +01:00
|
|
|
|
2015-12-06 12:02:16 +01:00
|
|
|
static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) {
|
2015-11-12 22:29:56 +01:00
|
|
|
stream strm;
|
|
|
|
char buf[1024];
|
|
|
|
char *linestart, *newline;
|
|
|
|
size_t len;
|
2015-11-12 19:34:25 +01:00
|
|
|
|
|
|
|
mstream_init(&strm);
|
2015-11-12 22:29:56 +01:00
|
|
|
nr_spell_syntax(&strm, spell->sbe, spell->lang);
|
2015-11-12 19:34:25 +01:00
|
|
|
strm.api->rewind(strm.handle);
|
|
|
|
len = strm.api->read(strm.handle, buf, sizeof(buf));
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
2015-11-12 22:29:56 +01:00
|
|
|
linestart = strtok(buf, "\n");
|
|
|
|
while (linestart && !strstr(linestart, "ZAUBERE"))
|
|
|
|
linestart = strtok(NULL, "\n") ;
|
|
|
|
|
2015-12-05 18:45:03 +01:00
|
|
|
CuAssertPtrNotNull(tc, linestart);
|
2015-11-12 22:29:56 +01:00
|
|
|
|
2015-12-05 18:45:03 +01:00
|
|
|
newline = strtok(NULL, "\n");
|
|
|
|
while (newline) {
|
|
|
|
*(newline - 1) = '\n';
|
|
|
|
newline = strtok(NULL, "\n");
|
|
|
|
}
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
CuAssertStrEquals_Msg(tc, msg, syntax, linestart);
|
2015-11-12 19:34:25 +01:00
|
|
|
|
|
|
|
mstream_done(&strm);
|
2015-11-12 22:29:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void set_parameter(spell_fixture spell, char *value) {
|
2015-11-13 15:35:17 +01:00
|
|
|
free(spell.sp->parameter);
|
|
|
|
spell.sp->parameter = _strdup(value);
|
2015-11-12 22:29:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_write_spell_syntax(CuTest *tc) {
|
|
|
|
spell_fixture spell;
|
|
|
|
|
|
|
|
test_cleanup();
|
|
|
|
setup_spell_fixture(&spell);
|
|
|
|
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "vanilla", &spell, " ZAUBERE \"Testzauber\"");
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
spell.sp->sptyp |= FARCASTING;
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "far", &spell, " ZAUBERE [REGION x y] \"Testzauber\"");
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
spell.sp->sptyp |= SPELLLEVEL;
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "farlevel", &spell, " ZAUBERE [REGION x y] [STUFE n] \"Testzauber\"");
|
2015-11-12 22:29:56 +01:00
|
|
|
spell.sp->sptyp = 0;
|
|
|
|
|
|
|
|
set_parameter(spell, "kc");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "kc", &spell, " ZAUBERE \"Testzauber\" ( REGION | EINHEIT <enr> | SCHIFF <snr> | BURG <bnr> )");
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
spell.sp->sptyp |= BUILDINGSPELL;
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "kc typed", &spell, " ZAUBERE \"Testzauber\" BURG <bnr>");
|
2015-11-12 22:29:56 +01:00
|
|
|
spell.sp->sptyp = 0;
|
|
|
|
|
|
|
|
set_parameter(spell, "b");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "b", &spell, " ZAUBERE \"Testzauber\" <bnr>");
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
set_parameter(spell, "s");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "s", &spell, " ZAUBERE \"Testzauber\" <snr>");
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
set_parameter(spell, "s+");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "s+", &spell, " ZAUBERE \"Testzauber\" <snr> [<snr> ...]");
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
set_parameter(spell, "u");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "u", &spell, " ZAUBERE \"Testzauber\" <enr>");
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
set_parameter(spell, "r");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "r", &spell, " ZAUBERE \"Testzauber\" <x> <y>");
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
set_parameter(spell, "bc");
|
2015-11-13 15:35:17 +01:00
|
|
|
free(spell.sp->syntax);
|
2015-11-12 22:29:56 +01:00
|
|
|
spell.sp->syntax = _strdup("hodor");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" <bnr> <Hodor>");
|
2015-11-12 22:29:56 +01:00
|
|
|
free(spell.sp->syntax);
|
2015-11-13 15:35:17 +01:00
|
|
|
spell.sp->syntax = 0;
|
2015-11-12 22:29:56 +01:00
|
|
|
|
2015-11-13 15:35:17 +01:00
|
|
|
set_parameter(spell, "c?");
|
|
|
|
free(spell.sp->syntax);
|
2015-11-12 22:29:56 +01:00
|
|
|
spell.sp->syntax = _strdup("hodor");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" [<Hodor>]");
|
2015-11-12 22:29:56 +01:00
|
|
|
free(spell.sp->syntax);
|
2015-11-13 15:35:17 +01:00
|
|
|
spell.sp->syntax = 0;
|
2015-11-12 22:29:56 +01:00
|
|
|
|
|
|
|
set_parameter(spell, "kc+");
|
2015-12-06 12:02:16 +01:00
|
|
|
check_spell_syntax(tc, "kc+", &spell,
|
2015-11-12 22:29:56 +01:00
|
|
|
" ZAUBERE \"Testzauber\" ( REGION | EINHEIT <enr> [<enr> ...] | SCHIFF <snr>\n [<snr> ...] | BURG <bnr> [<bnr> ...] )");
|
|
|
|
|
2015-11-12 19:34:25 +01:00
|
|
|
test_cleanup();
|
|
|
|
}
|
|
|
|
|
2012-05-17 21:23:25 +02:00
|
|
|
CuSuite *get_reports_suite(void)
|
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
CuSuite *suite = CuSuiteNew();
|
2015-08-05 14:45:46 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_cr_unit);
|
2015-01-30 20:37:14 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_reorder_units);
|
|
|
|
SUITE_ADD_TEST(suite, test_seen_faction);
|
|
|
|
SUITE_ADD_TEST(suite, test_regionid);
|
2015-05-19 08:26:44 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_write_spaces);
|
|
|
|
SUITE_ADD_TEST(suite, test_write_many_spaces);
|
2015-05-20 18:05:25 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_sparagraph);
|
2015-08-18 17:08:02 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_write_travelthru);
|
2015-08-26 21:19:14 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_write_unit);
|
2015-11-12 19:34:25 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_write_spell_syntax);
|
2015-01-30 20:37:14 +01:00
|
|
|
return suite;
|
2012-05-17 21:23:25 +02:00
|
|
|
}
|