fix parsing, again, tests were failing for good reasons.

This commit is contained in:
Enno Rehling 2021-08-21 22:15:58 +02:00
parent 46ab8f3cb6
commit c4aab2d000
4 changed files with 8 additions and 7 deletions

View File

@ -126,7 +126,7 @@ static void test_get_set_param(CuTest * tc)
{
struct param *par = 0;
test_setup();
CuAssertStrEquals(tc, 0, get_param(par, "foo"));
CuAssertStrEquals(tc, NULL, get_param(par, "foo"));
set_param(&par, "foo", "bar");
set_param(&par, "bar", "foo");
CuAssertStrEquals(tc, "bar", get_param(par, "foo"));

View File

@ -220,16 +220,16 @@ static void test_getstrtoken(CuTest *tc) {
CuAssertStrEquals(tc, "durr", getstrtoken());
CuAssertStrEquals(tc, "", getstrtoken());
CuAssertStrEquals(tc, "", getstrtoken());
CuAssertStrEquals(tc, 0, getstrtoken());
CuAssertStrEquals(tc, NULL, getstrtoken());
init_tokens_str(0);
CuAssertStrEquals(tc, 0, getstrtoken());
CuAssertStrEquals(tc, NULL, getstrtoken());
}
static void test_skip_token(CuTest *tc) {
init_tokens_str("hurr \"durr\"");
skip_token();
CuAssertStrEquals(tc, "durr", getstrtoken());
CuAssertStrEquals(tc, 0, getstrtoken());
CuAssertStrEquals(tc, NULL, getstrtoken());
}
static void test_replace_order(CuTest *tc) {

View File

@ -196,6 +196,7 @@ char *parse_token(const char **str, char *lbuf, size_t buflen)
else if (utf8_character == '"' || utf8_character == '\'') {
if (utf8_character == quotechar) {
quotechar = 0;
++ctoken;
break;
}
else if (quotechar == 0 && cstart == ctoken) {

View File

@ -21,11 +21,11 @@ static void test_transliterate(CuTest * tc)
CuAssertStrEquals(tc, "aeoeuess", transliterate(buffer, sizeof(buffer), "\xc3\x84\xc3\x96\xc3\x9c\xe1\xba\x9e"));
/* handle buffer that is too small */
CuAssertStrEquals(tc, 0, transliterate(buffer, 1, "herpderp"));
CuAssertStrEquals(tc, NULL, transliterate(buffer, 1, "herpderp"));
CuAssertStrEquals(tc, "", buffer);
CuAssertStrEquals(tc, 0, transliterate(buffer, 3, "herpderp"));
CuAssertStrEquals(tc, NULL, transliterate(buffer, 3, "herpderp"));
CuAssertStrEquals(tc, "he", buffer);
CuAssertStrEquals(tc, 0, transliterate(buffer, 3, "h\xc3\xa4rpd\xc3\xa4rp"));
CuAssertStrEquals(tc, NULL, transliterate(buffer, 3, "h\xc3\xa4rpd\xc3\xa4rp"));
CuAssertStrEquals(tc, "h?", buffer);
}