Add earlytrail test
This commit is contained in:
parent
7109ae6b70
commit
f0f0d95078
|
@ -91,6 +91,7 @@ if (BUILD_TESTS)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_test(NAME "FullLoop" COMMAND "fullloop")
|
add_test(NAME "FullLoop" COMMAND "fullloop")
|
||||||
|
add_test(NAME "EarlyTrail" COMMAND "earlytrail")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(uirc ${UIRC_SOURCE})
|
add_library(uirc ${UIRC_SOURCE})
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
include_directories(${uIRC_SOURCE_DIR}/include)
|
include_directories(${uIRC_SOURCE_DIR}/include)
|
||||||
|
|
||||||
add_executable(fullloop fullloop.c common.c)
|
add_executable(fullloop fullloop.c common.c)
|
||||||
target_link_libraries(fullloop uirc)
|
target_link_libraries(fullloop uirc)
|
||||||
|
|
||||||
|
add_executable(earlytrail earlytrail.c common.c)
|
||||||
|
target_link_libraries(earlytrail uirc)
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common.h" // expect() print_irc_message()
|
||||||
|
#include "uirc.h" // uirc_* IRC_*
|
||||||
|
|
||||||
|
#include <stdio.h> // fprintf()
|
||||||
|
#include <stdlib.h> // EXIT_*
|
||||||
|
#include <string.h> // strcmp()
|
||||||
|
|
||||||
|
#define TRAILING "random stuff here"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
const char* str = "NOTICE 0 1 2 3 4 5 6 7 8 9 10 11 12 13 " TRAILING "\r\n";
|
||||||
|
|
||||||
|
IRC_Message* m = NULL;
|
||||||
|
if ((m = uirc_tokenizer_message(str)) == NULL) {
|
||||||
|
fprintf(stderr, "Failed to convert string to IRC_Message struct.\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
if (strcmp(m->args[IRC_MAXARGS - 1], TRAILING) != 0) {
|
||||||
|
fprintf(stderr, "Trailing was parsed incorrectly, got %s instead of %s\n", m->args[IRC_MAXARGS - 1], TRAILING);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
uirc_free_message(m);
|
||||||
|
free(m);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Reference in New Issue