Add few tests

This commit is contained in:
Alex 2020-07-10 18:03:26 +02:00
parent 91d4ac1250
commit 081821c8bc
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
3 changed files with 62 additions and 0 deletions

22
tests/tagassm.c Normal file
View File

@ -0,0 +1,22 @@
#include "../include/uirc.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int main(void)
{
char mesg[513] = {0};
IRC_Tags input = {
.time = {.value = "now", .clientbound = true},
.msgid = {.value = "", .clientbound = false}};
int res = 0;
if ((res = Assm_tags(mesg, &input)) <= 0) {
printf("String could not be assembled. %i\n", res);
return EXIT_FAILURE;
}
if (strcmp(mesg, "@+time=now;msgid") && strcmp(mesg, "@msgid;+time=now")) {
printf("String was not assembled properly. Have %s\n", mesg);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

24
tests/tagtok.c Normal file
View File

@ -0,0 +1,24 @@
#include "../include/uirc.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int main(void)
{
char mesg[513] = "@msgid=1s32;+time QUIT";
IRC_Message parseout;
int res = 0;
if ((res = Tok_mesg(mesg, &parseout)) <= 0) {
printf("String could not be tokenized. %i\n", res);
return EXIT_FAILURE;
}
if (parseout.tags.msgid.value == NULL || strcmp(parseout.tags.msgid.value, "1s32")) {
printf("Message ID was not properly parsed.\n");
return EXIT_FAILURE;
}
if (parseout.tags.time.value == NULL || *parseout.tags.time.value != '\0' || !parseout.tags.time.clientbound) {
printf("Time was not properly parsed.\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

16
tests/tokenizer.c Normal file
View File

@ -0,0 +1,16 @@
#include "../include/uirc.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int main(void)
{
char mesg[513] = "@+msgid=1s32;time;+reply;account=x :nick!user@host QUIT :Finished!";
IRC_Message parseout;
int res = 0;
if ((res = Tok_mesg(mesg, &parseout)) <= 0) {
printf("String could not be tokenized. %i\n", res);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}