2018-01-14 18:02:30 +01:00
|
|
|
#ifdef _MSC_VER
|
2014-06-08 07:17:48 +02:00
|
|
|
#include <platform.h>
|
2018-01-14 18:02:30 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "kernel/types.h"
|
|
|
|
|
2014-06-08 07:17:48 +02:00
|
|
|
#include "jsonconf.h"
|
2014-06-16 07:17:08 +02:00
|
|
|
|
2018-01-14 18:02:30 +01:00
|
|
|
#include "kernel/config.h"
|
|
|
|
#include "kernel/building.h"
|
|
|
|
#include "kernel/item.h"
|
|
|
|
#include "kernel/race.h"
|
|
|
|
#include "kernel/ship.h"
|
|
|
|
#include "kernel/spell.h"
|
|
|
|
#include "kernel/order.h"
|
|
|
|
#include "kernel/terrain.h"
|
|
|
|
|
2018-09-29 18:13:32 +02:00
|
|
|
#include "util/keyword.h"
|
2018-01-14 18:02:30 +01:00
|
|
|
#include "util/language.h"
|
|
|
|
|
2018-02-14 20:00:48 +01:00
|
|
|
#include "kernel/calendar.h"
|
2014-06-16 07:17:08 +02:00
|
|
|
#include "direction.h"
|
2017-05-07 18:10:18 +02:00
|
|
|
#include "move.h"
|
2015-09-12 12:33:25 +02:00
|
|
|
#include "prefix.h"
|
|
|
|
|
2014-06-08 07:17:48 +02:00
|
|
|
#include <CuTest.h>
|
|
|
|
#include <cJSON.h>
|
|
|
|
#include <tests.h>
|
2014-10-29 08:30:07 +01:00
|
|
|
#include <string.h>
|
2014-06-08 07:17:48 +02:00
|
|
|
#include <stdio.h>
|
2016-09-11 17:19:27 +02:00
|
|
|
#include <errno.h>
|
2014-06-08 07:17:48 +02:00
|
|
|
|
2014-07-06 09:53:15 +02:00
|
|
|
static const struct race * race_with_flag(const char * name) {
|
2014-06-08 07:17:48 +02:00
|
|
|
char data[1024];
|
|
|
|
cJSON *json;
|
2014-06-25 23:30:24 +02:00
|
|
|
sprintf(data, "{\"races\" : { \"orc\": { \"speed\" : 1, \"flags\" : [ \"%s\"] }}}", name);
|
2014-06-08 07:17:48 +02:00
|
|
|
|
|
|
|
json = cJSON_Parse(data);
|
|
|
|
free_races();
|
|
|
|
json_config(json);
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2014-07-06 09:53:15 +02:00
|
|
|
return rc_find("orc");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_ec_flag(CuTest *tc, const char *name, int flag) {
|
|
|
|
const struct race *rc = race_with_flag(name);
|
|
|
|
CuAssertPtrNotNull(tc, rc);
|
|
|
|
CuAssertIntEquals(tc, flag, rc->ec_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_flag(CuTest *tc, const char *name, int flag) {
|
|
|
|
const struct race *rc = race_with_flag(name);
|
2014-06-08 07:17:48 +02:00
|
|
|
CuAssertPtrNotNull(tc, rc);
|
|
|
|
CuAssertIntEquals(tc, flag, rc->flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_flags(CuTest *tc) {
|
2017-12-27 19:58:39 +01:00
|
|
|
test_setup();
|
2018-05-10 22:00:23 +02:00
|
|
|
check_flag(tc, "player", RCF_PLAYABLE);
|
2014-06-13 17:04:06 +02:00
|
|
|
check_flag(tc, "scarepeasants", RCF_SCAREPEASANTS);
|
2014-07-06 04:29:12 +02:00
|
|
|
check_flag(tc, "nosteal", RCF_NOSTEAL);
|
2014-06-13 17:04:06 +02:00
|
|
|
check_flag(tc, "noheal", RCF_NOHEAL);
|
|
|
|
check_flag(tc, "undead", RCF_UNDEAD);
|
|
|
|
check_flag(tc, "dragon", RCF_DRAGON);
|
|
|
|
check_flag(tc, "fly", RCF_FLY);
|
2017-07-17 12:33:55 +02:00
|
|
|
check_ec_flag(tc, "getitem", ECF_GETITEM);
|
|
|
|
check_ec_flag(tc, "giveperson", ECF_GIVEPERSON);
|
|
|
|
check_ec_flag(tc, "giveunit", ECF_GIVEUNIT);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-08 07:17:48 +02:00
|
|
|
}
|
|
|
|
|
2015-09-10 23:16:17 +02:00
|
|
|
static void test_settings(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"settings\": { "
|
|
|
|
"\"string\" : \"1d4\","
|
|
|
|
"\"integer\" : 14,"
|
2015-09-11 09:17:07 +02:00
|
|
|
"\"true\": true,"
|
2017-01-21 20:59:16 +01:00
|
|
|
"\"game.id\": 4,"
|
2017-03-01 21:17:37 +01:00
|
|
|
"\"game.name\": \"E3\","
|
2015-09-11 09:17:07 +02:00
|
|
|
"\"false\": false,"
|
|
|
|
"\"float\" : 1.5 }}";
|
2015-09-10 23:16:17 +02:00
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2017-02-18 21:15:14 +01:00
|
|
|
config_set("game.id", "42"); /* should not be replaced */
|
2017-03-01 21:17:37 +01:00
|
|
|
config_set("game.name", "Eressea"); /* should not be replaced */
|
2015-09-10 23:16:17 +02:00
|
|
|
json_config(json);
|
2017-01-21 20:59:16 +01:00
|
|
|
CuAssertStrEquals(tc, "42", config_get("game.id"));
|
2017-03-01 21:17:37 +01:00
|
|
|
CuAssertStrEquals(tc, "Eressea", config_get("game.name"));
|
2015-11-22 10:44:46 +01:00
|
|
|
CuAssertStrEquals(tc, "1", config_get("true"));
|
|
|
|
CuAssertStrEquals(tc, "0", config_get("false"));
|
|
|
|
CuAssertStrEquals(tc, "1d4", config_get("string"));
|
|
|
|
CuAssertIntEquals(tc, 14, config_get_int("integer", 0));
|
|
|
|
CuAssertDblEquals(tc, 1.5f, config_get_flt("float", 0), 0.01);
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2015-09-10 23:16:17 +02:00
|
|
|
}
|
|
|
|
|
2015-09-12 12:24:10 +02:00
|
|
|
static void test_prefixes(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"prefixes\": [ "
|
|
|
|
"\"snow\","
|
|
|
|
"\"sea\","
|
|
|
|
"\"dark\""
|
|
|
|
"]}";
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2015-09-12 12:24:10 +02:00
|
|
|
json_config(json);
|
2015-09-12 12:33:25 +02:00
|
|
|
CuAssertPtrNotNull(tc, race_prefixes);
|
|
|
|
CuAssertStrEquals(tc, "snow", race_prefixes[0]);
|
|
|
|
CuAssertStrEquals(tc, "dark", race_prefixes[2]);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, race_prefixes[3]);
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2015-09-12 12:24:10 +02:00
|
|
|
}
|
|
|
|
|
2015-09-12 17:06:47 +02:00
|
|
|
static void test_disable(CuTest * tc)
|
|
|
|
{
|
2015-09-12 17:37:29 +02:00
|
|
|
const char * data = "{\"disabled\": [ "
|
2015-09-12 17:43:31 +02:00
|
|
|
"\"alchemy\","
|
2015-09-12 17:06:47 +02:00
|
|
|
"\"pay\","
|
2018-09-09 21:01:10 +02:00
|
|
|
"\"attack\","
|
2015-09-12 17:37:29 +02:00
|
|
|
"\"module\""
|
2015-09-12 17:06:47 +02:00
|
|
|
"]}";
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2015-09-12 17:43:31 +02:00
|
|
|
CuAssertTrue(tc, skill_enabled(SK_ALCHEMY));
|
2015-09-12 17:06:47 +02:00
|
|
|
CuAssertTrue(tc, !keyword_disabled(K_BANNER));
|
|
|
|
CuAssertTrue(tc, !keyword_disabled(K_PAY));
|
2018-09-09 21:01:10 +02:00
|
|
|
CuAssertTrue(tc, !keyword_disabled(K_ATTACK));
|
2015-11-22 10:44:46 +01:00
|
|
|
CuAssertIntEquals(tc, 1, config_get_int("module.enabled", 1));
|
2015-09-12 17:06:47 +02:00
|
|
|
json_config(json);
|
2015-09-12 17:43:31 +02:00
|
|
|
CuAssertTrue(tc, !skill_enabled(SK_ALCHEMY));
|
2015-09-12 17:06:47 +02:00
|
|
|
CuAssertTrue(tc, !keyword_disabled(K_BANNER));
|
|
|
|
CuAssertTrue(tc, keyword_disabled(K_PAY));
|
2018-09-09 21:01:10 +02:00
|
|
|
CuAssertTrue(tc, keyword_disabled(K_ATTACK));
|
2015-11-22 10:44:46 +01:00
|
|
|
CuAssertIntEquals(tc, 0, config_get_int("module.enabled", 1));
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2015-09-12 17:06:47 +02:00
|
|
|
}
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
static void test_calendar(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"calendar\": { "
|
|
|
|
"\"weeks\" : [ \"one\", \"two\", \"three\" ],"
|
|
|
|
"\"months\" : ["
|
|
|
|
"{ \"storm\" : 99, \"season\" : 1 },"
|
|
|
|
"{ \"storm\" : 22, \"season\" : 2 }"
|
|
|
|
"]"
|
|
|
|
"}}";
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
|
|
|
test_setup();
|
|
|
|
json_config(json);
|
|
|
|
CuAssertPtrNotNull(tc, storms);
|
|
|
|
CuAssertIntEquals(tc, 2, months_per_year);
|
|
|
|
CuAssertIntEquals(tc, 3, weeks_per_month);
|
|
|
|
CuAssertIntEquals(tc, 99, storms[0]);
|
|
|
|
CuAssertIntEquals(tc, 22, storms[1]);
|
|
|
|
CuAssertPtrNotNull(tc, month_season);
|
|
|
|
CuAssertIntEquals(tc, 1, month_season[0]);
|
|
|
|
CuAssertIntEquals(tc, 2, month_season[1]);
|
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2017-05-07 18:10:18 +02:00
|
|
|
}
|
|
|
|
|
2014-06-08 07:17:48 +02:00
|
|
|
static void test_races(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"races\": { \"orc\" : { "
|
|
|
|
"\"damage\" : \"1d4\","
|
2017-02-03 10:57:32 +01:00
|
|
|
"\"magres\" : 100,"
|
2017-02-03 20:06:01 +01:00
|
|
|
"\"maxaura\" : 200,"
|
2014-06-08 07:17:48 +02:00
|
|
|
"\"regaura\" : 3.0,"
|
|
|
|
"\"speed\" : 4.0,"
|
|
|
|
"\"recruitcost\" : 1,"
|
|
|
|
"\"maintenance\" : 2,"
|
|
|
|
"\"weight\" : 3,"
|
|
|
|
"\"capacity\" : 4,"
|
2016-10-04 09:14:49 +02:00
|
|
|
"\"income\" : 30,"
|
2014-06-08 07:17:48 +02:00
|
|
|
"\"hp\" : 5,"
|
2014-06-17 07:43:40 +02:00
|
|
|
"\"ac\" : 6,"
|
2018-05-10 22:00:23 +02:00
|
|
|
"\"flags\" : [ \"player\", \"walk\", \"undead\" ]"
|
2014-06-08 07:17:48 +02:00
|
|
|
"}}}";
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
const struct race *rc;
|
2014-06-13 17:04:06 +02:00
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-08 07:17:48 +02:00
|
|
|
|
2014-06-13 17:04:06 +02:00
|
|
|
CuAssertPtrNotNull(tc, json);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, races);
|
2014-06-08 07:17:48 +02:00
|
|
|
json_config(json);
|
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, races);
|
|
|
|
rc = rc_find("orc");
|
|
|
|
CuAssertPtrNotNull(tc, rc);
|
2018-05-10 22:00:23 +02:00
|
|
|
CuAssertIntEquals(tc, RCF_PLAYABLE | RCF_WALK | RCF_UNDEAD, rc->flags);
|
2014-06-08 07:17:48 +02:00
|
|
|
CuAssertStrEquals(tc, "1d4", rc->def_damage);
|
2017-02-24 20:47:47 +01:00
|
|
|
CuAssertTrue(tc, frac_equal(frac_one, rc->magres));
|
2017-02-03 20:06:01 +01:00
|
|
|
CuAssertIntEquals(tc, 200, rc->maxaura);
|
|
|
|
CuAssertDblEquals(tc, 2.0, rc_maxaura(rc), 0.0);
|
2014-06-08 07:17:48 +02:00
|
|
|
CuAssertDblEquals(tc, 3.0, rc->regaura, 0.0);
|
|
|
|
CuAssertDblEquals(tc, 4.0, rc->speed, 0.0);
|
|
|
|
CuAssertIntEquals(tc, 1, rc->recruitcost);
|
|
|
|
CuAssertIntEquals(tc, 2, rc->maintenance);
|
|
|
|
CuAssertIntEquals(tc, 3, rc->weight);
|
|
|
|
CuAssertIntEquals(tc, 4, rc->capacity);
|
2016-10-04 09:14:49 +02:00
|
|
|
CuAssertIntEquals(tc, 30, rc->income);
|
2014-06-08 07:17:48 +02:00
|
|
|
CuAssertIntEquals(tc, 5, rc->hitpoints);
|
|
|
|
CuAssertIntEquals(tc, 6, rc->armor);
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-13 17:04:06 +02:00
|
|
|
}
|
|
|
|
|
2014-07-17 00:45:45 +02:00
|
|
|
static void test_findrace(CuTest *tc) {
|
|
|
|
const char * data = "{\"races\": { \"dwarf\": {} }, \"strings\": { \"de\" : { \"race::dwarf\" : \"Zwerg\" } } }";
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
2014-10-29 20:01:55 +01:00
|
|
|
struct locale *lang;
|
2014-07-17 00:45:45 +02:00
|
|
|
const race *rc;
|
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-07-17 00:45:45 +02:00
|
|
|
lang = get_or_create_locale("de");
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, (void *)findrace("Zwerg", lang));
|
2014-07-17 00:45:45 +02:00
|
|
|
|
|
|
|
json_config(json);
|
2014-10-29 20:01:55 +01:00
|
|
|
init_locale(lang);
|
2014-07-17 00:45:45 +02:00
|
|
|
rc = findrace("Zwerg", lang);
|
|
|
|
CuAssertPtrNotNull(tc, rc);
|
2014-08-24 21:49:55 +02:00
|
|
|
CuAssertStrEquals(tc, "dwarf", rc->_name);
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-07-17 00:45:45 +02:00
|
|
|
}
|
|
|
|
|
2014-06-25 07:54:10 +02:00
|
|
|
static void test_items(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"items\": { "
|
2014-06-25 17:00:09 +02:00
|
|
|
"\"axe\" : { \"weight\" : 2},"
|
|
|
|
"\"horse\" : { \"flags\" : [ \"animal\", \"big\" ], \"capacity\" : 20 }"
|
2014-06-25 07:54:10 +02:00
|
|
|
"}}";
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
2014-06-25 17:00:09 +02:00
|
|
|
const item_type * itype;
|
2014-06-25 07:54:10 +02:00
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-25 07:54:10 +02:00
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, it_find("axe"));
|
|
|
|
CuAssertPtrEquals(tc, NULL, rt_find("axe"));
|
|
|
|
CuAssertPtrEquals(tc, NULL, (void *)get_resourcetype(R_HORSE));
|
2014-06-25 07:54:10 +02:00
|
|
|
|
|
|
|
json_config(json);
|
2014-06-25 17:00:09 +02:00
|
|
|
|
|
|
|
itype = it_find("axe");
|
|
|
|
CuAssertPtrNotNull(tc, itype);
|
|
|
|
CuAssertIntEquals(tc, 2, itype->weight);
|
|
|
|
CuAssertIntEquals(tc, 0, itype->flags);
|
|
|
|
|
|
|
|
itype = it_find("horse");
|
|
|
|
CuAssertPtrNotNull(tc, itype);
|
|
|
|
CuAssertIntEquals(tc, 20, itype->capacity);
|
2015-01-30 20:37:14 +01:00
|
|
|
CuAssertIntEquals(tc, ITF_ANIMAL | ITF_BIG, itype->flags);
|
2014-06-25 17:00:09 +02:00
|
|
|
|
2014-06-25 07:54:10 +02:00
|
|
|
CuAssertPtrNotNull(tc, rt_find("axe"));
|
|
|
|
CuAssertPtrNotNull(tc, (void *)get_resourcetype(R_HORSE));
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-25 07:54:10 +02:00
|
|
|
}
|
|
|
|
|
2014-06-13 17:04:06 +02:00
|
|
|
static void test_ships(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"ships\": { \"boat\" : { "
|
2014-06-18 06:33:42 +02:00
|
|
|
"\"construction\" : { \"maxsize\" : 20, \"reqsize\" : 10, \"minskill\" : 1 },"
|
2015-04-18 11:41:50 +02:00
|
|
|
"\"coasts\" : [ \"plain\" ],"
|
|
|
|
"\"range\" : 8,"
|
|
|
|
"\"maxrange\" : 16"
|
2014-06-13 17:04:06 +02:00
|
|
|
"}}}";
|
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
2014-06-18 06:33:42 +02:00
|
|
|
const ship_type *st;
|
|
|
|
const terrain_type *ter;
|
2014-06-13 17:04:06 +02:00
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-13 17:04:06 +02:00
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, shiptypes);
|
2014-06-13 17:04:06 +02:00
|
|
|
json_config(json);
|
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, shiptypes);
|
|
|
|
st = st_find("boat");
|
|
|
|
CuAssertPtrNotNull(tc, st);
|
|
|
|
CuAssertPtrNotNull(tc, st->construction);
|
|
|
|
CuAssertIntEquals(tc, 10, st->construction->reqsize);
|
|
|
|
CuAssertIntEquals(tc, 20, st->construction->maxsize);
|
|
|
|
CuAssertIntEquals(tc, 1, st->construction->minskill);
|
2015-04-18 11:41:50 +02:00
|
|
|
CuAssertIntEquals(tc, 8, st->range);
|
|
|
|
CuAssertIntEquals(tc, 16, st->range_max);
|
2014-06-18 06:33:42 +02:00
|
|
|
|
|
|
|
ter = get_terrain("plain");
|
|
|
|
CuAssertPtrNotNull(tc, ter);
|
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, st->coasts);
|
|
|
|
CuAssertPtrEquals(tc, (void *)ter, (void *)st->coasts[0]);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, (void *)st->coasts[1]);
|
2014-06-18 06:33:42 +02:00
|
|
|
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-08 07:17:48 +02:00
|
|
|
}
|
|
|
|
|
2014-07-01 04:21:28 +02:00
|
|
|
static void test_castles(CuTest *tc) {
|
|
|
|
const char * data = "{\"buildings\": { \"castle\" : { "
|
2018-05-01 15:32:06 +02:00
|
|
|
"\"stages\" : ["
|
|
|
|
"{ \"construction\": { \"maxsize\" : 2 }, \"name\": \"site\" },"
|
|
|
|
"{ \"construction\": { \"maxsize\" : 8 } },"
|
|
|
|
"{ \"construction\": { \"maxsize\" : -1 } }"
|
2014-07-01 04:21:28 +02:00
|
|
|
"]}}}";
|
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
const building_type *bt;
|
2018-05-01 15:32:06 +02:00
|
|
|
const building_stage *stage;
|
|
|
|
const construction *con;
|
2014-07-01 04:21:28 +02:00
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-07-01 04:21:28 +02:00
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, buildingtypes);
|
2014-07-01 04:21:28 +02:00
|
|
|
json_config(json);
|
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, buildingtypes);
|
|
|
|
bt = bt_find("castle");
|
|
|
|
CuAssertPtrNotNull(tc, bt);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrNotNull(tc, stage = bt->stages);
|
|
|
|
CuAssertStrEquals(tc, "site", stage->name);
|
|
|
|
CuAssertPtrNotNull(tc, con = stage->construction);
|
|
|
|
CuAssertIntEquals(tc, 2, con->maxsize);
|
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, stage = stage->next);
|
|
|
|
CuAssertPtrEquals(tc, NULL, stage->name);
|
|
|
|
CuAssertPtrNotNull(tc, con = stage->construction);
|
|
|
|
CuAssertIntEquals(tc, 6, con->maxsize);
|
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, stage = stage->next);
|
|
|
|
CuAssertPtrNotNull(tc, con = stage->construction);
|
|
|
|
CuAssertIntEquals(tc, -1, con->maxsize);
|
|
|
|
|
|
|
|
CuAssertPtrEquals(tc, NULL, stage->next);
|
|
|
|
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-07-01 04:21:28 +02:00
|
|
|
}
|
|
|
|
|
2014-07-03 06:15:22 +02:00
|
|
|
static void test_spells(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"spells\": { \"fireball\" : { \"syntax\" : \"u+\" } } }";
|
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
const spell *sp;
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-07-03 06:15:22 +02:00
|
|
|
CuAssertPtrNotNull(tc, json);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, find_spell("fireball"));
|
2014-07-03 06:15:22 +02:00
|
|
|
|
|
|
|
json_config(json);
|
|
|
|
sp = find_spell("fireball");
|
|
|
|
CuAssertPtrNotNull(tc, sp);
|
|
|
|
CuAssertStrEquals(tc, "u+", sp->syntax);
|
|
|
|
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, find_spell("fireball"));
|
2014-07-03 06:15:22 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 07:50:06 +01:00
|
|
|
static const char * building_data = "{\"buildings\": { "
|
|
|
|
"\"house\" : { "
|
|
|
|
"\"maintenance\" : "
|
2016-10-01 18:34:38 +02:00
|
|
|
"{ \"type\" : \"iron\", \"amount\" : 1, \"flags\" : [ \"variable\" ] }"
|
2014-10-29 07:50:06 +01:00
|
|
|
","
|
|
|
|
"\"construction\" : {"
|
|
|
|
"\"maxsize\" : 20,"
|
|
|
|
"\"reqsize\" : 10,"
|
|
|
|
"\"minskill\" : 1,"
|
|
|
|
"\"materials\" : {"
|
|
|
|
"\"stone\" : 2,"
|
|
|
|
"\"iron\" : 1"
|
|
|
|
"}}},"
|
|
|
|
"\"shed\" : {"
|
|
|
|
"\"maintenance\" : ["
|
|
|
|
"{ \"type\" : \"iron\", \"amount\" : 1 },"
|
|
|
|
"{ \"type\" : \"stone\", \"amount\" : 2 }"
|
|
|
|
"]}"
|
|
|
|
"}}";
|
|
|
|
|
2014-06-14 02:36:05 +02:00
|
|
|
static void test_buildings(CuTest * tc)
|
|
|
|
{
|
2014-10-29 07:50:06 +01:00
|
|
|
cJSON *json = cJSON_Parse(building_data);
|
2014-06-14 02:36:05 +02:00
|
|
|
const building_type *bt;
|
2018-05-01 15:32:06 +02:00
|
|
|
const construction *con;
|
2014-06-14 02:36:05 +02:00
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-14 02:36:05 +02:00
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, buildingtypes);
|
2014-06-14 02:36:05 +02:00
|
|
|
json_config(json);
|
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, buildingtypes);
|
2014-07-05 06:48:17 +02:00
|
|
|
bt = bt_find("shed");
|
|
|
|
CuAssertPtrNotNull(tc, bt);
|
|
|
|
CuAssertPtrNotNull(tc, bt->maintenance);
|
|
|
|
CuAssertPtrEquals(tc, (void *)get_resourcetype(R_IRON), (void *)bt->maintenance[0].rtype);
|
|
|
|
CuAssertPtrEquals(tc, (void *)get_resourcetype(R_STONE), (void *)bt->maintenance[1].rtype);
|
|
|
|
CuAssertIntEquals(tc, 1, bt->maintenance[0].number);
|
|
|
|
CuAssertIntEquals(tc, 2, bt->maintenance[1].number);
|
|
|
|
CuAssertIntEquals(tc, 0, bt->maintenance[2].number);
|
|
|
|
|
2014-06-14 02:36:05 +02:00
|
|
|
bt = bt_find("house");
|
|
|
|
CuAssertPtrNotNull(tc, bt);
|
2014-07-05 06:48:17 +02:00
|
|
|
|
|
|
|
CuAssertPtrNotNull(tc, bt->maintenance);
|
|
|
|
CuAssertIntEquals(tc, 1, bt->maintenance[0].number);
|
|
|
|
CuAssertPtrEquals(tc, (void *)get_resourcetype(R_IRON), (void *)bt->maintenance[0].rtype);
|
2016-10-01 18:34:38 +02:00
|
|
|
CuAssertIntEquals(tc, MTF_VARIABLE, bt->maintenance[0].flags);
|
2014-07-05 06:48:17 +02:00
|
|
|
CuAssertIntEquals(tc, 0, bt->maintenance[1].number);
|
|
|
|
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrNotNull(tc, bt->stages);
|
|
|
|
CuAssertPtrEquals(tc, NULL, bt->stages->next);
|
|
|
|
CuAssertPtrNotNull(tc, bt->stages->construction);
|
|
|
|
CuAssertPtrNotNull(tc, con = bt->stages->construction);
|
|
|
|
CuAssertPtrNotNull(tc, con->materials);
|
|
|
|
CuAssertIntEquals(tc, 2, con->materials[0].number);
|
|
|
|
CuAssertPtrEquals(tc, (void *)get_resourcetype(R_STONE), (void *)con->materials[0].rtype);
|
|
|
|
CuAssertIntEquals(tc, 1, con->materials[1].number);
|
|
|
|
CuAssertPtrEquals(tc, (void *)get_resourcetype(R_IRON), (void *)con->materials[1].rtype);
|
|
|
|
CuAssertIntEquals(tc, 0, con->materials[2].number);
|
|
|
|
CuAssertIntEquals(tc, 10, con->reqsize);
|
|
|
|
CuAssertIntEquals(tc, 20, con->maxsize);
|
|
|
|
CuAssertIntEquals(tc, 1, con->minskill);
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-14 02:36:05 +02:00
|
|
|
}
|
|
|
|
|
2015-02-02 16:55:18 +01:00
|
|
|
static const char * building_defaults_data = "{\"buildings\": { "
|
|
|
|
"\"house\" : { }"
|
|
|
|
"}}";
|
|
|
|
|
|
|
|
static void test_buildings_default(CuTest * tc)
|
|
|
|
{
|
|
|
|
cJSON *json = cJSON_Parse(building_defaults_data);
|
|
|
|
const building_type *bt;
|
|
|
|
building_type clone;
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2015-02-02 16:55:18 +01:00
|
|
|
|
|
|
|
bt = bt_get_or_create("house");
|
|
|
|
clone = *bt;
|
|
|
|
|
|
|
|
CuAssertIntEquals(tc, 0, memcmp(bt, &clone, sizeof(building_type)));
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
|
|
|
json_config(json);
|
|
|
|
|
|
|
|
CuAssertPtrEquals(tc, (void *)bt, (void *)bt_find("house"));
|
|
|
|
CuAssertIntEquals(tc, 0, memcmp(bt, &clone, sizeof(building_type)));
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2015-02-02 16:55:18 +01:00
|
|
|
}
|
|
|
|
|
2015-02-03 17:13:30 +01:00
|
|
|
static const char * ship_defaults_data = "{\"ships\": { "
|
|
|
|
"\"hodor\" : { }"
|
|
|
|
"}}";
|
|
|
|
|
|
|
|
static void test_ships_default(CuTest * tc)
|
|
|
|
{
|
|
|
|
cJSON *json = cJSON_Parse(ship_defaults_data);
|
|
|
|
const ship_type *st;
|
|
|
|
ship_type clone;
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2015-02-03 17:13:30 +01:00
|
|
|
|
|
|
|
st = st_get_or_create("hodor");
|
|
|
|
clone = *st;
|
|
|
|
|
|
|
|
CuAssertIntEquals(tc, 0, memcmp(st, &clone, sizeof(ship_type)));
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
|
|
|
json_config(json);
|
|
|
|
|
|
|
|
CuAssertPtrEquals(tc, (void *)st, (void *)st_find("hodor"));
|
|
|
|
CuAssertIntEquals(tc, 0, memcmp(st, &clone, sizeof(ship_type)));
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2015-02-03 17:13:30 +01:00
|
|
|
}
|
|
|
|
|
2014-10-29 07:50:06 +01:00
|
|
|
static void test_configs(CuTest * tc)
|
|
|
|
{
|
2014-10-29 19:40:09 +01:00
|
|
|
const char * data = "{\"include\": [ \"test.json\" ] }";
|
2014-10-29 07:50:06 +01:00
|
|
|
FILE *F;
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-10-29 07:50:06 +01:00
|
|
|
|
2016-02-05 23:10:05 +01:00
|
|
|
F = fopen("test.json", "w");
|
2014-10-29 07:50:06 +01:00
|
|
|
fwrite(building_data, 1, strlen(building_data), F);
|
|
|
|
fclose(F);
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, buildingtypes);
|
2014-10-29 07:50:06 +01:00
|
|
|
json_config(json);
|
|
|
|
CuAssertPtrNotNull(tc, buildingtypes);
|
2017-01-10 18:40:01 +01:00
|
|
|
if (remove("test.json")!=0 && errno==ENOENT) {
|
2016-09-11 17:19:27 +02:00
|
|
|
errno = 0;
|
|
|
|
}
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-10-29 07:50:06 +01:00
|
|
|
}
|
|
|
|
|
2014-06-14 02:36:05 +02:00
|
|
|
static void test_terrains(CuTest * tc)
|
|
|
|
{
|
2015-09-11 12:12:53 +02:00
|
|
|
const char * data = "{\"terrains\": { \"plain\" : { "
|
|
|
|
"\"herbs\": [ \"h0\", \"h1\" ], "
|
|
|
|
"\"production\": { \"stone\": { \"chance\": 0.1, \"base\": \"1d4\", \"div\": \"1d5\", \"level\": \"1d6\" }, \"iron\": {} }, "
|
|
|
|
"\"size\": 4000, "
|
|
|
|
"\"road\": 50, "
|
|
|
|
"\"seed\": 3, "
|
2016-06-10 20:55:27 +02:00
|
|
|
"\"flags\" : [ \"forbidden\", \"arctic\", \"cavalry\", \"sea\", \"forest\", \"land\", \"fly\", \"swim\", \"walk\" ] } }}";
|
2014-06-17 07:19:19 +02:00
|
|
|
const terrain_type *ter;
|
2014-06-14 02:36:05 +02:00
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-14 02:36:05 +02:00
|
|
|
CuAssertPtrNotNull(tc, json);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, (void *)get_terrain("plain"));
|
2014-06-14 02:36:05 +02:00
|
|
|
|
|
|
|
json_config(json);
|
2014-06-17 07:19:19 +02:00
|
|
|
ter = get_terrain("plain");
|
|
|
|
CuAssertPtrNotNull(tc, ter);
|
2016-06-10 20:55:27 +02:00
|
|
|
CuAssertIntEquals(tc, ARCTIC_REGION | LAND_REGION | SEA_REGION | FOREST_REGION | CAVALRY_REGION | FORBIDDEN_REGION | FLY_INTO | WALK_INTO | SWIM_INTO , ter->flags);
|
2015-09-11 12:12:53 +02:00
|
|
|
CuAssertIntEquals(tc, 4000, ter->size);
|
|
|
|
CuAssertIntEquals(tc, 50, ter->max_road);
|
|
|
|
CuAssertIntEquals(tc, 3, ter->distribution);
|
|
|
|
CuAssertPtrNotNull(tc, ter->herbs);
|
|
|
|
CuAssertPtrEquals(tc, rt_get_or_create("h0"), ter->herbs[0]->rtype);
|
|
|
|
CuAssertPtrEquals(tc, rt_get_or_create("h1"), ter->herbs[1]->rtype);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, (void *)ter->herbs[2]);
|
2017-02-18 21:15:14 +01:00
|
|
|
CuAssertPtrNotNull(tc, ter->name); /* anything named "plain" uses plain_name() */
|
2015-09-11 12:12:53 +02:00
|
|
|
CuAssertPtrNotNull(tc, ter->production);
|
|
|
|
CuAssertPtrEquals(tc, rt_get_or_create("stone"), (resource_type *)ter->production[0].type);
|
2015-09-11 12:27:45 +02:00
|
|
|
CuAssertDblEquals(tc, 0.1, ter->production[0].chance, 0.01);
|
|
|
|
CuAssertStrEquals(tc, "1d4", ter->production[0].base);
|
|
|
|
CuAssertStrEquals(tc, "1d5", ter->production[0].divisor);
|
|
|
|
CuAssertStrEquals(tc, "1d6", ter->production[0].startlevel);
|
2015-09-11 12:12:53 +02:00
|
|
|
CuAssertPtrEquals(tc, rt_get_or_create("iron"), (resource_type *)ter->production[1].type);
|
2018-05-01 15:32:06 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, (void *)ter->production[2].type);
|
2014-06-14 02:36:05 +02:00
|
|
|
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-14 02:36:05 +02:00
|
|
|
}
|
|
|
|
|
2014-06-16 07:17:08 +02:00
|
|
|
static void test_directions(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"directions\": { \"de\" : { \"east\" : \"osten\", \"northwest\" : [ \"nw\", \"nordwest\" ], \"pause\" : \"pause\" }}}";
|
|
|
|
const struct locale * lang;
|
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-16 07:17:08 +02:00
|
|
|
lang = get_or_create_locale("de");
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
|
|
|
CuAssertIntEquals(tc, NODIRECTION, get_direction("ost", lang));
|
|
|
|
|
|
|
|
json_config(json);
|
|
|
|
CuAssertIntEquals(tc, D_EAST, get_direction("ost", lang));
|
|
|
|
CuAssertIntEquals(tc, D_NORTHWEST, get_direction("nw", lang));
|
|
|
|
CuAssertIntEquals(tc, D_NORTHWEST, get_direction("nordwest", lang));
|
|
|
|
CuAssertIntEquals(tc, D_PAUSE, get_direction("pause", lang));
|
|
|
|
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-16 07:17:08 +02:00
|
|
|
}
|
|
|
|
|
2014-06-21 17:53:14 +02:00
|
|
|
static void test_skills(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"skills\": { \"de\" : { \"alchemy\" : \"ALCHEMIE\", \"crossbow\" : [ \"ARMBRUST\", \"KREUZBOGEN\" ] }}}";
|
|
|
|
const struct locale * lang;
|
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-21 17:53:14 +02:00
|
|
|
lang = get_or_create_locale("de");
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
|
|
|
CuAssertIntEquals(tc, NOSKILL, get_skill("potato", lang));
|
|
|
|
|
|
|
|
json_config(json);
|
|
|
|
CuAssertIntEquals(tc, NOSKILL, get_skill("potato", lang));
|
|
|
|
CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("armbrust", lang));
|
|
|
|
CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("kreuz", lang));
|
|
|
|
CuAssertIntEquals(tc, SK_ALCHEMY, get_skill("alchemie", lang));
|
|
|
|
|
2015-01-08 20:55:29 +01:00
|
|
|
CuAssertStrEquals(tc, "ALCHEMIE", LOC(lang, "skill::alchemy"));
|
|
|
|
CuAssertStrEquals(tc, "ARMBRUST", LOC(lang, "skill::crossbow"));
|
2014-06-21 17:53:14 +02:00
|
|
|
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-21 17:53:14 +02:00
|
|
|
}
|
|
|
|
|
2014-06-16 20:30:23 +02:00
|
|
|
static void test_keywords(CuTest * tc)
|
|
|
|
{
|
2014-06-17 05:41:08 +02:00
|
|
|
const char * data = "{\"keywords\": { \"de\" : { \"move\" : \"NACH\", \"study\" : [ \"LERNEN\", \"STUDIEREN\" ] }}}";
|
2014-06-16 20:30:23 +02:00
|
|
|
const struct locale * lang;
|
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-16 20:30:23 +02:00
|
|
|
lang = get_or_create_locale("de");
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
|
|
|
CuAssertIntEquals(tc, NOKEYWORD, get_keyword("potato", lang));
|
|
|
|
|
|
|
|
json_config(json);
|
2014-06-17 05:41:08 +02:00
|
|
|
CuAssertIntEquals(tc, K_STUDY, get_keyword("studiere", lang));
|
2014-06-16 20:30:23 +02:00
|
|
|
CuAssertIntEquals(tc, K_STUDY, get_keyword("lerne", lang));
|
|
|
|
CuAssertIntEquals(tc, K_MOVE, get_keyword("nach", lang));
|
|
|
|
|
2015-01-08 20:55:29 +01:00
|
|
|
CuAssertStrEquals(tc, "LERNEN", LOC(lang, "keyword::study"));
|
|
|
|
CuAssertStrEquals(tc, "NACH", LOC(lang, "keyword::move"));
|
2014-06-17 05:41:08 +02:00
|
|
|
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-16 20:30:23 +02:00
|
|
|
}
|
|
|
|
|
2014-06-28 19:37:40 +02:00
|
|
|
static void test_strings(CuTest * tc)
|
|
|
|
{
|
|
|
|
const char * data = "{\"strings\": { \"de\" : { \"move\" : \"NACH\", \"study\" : \"LERNEN\" }}}";
|
|
|
|
const struct locale * lang;
|
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
|
|
|
|
2017-05-07 18:10:18 +02:00
|
|
|
test_setup();
|
2014-06-28 19:37:40 +02:00
|
|
|
lang = get_or_create_locale("de");
|
|
|
|
CuAssertPtrNotNull(tc, lang);
|
2015-01-08 20:55:29 +01:00
|
|
|
CuAssertPtrEquals(tc, NULL, (void *)LOC(lang, "move"));
|
2014-06-28 19:37:40 +02:00
|
|
|
json_config(json);
|
2015-01-08 20:55:29 +01:00
|
|
|
CuAssertStrEquals(tc, "NACH", LOC(lang, "move"));
|
|
|
|
CuAssertStrEquals(tc, "LERNEN", LOC(lang, "study"));
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-06-28 19:37:40 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 19:40:09 +01:00
|
|
|
static void test_infinitive_from_config(CuTest *tc) {
|
|
|
|
char buffer[32];
|
|
|
|
struct locale *lang;
|
|
|
|
struct order *ord;
|
|
|
|
const char * data = "{\"keywords\": { \"de\" : { \"study\" : [ \"LERNE\", \"LERNEN\" ] }}}";
|
|
|
|
|
|
|
|
cJSON *json = cJSON_Parse(data);
|
|
|
|
CuAssertPtrNotNull(tc, json);
|
2017-02-12 06:06:33 +01:00
|
|
|
test_setup();
|
|
|
|
lang = get_or_create_locale("de");
|
2014-10-29 19:40:09 +01:00
|
|
|
json_config(json);
|
|
|
|
|
|
|
|
CuAssertIntEquals(tc, K_STUDY, get_keyword("LERN", lang));
|
|
|
|
CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNE", lang));
|
|
|
|
CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNEN", lang));
|
|
|
|
|
|
|
|
ord = create_order(K_STUDY, lang, "");
|
2017-10-08 17:07:42 +02:00
|
|
|
CuAssertStrEquals(tc, "LERNE", get_command(ord, lang, buffer, sizeof(buffer)));
|
2015-10-13 15:45:38 +02:00
|
|
|
free_order(ord);
|
2015-10-13 21:21:31 +02:00
|
|
|
cJSON_Delete(json);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2014-10-29 19:40:09 +01:00
|
|
|
}
|
|
|
|
|
2014-06-08 07:17:48 +02:00
|
|
|
CuSuite *get_jsonconf_suite(void)
|
|
|
|
{
|
|
|
|
CuSuite *suite = CuSuiteNew();
|
2014-06-16 20:30:23 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_keywords);
|
2014-06-21 17:53:14 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_skills);
|
2014-06-16 07:17:08 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_directions);
|
2014-06-25 07:54:10 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_items);
|
2015-02-03 17:13:30 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_ships_default);
|
2014-06-13 17:04:06 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_ships);
|
2014-06-14 02:36:05 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_buildings);
|
2015-02-02 16:55:18 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_buildings_default);
|
2014-10-29 07:50:06 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_configs);
|
2014-07-01 04:21:28 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_castles);
|
2014-06-14 02:36:05 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_terrains);
|
2014-06-08 07:17:48 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_races);
|
2014-07-17 00:45:45 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_findrace);
|
2014-06-28 19:37:40 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_strings);
|
2014-07-03 06:15:22 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_spells);
|
2014-06-08 07:17:48 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_flags);
|
2015-09-10 23:16:17 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_settings);
|
2015-09-12 12:24:10 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_prefixes);
|
2015-09-12 17:06:47 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_disable);
|
2014-10-29 19:40:09 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_infinitive_from_config);
|
2017-05-07 18:10:18 +02:00
|
|
|
SUITE_ADD_TEST(suite, test_calendar);
|
2014-06-08 07:17:48 +02:00
|
|
|
return suite;
|
|
|
|
}
|
2014-06-13 17:04:06 +02:00
|
|
|
|