Added object-name c-string getter function to basic objects so they can be referenced to free if dynamically created. (#754)

* Added basic object-name get for ASCII names to enable free if they were dynamically created. Added unit testing to validate the basic object ASCII object-name API.

* Removed static scope on character array used for name since the array gets copied into characterstring array and static is not needed.
This commit is contained in:
Steve Karg
2024-08-28 16:21:58 -05:00
committed by GitHub
parent b3c8c10c03
commit 3d3e192ae9
86 changed files with 872 additions and 87 deletions
+12
View File
@@ -26,6 +26,8 @@ static void testInteger_Value(void)
unsigned count = 0;
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
const int skip_fail_property_list[] = { -1 };
const char *test_name = NULL;
char *sample_name = "sample";
Integer_Value_Init();
object_instance = Integer_Value_Create(object_instance);
@@ -37,6 +39,16 @@ static void testInteger_Value(void)
OBJECT_INTEGER_VALUE, object_instance, Integer_Value_Property_Lists,
Integer_Value_Read_Property, Integer_Value_Write_Property,
skip_fail_property_list);
/* test the ASCII name get/set */
status = Integer_Value_Name_Set(object_instance, sample_name);
zassert_true(status, NULL);
test_name = Integer_Value_Name_ASCII(object_instance);
zassert_equal(test_name, sample_name, NULL);
status = Integer_Value_Name_Set(object_instance, NULL);
zassert_true(status, NULL);
test_name = Integer_Value_Name_ASCII(object_instance);
zassert_equal(test_name, NULL, NULL);
/* cleanup */
status = Integer_Value_Delete(object_instance);
zassert_true(status, NULL);
}