/* * This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC) * Copyright (c) 2019, 2020 Alex-David Denes * * uIRC is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * uIRC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with uIRC. If not, see . */ #include "../public/commands.h" #include "../public/tokenizers.h" #include #include #include #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) != 0) { 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) != 0) { 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; }