failing test for bug 2427: create_order(K_STUDY, ...)

This commit is contained in:
Enno Rehling 2018-03-16 19:52:54 +01:00
parent bf21f24f98
commit db5d9e069e
2 changed files with 63 additions and 1 deletions

View File

@ -3,10 +3,14 @@
#include "order.h"
#include <kernel/skills.h>
#include <kernel/unit.h>
#include <util/parser.h>
#include <util/language.h>
#include <stream.h>
#include <memstream.h>
#include <tests.h>
#include <CuTest.h>
#include <stdlib.h>
@ -331,11 +335,69 @@ static void test_study_orders(CuTest *tc) {
test_teardown();
}
static void test_stream_order(CuTest *tc) {
char token[32];
stream out;
unit *u;
struct locale *lang;
test_setup();
lang = get_or_create_locale("de");
locale_setstring(lang, mkname("skill", skillnames[SK_ALCHEMY]), "Alchemie");
locale_setstring(lang, "keyword::study", "LERNE");
init_keywords(lang);
init_skills(lang);
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u->thisorder = create_order(K_STUDY, lang, "ALCH");
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
CuAssertStrEquals(tc, skillname(SK_ALCHEMY, lang), gettoken(token, sizeof(token)));
mstream_init(&out);
stream_order(&out, u->thisorder, lang, true);
swrite("\n", 1, 1, &out);
out.api->rewind(out.handle);
out.api->readln(out.handle, token, sizeof(token));
CuAssertStrEquals(tc, "LERNE Alchemie", token);
mstream_done(&out);
test_teardown();
}
static void test_stream_order_quoted(CuTest *tc) {
char token[32];
stream out;
unit *u;
struct locale *lang;
test_setup();
lang = get_or_create_locale("de");
locale_setstring(lang, mkname("skill", skillnames[SK_WEAPONLESS]), "Waffenloser Kampf");
locale_setstring(lang, "keyword::study", "LERNE");
init_keywords(lang);
init_skills(lang);
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
u->thisorder = create_order(K_STUDY, lang, "Waffenloser~Kampf");
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
CuAssertStrEquals(tc, skillname(SK_WEAPONLESS, lang), gettoken(token, sizeof(token)));
mstream_init(&out);
stream_order(&out, u->thisorder, lang, true);
swrite("\n", 1, 1, &out);
out.api->rewind(out.handle);
out.api->readln(out.handle, token, sizeof(token));
CuAssertStrEquals(tc, "LERNE 'Waffenloser Kampf'", token);
mstream_done(&out);
test_teardown();
}
CuSuite *get_order_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_create_order);
SUITE_ADD_TEST(suite, test_study_orders);
SUITE_ADD_TEST(suite, test_stream_order);
SUITE_ADD_TEST(suite, test_stream_order_quoted);
SUITE_ADD_TEST(suite, test_parse_order);
SUITE_ADD_TEST(suite, test_parse_make);
SUITE_ADD_TEST(suite, test_parse_make_temp);

@ -1 +1 @@
Subproject commit d807ef5ce64b3425b31fb440e0b93a4d233f517a
Subproject commit 5623ee6527e97af20c7d8efc03800b6fe1579744