mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
Added unit tests
This commit is contained in:
parent
7a3abd2768
commit
001b8a5529
34
test/test.cc
34
test/test.cc
@ -1457,6 +1457,20 @@ TEST_F(ServerTest, Gzip) {
|
|||||||
EXPECT_EQ(200, res->status);
|
EXPECT_EQ(200, res->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ServerTest, GzipWithoutAcceptEncoding) {
|
||||||
|
Headers headers;
|
||||||
|
auto res = cli_.Get("/gzip", headers);
|
||||||
|
|
||||||
|
ASSERT_TRUE(res != nullptr);
|
||||||
|
EXPECT_EQ("", res->get_header_value("Content-Encoding"));
|
||||||
|
EXPECT_EQ("text/plain", res->get_header_value("Content-Type"));
|
||||||
|
EXPECT_EQ("100", res->get_header_value("Content-Length"));
|
||||||
|
EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456"
|
||||||
|
"7890123456789012345678901234567890",
|
||||||
|
res->body);
|
||||||
|
EXPECT_EQ(200, res->status);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ServerTest, GzipWithContentReceiver) {
|
TEST_F(ServerTest, GzipWithContentReceiver) {
|
||||||
Headers headers;
|
Headers headers;
|
||||||
headers.emplace("Accept-Encoding", "gzip, deflate");
|
headers.emplace("Accept-Encoding", "gzip, deflate");
|
||||||
@ -1478,6 +1492,26 @@ TEST_F(ServerTest, GzipWithContentReceiver) {
|
|||||||
EXPECT_EQ(200, res->status);
|
EXPECT_EQ(200, res->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ServerTest, GzipWithContentReceiverWithoutAcceptEncoding) {
|
||||||
|
Headers headers;
|
||||||
|
std::string body;
|
||||||
|
auto res = cli_.Get("/gzip", headers,
|
||||||
|
[&](const char *data, uint64_t data_length,
|
||||||
|
uint64_t /*offset*/, uint64_t /*content_length*/) {
|
||||||
|
body.append(data, data_length);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
ASSERT_TRUE(res != nullptr);
|
||||||
|
EXPECT_EQ("", res->get_header_value("Content-Encoding"));
|
||||||
|
EXPECT_EQ("text/plain", res->get_header_value("Content-Type"));
|
||||||
|
EXPECT_EQ("100", res->get_header_value("Content-Length"));
|
||||||
|
EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456"
|
||||||
|
"7890123456789012345678901234567890",
|
||||||
|
body);
|
||||||
|
EXPECT_EQ(200, res->status);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ServerTest, NoGzip) {
|
TEST_F(ServerTest, NoGzip) {
|
||||||
Headers headers;
|
Headers headers;
|
||||||
headers.emplace("Accept-Encoding", "gzip, deflate");
|
headers.emplace("Accept-Encoding", "gzip, deflate");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user