Feature/zephyr ztest (#118)
* 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>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Legrand North America, LLC.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <bacnet/lso.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test
|
||||
*/
|
||||
static void testLSO(void)
|
||||
{
|
||||
uint8_t apdu[1000];
|
||||
int len;
|
||||
|
||||
BACNET_LSO_DATA data;
|
||||
BACNET_LSO_DATA rxdata;
|
||||
|
||||
memset(&rxdata, 0, sizeof(rxdata));
|
||||
|
||||
characterstring_init_ansi(&data.requestingSrc, "foobar");
|
||||
data.operation = LIFE_SAFETY_OP_RESET;
|
||||
data.processId = 0x1234;
|
||||
data.use_target = true;
|
||||
data.targetObject.instance = 0x1000;
|
||||
data.targetObject.type = OBJECT_BINARY_INPUT;
|
||||
|
||||
len = lso_encode_apdu(apdu, 100, &data);
|
||||
|
||||
lso_decode_service_request(&apdu[4], len, &rxdata);
|
||||
|
||||
zassert_equal(data.operation, rxdata.operation, NULL);
|
||||
zassert_equal(data.processId, rxdata.processId, NULL);
|
||||
zassert_equal(data.use_target, rxdata.use_target, NULL);
|
||||
zassert_equal(data.targetObject.instance, rxdata.targetObject.instance, NULL);
|
||||
zassert_equal(data.targetObject.type, rxdata.targetObject.type, NULL);
|
||||
zassert_equal(
|
||||
memcmp(data.requestingSrc.value, rxdata.requestingSrc.value,
|
||||
rxdata.requestingSrc.length), 0, NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(lso_tests,
|
||||
ztest_unit_test(testLSO)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(lso_tests);
|
||||
}
|
||||
Reference in New Issue
Block a user