Skip to content

Commit 001b8a5

Browse files
committed
Added unit tests
1 parent 7a3abd2 commit 001b8a5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/test.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,20 @@ TEST_F(ServerTest, Gzip) {
14571457
EXPECT_EQ(200, res->status);
14581458
}
14591459

1460+
TEST_F(ServerTest, GzipWithoutAcceptEncoding) {
1461+
Headers headers;
1462+
auto res = cli_.Get("/gzip", headers);
1463+
1464+
ASSERT_TRUE(res != nullptr);
1465+
EXPECT_EQ("", res->get_header_value("Content-Encoding"));
1466+
EXPECT_EQ("text/plain", res->get_header_value("Content-Type"));
1467+
EXPECT_EQ("100", res->get_header_value("Content-Length"));
1468+
EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456"
1469+
"7890123456789012345678901234567890",
1470+
res->body);
1471+
EXPECT_EQ(200, res->status);
1472+
}
1473+
14601474
TEST_F(ServerTest, GzipWithContentReceiver) {
14611475
Headers headers;
14621476
headers.emplace("Accept-Encoding", "gzip, deflate");
@@ -1478,6 +1492,26 @@ TEST_F(ServerTest, GzipWithContentReceiver) {
14781492
EXPECT_EQ(200, res->status);
14791493
}
14801494

1495+
TEST_F(ServerTest, GzipWithContentReceiverWithoutAcceptEncoding) {
1496+
Headers headers;
1497+
std::string body;
1498+
auto res = cli_.Get("/gzip", headers,
1499+
[&](const char *data, uint64_t data_length,
1500+
uint64_t /*offset*/, uint64_t /*content_length*/) {
1501+
body.append(data, data_length);
1502+
return true;
1503+
});
1504+
1505+
ASSERT_TRUE(res != nullptr);
1506+
EXPECT_EQ("", res->get_header_value("Content-Encoding"));
1507+
EXPECT_EQ("text/plain", res->get_header_value("Content-Type"));
1508+
EXPECT_EQ("100", res->get_header_value("Content-Length"));
1509+
EXPECT_EQ("123456789012345678901234567890123456789012345678901234567890123456"
1510+
"7890123456789012345678901234567890",
1511+
body);
1512+
EXPECT_EQ(200, res->status);
1513+
}
1514+
14811515
TEST_F(ServerTest, NoGzip) {
14821516
Headers headers;
14831517
headers.emplace("Accept-Encoding", "gzip, deflate");

0 commit comments

Comments
 (0)