Rollback trailing change with a bugfix, add test for non-delimited trailing
This commit is contained in:
parent
907c086b0f
commit
23b66bf33d
|
@ -116,7 +116,9 @@ signed int Tok_mesg(char* str, IRC_Message* out)
|
|||
}
|
||||
out->args[i] = NULL;
|
||||
if (*progr == ':')
|
||||
out->trailing = ++progr;
|
||||
++progr;
|
||||
if (*progr != '\0')
|
||||
out->trailing = progr;
|
||||
return 1;
|
||||
}
|
||||
signed int Assm_mesg(char* buf, IRC_Message* in)
|
||||
|
|
|
@ -8,11 +8,13 @@ int main(void)
|
|||
IRC_Message results[] = {
|
||||
{.name.nick = "user", .cmd = NOTICE, .trailing = "ok"},
|
||||
{.cmd = QUIT},
|
||||
{.name = {.nick = "nick", .user = "user", .host = "host"}, .cmd = PRIVMSG, .args[0] = "friend", .trailing = "hello there"}};
|
||||
{.name = {.nick = "nick", .user = "user", .host = "host"}, .cmd = PRIVMSG, .args[0] = "friend", .trailing = "hello there"},
|
||||
{.cmd = QUIT, .args = {"one", "two", "three", "four", "5", "6", "seven", "8", "nein", "10", "11", "12", "13", "14"}, .trailing = "i'm trailing"}};
|
||||
char mesg[][513] = {
|
||||
":user NOTICE :ok",
|
||||
"QUIT",
|
||||
":nick!user@host PRIVMSG friend :hello there"};
|
||||
":nick!user@host PRIVMSG friend :hello there",
|
||||
"QUIT one two three four 5 6 seven 8 nein 10 11 12 13 14 i'm trailing"};
|
||||
IRC_Message parseout;
|
||||
int res = 0;
|
||||
for (unsigned long i = 0; i < sizeof(results) / sizeof(IRC_Message); i++) {
|
||||
|
@ -40,27 +42,6 @@ int main(void)
|
|||
{parseout.tags.reply.value, results[i].tags.reply.value} // 12
|
||||
};
|
||||
printf("Validation:\n");
|
||||
printf("\tStrings:\n");
|
||||
for (unsigned long j = 0; j < sizeof(strings) / sizeof(char* [2]); j++) {
|
||||
if (strings[j][0] != NULL && *strings[j][0] != '\0') {
|
||||
printf("\t\t[%lu]: ", j);
|
||||
if (strings[j][1] == NULL || *strings[j][1] == '\0') {
|
||||
printf("Matching argument is a NULL pointer or zero-lenght: --> %lu\n", i);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (strcmp(strings[j][0], strings[j][1])) {
|
||||
printf("Arguments didn't match at iteration %lu: expected %s but got %s", i, strings[j][1], strings[j][0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("OK\n");
|
||||
}
|
||||
}
|
||||
printf("\tCommand: ");
|
||||
if (parseout.cmd == 0 || parseout.cmd != results[i].cmd) {
|
||||
printf("Command is not parsed or non-matching. Got %s (%i)\n", uirc_ircmd[parseout.cmd], parseout.cmd);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("OK\n");
|
||||
printf("\tArguments:\n");
|
||||
for (int k = 0; i < 14 && results[i].args[k] != NULL; k++) {
|
||||
printf("\t\t[%i]: ", k);
|
||||
|
@ -72,8 +53,29 @@ int main(void)
|
|||
printf("Argument %i does not match expected value. Expected %s, got %s instead\n", k, results[i].args[k], parseout.args[k]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("OK\n");
|
||||
printf("OK %s\n", parseout.args[k]);
|
||||
}
|
||||
printf("\tStrings:\n");
|
||||
for (unsigned long j = 0; j < sizeof(strings) / sizeof(char* [2]); j++) {
|
||||
if (strings[j][1] != NULL && *strings[j][1] != '\0') {
|
||||
printf("\t\t[%lu]: ", j);
|
||||
if (strings[j][0] == NULL || *strings[j][0] == '\0') {
|
||||
printf("Matching argument is a NULL pointer or zero-lenght --> %s\n", strings[j][0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (strcmp(strings[j][0], strings[j][1])) {
|
||||
printf("Arguments didn't match at iteration %lu: expected %s but got %s", i, strings[j][1], strings[j][0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("OK %s\n", strings[j][0]);
|
||||
}
|
||||
}
|
||||
printf("\tCommand: ");
|
||||
if (parseout.cmd == 0 || parseout.cmd != results[i].cmd) {
|
||||
printf("Command is not parsed or non-matching. Got %s (%i) and expected %s\n", uirc_ircmd[parseout.cmd], parseout.cmd, uirc_ircmd[results[i].cmd]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("OK\n");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Reference in New Issue