1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
/*
* test-core-url.cpp - test URL functions
*
* Copyright (C) 2014-2024 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 <https://www.gnu.org/licenses/>.
*/
#include "CppUTest/TestHarness.h"
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)
{
};
/*
* 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
*/
TEST(CoreUrl, Download)
{
/* TODO: write tests */
}
/*
* Tests functions:
* weeurl_option_add_to_infolist
*/
TEST(CoreUrl, AddToInfolist)
{
/* TODO: write tests */
}
|