]> jfr.im git - irc/weechat/weechat.git/commitdiff
tests: add tests on function xfer_file_search_crc32
authorSébastien Helleu <redacted>
Mon, 8 Aug 2022 06:05:47 +0000 (08:05 +0200)
committerSébastien Helleu <redacted>
Mon, 8 Aug 2022 06:06:23 +0000 (08:06 +0200)
ChangeLog.adoc
doc/en/weechat_dev.en.adoc
doc/fr/weechat_dev.fr.adoc
doc/ja/weechat_dev.ja.adoc
doc/sr/weechat_dev.sr.adoc
tests/CMakeLists.txt
tests/Makefile.am
tests/unit/plugins/xfer/test-xfer-file.cpp [new file with mode: 0644]

index 77f6419c1a694aa7a111830d7c4663fec72f32b8..8037c84af7581d72d3844dc7233f8e4eec8b6380 100644 (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)
index 55c2c6f74b99ee0eaa90cd9b6cc788ef12e969e6..f06b2d5ad6ca8af7bc2ba8552dd3c1f0bf546759 100644 (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]]
index b0188a3c1b90fbbf2750093119b8d7e8458d73f7..8b61d80f6aaa781023f62affb7b96f860500108a 100644 (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]]
index 8866da6f3cfe210eca10bf1ae9d86986f520f84a..4779b2ccf2924ccc3e08f01afd67ffbf7637c768 100644 (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]]
index 7a63df59d674e150cb06edc619a5b977a81263df..1e60e2c4cd20cd0a475df1864a228bf706d55f19 100644 (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]]
index 172e5a39acc7e834d2ad133002d38179318da728..0f5bd1e27089cdf4a0b3edd810b90d5ededfea72 100644 (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)
index 892837f1b7b0553a670e546300c0f1a77b97a5d0..0ae07b746c5d61e9740adf3660159d68e8f85f66 100644 (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
 
diff --git a/tests/unit/plugins/xfer/test-xfer-file.cpp b/tests/unit/plugins/xfer/test-xfer-file.cpp
new file mode 100644 (file)
index 0000000..7a3c50b
--- /dev/null
@@ -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 */
+}