From b942dc6491b75bb7f247a55f79ba017d4fa9a207 Mon Sep 17 00:00:00 2001 From: Marlon Marshall Date: Fri, 25 Oct 2024 14:32:28 +0300 Subject: [PATCH] Add a test case for element that has a high param_count This is also a test for realloc_array wrapper. --- test/function/element.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/function/element.cpp b/test/function/element.cpp index 4391027e9..28f447cb9 100644 --- a/test/function/element.cpp +++ b/test/function/element.cpp @@ -607,6 +607,23 @@ namespace { EXPECT_ERROR_ID_EQ( STUMPLESS_INVALID_ENCODING ); } + TEST_F( ElementTest, HighParamCount ) { + size_t original_param_count; + const struct stumpless_element *result; + + original_param_count = stumpless_get_param_count( basic_element ); + basic_element->param_count = SIZE_MAX - 1; + + result = stumpless_add_new_param( basic_element, "high-param-count-name", "high-param-count-value" ); + EXPECT_NULL( result ); + + EXPECT_ERROR_ID_EQ( STUMPLESS_MEMORY_ALLOCATION_FAILURE ); + + basic_element->param_count = original_param_count; + EXPECT_EQ( stumpless_get_param_count( basic_element ), + original_param_count ); + } + TEST_F( ElementTest, SetName ) { const char *new_name = "awesome-new-name"; const struct stumpless_element *result;