Skip to content

Commit 56bc097

Browse files
add test
1 parent 2a22c94 commit 56bc097

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ add_test_case(hpack_dynamic_table_get)
297297
add_test_case(hpack_decode_indexed_from_dynamic_table)
298298
add_test_case(hpack_dynamic_table_empty_value)
299299
add_test_case(hpack_dynamic_table_with_empty_header)
300+
add_test_case(hpack_dynamic_table_growth_corner_case)
300301
add_test_case(hpack_dynamic_table_size_update_from_setting)
301302

302303
if(ENABLE_LOCALHOST_INTEGRATION_TESTS)

tests/test_hpack.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,34 @@ static int test_hpack_dynamic_table_with_empty_header(struct aws_allocator *allo
815815
return AWS_OP_SUCCESS;
816816
}
817817

818+
AWS_TEST_CASE(hpack_dynamic_table_growth_corner_case, test_hpack_dynamic_table_growth_corner_case)
819+
static int test_hpack_dynamic_table_growth_corner_case(struct aws_allocator *allocator, void *ctx) {
820+
(void)ctx;
821+
822+
aws_http_library_init(allocator);
823+
struct aws_hpack_context context;
824+
aws_hpack_context_init(&context, allocator, AWS_LS_HTTP_GENERAL, NULL);
825+
826+
DEFINE_STATIC_HEADER(h1, "herp", "derp");
827+
DEFINE_STATIC_HEADER(h2, "fizz", "buzz");
828+
829+
const size_t h1_size = aws_hpack_get_header_size(&h1);
830+
const size_t h2_size = aws_hpack_get_header_size(&h2);
831+
832+
ASSERT_SUCCESS(aws_hpack_insert_header(&context, &h1));
833+
ASSERT_UINT_EQUALS(1, aws_hpack_get_dynamic_table_num_elements(&context));
834+
835+
ASSERT_SUCCESS(aws_hpack_resize_dynamic_table(&context, h1_size + h2_size + 1));
836+
ASSERT_UINT_EQUALS(1, aws_hpack_get_dynamic_table_num_elements(&context));
837+
838+
ASSERT_SUCCESS(aws_hpack_insert_header(&context, &h2));
839+
ASSERT_UINT_EQUALS(2, aws_hpack_get_dynamic_table_num_elements(&context));
840+
841+
aws_hpack_context_clean_up(&context);
842+
aws_http_library_clean_up();
843+
return AWS_OP_SUCCESS;
844+
}
845+
818846
AWS_TEST_CASE(hpack_dynamic_table_size_update_from_setting, test_hpack_dynamic_table_size_update_from_setting)
819847
static int test_hpack_dynamic_table_size_update_from_setting(struct aws_allocator *allocator, void *ctx) {
820848
(void)ctx;

0 commit comments

Comments
 (0)