19869dccdb
* Leverage (older) embedded unit tests into external unit tests build upon copy of Zephyr's ztest library and CMake. * Expand top-level CMake build to run external unit tests. * Expand Zephyr module extension to run external unit tests via west or sanitycheck. Co-authored-by: Gregory Shue <gregory.shue@legrand.us>
62 lines
1.4 KiB
C
62 lines
1.4 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/access_user.h>
|
|
|
|
/**
|
|
* @addtogroup bacnet_tests
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @brief Test
|
|
*/
|
|
static void testAccessUser(void)
|
|
{
|
|
uint8_t apdu[MAX_APDU] = { 0 };
|
|
int len = 0;
|
|
uint32_t len_value = 0;
|
|
uint8_t tag_number = 0;
|
|
uint32_t decoded_instance = 0;
|
|
BACNET_OBJECT_TYPE decoded_type = 0;
|
|
BACNET_READ_PROPERTY_DATA rpdata;
|
|
|
|
Access_User_Init();
|
|
rpdata.application_data = &apdu[0];
|
|
rpdata.application_data_len = sizeof(apdu);
|
|
rpdata.object_type = OBJECT_ACCESS_USER;
|
|
rpdata.object_instance = 1;
|
|
rpdata.object_property = PROP_OBJECT_IDENTIFIER;
|
|
rpdata.array_index = BACNET_ARRAY_ALL;
|
|
len = Access_User_Read_Property(&rpdata);
|
|
zassert_not_equal(len, 0, NULL);
|
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
|
zassert_equal(tag_number, BACNET_APPLICATION_TAG_OBJECT_ID, NULL);
|
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
zassert_equal(decoded_type, rpdata.object_type, NULL);
|
|
zassert_equal(decoded_instance, rpdata.object_instance, NULL);
|
|
|
|
return;
|
|
}
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
|
|
void test_main(void)
|
|
{
|
|
ztest_test_suite(access_user_tests,
|
|
ztest_unit_test(testAccessUser)
|
|
);
|
|
|
|
ztest_run_test_suite(access_user_tests);
|
|
}
|