增加对BR压缩编码的支持及对应的单元测试用例
This commit is contained in:
@@ -213,14 +213,13 @@ TEST_F(HttpConvertUncompress, GzipMonkeyFrag)
|
||||
EXPECT_EQ(memcmp(__ctx->data, monkey, monkey_len), 0);
|
||||
}
|
||||
|
||||
class HttpConvertCompress : public ::testing::Test
|
||||
class HttpConvertCompress : public ::testing::TestWithParam<unsigned int>
|
||||
{
|
||||
protected:
|
||||
static constexpr unsigned int __encode = HTTP_ACCEPT_ENCODING_GZIP;
|
||||
void SetUp() override
|
||||
{
|
||||
cv_compress_object = hf_content_compress_create(__encode);
|
||||
cv_uncompress_object = hf_content_uncompress_create(__encode, __gzip_uncompress_callback, &uncompress_buf);
|
||||
cv_compress_object = hf_content_compress_create(encode);
|
||||
cv_uncompress_object = hf_content_uncompress_create(encode, __gzip_uncompress_callback, &uncompress_buf);
|
||||
ASSERT_TRUE(cv_compress_object != NULL);
|
||||
}
|
||||
|
||||
@@ -231,6 +230,7 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned int encode = GetParam();
|
||||
struct hf_content_compress * cv_compress_object{};
|
||||
struct hf_content_uncompress * cv_uncompress_object{};
|
||||
struct evbuffer * buf{evbuffer_new()};
|
||||
@@ -246,7 +246,7 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(HttpConvertCompress, MonkeyToGzip)
|
||||
TEST_P(HttpConvertCompress, MonkeyToGzip)
|
||||
{
|
||||
int ret = hf_content_compress_write(cv_compress_object, monkey, sizeof(monkey), buf, 1);
|
||||
ASSERT_EQ(ret, 0);
|
||||
@@ -263,7 +263,7 @@ TEST_F(HttpConvertCompress, MonkeyToGzip)
|
||||
EXPECT_EQ(memcmp(uncompress_buf.data(), monkey, sizeof(monkey)), 0);
|
||||
}
|
||||
|
||||
TEST_F(HttpConvertCompress, MonkeyToGzipStream)
|
||||
TEST_P(HttpConvertCompress, MonkeyToGzipStream)
|
||||
{
|
||||
unsigned frag_length = sizeof(monkey) / 2;
|
||||
|
||||
@@ -287,7 +287,7 @@ TEST_F(HttpConvertCompress, MonkeyToGzipStream)
|
||||
EXPECT_EQ(memcmp(uncompress_buf.data(), monkey, sizeof(monkey)), 0);
|
||||
}
|
||||
|
||||
TEST_F(HttpConvertCompress, MonkeyToGzipStreamWithNullEnd)
|
||||
TEST_P(HttpConvertCompress, MonkeyToGzipStreamWithNullEnd)
|
||||
{
|
||||
unsigned frag_length = sizeof(monkey) / 2;
|
||||
|
||||
@@ -315,11 +315,80 @@ TEST_F(HttpConvertCompress, MonkeyToGzipStreamWithNullEnd)
|
||||
EXPECT_EQ(memcmp(uncompress_buf.data(), monkey, sizeof(monkey)), 0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(HttpConvertCompressGroup, HttpConvertCompress,
|
||||
::testing::Values(HTTP_ACCEPT_ENCODING_GZIP, HTTP_ACCEPT_ENCODING_DEFLATE, HTTP_ACCEPT_ENCODING_BR));
|
||||
|
||||
void tfe_stream_write_access_log(const struct tfe_stream * stream, int level, const char * fmt, ...)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void tfe_stream_resume(const struct tfe_stream * stream)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void tfe_stream_suspend(const struct tfe_stream * stream, enum tfe_conn_dir by)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int tfe_stream_write(const struct tfe_stream * stream, enum tfe_conn_dir dir, const unsigned char * data, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tfe_stream_write_frag(struct tfe_stream_write_ctx * w_ctx, const unsigned char * data, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tfe_stream_action_set_opt(const struct tfe_stream * stream, enum tfe_stream_action_opt type,
|
||||
void * value, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct tfe_stream_write_ctx * tfe_stream_write_frag_start(const struct tfe_stream * stream, enum tfe_conn_dir dir)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct event_base * tfe_proxy_get_work_thread_evbase(unsigned int thread_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct event_base * tfe_proxy_get_gc_evbase(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void tfe_stream_write_frag_end(struct tfe_stream_write_ctx * w_ctx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void tfe_stream_detach(const struct tfe_stream * stream)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int tfe_stream_preempt(const struct tfe_stream * stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int tfe_proxy_get_work_thread_count()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * tfe_version()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
Reference in New Issue
Block a user