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:
@@ -11,6 +11,7 @@
|
||||
#include <bacnet/rp.h>
|
||||
#include <bacnet/rpm.h>
|
||||
#include <bacnet/wp.h>
|
||||
#include "property_test.h"
|
||||
|
||||
/**
|
||||
* @brief Perform a read/write test on a property
|
||||
@@ -221,3 +222,28 @@ void bacnet_object_properties_read_write_test(
|
||||
zassert_false(status, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Perform a test on the ASCII name of an object
|
||||
* @param object_instance The instance number of the object to test
|
||||
* @param ascii_set The function to set the ASCII name
|
||||
* @param ascii_get The function to get the ASCII name
|
||||
*/
|
||||
void bacnet_object_name_ascii_test(
|
||||
uint32_t object_instance,
|
||||
object_name_ascii_set_function ascii_set,
|
||||
object_name_ascii_function ascii_get)
|
||||
{
|
||||
bool status = false;
|
||||
const char *test_name = NULL;
|
||||
char *sample_name = "sample";
|
||||
|
||||
status = ascii_set(object_instance, sample_name);
|
||||
zassert_true(status, NULL);
|
||||
test_name = ascii_get(object_instance);
|
||||
zassert_equal(test_name, sample_name, NULL);
|
||||
status = ascii_set(object_instance, NULL);
|
||||
zassert_true(status, NULL);
|
||||
test_name = ascii_get(object_instance);
|
||||
zassert_equal(test_name, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,17 @@
|
||||
#include <bacnet/rpm.h>
|
||||
#include <bacnet/wp.h>
|
||||
|
||||
/* function API pattern for testing ASCII name get/set */
|
||||
typedef bool (*object_name_ascii_set_function) (uint32_t object_instance,
|
||||
char *new_name);
|
||||
typedef const char * (*object_name_ascii_function) (
|
||||
uint32_t object_instance);
|
||||
|
||||
void bacnet_object_name_ascii_test(
|
||||
uint32_t object_instance,
|
||||
object_name_ascii_set_function ascii_set,
|
||||
object_name_ascii_function ascii_get);
|
||||
|
||||
void bacnet_object_properties_read_write_test(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
|
||||
Reference in New Issue
Block a user