summaryrefslogtreecommitdiff
path: root/tests/unit/core/test-core-url.cpp
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-03-12 08:02:47 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-03-12 08:02:47 +0100
commitb21bc633135aed6dddcb583f83f6a57914c30243 (patch)
treebc82b162f952c0e7667f150530b3893cde206623 /tests/unit/core/test-core-url.cpp
parent7ba9f9ac7ba226a083307e48a439e117cef25aea (diff)
downloadweechat-b21bc633135aed6dddcb583f83f6a57914c30243.zip
tests: add tests on functions weeurl_search_constant and weeurl_search_option
Diffstat (limited to 'tests/unit/core/test-core-url.cpp')
-rw-r--r--tests/unit/core/test-core-url.cpp109
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/unit/core/test-core-url.cpp b/tests/unit/core/test-core-url.cpp
index 049100afb..e3aaa25db 100644
--- a/tests/unit/core/test-core-url.cpp
+++ b/tests/unit/core/test-core-url.cpp
@@ -24,6 +24,12 @@
extern "C"
{
#include "src/core/wee-url.h"
+
+extern struct t_url_constant url_proxy_types[];
+extern struct t_url_constant url_protocols[];
+extern int weeurl_search_constant (struct t_url_constant *constants,
+ const char *name);
+extern int weeurl_search_option (const char *name);
}
TEST_GROUP(CoreUrl)
@@ -32,6 +38,109 @@ TEST_GROUP(CoreUrl)
/*
* Tests functions:
+ * weeurl_search_constant
+ */
+
+TEST(CoreUrl, SearchConstant)
+{
+ LONGS_EQUAL(-1, weeurl_search_constant (NULL, NULL));
+ LONGS_EQUAL(-1, weeurl_search_constant (NULL, ""));
+ LONGS_EQUAL(-1, weeurl_search_constant (NULL, "test"));
+ LONGS_EQUAL(-1, weeurl_search_constant (url_proxy_types, NULL));
+ LONGS_EQUAL(-1, weeurl_search_constant (url_proxy_types, ""));
+ LONGS_EQUAL(-1, weeurl_search_constant (url_proxy_types, "does_not_exist"));
+
+ CHECK(weeurl_search_constant (url_proxy_types, "socks4") >= 0);
+ CHECK(weeurl_search_constant (url_proxy_types, "SOCKS4") >= 0);
+
+ CHECK(weeurl_search_constant (url_protocols, "https") >= 0);
+ CHECK(weeurl_search_constant (url_protocols, "HTTPS") >= 0);
+}
+
+/*
+ * Tests functions:
+ * weeurl_get_mask_value
+ */
+
+TEST(CoreUrl, GetMaskValue)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * weeurl_search_option
+ */
+
+TEST(CoreUrl, SearchOption)
+{
+ LONGS_EQUAL(-1, weeurl_search_option (NULL));
+ LONGS_EQUAL(-1, weeurl_search_option (""));
+ LONGS_EQUAL(-1, weeurl_search_option ("does_not_exist"));
+
+ /* string */
+ CHECK(weeurl_search_option ("interface") >= 0);
+ CHECK(weeurl_search_option ("INTERFACE") >= 0);
+
+ /* long */
+ CHECK(weeurl_search_option ("proxyport") >= 0);
+ CHECK(weeurl_search_option ("PROXYPORT") >= 0);
+
+ /* long long */
+ CHECK(weeurl_search_option ("resume_from_large") >= 0);
+ CHECK(weeurl_search_option ("RESUME_FROM_LARGE") >= 0);
+
+ /* list */
+ CHECK(weeurl_search_option ("httpheader") >= 0);
+ CHECK(weeurl_search_option ("HTTPHEADER") >= 0);
+
+ /* mask */
+ CHECK(weeurl_search_option ("httpauth") >= 0);
+ CHECK(weeurl_search_option ("HTTPAUTH") >= 0);
+}
+
+/*
+ * Tests functions:
+ * weeurl_read
+ */
+
+TEST(CoreUrl, Read)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * weeurl_write
+ */
+
+TEST(CoreUrl, Write)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * weeurl_option_map_cb
+ */
+
+TEST(CoreUrl, OptionMapCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * weeurl_set_proxy
+ */
+
+TEST(CoreUrl, SetProxy)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
* weeurl_download
*/