Files
bacnet_stack/test/bacnet/basic/object/bacfile/src/main.c
T

84 lines
2.1 KiB
C

/**
* @file
* @brief Test for BACnet File object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date January 2023
* @section LICENSE
*
* Copyright (C) 2022 Steve Karg <skarg@users.sourceforge.net>
*
* SPDX-License-Identifier: MIT
*/
#include <zephyr/ztest.h>
#include <bacnet/basic/object/bacfile.h>
/**
* @addtogroup bacnet_tests
* @{
*/
/**
* @brief Test
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(bacfile_tests, test_BACnet_File_Object)
#else
static void test_BACnet_File_Object(void)
#endif
{
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 *required_property = NULL;
const uint32_t instance = 1;
bacfile_init();
bacfile_create(1);
rpdata.application_data = &apdu[0];
rpdata.application_data_len = sizeof(apdu);
rpdata.object_type = OBJECT_FILE;
rpdata.object_instance = instance;
rpdata.array_index = BACNET_ARRAY_ALL;
BACfile_Property_Lists(&required_property, NULL, NULL);
while ((*required_property) >= 0) {
rpdata.object_property = *required_property;
len = bacfile_read_property(&rpdata);
if (len < 0) {
printf(
"property %u: failed to read!\n",
(unsigned)rpdata.object_property);
}
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 %u: failed to decode!\n",
(unsigned)rpdata.object_property);
}
zassert_equal(len, test_len, NULL);
}
required_property++;
}
return;
}
/**
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(bacfile_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(bacfile_tests, ztest_unit_test(test_BACnet_File_Object));
ztest_run_test_suite(bacfile_tests);
}
#endif