From bb6be1d8ec3610734cbc5e1686da0ccf14ef8206 Mon Sep 17 00:00:00 2001 From: Alex Denes Date: Mon, 22 Feb 2021 17:09:41 +0000 Subject: [PATCH] Bump version, fix inclustions and move tests outside of main repo --- CMakeLists.txt | 44 ++++--------- {src/assemblers => include}/assemblers.h | 3 +- {src => include}/ctcp.h | 1 + {src/memory => include}/memory.h | 2 +- {src => include}/modes.h | 0 {src => include}/replies.h | 0 {src/tokenizers => include}/tokenizers.h | 2 +- {src => include}/types.h | 0 {src => include}/uirc.h | 7 +- {src/validators => include}/validators.h | 2 +- src/assemblers/message.c | 2 +- src/assemblers/tag.c | 2 +- src/assemblers/user.c | 2 +- src/memory/allocators.c | 2 +- src/memory/free.c | 2 +- src/tests/assemblers/message.c | 67 ------------------- src/tests/assemblers/tag.c | 52 --------------- src/tests/assemblers/user.c | 50 --------------- src/tests/common.c | 82 ------------------------ src/tests/common.h | 40 ------------ src/tests/general/fullloop.c | 57 ---------------- src/tests/tokenizers/message.c | 45 ------------- src/tests/tokenizers/tag.c | 63 ------------------ src/tests/tokenizers/user.c | 41 ------------ src/tokenizers/message.c | 6 +- src/tokenizers/tag.c | 6 +- src/tokenizers/user.c | 6 +- src/validators/validators.c | 2 - 28 files changed, 35 insertions(+), 553 deletions(-) rename {src/assemblers => include}/assemblers.h (95%) rename {src => include}/ctcp.h (99%) rename {src/memory => include}/memory.h (96%) rename {src => include}/modes.h (100%) rename {src => include}/replies.h (100%) rename {src/tokenizers => include}/tokenizers.h (98%) rename {src => include}/types.h (100%) rename {src => include}/uirc.h (90%) rename {src/validators => include}/validators.h (96%) delete mode 100644 src/tests/assemblers/message.c delete mode 100644 src/tests/assemblers/tag.c delete mode 100644 src/tests/assemblers/user.c delete mode 100644 src/tests/common.c delete mode 100644 src/tests/common.h delete mode 100644 src/tests/general/fullloop.c delete mode 100644 src/tests/tokenizers/message.c delete mode 100644 src/tests/tokenizers/tag.c delete mode 100644 src/tests/tokenizers/user.c diff --git a/CMakeLists.txt b/CMakeLists.txt index c880112..e75685b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) project( uIRC - VERSION 0.2.3 + VERSION 0.2.4 DESCRIPTION "Simple and lightweight IRC protocol helper" LANGUAGES C ) @@ -13,7 +13,6 @@ add_compile_definitions(UIRC_VERSION="${UIRC_VERSION}") OPTION(BUILD_IRCV3 "Build IRCv3 components" OFF) OPTION(BUILD_VALIDATORS "Build message validators" OFF) -OPTION(BUILD_TESTS "Build tests for ctest" OFF) OPTION(BUILD_DOCS "Build documentation with doxygen" OFF) OPTION(CODE_ANALYZER "Analyze the code statically" OFF) OPTION(CODE_COVERAGE "Build with coverage tools" OFF) @@ -28,14 +27,15 @@ set(UIRC_SOURCE ) set(UIRC_HEADERS - src/uirc.h - src/ctcp.h - src/modes.h - src/replies.h - src/types.h - src/assemblers/assemblers.h - src/tokenizers/tokenizers.h - src/memory/memory.h + include/assemblers.h + include/ctcp.h + include/memory.h + include/modes.h + include/replies.h + include/tokenizers.h + include/types.h + include/uirc.h + include/validators.h ) # Libraries used @@ -67,26 +67,6 @@ if (BUILD_VALIDATORS) src/validators/validators.h ) endif() -if (BUILD_TESTS) - message(STATUS "Tests are going to be built.") - enable_testing() - - macro(buildtest categ name) - add_executable("uirc-test-${categ}-${name}" "src/tests/${categ}/${name}.c" src/tests/common.c) - target_link_libraries("uirc-test-${categ}-${name}" uirc) - add_test(NAME "${categ}/${name}" COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uirc-test-${categ}-${name}") - endmacro() - - buildtest(tokenizers tag) - buildtest(tokenizers user) - buildtest(tokenizers message) - - buildtest(assemblers tag) - buildtest(assemblers user) - buildtest(assemblers message) - - buildtest(general fullloop) -endif() if(BUILD_DOCS) find_package(Doxygen REQUIRED) if (DOXYGEN_FOUND) @@ -108,6 +88,10 @@ endif() add_library(uirc ${UIRC_SOURCE}) target_link_libraries(uirc ${UIRC_LIBS}) +target_include_directories(uirc PUBLIC + $ + $ +) separate_arguments(UIRC_HEADERS) set_target_properties(uirc PROPERTIES diff --git a/src/assemblers/assemblers.h b/include/assemblers.h similarity index 95% rename from src/assemblers/assemblers.h rename to include/assemblers.h index fea5d11..48ee1b0 100644 --- a/src/assemblers/assemblers.h +++ b/include/assemblers.h @@ -18,10 +18,9 @@ /*! \file */ -#include "../types.h" // IRC_User IRC_Message +#include "types.h" // IRC_User IRC_Message #include // llist_t -#include // bool #include // ssize_t ssize_t #ifndef UIRC_GUARD_PUBLIC_ASSEMBLERS diff --git a/src/ctcp.h b/include/ctcp.h similarity index 99% rename from src/ctcp.h rename to include/ctcp.h index 7359c58..6e7de50 100644 --- a/src/ctcp.h +++ b/include/ctcp.h @@ -17,6 +17,7 @@ */ /*! \file */ + #ifndef UIRC_GUARD_PUBLIC_CTCP #define UIRC_GUARD_PUBLIC_CTCP diff --git a/src/memory/memory.h b/include/memory.h similarity index 96% rename from src/memory/memory.h rename to include/memory.h index f1b8499..287e42f 100644 --- a/src/memory/memory.h +++ b/include/memory.h @@ -18,7 +18,7 @@ /*! \file */ -#include "../types.h" // IRC_Tag IRC_User IRC_Meesage +#include "types.h" // IRC_Tag IRC_User IRC_Message #ifndef UIRC_GUARD_PUBLIC_MEMORY #define UIRC_GUARD_PUBLIC_MEMORY diff --git a/src/modes.h b/include/modes.h similarity index 100% rename from src/modes.h rename to include/modes.h diff --git a/src/replies.h b/include/replies.h similarity index 100% rename from src/replies.h rename to include/replies.h diff --git a/src/tokenizers/tokenizers.h b/include/tokenizers.h similarity index 98% rename from src/tokenizers/tokenizers.h rename to include/tokenizers.h index 5d7b85a..a392665 100644 --- a/src/tokenizers/tokenizers.h +++ b/include/tokenizers.h @@ -18,7 +18,7 @@ /*! \file */ -#include "../types.h" // IRC_User +#include "types.h" // IRC_User #include // llist_t #include // bool diff --git a/src/types.h b/include/types.h similarity index 100% rename from src/types.h rename to include/types.h diff --git a/src/uirc.h b/include/uirc.h similarity index 90% rename from src/uirc.h rename to include/uirc.h index ac58b83..7d33ede 100644 --- a/src/uirc.h +++ b/include/uirc.h @@ -17,13 +17,10 @@ */ #include "assemblers.h" -#include "errors.h" +#include "ctcp.h" +#include "memory.h" #include "modes.h" #include "replies.h" #include "tokenizers.h" #include "types.h" - -#ifdef UIRC_FEATURE_VALIDATORS #include "validators.h" -#endif /* UIRC_FEATURE_VALIDATORS */ - diff --git a/src/validators/validators.h b/include/validators.h similarity index 96% rename from src/validators/validators.h rename to include/validators.h index 053c15b..c82054c 100644 --- a/src/validators/validators.h +++ b/include/validators.h @@ -18,7 +18,7 @@ /*! \file */ -#include "../types.h" // IRC_Message +#include "types.h" // IRC_Message #include diff --git a/src/assemblers/message.c b/src/assemblers/message.c index 2629fcc..c60c16f 100644 --- a/src/assemblers/message.c +++ b/src/assemblers/message.c @@ -16,8 +16,8 @@ * along with uIRC. If not, see . */ -#include "../types.h" // IRC_Message IRC_Tag IRC_User #include "assemblers.h" // uirc_assembler_* +#include "types.h" // IRC_Message IRC_Tag IRC_User #include // assert() #include // NULL, snprintf() diff --git a/src/assemblers/tag.c b/src/assemblers/tag.c index 2daba4e..60db2b5 100644 --- a/src/assemblers/tag.c +++ b/src/assemblers/tag.c @@ -16,8 +16,8 @@ * along with uIRC. If not, see . */ -#include "../types.h" // IRC_Tag #include "assemblers.h" // uirc_assembler_tag_* +#include "types.h" // IRC_Tag #include // assert() #include // llist_t diff --git a/src/assemblers/user.c b/src/assemblers/user.c index fc4e256..e9928fe 100644 --- a/src/assemblers/user.c +++ b/src/assemblers/user.c @@ -16,8 +16,8 @@ * along with uIRC. If not, see . */ -#include "../types.h" // IRC_User #include "assemblers.h" // Assm_user() +#include "types.h" // IRC_User #include // assert() #include // bool diff --git a/src/memory/allocators.c b/src/memory/allocators.c index f3bf903..069f788 100644 --- a/src/memory/allocators.c +++ b/src/memory/allocators.c @@ -16,8 +16,8 @@ * along with uIRC. If not, see . */ -#include "../types.h" // IRC_* #include "memory.h" +#include "types.h" // IRC_* #include // assert() #include // llist_t remove_linked_list_elem() diff --git a/src/memory/free.c b/src/memory/free.c index 08d4222..25bbd6f 100644 --- a/src/memory/free.c +++ b/src/memory/free.c @@ -16,8 +16,8 @@ * along with uIRC. If not, see . */ -#include "../types.h" // IRC_* #include "memory.h" +#include "types.h" // IRC_* #include // assert() #include // llist_t remove_linked_list_elem() diff --git a/src/tests/assemblers/message.c b/src/tests/assemblers/message.c deleted file mode 100644 index a9a2a83..0000000 --- a/src/tests/assemblers/message.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 "../../assemblers/assemblers.h" // Assm_mesg() -#include "../../types.h" // IRC_* -#include "../common.h" // expect() - -#include // assert() -#include // bool -#include // EXIT_SUCCESS - -#define KEY1 "msgid" -#define VAL1 "lol" -#define KEY2 "wow" -#define NICK "bazinga" -#define HOST "monke.uk" -#define COMMAND "NOTICE" -#define ARG1 "urmomgay" -#define TRAILING "what's up retard" - -int -main(void) -{ - IRC_Message m[] = { - { .command = COMMAND, .args = { ARG1, TRAILING, NULL }, .trailing = true }, - { .tag_list = &(llist_t) { .content = &(IRC_Tag) { .key = KEY1, .value = VAL1, .clientbound = true }, - .next = &(llist_t) { .content = &(IRC_Tag) { .key = KEY2 } } }, - .source = &(IRC_User) { .nick = NICK, .host = HOST }, - .command = COMMAND, - .args = { ARG1, TRAILING, NULL }, - .trailing = true }, - }; - const char* str[] = { COMMAND " " ARG1 " :" TRAILING, "@+" KEY1 "=" VAL1 ";" KEY2 " :" NICK "@" HOST " " COMMAND " " ARG1 " :" TRAILING }; - - char buf[513]; - signed long ret; - for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) { - if ((ret = uirc_assembler_message(buf, &m[i], sizeof(buf) / sizeof(char))) < 0) { - printf("Failed to convert IRC_Message struct to a string. %li\n", ret); - return EXIT_FAILURE; - } - size_t len = strlen(str[i]); - if ((size_t) ret != len) { - printf("String lenght doesn't match with amount of bytes printed. Expected %li but got %li\n", len, ret); - return EXIT_FAILURE; - } - expect(buf, str[i]); - print_irc_message(&m[i]); - } - return EXIT_SUCCESS; -} - diff --git a/src/tests/assemblers/tag.c b/src/tests/assemblers/tag.c deleted file mode 100644 index 9000705..0000000 --- a/src/tests/assemblers/tag.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 "../../assemblers/assemblers.h" // Assm_mesg() -#include "../common.h" // expect() - -#include // EXIT_SUCCESS EXIT_FAILURE - -#define key1 "msgid" -#define val1 "30" -#define key2 "time" -#define key3 "x" -#define val3 "spx" - -int -main(void) -{ - const char* str[] = { "+" key1 "=" val1, key2, key3 "=" val3 }; - const IRC_Tag tag[] = { { .key = key1, .value = val1, .clientbound = true }, { .key = key2 }, { .key = key3, .value = val3 } }; - char buf[513]; - signed long ret; - for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) { - if ((ret = uirc_assembler_tag(buf, &tag[i], sizeof(buf) / sizeof(char))) < 0) { - printf("Failed to convert tag %lu to \"%s\". Error %li\n", i, str[i], ret); - return EXIT_FAILURE; - } - size_t len = strlen(str[i]); - if ((size_t) ret != len) { - printf("String lenght doesn't match with amount of bytes printed. Expected %li but got %li\n", len, ret); - return EXIT_FAILURE; - } - expect(buf, str[i]); - print_irc_tag(&tag[i]); - } - return EXIT_SUCCESS; -} - diff --git a/src/tests/assemblers/user.c b/src/tests/assemblers/user.c deleted file mode 100644 index 11896fd..0000000 --- a/src/tests/assemblers/user.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 "../../assemblers/assemblers.h" // Assm_user() -#include "../common.h" // expect() - -#include // EXIT_SUCCESS EXIT_FAILURE - -#define NICK "bruh" -#define USER "sound" -#define HOST "numero.dos" - -int -main(void) -{ - const char* str[] = { NICK "!" USER "@" HOST, HOST }; - IRC_User u[] = { { .nick = NICK, .user = USER, .host = HOST }, { .host = HOST } }; - char buf[513]; - signed long ret; - for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) { - if ((ret = uirc_assembler_user(buf, &u[i], sizeof(buf) / sizeof(char))) <= 0) { - printf("Failed to convert IRC_User struct to a string. %li\n", ret); - return EXIT_FAILURE; - } - size_t len = strlen(str[i]); - if ((size_t) ret != len) { - printf("String lenght doesn't match with amount of bytes printed. Expected %li but got %li\n", len, ret); - return EXIT_FAILURE; - } - expect(buf, str[i]); - print_irc_user(&u[i]); - } - return EXIT_SUCCESS; -} - diff --git a/src/tests/common.c b/src/tests/common.c deleted file mode 100644 index 6d0c054..0000000 --- a/src/tests/common.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 "common.h" - -#include "../types.h" // IRC_Message - -#include // printf() -#include // exit() -#include // strcmp() - -#define DELIMITER "-------------\n" -#define PRINTVARORNULL(VAR) ((VAR != NULL) ? VAR : "NULL") - -void -expect(const char* var, const char* exp) -{ - if (strcmp(var, exp) != 0) { - printf("Expected \"%s\" but got \"%s\" instead.\n", exp, var); - exit(EXIT_FAILURE); - } -} - -void -print_irc_message(const IRC_Message* ptr) -{ -#ifdef UIRC_FEATURE_IRCV3 - printf(DELIMITER); - - llist_t* tmp = ptr->tag_list; - for (; tmp != NULL; tmp = tmp->next) { print_irc_tag((IRC_Tag*) tmp->content); } -#endif /* UIRC_FEATURE_IRCV3 */ - - if (ptr->source != NULL) { print_irc_user(ptr->source); } - - if (ptr->command != NULL) printf("mc: %s\n", ptr->command); - - for (short i = 0; i < IRC_MAXARGS && ptr->args[i] != NULL; i++) { printf("marg[%i]: %s\n", i, ptr->args[i]); } - - printf(DELIMITER); -} - -#ifdef UIRC_FEATURE_IRCV3 -void -print_irc_tag(const IRC_Tag* tag) -{ - printf(DELIMITER "tn: %s\n" - "tv: %s\n" - "tc: %i\n" DELIMITER, - PRINTVARORNULL(tag->key), - PRINTVARORNULL(tag->value), - tag->clientbound); -} -#endif /* UIRC_FEATURE_IRCV3 */ - -void -print_irc_user(const IRC_User* user) -{ - printf(DELIMITER "un: %s\n" - "uu: %s\n" - "ur: %s\n" - "uh: %s\n" DELIMITER, - PRINTVARORNULL(user->nick), - PRINTVARORNULL(user->user), - PRINTVARORNULL(user->real), - PRINTVARORNULL(user->host)); -} diff --git a/src/tests/common.h b/src/tests/common.h deleted file mode 100644 index 107ee2e..0000000 --- a/src/tests/common.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 "../types.h" // IRC_* - -#include // printf() -#include // exit() -#include // strcmp() - -#ifndef UIRC_GUARD_PRIVATE_COMMONTESTS -#define UIRC_GUARD_PRIVATE_COMMONTESTS - -#define ERRIFNULL(VAR, ...) \ - if (VAR == NULL) printf(__VA_ARGS__) - -void expect(const char* var, const char* exp); - -void print_irc_message(const IRC_Message* ptr); -#ifdef UIRC_FEATURE_IRCV3 -void print_irc_tag(const IRC_Tag* tag); -#endif /* UIRC_FEATURE_IRCV3 */ -void print_irc_user(const IRC_User* user); - -#endif /* UIRC_GUARD_PRIVATE_COMMONTESTS */ - diff --git a/src/tests/general/fullloop.c b/src/tests/general/fullloop.c deleted file mode 100644 index 6ac4816..0000000 --- a/src/tests/general/fullloop.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 "../../assemblers/assemblers.h" // Assm_mesg() -#include "../../tokenizers/tokenizers.h" // Tok_mesg() -#include "../../types.h" // IRC_User -#include "../common.h" // expect() - -#include // assert() -#include // EXIT_SUCCESS - -int -main(void) -{ - const char* str[] = { ":buddy@hostnet.com PRIVMSG #general :login hunter12", - "NOTICE * :nice cock bro", - "@day=13;willtolive=0 PRIVMSG you :helo", - ":mom!mother@localhost NOTICE #netadmin :johnny, your pizza is done" }; - - for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) { - IRC_Message* m = NULL; - if ((m = uirc_tokenizer_message(str[i])) == NULL) { - printf("Failed to convert string to IRC_Message struct.\n"); - return EXIT_FAILURE; - } - ssize_t ret; - char buf[513]; - if ((ret = uirc_assembler_message(buf, m, sizeof(buf) / sizeof(char))) <= 0) { - printf("Failed to convert IRC_Message struct to a string. (%li)\n", ret); - return EXIT_FAILURE; - } - size_t s1 = strlen(str[i]), s2 = strlen(buf); - if (s1 != s2) { - printf("String lenght doesn't match after parsing and assembly. Expected %li but got %li\n", s1, s2); - return EXIT_FAILURE; - } - expect(buf, str[i]); - print_irc_message(m); - } - - return EXIT_SUCCESS; -} diff --git a/src/tests/tokenizers/message.c b/src/tests/tokenizers/message.c deleted file mode 100644 index 5f2d6d3..0000000 --- a/src/tests/tokenizers/message.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 "../../tokenizers/tokenizers.h" // Tok_user() -#include "../../types.h" // IRC_User -#include "../common.h" // expect() - -#include // assert() -#include // EXIT_SUCCESS - -#define COMMAND "NOTICE" -#define ARG1 "urmomgay" -#define TRAILING "what's up retard" - -int -main(void) -{ - IRC_Message* m = uirc_tokenizer_message(COMMAND " " ARG1 " :" TRAILING); - ERRIFNULL(m, "Message wasn't tokenized successfully.\n"); - expect(m->command, COMMAND); - expect(m->args[0], ARG1); - expect(m->args[1], TRAILING); - if (!m->trailing) { - printf("Message wasn't trailing when it should've been.\n"); - return EXIT_FAILURE; - } - print_irc_message(m); - return EXIT_SUCCESS; -} - diff --git a/src/tests/tokenizers/tag.c b/src/tests/tokenizers/tag.c deleted file mode 100644 index 53c73da..0000000 --- a/src/tests/tokenizers/tag.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 "../../tokenizers/tokenizers.h" // uirc_tokenizer_*() -#include "../common.h" // expect() - -#include // assert() -#include // llist_t -#include // EXIT_SUCCESS - -#define key1 "msgid" -#define val1 "30" -#define key2 "time" -#define key3 "x" -#define val3 "spx" - -int -main(void) -{ - IRC_Tag* cur = NULL; - llist_t* tags = uirc_tokenizer_tag_list("+" key1 "=" val1 ";" key2 ";" key3 "=" val3); - ERRIFNULL(tags, "Tags weren't tokenized successfully.\n"); - - cur = tags->content; - expect(cur->key, key1); - expect(cur->value, val1); - if (!cur->clientbound) { - printf("Tag #1 wasn't clientbound.\n"); - return EXIT_FAILURE; - } - print_irc_tag(cur); - - cur = (tags = tags->next)->content; - expect(cur->key, key2); - if (cur->clientbound) { - printf("Tag #2 was clientbound.\n"); - return EXIT_FAILURE; - } - print_irc_tag(cur); - - cur = (tags = tags->next)->content; - expect(cur->key, key3); - expect(cur->value, val3); - print_irc_tag(cur); - - return EXIT_SUCCESS; -} - diff --git a/src/tests/tokenizers/user.c b/src/tests/tokenizers/user.c deleted file mode 100644 index b7e923d..0000000 --- a/src/tests/tokenizers/user.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 "../../tokenizers/tokenizers.h" // Tok_user() -#include "../../types.h" // IRC_User -#include "../common.h" // expect() - -#include // assert() -#include // EXIT_SUCCESS - -#define NICK "minion" -#define USER "banana" -#define HOST "freebanana.com" - -int -main(void) -{ - IRC_User* user = uirc_tokenizer_user(NICK "!" USER "@" HOST); - ERRIFNULL(user, "User wasn't successfully tokenized.\n"); - expect(user->nick, NICK); - expect(user->user, USER); - expect(user->host, HOST); - print_irc_user(user); - return EXIT_SUCCESS; -} - diff --git a/src/tokenizers/message.c b/src/tokenizers/message.c index 8172288..d4cd172 100644 --- a/src/tokenizers/message.c +++ b/src/tokenizers/message.c @@ -16,9 +16,9 @@ * along with uIRC. If not, see . */ -#include "../memory/memory.h" // uirc_memory_*() -#include "../types.h" // IRC_Message -#include "tokenizers.h" // uirc_tokenizer_*() +#include "memory.h" // uirc_memory_*() +#include "tokenizers.h" // uirc_tokenizer_*() +#include "types.h" // IRC_Message #include // assert() #include // malloc_string() strtok_mr() diff --git a/src/tokenizers/tag.c b/src/tokenizers/tag.c index b2c51ca..44abfff 100644 --- a/src/tokenizers/tag.c +++ b/src/tokenizers/tag.c @@ -16,9 +16,9 @@ * along with uIRC. If not, see . */ -#include "../memory/memory.h" // Free_IRC_Tag() -#include "../types.h" // IRC_Tag -#include "tokenizers.h" // uirc_tokenizer_tags() +#include "memory.h" // Free_IRC_Tag() +#include "tokenizers.h" // uirc_tokenizer_tags() +#include "types.h" // IRC_Tag #include // assert() #include // allocate_linked_list_elem() connect_linked_list_elem() remove_linked_list_elem() diff --git a/src/tokenizers/user.c b/src/tokenizers/user.c index 6bc78ea..f724bc1 100644 --- a/src/tokenizers/user.c +++ b/src/tokenizers/user.c @@ -16,9 +16,9 @@ * along with uIRC. If not, see . */ -#include "../memory/memory.h" // uirc_memory_*() -#include "../types.h" // IRC_Message -#include "tokenizers.h" // uirc_tokenizer_*() +#include "memory.h" // uirc_memory_*() +#include "tokenizers.h" // uirc_tokenizer_*() +#include "types.h" // IRC_Message #include // assert() #include // malloc_string() diff --git a/src/validators/validators.c b/src/validators/validators.c index 6ee093f..e44ffc3 100644 --- a/src/validators/validators.c +++ b/src/validators/validators.c @@ -18,8 +18,6 @@ #include "validators.h" -#include "../errors.h" // ERR_UIRC_* - #include // assert() #include // NULL #include // strchr()