summaryrefslogtreecommitdiff
path: root/tests/unit/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-09-03 22:29:46 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-09-03 22:29:46 +0200
commite8524ea2c41beb087bd8ee0c9f03498ebc5d3d42 (patch)
treeb40d3232d3fa16342b6379609842547c0b3f0d6b /tests/unit/plugins
parent7cf939961606f079e9b097a7310e86f4e21c7535 (diff)
downloadweechat-e8524ea2c41beb087bd8ee0c9f03498ebc5d3d42.zip
xfer: fix DCC file receive on Termux (closes #1811)
This fixes such error displayed on Termux when receiving a DCC file: xfer: invalid address "96747949": error 8 hostname nor servname provided, or not known
Diffstat (limited to 'tests/unit/plugins')
-rw-r--r--tests/unit/plugins/xfer/test-xfer-network.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/unit/plugins/xfer/test-xfer-network.cpp b/tests/unit/plugins/xfer/test-xfer-network.cpp
new file mode 100644
index 000000000..d9d3ae6f5
--- /dev/null
+++ b/tests/unit/plugins/xfer/test-xfer-network.cpp
@@ -0,0 +1,58 @@
+/*
+ * test-xfer-network.cpp - test xfer network 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"
+
+#include "tests/tests.h"
+
+extern "C"
+{
+#include "src/plugins/xfer/xfer-network.h"
+
+extern char *xfer_network_convert_integer_to_ipv4 (const char *str_address);
+}
+
+TEST_GROUP(XferNetwork)
+{
+};
+
+/*
+ * Tests functions:
+ * xfer_network_convert_integer_to_ipv4
+ */
+
+TEST(XferNetwork, ConvertIntegerToIpv4)
+{
+ char *str;
+
+ POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 (NULL));
+ POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 (""));
+ POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 ("abc"));
+ POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 ("0"));
+ POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 ("-1"));
+
+ WEE_TEST_STR("0.0.0.1", xfer_network_convert_integer_to_ipv4 ("1"));
+ WEE_TEST_STR("0.0.1.0", xfer_network_convert_integer_to_ipv4 ("256"));
+ WEE_TEST_STR("0.1.0.0", xfer_network_convert_integer_to_ipv4 ("65536"));
+ WEE_TEST_STR("1.0.0.0", xfer_network_convert_integer_to_ipv4 ("16777216"));
+ WEE_TEST_STR("127.0.0.1", xfer_network_convert_integer_to_ipv4 ("2130706433"));
+ WEE_TEST_STR("192.168.1.2", xfer_network_convert_integer_to_ipv4 ("3232235778"));
+}