Files
bacnet_stack/test/bacnet/basic/object/bv/src/main.c
T
Steve Karg a945588340 Bugfix/print property name units lighting (#313)
* Fix EPICS property name proprietary range

* Fix Lighting Command decode length

* add function to determine property name and units proprietary range

* improve test coverage for AI, AO, AV, BI, BO, BV, LO

* refactor common property encoding to proplist module

* add decoder for priority array

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-07-29 17:11:38 -05:00

76 lines
1.9 KiB
C

/*
* Copyright (c) 2020 Legrand North America, LLC.
*
* SPDX-License-Identifier: MIT
*/
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <ztest.h>
#include <bacnet/basic/object/bv.h>
/**
* @addtogroup bacnet_tests
* @{
*/
/**
* @brief Test
*/
static void testBinary_Value(void)
{
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
uint32_t len_value = 0;
uint8_t tag_number = 0;
BACNET_OBJECT_TYPE decoded_type = 0;
uint32_t decoded_instance = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
const int *required_property = NULL;
const uint32_t instance = 1;
Binary_Value_Init();
rpdata.application_data = &apdu[0];
rpdata.application_data_len = sizeof(apdu);
rpdata.object_type = OBJECT_BINARY_VALUE;
rpdata.object_instance = instance;
rpdata.array_index = BACNET_ARRAY_ALL;
Binary_Value_Property_Lists(&required_property, NULL, NULL);
while ((*required_property) >= 0) {
rpdata.object_property = *required_property;
len = Binary_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);
}
required_property++;
}
}
/**
* @}
*/
void test_main(void)
{
ztest_test_suite(bv_tests,
ztest_unit_test(testBinary_Value)
);
ztest_run_test_suite(bv_tests);
}