Skip to content

Commit 5b9d0e2

Browse files
committed
Added test for sweet_kill method
1 parent a4396db commit 5b9d0e2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/integ/ws_start_stop.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,45 @@ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, start_stop)
130130
}
131131
LT_END_AUTO_TEST(start_stop)
132132

133+
134+
LT_BEGIN_AUTO_TEST(ws_start_stop_suite, sweet_kill)
135+
webserver ws = create_webserver(8080);
136+
ok_resource* ok = new ok_resource();
137+
ws.register_resource("base", ok);
138+
ws.start(false);
139+
140+
{
141+
curl_global_init(CURL_GLOBAL_ALL);
142+
std::string s;
143+
CURL *curl = curl_easy_init();
144+
CURLcode res;
145+
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/base");
146+
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
147+
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
148+
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
149+
res = curl_easy_perform(curl);
150+
LT_ASSERT_EQ(res, 0);
151+
LT_CHECK_EQ(s, "OK");
152+
curl_easy_cleanup(curl);
153+
}
154+
155+
ws.sweet_kill();
156+
157+
{
158+
curl_global_init(CURL_GLOBAL_ALL);
159+
std::string s;
160+
CURL *curl = curl_easy_init();
161+
CURLcode res;
162+
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/base");
163+
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
164+
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
165+
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
166+
res = curl_easy_perform(curl);
167+
LT_ASSERT_EQ(res, 7);
168+
curl_easy_cleanup(curl);
169+
}
170+
LT_END_AUTO_TEST(sweet_kill)
171+
133172
LT_BEGIN_AUTO_TEST(ws_start_stop_suite, disable_options)
134173
webserver ws = create_webserver(8080)
135174
.no_ssl()

0 commit comments

Comments
 (0)