1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 08:43:13 +02:00

tests: add tests on function xfer_file_search_crc32

This commit is contained in:
Sébastien Helleu
2022-08-08 08:05:47 +02:00
parent bbe8afcbd4
commit a8080505f3
8 changed files with 128 additions and 1 deletions
+1
View File
@@ -50,6 +50,7 @@ Tests::
* core: remove macOS 10.15, add macOS 12 in CI
* scripts: add tests on hdata functions
* scripts: fix run of Guile test script
* xfer: add tests on file functions
[[v3.6]]
== Version 3.6 (2022-07-10)
+2
View File
@@ -453,6 +453,8 @@ WeeChat "core" is located in following directories:
|             test-typing-status.cpp | Tests: typing status.
|          relay/ | Root of unit tests for Relay plugin.
|             test-relay-auth.cpp | Tests: clients authentication.
|          xfer/ | Root of unit tests for Xfer plugin.
|             test-xfer-file.cpp | Tests: file functions.
|===
[[documentation_translations]]
+2
View File
@@ -455,6 +455,8 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|             test-typing-status.cpp | Tests : statut d'écriture.
|          relay/ | Racine des tests unitaires pour l'extension Relay.
|             test-relay-auth.cpp | Tests : authentification des clients.
|          xfer/ | Racine des tests unitaires pour l'extension Xfer.
|             test-xfer-file.cpp | Tests : fonctions sur les fichiers.
|===
[[documentation_translations]]
+4
View File
@@ -506,6 +506,10 @@ WeeChat "core" は以下のディレクトリに配置されています:
|          relay/ | Root of unit tests for Relay plugin.
// TRANSLATION MISSING
|             test-relay-auth.cpp | Tests: clients authentication.
// TRANSLATION MISSING
|          xfer/ | Root of unit tests for Xfer plugin.
// TRANSLATION MISSING
|             test-xfer-file.cpp | Tests: file functions.
|===
[[documentation_translations]]
+4
View File
@@ -455,6 +455,10 @@ WeeChat „језгро” се налази у следећим директо
|             test-typing-status.cpp | Тестови: typing статус.
|          relay/ | Корен unit тестова за Релеј додатак.
|             test-relay-auth.cpp | Тестови: аутентификација клијената.
// TRANSLATION MISSING
|          xfer/ | Root of unit tests for Xfer plugin.
// TRANSLATION MISSING
|             test-xfer-file.cpp | Tests: file functions.
|===
[[documentation_translations]]
+6
View File
@@ -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)
+6 -1
View File
@@ -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
+103
View File
@@ -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 */
}