diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/Makefile.am | 7 | ||||
-rw-r--r-- | tests/unit/plugins/xfer/test-xfer-file.cpp | 103 |
3 files changed, 115 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 172e5a39a..0f5bd1e27 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,6 +101,12 @@ if(ENABLE_TYPING) ) endif() +if(ENABLE_XFER) + list(APPEND LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC + unit/plugins/xfer/test-xfer-file.cpp + ) +endif() + add_library(weechat_unit_tests_plugins MODULE ${LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC}) if(ICONV_LIBRARY) diff --git a/tests/Makefile.am b/tests/Makefile.am index 892837f1b..0ae07b746 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -107,12 +107,17 @@ tests_typing = unit/plugins/typing/test-typing.cpp \ unit/plugins/typing/test-typing-status.cpp endif +if PLUGIN_XFER +tests_xfer = unit/plugins/xfer/test-xfer-file.cpp +endif + lib_weechat_unit_tests_plugins_la_SOURCES = unit/plugins/test-plugins.cpp \ $(tests_irc) \ $(tests_logger) \ $(tests_relay) \ $(tests_trigger) \ - $(tests_typing) + $(tests_typing) \ + $(tests_xfer) lib_weechat_unit_tests_plugins_la_LDFLAGS = -module -no-undefined diff --git a/tests/unit/plugins/xfer/test-xfer-file.cpp b/tests/unit/plugins/xfer/test-xfer-file.cpp new file mode 100644 index 000000000..7a3c50b67 --- /dev/null +++ b/tests/unit/plugins/xfer/test-xfer-file.cpp @@ -0,0 +1,103 @@ +/* + * test-xfer-file.cpp - test xfer file functions + * + * Copyright (C) 2022 Sébastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat 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 + * (at your option) any later version. + * + * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "CppUTest/TestHarness.h" + +extern "C" +{ +#include "src/plugins/xfer/xfer-file.h" +} + +TEST_GROUP(XferFile) +{ +}; + +/* + * Tests functions: + * xfer_file_search_crc32 + */ + +TEST(XferFile, SearchCrc32) +{ + POINTERS_EQUAL(NULL, xfer_file_search_crc32 (NULL)); + POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("")); + POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("a")); + POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("z")); + POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("123456781234abcd")); + POINTERS_EQUAL(NULL, xfer_file_search_crc32 ("test_filename")); + + /* valid CRC32 */ + STRCMP_EQUAL("1234abcd", xfer_file_search_crc32 ("test_1234abcd")); + STRCMP_EQUAL("1234aBCd", xfer_file_search_crc32 ("test_1234aBCd")); + STRCMP_EQUAL("1234abcd_test", xfer_file_search_crc32 ("1234abcd_test")); + STRCMP_EQUAL("1234Abcd_test", xfer_file_search_crc32 ("1234Abcd_test")); + STRCMP_EQUAL("12345678", xfer_file_search_crc32 ("1234abcd_12345678")); +} + +/* + * Tests functions: + * xfer_file_resume + */ + +TEST(XferFile, Resume) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * xfer_file_check_suffix + */ + +TEST(XferFile, CheckSuffix) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * xfer_file_find_suffix + */ + +TEST(XferFile, FindSuffix) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * xfer_file_find_filename + */ + +TEST(XferFile, FindFilename) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * xfer_file_calculate_speed + */ + +TEST(XferFile, CalculateSpeed) +{ + /* TODO: write tests */ +} |