diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ee0b75..0c9291a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -91,6 +91,7 @@ if (BUILD_TESTS)
add_subdirectory(tests)
enable_testing()
add_test(NAME "FullLoop" COMMAND "fullloop")
+ add_test(NAME "EarlyTrail" COMMAND "earlytrail")
endif()
add_library(uirc ${UIRC_SOURCE})
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index d5f43ce..d0e2c87 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.16)
include_directories(${uIRC_SOURCE_DIR}/include)
+
add_executable(fullloop fullloop.c common.c)
target_link_libraries(fullloop uirc)
+
+add_executable(earlytrail earlytrail.c common.c)
+target_link_libraries(earlytrail uirc)
diff --git a/tests/earlytrail.c b/tests/earlytrail.c
new file mode 100644
index 0000000..96e43dc
--- /dev/null
+++ b/tests/earlytrail.c
@@ -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 .
+ */
+
+#include "common.h" // expect() print_irc_message()
+#include "uirc.h" // uirc_* IRC_*
+
+#include // fprintf()
+#include // EXIT_*
+#include // 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;
+}