This repository has been archived on 2021-04-17. You can view files and clone it, but cannot push or open issues or pull requests.
uIRC/tests/tokenizer.c

49 lines
1.3 KiB
C

#include "../include/uirc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define nickname "nick"
#define username "user"
#define hostname "host"
#define arg2 "Finished!"
int main(void)
{
char mesg[2][513] = {
#ifdef UIRC_IRCV3
"@+msgid=1s32;time;+reply;account=x "
#endif
":" nickname "!" username "@" hostname " QUIT arg1 :" arg2,
"001 hell :sup cj"
};
IRC_Message parseout = {0};
int res = 0;
if ((res = Tok_mesg(mesg[0], &parseout)) <= 0) {
printf("String could not be tokenized. %i\n", res);
return EXIT_FAILURE;
}
if (parseout.args[1] == NULL || strcmp(parseout.args[1], arg2)) {
printf("Unexpected result. Got %s instead of %s\n", parseout.args[1], arg2);
return EXIT_FAILURE;
}
if (parseout.name.user == NULL || strcmp(parseout.name.user, username)) {
printf("Unexpected result. Got %s instead of %s\n", parseout.name.user, username);
return EXIT_FAILURE;
}
if (parseout.cmd != QUIT) {
printf("Unexpected command result. Got %i instead of %i\n", parseout.cmd, QUIT);
return EXIT_FAILURE;
}
if ((res = Tok_mesg(mesg[1], &parseout)) <= 0) {
printf("String could not be tokenized. %i\n", res);
return EXIT_FAILURE;
}
if (parseout.cmd != 1) {
printf("Unexpected command result. Got %i instead of %i\n", parseout.cmd, 1);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}