Added CreateObject, DeleteObject, and COV to Integer Value object (#719)
Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
This commit is contained in:
@@ -27,6 +27,7 @@ add_compile_definitions(
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/bacnet/basic/object/test
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
@@ -44,12 +45,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
@@ -57,8 +58,13 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${TST_DIR}/bacnet/basic/object/test/property_test.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/object/iv.h>
|
||||
#include <bacnet/bactext.h>
|
||||
#include <property_test.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -21,74 +22,23 @@
|
||||
*/
|
||||
static void testInteger_Value(void)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0, test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
unsigned count = 0;
|
||||
bool status = false;
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
|
||||
const int skip_fail_property_list[] = { -1 };
|
||||
|
||||
Integer_Value_Init();
|
||||
object_instance = Integer_Value_Create(object_instance);
|
||||
count = Integer_Value_Count();
|
||||
zassert_true(count > 0, NULL);
|
||||
rpdata.application_data = &apdu[0];
|
||||
rpdata.application_data_len = sizeof(apdu);
|
||||
rpdata.object_type = OBJECT_INTEGER_VALUE;
|
||||
rpdata.object_instance = Integer_Value_Index_To_Instance(0);
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
status = Integer_Value_Valid_Instance(rpdata.object_instance);
|
||||
zassert_true(count == 1, NULL);
|
||||
test_object_instance = Integer_Value_Index_To_Instance(0);
|
||||
zassert_equal(object_instance, test_object_instance, NULL);
|
||||
bacnet_object_properties_read_write_test(
|
||||
OBJECT_INTEGER_VALUE, object_instance, Integer_Value_Property_Lists,
|
||||
Integer_Value_Read_Property, Integer_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
status = Integer_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
Integer_Value_Property_Lists(&pRequired, &pOptional, &pProprietary);
|
||||
while ((*pRequired) >= 0) {
|
||||
rpdata.object_property = *pRequired;
|
||||
len = Integer_Value_Read_Property(&rpdata);
|
||||
zassert_true(len >= 0, NULL);
|
||||
if (len >= 0) {
|
||||
test_len = bacapp_decode_known_property(
|
||||
rpdata.application_data, len, &value, rpdata.object_type,
|
||||
rpdata.object_property);
|
||||
if (len != test_len) {
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
|
||||
/* FIXME: known fail to decode */
|
||||
len = test_len;
|
||||
}
|
||||
zassert_equal(len, test_len, NULL);
|
||||
} else {
|
||||
printf(
|
||||
"property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pRequired++;
|
||||
}
|
||||
while ((*pOptional) != -1) {
|
||||
rpdata.object_property = *pOptional;
|
||||
rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Integer_Value_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
if (len > 0) {
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, (uint8_t)rpdata.application_data_len,
|
||||
&value);
|
||||
if (len != test_len) {
|
||||
printf(
|
||||
"property '%s': failed to decode!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
zassert_true(test_len >= 0, NULL);
|
||||
} else {
|
||||
printf(
|
||||
"property '%s': failed to read!\n",
|
||||
bactext_property_name(rpdata.object_property));
|
||||
}
|
||||
pOptional++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user