From 5ba873a0f3e5ce62e5324e6920fe8d577ba8ec0e Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 2 Aug 2024 16:21:33 +0900 Subject: [PATCH] gzip: test: Add normal case of counting concatenated gzip payload Signed-off-by: Hiroshi Hatake --- tests/internal/gzip.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/internal/gzip.c b/tests/internal/gzip.c index d9542d60778..fcad4b684ac 100644 --- a/tests/internal/gzip.c +++ b/tests/internal/gzip.c @@ -40,6 +40,36 @@ void test_compress() flb_free(str); } +void test_concatenated_gzip_count() +{ + int ret; + int sample_len; + char *in_data = morpheus; + size_t in_len; + void *str; + size_t len; + flb_sds_t payload = NULL; + flb_sds_t payload2 = NULL; + size_t border_count = 0; + + sample_len = strlen(morpheus); + in_len = sample_len; + ret = flb_gzip_compress(in_data, in_len, &str, &len); + TEST_CHECK(ret == 0); + + payload = flb_sds_create_len((char *)str, len); + payload2 = flb_sds_create_len((char *)str, len); + ret = flb_sds_cat_safe(&payload, payload2, flb_sds_len(payload2)); + TEST_CHECK(ret == 0); + + border_count = flb_gzip_count(payload, flb_sds_len(payload), NULL, 0); + TEST_CHECK(border_count == 1); + + flb_free(str); + flb_sds_destroy(payload); + flb_sds_destroy(payload2); +} + void test_not_overflow_for_concatenated_gzip() { const char data[] = { @@ -72,6 +102,7 @@ void test_not_overflow_for_concatenated_gzip() TEST_LIST = { {"compress", test_compress}, + {"count", test_concatenated_gzip_count}, {"not_overflow", test_not_overflow_for_concatenated_gzip}, { 0 } };