Feature/write property type check refactor (#182)

* refactor write-property tag check

* modify ports objects to use write-property tag check API

* modify example objects to use write-property tag check API

* Fix object unit test builds

* Fix and run unit ztests via CMake

* Enable unit testing on Travis CI

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2021-06-23 10:10:12 -05:00
committed by GitHub
parent 31b7fb3c40
commit 810a2f93de
139 changed files with 1142 additions and 4375 deletions
-75
View File
@@ -441,78 +441,3 @@ void Accumulator_Init(void)
unsigned_value |= (unsigned_value << 1);
}
}
#ifdef TEST_ACCUMULATOR
#include <assert.h>
#include <string.h>
#include "ctest.h"
#include "bactext.h"
void test_Accumulator(Test *pTest)
{
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0;
int test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *property = &Properties_Required[0];
BACNET_UNSIGNED_INTEGER unsigned_value = 1;
Accumulator_Init();
rpdata.application_data = &apdu[0];
rpdata.application_data_len = sizeof(apdu);
rpdata.object_type = OBJECT_ACCUMULATOR;
rpdata.object_instance = 1;
while ((*property) >= 0) {
rpdata.object_property = *property;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Accumulator_Read_Property(&rpdata);
ct_test(pTest, len != 0);
if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) {
test_len = bacapp_decode_context_data(
rpdata.application_data, len, &value, rpdata.object_property);
} else {
test_len = bacapp_decode_application_data(
rpdata.application_data, len, &value);
}
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
ct_test(pTest, len == test_len);
property++;
}
/* test 1-bit to 64-bit encode/decode of present-value */
rpdata.object_property = PROP_PRESENT_VALUE;
while (unsigned_value != BACNET_UNSIGNED_INTEGER_MAX) {
Accumulator_Present_Value_Set(0, unsigned_value);
len = Accumulator_Read_Property(&rpdata);
ct_test(pTest, len != 0);
test_len = bacapp_decode_application_data(
rpdata.application_data, len, &value);
ct_test(pTest, len == test_len);
unsigned_value |= (unsigned_value << 1);
}
return;
}
int main(void)
{
Test *pTest;
bool rc;
pTest = ct_create("BACnet Accumulator", NULL);
/* individual tests */
rc = ct_addTestFunction(pTest, test_Accumulator);
assert(rc);
ct_setStream(pTest, stdout);
ct_run(pTest);
(void)ct_report(pTest);
ct_destroy(pTest);
return 0;
}
#endif