server/src/kernel/order.test.c

601 lines
20 KiB
C
Raw Normal View History

#include <platform.h>
#include <kernel/config.h>
#include "order.h"
2017-10-09 20:33:47 +02:00
#include <kernel/skills.h>
#include <kernel/unit.h>
2017-10-09 20:33:47 +02:00
2018-09-29 19:32:39 +02:00
#include "util/param.h"
#include <util/parser.h>
#include <util/language.h>
#include <stream.h>
#include <memstream.h>
#include <tests.h>
#include <CuTest.h>
#include <stdlib.h>
#include <string.h>
static void test_create_order(CuTest *tc) {
char cmd[32];
order *ord;
struct locale * lang;
test_setup();
lang = test_create_locale();
ord = create_order(K_MOVE, lang, "NORTH");
CuAssertPtrNotNull(tc, ord);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "move NORTH", get_command(ord, lang, cmd, sizeof(cmd)));
2017-10-09 20:33:47 +02:00
CuAssertIntEquals(tc, K_MOVE, init_order_depr(ord));
CuAssertStrEquals(tc, "NORTH", getstrtoken());
free_order(ord);
test_teardown();
}
static void test_parse_order(CuTest *tc) {
char cmd[32];
order *ord;
struct locale * lang;
test_setup();
lang = test_create_locale();
ord = parse_order("MOVE NORTH", lang);
CuAssertPtrNotNull(tc, ord);
2017-09-30 19:22:24 +02:00
CuAssertIntEquals(tc, K_MOVE, ord->command);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "move NORTH", get_command(ord, lang, cmd, sizeof(cmd)));
2017-10-09 20:33:47 +02:00
CuAssertIntEquals(tc, K_MOVE, init_order_depr(ord));
CuAssertStrEquals(tc, "NORTH", getstrtoken());
free_order(ord);
ord = parse_order("!MOVE NORTH", lang);
CuAssertPtrNotNull(tc, ord);
CuAssertTrue(tc, ord->id > 0);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
2017-09-30 19:22:24 +02:00
CuAssertIntEquals(tc, K_MOVE | CMD_QUIET, ord->command);
free_order(ord);
ord = parse_order("@MOVE NORTH", lang);
CuAssertPtrNotNull(tc, ord);
CuAssertTrue(tc, ord->id > 0);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
2017-09-30 19:22:24 +02:00
CuAssertIntEquals(tc, K_MOVE | CMD_PERSIST, ord->command);
free_order(ord);
2017-09-30 19:22:24 +02:00
ord = parse_order("!@MOVE NORTH", lang);
CuAssertPtrNotNull(tc, ord);
CuAssertTrue(tc, ord->id > 0);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
2017-09-30 19:22:24 +02:00
CuAssertIntEquals(tc, K_MOVE | CMD_PERSIST | CMD_QUIET, ord->command);
free_order(ord);
2017-09-30 19:22:24 +02:00
ord = parse_order("@!MOVE NORTH", lang);
CuAssertPtrNotNull(tc, ord);
CuAssertTrue(tc, ord->id > 0);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
2017-09-30 19:22:24 +02:00
CuAssertIntEquals(tc, K_MOVE | CMD_PERSIST | CMD_QUIET, ord->command);
free_order(ord);
ord = parse_order(" !@MOVE NORTH", lang);
CuAssertPtrNotNull(tc, ord);
CuAssertTrue(tc, ord->id > 0);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
2017-09-30 19:22:24 +02:00
CuAssertIntEquals(tc, K_MOVE | CMD_PERSIST | CMD_QUIET, ord->command);
free_order(ord);
test_teardown();
}
static void test_parse_make(CuTest *tc) {
char cmd[32];
order *ord;
struct locale * lang;
test_setup();
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));
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "MAKE hurrdurr", get_command(ord, lang, cmd, sizeof(cmd)));
2017-10-09 20:33:47 +02:00
CuAssertIntEquals(tc, K_MAKE, init_order_depr(ord));
CuAssertStrEquals(tc, "hurrdurr", getstrtoken());
free_order(ord);
test_teardown();
}
static void test_parse_autostudy(CuTest *tc) {
char cmd[32];
order *ord;
struct locale * lang;
test_setup();
lang = get_or_create_locale("en");
locale_setstring(lang, mkname("skill", skillnames[SK_ENTERTAINMENT]), "Entertainment");
locale_setstring(lang, mkname("skill", skillnames[SK_MAGIC]), "Magic");
locale_setstring(lang, mkname("skill", skillnames[SK_TACTICS]), "Tactics");
locale_setstring(lang, keyword(K_STUDY), "STUDY");
locale_setstring(lang, keyword(K_AUTOSTUDY), "AUTOSTUDY");
locale_setstring(lang, parameters[P_AUTO], "AUTO");
init_locale(lang);
ord = parse_order("STUDY AUTO Entertainment", lang);
CuAssertPtrNotNull(tc, ord);
CuAssertIntEquals(tc, K_AUTOSTUDY, getkeyword(ord));
CuAssertStrEquals(tc, "AUTOSTUDY Entertainment", get_command(ord, lang, cmd, sizeof(cmd)));
CuAssertIntEquals(tc, K_AUTOSTUDY, init_order(ord, lang));
CuAssertStrEquals(tc, "Entertainment", getstrtoken());
free_order(ord);
ord = parse_order("STUDY AUTO Magic", lang);
CuAssertIntEquals(tc, K_STUDY, getkeyword(ord));
CuAssertStrEquals(tc, "STUDY Magic", get_command(ord, lang, cmd, sizeof(cmd)));
free_order(ord);
ord = parse_order("STUDY AUTO Tactics", lang);
CuAssertIntEquals(tc, K_STUDY, getkeyword(ord));
CuAssertStrEquals(tc, "STUDY Tactics", get_command(ord, lang, cmd, sizeof(cmd)));
free_order(ord);
test_teardown();
}
static void test_parse_make_temp(CuTest *tc) {
char cmd[32];
order *ord;
struct locale * lang;
test_setup();
lang = get_or_create_locale("en");
locale_setstring(lang, keyword(K_MAKE), "MAKE");
locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
locale_setstring(lang, parameters[P_TEMP], "TEMP");
init_locale(lang);
ord = parse_order("M T herp", lang);
CuAssertPtrNotNull(tc, ord);
CuAssertIntEquals(tc, K_MAKETEMP, getkeyword(ord));
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "MAKETEMP herp", get_command(ord, lang, cmd, sizeof(cmd)));
CuAssertIntEquals(tc, K_MAKETEMP, init_order(ord, lang));
CuAssertStrEquals(tc, "herp", getstrtoken());
free_order(ord);
test_teardown();
}
static void test_parse_maketemp(CuTest *tc) {
char cmd[32];
order *ord;
2015-10-14 20:48:01 +02:00
struct locale * lang;
test_setup();
2015-10-14 20:48:01 +02:00
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);
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "MAKETEMP herp", get_command(ord, lang, cmd, sizeof(cmd)));
CuAssertIntEquals(tc, K_MAKETEMP, getkeyword(ord));
CuAssertIntEquals(tc, K_MAKETEMP, init_order(ord, lang));
CuAssertStrEquals(tc, "herp", getstrtoken());
free_order(ord);
test_teardown();
}
static void test_init_order(CuTest *tc) {
order *ord;
2015-10-14 20:48:01 +02:00
struct locale * lang;
test_setup();
2015-10-14 20:48:01 +02:00
lang = get_or_create_locale("en");
ord = create_order(K_MAKETEMP, lang, "hurr durr");
CuAssertIntEquals(tc, K_MAKETEMP, init_order(ord, lang));
CuAssertStrEquals(tc, "hurr", getstrtoken());
CuAssertStrEquals(tc, "durr", getstrtoken());
free_order(ord);
test_teardown();
}
static void test_getstrtoken(CuTest *tc) {
2014-12-31 01:00:10 +01:00
init_tokens_str("hurr \"durr\" \"\" \'\'");
CuAssertStrEquals(tc, "hurr", getstrtoken());
CuAssertStrEquals(tc, "durr", getstrtoken());
CuAssertStrEquals(tc, "", getstrtoken());
CuAssertStrEquals(tc, "", getstrtoken());
CuAssertStrEquals(tc, 0, getstrtoken());
init_tokens_str(0);
CuAssertStrEquals(tc, 0, getstrtoken());
}
static void test_skip_token(CuTest *tc) {
2014-12-31 01:00:10 +01:00
init_tokens_str("hurr \"durr\"");
skip_token();
CuAssertStrEquals(tc, "durr", getstrtoken());
CuAssertStrEquals(tc, 0, getstrtoken());
}
static void test_replace_order(CuTest *tc) {
order *orders = 0, *orig, *repl;
2015-10-14 20:49:30 +02:00
struct locale * lang;
test_setup();
lang = test_create_locale();
orig = create_order(K_MAKE, lang, NULL);
repl = create_order(K_ALLY, lang, NULL);
replace_order(&orders, orig, repl);
2018-10-14 11:48:21 +02:00
CuAssertPtrEquals(tc, NULL, orders);
orders = orig;
replace_order(&orders, orig, repl);
CuAssertPtrNotNull(tc, orders);
2018-10-14 11:48:21 +02:00
CuAssertPtrEquals(tc, NULL, orders->next);
CuAssertIntEquals(tc, getkeyword(repl), getkeyword(orders));
free_order(orders);
free_order(repl);
test_teardown();
}
static void test_get_command(CuTest *tc) {
struct locale * lang;
order *ord;
char buf[64];
test_setup();
lang = test_create_locale();
ord = create_order(K_MAKE, lang, "iron");
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "make iron", get_command(ord, lang, buf, sizeof(buf)));
2017-09-30 19:22:24 +02:00
ord->command |= CMD_QUIET;
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "!make iron", get_command(ord, lang, buf, sizeof(buf)));
2017-09-30 19:22:24 +02:00
ord->command |= CMD_PERSIST;
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "!@make iron", get_command(ord, lang, buf, sizeof(buf)));
2017-09-30 19:22:24 +02:00
ord->command = K_MAKE | CMD_PERSIST;
2017-10-08 17:07:42 +02:00
CuAssertStrEquals(tc, "@make iron", get_command(ord, lang, buf, sizeof(buf)));
free_order(ord);
test_teardown();
}
2017-09-30 19:35:40 +02:00
static void test_is_persistent(CuTest *tc) {
order *ord;
struct locale *lang;
test_setup();
lang = test_create_locale();
2017-09-30 19:44:39 +02:00
ord = parse_order("@invalid", lang);
CuAssertPtrEquals(tc, NULL, ord);
free_order(ord);
2017-09-30 19:44:39 +02:00
ord = parse_order("give", lang);
CuAssertIntEquals(tc, K_GIVE, ord->command);
CuAssertTrue(tc, !is_persistent(ord));
free_order(ord);
ord = parse_order("@give", lang);
CuAssertTrue(tc, !is_repeated(K_GIVE));
CuAssertIntEquals(tc, K_GIVE | CMD_PERSIST, ord->command);
CuAssertTrue(tc, is_persistent(ord));
free_order(ord);
ord = parse_order("make", lang);
CuAssertTrue(tc, is_repeated(K_MAKE));
CuAssertIntEquals(tc, K_MAKE , ord->command);
CuAssertTrue(tc, is_persistent(ord));
free_order(ord);
2017-09-30 19:35:40 +02:00
ord = parse_order("@move", lang);
CuAssertIntEquals(tc, K_MOVE | CMD_PERSIST, ord->command);
CuAssertTrue(tc, !is_persistent(ord));
free_order(ord);
2017-09-30 19:44:39 +02:00
ord = parse_order("// comment", lang);
CuAssertTrue(tc, is_persistent(ord));
CuAssertIntEquals(tc, K_KOMMENTAR, ord->command);
free_order(ord);
test_teardown();
2017-09-30 19:44:39 +02:00
}
static void test_is_silent(CuTest *tc) {
order *ord;
struct locale *lang;
test_setup();
lang = test_create_locale();
ord = parse_order("make", lang);
CuAssertIntEquals(tc, K_MAKE, ord->command);
CuAssertTrue(tc, !is_silent(ord));
free_order(ord);
ord = parse_order("!make", lang);
CuAssertIntEquals(tc, K_MAKE | CMD_QUIET, ord->command);
CuAssertTrue(tc, is_silent(ord));
free_order(ord);
2017-09-30 19:35:40 +02:00
ord = parse_order("@invalid", lang);
CuAssertPtrEquals(tc, NULL, ord);
free_order(ord);
2017-09-30 19:35:40 +02:00
ord = parse_order("// comment", lang);
CuAssertTrue(tc, is_persistent(ord));
CuAssertIntEquals(tc, K_KOMMENTAR, ord->command);
free_order(ord);
test_teardown();
2017-09-30 19:35:40 +02:00
}
2017-10-09 20:33:47 +02:00
static void test_study_orders(CuTest *tc) {
order *ord;
struct locale *lang;
const char *s;
char token[16];
test_setup();
lang = test_create_locale();
ord = create_order(K_STUDY, lang, skillname(SK_CROSSBOW, lang));
CuAssertIntEquals(tc, K_STUDY, getkeyword(ord));
CuAssertIntEquals(tc, K_STUDY, init_order(ord, lang));
s = gettoken(token, sizeof(token));
CuAssertStrEquals(tc, skillname(SK_CROSSBOW, lang), s);
CuAssertPtrEquals(tc, NULL, (void *)getstrtoken());
free_order(ord);
ord = create_order(K_STUDY, lang, skillname(SK_MAGIC, lang));
CuAssertIntEquals(tc, K_STUDY, getkeyword(ord));
CuAssertIntEquals(tc, K_STUDY, init_order(ord, lang));
s = gettoken(token, sizeof(token));
CuAssertStrEquals(tc, skillname(SK_MAGIC, lang), s);
CuAssertPtrEquals(tc, NULL, (void *)getstrtoken());
free_order(ord);
ord = create_order(K_STUDY, lang, "%s 100", skillname(SK_MAGIC, lang));
CuAssertIntEquals(tc, K_STUDY, getkeyword(ord));
CuAssertIntEquals(tc, K_STUDY, init_order(ord, lang));
s = gettoken(token, sizeof(token));
CuAssertStrEquals(tc, skillname(SK_MAGIC, lang), s);
CuAssertIntEquals(tc, 100, getint());
free_order(ord);
test_teardown();
2017-10-09 20:33:47 +02:00
}
static void test_study_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)));
CuAssertStrEquals(tc, "LERNE Alchemie", get_command(u->thisorder, lang, 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();
}
2018-03-17 12:55:26 +01:00
static void test_study_order_unknown(CuTest *tc) {
char token[32];
stream out;
unit *u;
struct locale *lang;
test_setup();
lang = get_or_create_locale("de");
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, "Schiffsbau");
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
CuAssertStrEquals(tc, "Schiffsbau", gettoken(token, sizeof(token)));
CuAssertStrEquals(tc, "LERNE Schiffsbau", get_command(u->thisorder, lang, 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 Schiffsbau", token);
mstream_done(&out);
test_teardown();
}
static void test_study_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)));
CuAssertStrEquals(tc, "LERNE 'Waffenloser Kampf'", get_command(u->thisorder, lang, 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();
}
2018-03-17 12:55:26 +01:00
static void test_study_order_unknown_tilde(CuTest *tc) {
char token[32];
stream out;
unit *u;
struct locale *lang;
test_setup();
lang = get_or_create_locale("de");
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~Mampf");
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
CuAssertStrEquals(tc, "Waffenloser Mampf", gettoken(token, sizeof(token)));
CuAssertStrEquals(tc, "LERNE Waffenloser~Mampf", get_command(u->thisorder, lang, 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~Mampf", token);
mstream_done(&out);
test_teardown();
}
static void test_study_order_unknown_quoted(CuTest *tc) {
char token[32];
stream out;
unit *u;
struct locale *lang;
test_setup();
lang = get_or_create_locale("de");
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 Dampf'");
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
CuAssertStrEquals(tc, "Waffenloser Dampf", gettoken(token, sizeof(token)));
CuAssertStrEquals(tc, "LERNE 'Waffenloser Dampf'", get_command(u->thisorder, lang, 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 Dampf'", token);
mstream_done(&out);
test_teardown();
}
static void test_create_order_long(CuTest *tc) {
char buffer[2048];
order *ord;
struct locale *lang;
stream out;
const char * longstr = "// BESCHREIBEN EINHEIT \"In weiÃ&#131; &#131; &#131; &#131; &#131; &#131; &#131; &#"
"131;&#131;&#131;&#131;&#131;&#131;&#131;?e GewÃ&#131;&#131;&#131;&#131;&#13"
"1;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;Ã&#131;&#131;&#131;"
"&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;Ã&#131;&#131;&#131;&#"
"131;&#131;&#131;&#131;&#131;&#131;&#131;&#130;Ã&#131;&#131;&#131;&#131;&#13"
"1;&#131;&#131;&#131;&#131;&#130;Ã&#131;&#131;&#131;&#131;&#131;&#131;&#131;"
"&#131;&#130;Ã&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#130;Ã&#131;&#131;&"
"#131;&#131;&#131;&#131;&#130;Ã&#131;&#131;&#131;&#131;&#131;&#130;Ã&#131;&#"
"131;&#131;&#131;&#130;Ã&#131;&#131;&#131;&#130;Ã&#131;&#131;&#130;Ã&#131;&#"
"130;Ã&#130;¢&#130;Ã&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&"
"#131;&#131;&#130;Ã&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#1"
"31;&#130;Ã&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#130;Ã&#13"
"1;&#131;&#131;&#131;&#131;&#131;&#131;&#131;&#130;Ã&#131;&#131;&#131;&#131;"
"&#131;&#131;&#131;&#130[...]hB&#65533;&#65533;2&#65533;xa&#65533;Hv$P&#65533;xa&#65533;&#65533;A&#65533;&#65533;&#65533;A&#65533;&#65533;";
test_setup();
lang = test_create_locale();
ord = parse_order(longstr, lang);
CuAssertIntEquals(tc, 0, ord->command);
mstream_init(&out);
stream_order(&out, ord, lang, true);
out.api->rewind(out.handle);
out.api->readln(out.handle, buffer, sizeof(buffer));
CuAssertIntEquals(tc, 1026, strlen(buffer));
mstream_done(&out);
free_order(ord);
test_teardown();
}
static void test_crescape(CuTest *tc) {
char buffer[16];
const char *input = "12345678901234567890";
CuAssertStrEquals(tc, "1234", crescape("1234", buffer, 16));
CuAssertPtrEquals(tc, (void *)input, (void *)crescape(input, buffer, 16));
CuAssertStrEquals(tc, "\\\"1234\\\"", crescape("\"1234\"", buffer, 16));
CuAssertStrEquals(tc, "\\\"1234\\\"", buffer);
CuAssertStrEquals(tc, "\\\"1234", crescape("\"1234\"", buffer, 8));
/* unlike in C strings, only " and \ are escaped: */
CuAssertStrEquals(tc, "\\\"\\\\\n\r\'", crescape("\"\\\n\r\'", buffer, 16));
}
CuSuite *get_order_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_crescape);
SUITE_ADD_TEST(suite, test_create_order);
SUITE_ADD_TEST(suite, test_create_order_long);
2017-10-09 20:33:47 +02:00
SUITE_ADD_TEST(suite, test_study_orders);
SUITE_ADD_TEST(suite, test_study_order);
2018-03-17 12:55:26 +01:00
SUITE_ADD_TEST(suite, test_study_order_unknown);
SUITE_ADD_TEST(suite, test_study_order_unknown_tilde);
SUITE_ADD_TEST(suite, test_study_order_unknown_quoted);
SUITE_ADD_TEST(suite, test_study_order_quoted);
SUITE_ADD_TEST(suite, test_parse_order);
SUITE_ADD_TEST(suite, test_parse_make);
SUITE_ADD_TEST(suite, test_parse_autostudy);
SUITE_ADD_TEST(suite, test_parse_make_temp);
SUITE_ADD_TEST(suite, test_parse_maketemp);
SUITE_ADD_TEST(suite, test_init_order);
SUITE_ADD_TEST(suite, test_replace_order);
SUITE_ADD_TEST(suite, test_skip_token);
SUITE_ADD_TEST(suite, test_getstrtoken);
SUITE_ADD_TEST(suite, test_get_command);
2017-09-30 19:35:40 +02:00
SUITE_ADD_TEST(suite, test_is_persistent);
2017-09-30 19:44:39 +02:00
SUITE_ADD_TEST(suite, test_is_silent);
return suite;
}