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
+15
View File
@@ -27,9 +27,12 @@ ZTEST(testsLifeSafetyZone, testLifeSafetyZone)
static void testLifeSafetyZone(void)
#endif
{
bool status;
unsigned count = 0;
uint32_t object_instance = 0, test_object_instance = 0;
const int skip_fail_property_list[] = { -1 };
const char *test_name = NULL;
char *sample_name = "sample";
Life_Safety_Zone_Init();
object_instance = Life_Safety_Zone_Create(BACNET_MAX_INSTANCE);
@@ -41,6 +44,18 @@ static void testLifeSafetyZone(void)
OBJECT_LIFE_SAFETY_ZONE, object_instance,
Life_Safety_Zone_Property_Lists, Life_Safety_Zone_Read_Property,
Life_Safety_Zone_Write_Property, skip_fail_property_list);
/* test the ASCII name get/set */
status = Life_Safety_Zone_Name_Set(object_instance, sample_name);
zassert_true(status, NULL);
test_name = Life_Safety_Zone_Name_ASCII(object_instance);
zassert_equal(test_name, sample_name, NULL);
status = Life_Safety_Zone_Name_Set(object_instance, NULL);
zassert_true(status, NULL);
test_name = Life_Safety_Zone_Name_ASCII(object_instance);
zassert_equal(test_name, NULL, NULL);
/* cleanup */
status = Life_Safety_Zone_Delete(object_instance);
}
/**
* @}