forked from github/server
Repair MAKE, which broke when I changed MAKE TEMP.
You can now also write MAKETEMP as one word, and we treat it that way. Added unit test coverage for MAKE order parsing.
This commit is contained in:
parent
aed64a70fb
commit
a84e628522
|
@ -1989,8 +1989,8 @@
|
|||
<string name="STUFE">
|
||||
<text locale="de">STUFE</text>
|
||||
</string>
|
||||
<string name="TEMPORAERE">
|
||||
<text locale="de">TEMPORÄRE</text>
|
||||
<string name="TEMP">
|
||||
<text locale="de">TEMP</text>
|
||||
</string>
|
||||
<string name="TRAENKE">
|
||||
<text locale="de">TRÄNKE</text>
|
||||
|
|
|
@ -1274,7 +1274,7 @@
|
|||
<string name="STUFE">
|
||||
<text locale="en">LEVEL</text>
|
||||
</string>
|
||||
<string name="TEMPORAERE">
|
||||
<string name="TEMP">
|
||||
<text locale="en">TEMPORARY</text>
|
||||
</string>
|
||||
<string name="TRAENKE">
|
||||
|
|
|
@ -346,7 +346,7 @@ const char *parameters[MAXPARAMS] = {
|
|||
"SCHIFF",
|
||||
"SILBER",
|
||||
"STRASSEN",
|
||||
"TEMPORAERE",
|
||||
"TEMP",
|
||||
"FLIEHE",
|
||||
"GEBAEUDE",
|
||||
"GIB", /* Für HELFE */
|
||||
|
@ -1791,7 +1791,7 @@ void init_options_translation(const struct locale * lang) {
|
|||
}
|
||||
}
|
||||
|
||||
static void init_locale(const struct locale *lang)
|
||||
void init_locale(const struct locale *lang)
|
||||
{
|
||||
variant var;
|
||||
int i;
|
||||
|
|
|
@ -177,6 +177,7 @@ extern "C" {
|
|||
|
||||
int distribute(int old, int new_value, int n);
|
||||
void init_locales(void);
|
||||
void init_locale(const struct locale *lang);
|
||||
|
||||
int newunitid(void);
|
||||
int forbiddenid(int id);
|
||||
|
|
|
@ -364,9 +364,11 @@ order *parse_order(const char *s, const struct locale * lang)
|
|||
sptr = s;
|
||||
kwd = get_keyword(parse_token(&sptr), lang);
|
||||
if (kwd == K_MAKE) {
|
||||
const char *s = parse_token(&sptr);
|
||||
const char *s, *sp = sptr;
|
||||
s = parse_token(&sp);
|
||||
if (isparam(s, lang, P_TEMP)) {
|
||||
kwd = K_MAKETEMP;
|
||||
sptr = sp;
|
||||
}
|
||||
}
|
||||
if (kwd != NOKEYWORD) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <config.h>
|
||||
#include <kernel/config.h>
|
||||
#include "order.h"
|
||||
|
||||
#include <util/parser.h>
|
||||
|
@ -39,10 +40,71 @@ static void test_parse_order(CuTest *tc) {
|
|||
free_order(ord);
|
||||
}
|
||||
|
||||
static void test_parse_make(CuTest *tc) {
|
||||
char cmd[32];
|
||||
order *ord;
|
||||
struct locale * lang = get_or_create_locale("en");
|
||||
|
||||
locale_setstring(lang, keyword(K_MAKE), "MAKE");
|
||||
locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
|
||||
init_locale(lang);
|
||||
ord = parse_order("M hurrdurr", lang);
|
||||
CuAssertPtrNotNull(tc, ord);
|
||||
CuAssertIntEquals(tc, K_MAKE, getkeyword(ord));
|
||||
init_tokens(ord);
|
||||
CuAssertStrEquals(tc, "MAKE hurrdurr", get_command(ord, cmd, sizeof(cmd)));
|
||||
CuAssertStrEquals(tc, "MAKE", getstrtoken());
|
||||
CuAssertStrEquals(tc, "hurrdurr", getstrtoken());
|
||||
free_order(ord);
|
||||
}
|
||||
|
||||
static void test_parse_make_temp(CuTest *tc) {
|
||||
char cmd[32];
|
||||
order *ord;
|
||||
struct locale * lang = get_or_create_locale("en");
|
||||
|
||||
locale_setstring(lang, keyword(K_MAKE), "MAKE");
|
||||
locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
|
||||
locale_setstring(lang, "TEMP", "TEMP");
|
||||
init_locale(lang);
|
||||
|
||||
ord = parse_order("M T herp", lang);
|
||||
CuAssertPtrNotNull(tc, ord);
|
||||
CuAssertIntEquals(tc, K_MAKETEMP, getkeyword(ord));
|
||||
init_tokens(ord);
|
||||
CuAssertStrEquals(tc, "MAKETEMP herp", get_command(ord, cmd, sizeof(cmd)));
|
||||
CuAssertStrEquals(tc, "MAKETEMP", getstrtoken());
|
||||
CuAssertStrEquals(tc, "herp", getstrtoken());
|
||||
free_order(ord);
|
||||
}
|
||||
|
||||
static void test_parse_maketemp(CuTest *tc) {
|
||||
char cmd[32];
|
||||
order *ord;
|
||||
struct locale * lang = get_or_create_locale("en");
|
||||
|
||||
locale_setstring(lang, keyword(K_MAKE), "MAKE");
|
||||
locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
|
||||
locale_setstring(lang, "TEMP", "TEMP");
|
||||
init_locale(lang);
|
||||
|
||||
ord = parse_order("MAKET herp", lang);
|
||||
CuAssertPtrNotNull(tc, ord);
|
||||
CuAssertIntEquals(tc, K_MAKETEMP, getkeyword(ord));
|
||||
init_tokens(ord);
|
||||
CuAssertStrEquals(tc, "MAKETEMP herp", get_command(ord, cmd, sizeof(cmd)));
|
||||
CuAssertStrEquals(tc, "MAKETEMP", getstrtoken());
|
||||
CuAssertStrEquals(tc, "herp", getstrtoken());
|
||||
free_order(ord);
|
||||
}
|
||||
|
||||
CuSuite *get_order_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_create_order);
|
||||
SUITE_ADD_TEST(suite, test_parse_order);
|
||||
SUITE_ADD_TEST(suite, test_parse_make);
|
||||
SUITE_ADD_TEST(suite, test_parse_make_temp);
|
||||
SUITE_ADD_TEST(suite, test_parse_maketemp);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ typedef struct locale_str {
|
|||
} locale_str;
|
||||
|
||||
typedef struct locale {
|
||||
const char *name;
|
||||
unsigned int index;
|
||||
struct locale *next;
|
||||
unsigned int hashkey;
|
||||
const char *name;
|
||||
struct locale_str *strings[SMAXHASH];
|
||||
struct locale *fallback;
|
||||
} locale;
|
||||
|
|
Loading…
Reference in New Issue