From 70c54817fd6ff1d28cecdc5219b58e9c4e675ecf Mon Sep 17 00:00:00 2001 From: Steve Karg Date: Wed, 24 Apr 2024 09:38:12 -0500 Subject: [PATCH] Added AlignAfterOpenBracket: AlwaysBreak and BinPackArguments: true to clang-format. Updated test/bacnet c/h files with updated format. --- .clang-format | 8 +- Makefile | 2 +- test/bacnet/abort/src/main.c | 18 +- test/bacnet/alarm_ack/src/main.c | 39 +- test/bacnet/arf/src/main.c | 54 ++- test/bacnet/awf/src/main.c | 45 +- test/bacnet/bacaddr/src/main.c | 3 +- test/bacnet/bacapp/src/main.c | 109 +++-- test/bacnet/bacdcode/src/main.c | 102 +++-- test/bacnet/bacdest/src/main.c | 75 ++- test/bacnet/bacdevobjpropref/src/main.c | 29 +- test/bacnet/bacerror/src/main.c | 40 +- test/bacnet/bacint/src/main.c | 47 +- test/bacnet/bacreal/main.c | 5 +- test/bacnet/bacreal/src/main.c | 8 +- test/bacnet/bacstr/src/main.c | 49 +- test/bacnet/bactimevalue/src/main.c | 28 +- test/bacnet/basic/bbmd/main.c | 39 +- test/bacnet/basic/bbmd6/src/main.c | 85 ++-- test/bacnet/basic/binding/address/src/main.c | 26 +- test/bacnet/basic/object/acc/src/main.c | 23 +- .../basic/object/access_credential/src/main.c | 9 +- .../basic/object/access_door/src/main.c | 11 +- .../basic/object/access_point/src/main.c | 14 +- .../basic/object/access_rights/src/main.c | 5 +- .../basic/object/access_user/src/main.c | 5 +- .../basic/object/access_zone/src/main.c | 5 +- test/bacnet/basic/object/ai/src/main.c | 12 +- test/bacnet/basic/object/ai/stubs.c | 3 +- test/bacnet/basic/object/ao/src/main.c | 12 +- test/bacnet/basic/object/av/src/main.c | 12 +- test/bacnet/basic/object/av/stubs.c | 3 +- test/bacnet/basic/object/bacfile/src/main.c | 18 +- test/bacnet/basic/object/bi/src/main.c | 12 +- test/bacnet/basic/object/blo/src/main.c | 52 ++- test/bacnet/basic/object/bo/src/main.c | 12 +- test/bacnet/basic/object/bv/src/main.c | 12 +- test/bacnet/basic/object/calendar/src/main.c | 44 +- test/bacnet/basic/object/calendar/stubs.c | 8 +- test/bacnet/basic/object/channel/src/main.c | 32 +- .../basic/object/color_object/src/main.c | 30 +- .../basic/object/color_temperature/src/main.c | 44 +- test/bacnet/basic/object/command/src/main.c | 8 +- .../object/credential_data_input/src/main.c | 20 +- test/bacnet/basic/object/csv/src/main.c | 24 +- test/bacnet/basic/object/device/src/main.c | 74 +-- test/bacnet/basic/object/device/stubs.c | 16 +- test/bacnet/basic/object/iv/src/main.c | 24 +- test/bacnet/basic/object/lc/src/main.c | 280 ++++++------ test/bacnet/basic/object/lc/stubs.c | 8 +- test/bacnet/basic/object/lo/src/main.c | 41 +- test/bacnet/basic/object/lsp/src/main.c | 35 +- test/bacnet/basic/object/lsz/src/main.c | 13 +- test/bacnet/basic/object/mock/device_mock.c | 22 +- test/bacnet/basic/object/mock/tsm_mock.c | 8 +- test/bacnet/basic/object/ms-input/src/main.c | 14 +- test/bacnet/basic/object/mso/src/main.c | 14 +- test/bacnet/basic/object/msv/src/main.c | 14 +- test/bacnet/basic/object/nc/src/main.c | 38 +- test/bacnet/basic/object/nc/stubs.c | 12 +- test/bacnet/basic/object/netport/src/main.c | 27 +- test/bacnet/basic/object/objects/main.c | 4 +- test/bacnet/basic/object/objects/src/main.c | 15 +- test/bacnet/basic/object/osv/src/main.c | 18 +- test/bacnet/basic/object/piv/src/main.c | 15 +- test/bacnet/basic/object/property_test.c | 32 +- test/bacnet/basic/object/schedule/src/main.c | 17 +- .../bacnet/basic/object/time_value/src/main.c | 11 +- test/bacnet/basic/object/time_value/stubs.c | 8 +- test/bacnet/basic/object/trendlog/src/main.c | 11 +- test/bacnet/basic/sys/color_rgb/src/main.c | 55 ++- test/bacnet/basic/sys/days/src/main.c | 48 +- test/bacnet/basic/sys/fifo/src/main.c | 9 +- test/bacnet/basic/sys/filename/src/main.c | 5 +- test/bacnet/basic/sys/keylist/src/main.c | 14 +- test/bacnet/basic/sys/linear/src/main.c | 17 +- test/bacnet/basic/sys/ringbuf/src/main.c | 34 +- test/bacnet/basic/sys/sbuf/src/main.c | 5 +- test/bacnet/cov/src/main.c | 59 ++- test/bacnet/create_object/src/main.c | 14 +- test/bacnet/datalink/automac/src/main.c | 7 +- test/bacnet/datalink/bvlc/src/main.c | 114 +++-- test/bacnet/datalink/cobs/src/main.c | 34 +- test/bacnet/datalink/crc/src/main.c | 11 +- test/bacnet/datalink/mock/src/arcnet-mock.c | 11 +- test/bacnet/datalink/mock/src/bip-mock.c | 7 +- test/bacnet/datalink/mock/src/bip6-mock.c | 3 +- test/bacnet/datalink/mock/src/dlmstp-mock.c | 16 +- test/bacnet/datalink/mock/src/ethernet-mock.c | 14 +- test/bacnet/datalink/mock/src/main.c | 125 +++-- test/bacnet/datalink/mstp/src/main.c | 119 +++-- test/bacnet/datetime/src/main.c | 28 +- test/bacnet/dcc/src/main.c | 70 +-- test/bacnet/event/src/main.c | 431 +++++++++++------- test/bacnet/getalarm/src/main.c | 29 +- test/bacnet/getevent/src/main.c | 38 +- test/bacnet/hostnport/src/main.c | 8 +- test/bacnet/iam/src/main.c | 13 +- test/bacnet/ihave/src/main.c | 5 +- test/bacnet/indtext/src/main.c | 13 +- test/bacnet/lighting/src/main.c | 104 +++-- test/bacnet/list_element/src/main.c | 11 +- test/bacnet/lso/src/main.c | 14 +- test/bacnet/memcopy/src/main.c | 5 +- test/bacnet/npdu/src/main.c | 32 +- test/bacnet/npdu/stubs.c | 7 +- test/bacnet/property/src/main.c | 14 +- test/bacnet/ptransfer/src/main.c | 87 ++-- test/bacnet/rd/src/main.c | 6 +- test/bacnet/reject/src/main.c | 15 +- test/bacnet/rp/src/main.c | 9 +- test/bacnet/rpm/src/main.c | 106 +++-- test/bacnet/specialevent/src/main.c | 101 ++-- test/bacnet/timestamp/src/main.c | 46 +- test/bacnet/timesync/src/main.c | 49 +- test/bacnet/weeklyschedule/src/main.c | 52 +-- test/bacnet/whohas/src/main.c | 13 +- test/bacnet/whois/src/main.c | 5 +- test/bacnet/wp/src/main.c | 29 +- test/bacnet/wpm/src/main.c | 3 +- 120 files changed, 2182 insertions(+), 1894 deletions(-) diff --git a/.clang-format b/.clang-format index d5f24a0e..c5b29d95 100644 --- a/.clang-format +++ b/.clang-format @@ -1,15 +1,17 @@ --- BasedOnStyle: WebKit +AlignAfterOpenBracket: AlwaysBreak +BinPackArguments: true BinPackParameters: false -AlignEscapedNewlines: Left -PointerAlignment: Right +PenaltyBreakBeforeFirstCallParameter: 1 AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false +AlignEscapedNewlines: Left +PointerAlignment: Right BreakBeforeBraces: Linux BreakBeforeBinaryOperators: None KeepEmptyLinesAtTheStartOfBlocks: false -PenaltyBreakBeforeFirstCallParameter: 1 IndentCaseLabels: true IndentWidth: 4 UseTab: Never diff --git a/Makefile b/Makefile index fe037d81..c45fa469 100644 --- a/Makefile +++ b/Makefile @@ -322,7 +322,7 @@ pretty-ports: .PHONY: pretty-test pretty-test: - find ./test/bacnet -maxdepth 2 -type f -iname *.h -o -iname *.c -exec \ + find ./test/bacnet -type f -iname *.h -o -iname *.c -exec \ clang-format -i -style=file -fallback-style=none {} \; CLANG_TIDY_OPTIONS = -fix-errors -checks="readability-braces-around-statements" diff --git a/test/bacnet/abort/src/main.c b/test/bacnet/abort/src/main.c index 756c3a12..26cdeafe 100644 --- a/test/bacnet/abort/src/main.c +++ b/test/bacnet/abort/src/main.c @@ -19,7 +19,8 @@ /** * @brief decode the whole APDU - mainly used for unit testing */ -static int abort_decode_apdu(uint8_t *apdu, +static int abort_decode_apdu( + uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id, uint8_t *abort_reason, @@ -49,8 +50,7 @@ static int abort_decode_apdu(uint8_t *apdu, /** * @brief Test Abort ADPU */ -static void testAbortAPDU( - uint8_t invoke_id, uint8_t abort_reason, bool server) +static void testAbortAPDU(uint8_t invoke_id, uint8_t abort_reason, bool server) { uint8_t apdu[480] = { 0 }; int len = 0; @@ -145,8 +145,8 @@ static void testAbortError(void) error_code = abort_convert_to_error_code(abort_code); test_abort_code = abort_convert_error_code(error_code); if (test_abort_code != abort_code) { - printf("Abort: result=%u abort-code=%u\n", - test_abort_code, + printf( + "Abort: result=%u abort-code=%u\n", test_abort_code, abort_code); } zassert_equal(test_abort_code, abort_code, NULL); @@ -156,16 +156,14 @@ static void testAbortError(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(abort_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(abort_tests, - ztest_unit_test(testAbortEncodeDecode), - ztest_unit_test(testAbortError) - ); + ztest_test_suite( + abort_tests, ztest_unit_test(testAbortEncodeDecode), + ztest_unit_test(testAbortError)); ztest_run_test_suite(abort_tests); } diff --git a/test/bacnet/alarm_ack/src/main.c b/test/bacnet/alarm_ack/src/main.c index acb4d3ad..12297776 100644 --- a/test/bacnet/alarm_ack/src/main.c +++ b/test/bacnet/alarm_ack/src/main.c @@ -54,32 +54,43 @@ static void testAlarmAck(void) zassert_equal(inLen, outLen, "inlen=%d outlen=%d", inLen, outLen); - zassert_equal(testAlarmAckIn.ackProcessIdentifier, + zassert_equal( + testAlarmAckIn.ackProcessIdentifier, testAlarmAckOut.ackProcessIdentifier, NULL); - zassert_equal(testAlarmAckIn.ackTimeStamp.tag, - testAlarmAckOut.ackTimeStamp.tag, "in-tag=%d out-tag=%d", - testAlarmAckIn.ackTimeStamp.tag, testAlarmAckOut.ackTimeStamp.tag); - zassert_equal(testAlarmAckIn.ackTimeStamp.value.sequenceNum, + zassert_equal( + testAlarmAckIn.ackTimeStamp.tag, testAlarmAckOut.ackTimeStamp.tag, + "in-tag=%d out-tag=%d", testAlarmAckIn.ackTimeStamp.tag, + testAlarmAckOut.ackTimeStamp.tag); + zassert_equal( + testAlarmAckIn.ackTimeStamp.value.sequenceNum, testAlarmAckOut.ackTimeStamp.value.sequenceNum, NULL); - zassert_equal(testAlarmAckIn.ackProcessIdentifier, + zassert_equal( + testAlarmAckIn.ackProcessIdentifier, testAlarmAckOut.ackProcessIdentifier, NULL); - zassert_equal(testAlarmAckIn.eventObjectIdentifier.instance, + zassert_equal( + testAlarmAckIn.eventObjectIdentifier.instance, testAlarmAckOut.eventObjectIdentifier.instance, NULL); - zassert_equal(testAlarmAckIn.eventObjectIdentifier.type, + zassert_equal( + testAlarmAckIn.eventObjectIdentifier.type, testAlarmAckOut.eventObjectIdentifier.type, NULL); - zassert_equal(testAlarmAckIn.eventTimeStamp.tag, - testAlarmAckOut.eventTimeStamp.tag, NULL); - zassert_equal(testAlarmAckIn.eventTimeStamp.value.time.hour, + zassert_equal( + testAlarmAckIn.eventTimeStamp.tag, testAlarmAckOut.eventTimeStamp.tag, + NULL); + zassert_equal( + testAlarmAckIn.eventTimeStamp.value.time.hour, testAlarmAckOut.eventTimeStamp.value.time.hour, NULL); - zassert_equal(testAlarmAckIn.eventTimeStamp.value.time.min, + zassert_equal( + testAlarmAckIn.eventTimeStamp.value.time.min, testAlarmAckOut.eventTimeStamp.value.time.min, NULL); - zassert_equal(testAlarmAckIn.eventTimeStamp.value.time.sec, + zassert_equal( + testAlarmAckIn.eventTimeStamp.value.time.sec, testAlarmAckOut.eventTimeStamp.value.time.sec, NULL); - zassert_equal(testAlarmAckIn.eventTimeStamp.value.time.hundredths, + zassert_equal( + testAlarmAckIn.eventTimeStamp.value.time.hundredths, testAlarmAckOut.eventTimeStamp.value.time.hundredths, NULL); zassert_equal( diff --git a/test/bacnet/arf/src/main.c b/test/bacnet/arf/src/main.c index 88ab4990..95d58649 100644 --- a/test/bacnet/arf/src/main.c +++ b/test/bacnet/arf/src/main.c @@ -19,8 +19,7 @@ /** * @brief Test */ -static void testAtomicReadFileAckAccess( - BACNET_ATOMIC_READ_FILE_DATA *data) +static void testAtomicReadFileAckAccess(BACNET_ATOMIC_READ_FILE_DATA *data) { BACNET_ATOMIC_READ_FILE_DATA test_data = { 0 }; uint8_t apdu[480] = { 0 }; @@ -31,7 +30,7 @@ static void testAtomicReadFileAckAccess( uint8_t test_invoke_id = 0; unsigned int i = 0; - null_len = arf_ack_encode_apdu(NULL, invoke_id, data); + null_len = arf_ack_encode_apdu(NULL, invoke_id, data); len = arf_ack_encode_apdu(&apdu[0], invoke_id, data); zassert_not_equal(len, 0, NULL); zassert_equal(null_len, len, NULL); @@ -46,28 +45,33 @@ static void testAtomicReadFileAckAccess( if (test_data.access == FILE_STREAM_ACCESS) { zassert_equal( test_data.type.stream.fileStartPosition, - data->type.stream.fileStartPosition, NULL); + data->type.stream.fileStartPosition, NULL); zassert_equal( octetstring_length(&test_data.fileData[0]), - octetstring_length(&data->fileData[0]), NULL); + octetstring_length(&data->fileData[0]), NULL); zassert_equal( - memcmp(octetstring_value(&test_data.fileData[0]), + memcmp( + octetstring_value(&test_data.fileData[0]), octetstring_value(&data->fileData[0]), - octetstring_length(&test_data.fileData[0])), 0, NULL); + octetstring_length(&test_data.fileData[0])), + 0, NULL); } else if (test_data.access == FILE_RECORD_ACCESS) { zassert_equal( test_data.type.record.fileStartRecord, - data->type.record.fileStartRecord, NULL); + data->type.record.fileStartRecord, NULL); zassert_equal( - test_data.type.record.RecordCount, data->type.record.RecordCount, NULL); + test_data.type.record.RecordCount, data->type.record.RecordCount, + NULL); for (i = 0; i < data->type.record.RecordCount; i++) { zassert_equal( octetstring_length(&test_data.fileData[i]), - octetstring_length(&data->fileData[i]), NULL); + octetstring_length(&data->fileData[i]), NULL); zassert_equal( - memcmp(octetstring_value(&test_data.fileData[i]), + memcmp( + octetstring_value(&test_data.fileData[i]), octetstring_value(&data->fileData[i]), - octetstring_length(&test_data.fileData[i])), 0, NULL); + octetstring_length(&test_data.fileData[i])), + 0, NULL); } } /* test APDU too short */ @@ -134,16 +138,17 @@ static void testAtomicReadFileAccess(BACNET_ATOMIC_READ_FILE_DATA *data) if (test_data.access == FILE_STREAM_ACCESS) { zassert_equal( test_data.type.stream.fileStartPosition, - data->type.stream.fileStartPosition, NULL); + data->type.stream.fileStartPosition, NULL); zassert_equal( test_data.type.stream.requestedOctetCount, - data->type.stream.requestedOctetCount, NULL); + data->type.stream.requestedOctetCount, NULL); } else if (test_data.access == FILE_RECORD_ACCESS) { zassert_equal( test_data.type.record.fileStartRecord, - data->type.record.fileStartRecord, NULL); + data->type.record.fileStartRecord, NULL); zassert_equal( - test_data.type.record.RecordCount, data->type.record.RecordCount, NULL); + test_data.type.record.RecordCount, data->type.record.RecordCount, + NULL); } /* test APDU too short */ while (apdu_len) { @@ -186,10 +191,11 @@ static void testAtomicReadFileMalformed(void) { uint8_t apdu[480] = { 0 }; /* payloads with malformation */ - uint8_t payload_1[] = { 0xc4, 0x02, 0x80, 0x00, 0x00, 0x0e, 0x35, 0xff, - 0xdf, 0x62, 0xee, 0x00, 0x00, 0x22, 0x05, 0x84, 0x0f }; + uint8_t payload_1[] = { 0xc4, 0x02, 0x80, 0x00, 0x00, 0x0e, + 0x35, 0xff, 0xdf, 0x62, 0xee, 0x00, + 0x00, 0x22, 0x05, 0x84, 0x0f }; uint8_t payload_2[] = { 0xc4, 0x02, 0x80, 0x00, 0x00, 0x0e, 0x31, 0x00, - 0x25, 0xff, 0xd4, 0x9e, 0xbf, 0x79, 0x05, 0x84 }; + 0x25, 0xff, 0xd4, 0x9e, 0xbf, 0x79, 0x05, 0x84 }; BACNET_ATOMIC_READ_FILE_DATA data = { 0 }; int len = 0; uint8_t test_invoke_id = 0; @@ -216,17 +222,15 @@ static void testAtomicReadFileMalformed(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(arf_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(arf_tests, - ztest_unit_test(testAtomicReadFile), - ztest_unit_test(testAtomicReadFileAck), - ztest_unit_test(testAtomicReadFileMalformed) - ); + ztest_test_suite( + arf_tests, ztest_unit_test(testAtomicReadFile), + ztest_unit_test(testAtomicReadFileAck), + ztest_unit_test(testAtomicReadFileMalformed)); ztest_run_test_suite(arf_tests); } diff --git a/test/bacnet/awf/src/main.c b/test/bacnet/awf/src/main.c index 99f3d6ef..8ac418ce 100644 --- a/test/bacnet/awf/src/main.c +++ b/test/bacnet/awf/src/main.c @@ -45,22 +45,24 @@ static void testAtomicWriteFileAccess(BACNET_ATOMIC_WRITE_FILE_DATA *data) if (test_data.access == FILE_STREAM_ACCESS) { zassert_equal( test_data.type.stream.fileStartPosition, - data->type.stream.fileStartPosition, NULL); + data->type.stream.fileStartPosition, NULL); } else if (test_data.access == FILE_RECORD_ACCESS) { zassert_equal( test_data.type.record.fileStartRecord, - data->type.record.fileStartRecord, NULL); + data->type.record.fileStartRecord, NULL); zassert_equal( test_data.type.record.returnedRecordCount, - data->type.record.returnedRecordCount, NULL); + data->type.record.returnedRecordCount, NULL); } zassert_equal( octetstring_length(&test_data.fileData[0]), - octetstring_length(&data->fileData[0]), NULL); + octetstring_length(&data->fileData[0]), NULL); zassert_equal( - memcmp(octetstring_value(&test_data.fileData[0]), + memcmp( + octetstring_value(&test_data.fileData[0]), octetstring_value(&data->fileData[0]), - octetstring_length(&test_data.fileData[0])), 0, NULL); + octetstring_length(&test_data.fileData[0])), + 0, NULL); /* test APDU too short */ while (apdu_len) { apdu_len--; @@ -98,8 +100,7 @@ static void testAtomicWriteFile(void) return; } -static void testAtomicWriteFileAckAccess( - BACNET_ATOMIC_WRITE_FILE_DATA *data) +static void testAtomicWriteFileAckAccess(BACNET_ATOMIC_WRITE_FILE_DATA *data) { BACNET_ATOMIC_WRITE_FILE_DATA test_data = { 0 }; uint8_t apdu[480] = { 0 }; @@ -130,11 +131,11 @@ static void testAtomicWriteFileAckAccess( if (test_data.access == FILE_STREAM_ACCESS) { zassert_equal( test_data.type.stream.fileStartPosition, - data->type.stream.fileStartPosition, NULL); + data->type.stream.fileStartPosition, NULL); } else if (test_data.access == FILE_RECORD_ACCESS) { zassert_equal( test_data.type.record.fileStartRecord, - data->type.record.fileStartRecord, NULL); + data->type.record.fileStartRecord, NULL); } /* test APDU too short */ while (apdu_len) { @@ -171,12 +172,14 @@ static void testAtomicWriteFileMalformed(void) { uint8_t apdu[480] = { 0 }; /* payloads with malformation */ - uint8_t payload_1[] = { 0xc4, 0x02, 0x80, 0x00, 0x00, 0x0e, 0x35, 0xff, - 0x5e, 0xd5, 0xc0, 0x85, 0x0a, 0x62, 0x64, 0x0a, 0x0f }; - uint8_t payload_2[] = { 0xc4, 0x02, 0x80, 0x00, 0x00, 0x0e, 0x35, 0xff, - 0xc4, 0x4d, 0x92, 0xd9, 0x0a, 0x62, 0x64, 0x0a, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f }; + uint8_t payload_1[] = { 0xc4, 0x02, 0x80, 0x00, 0x00, 0x0e, + 0x35, 0xff, 0x5e, 0xd5, 0xc0, 0x85, + 0x0a, 0x62, 0x64, 0x0a, 0x0f }; + uint8_t payload_2[] = { 0xc4, 0x02, 0x80, 0x00, 0x00, 0x0e, 0x35, + 0xff, 0xc4, 0x4d, 0x92, 0xd9, 0x0a, 0x62, + 0x64, 0x0a, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f }; BACNET_ATOMIC_WRITE_FILE_DATA data = { 0 }; int len = 0; uint8_t test_invoke_id = 0; @@ -203,17 +206,15 @@ static void testAtomicWriteFileMalformed(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(awf_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(awf_tests, - ztest_unit_test(testAtomicWriteFile), - ztest_unit_test(testAtomicWriteFileAck), - ztest_unit_test(testAtomicWriteFileMalformed) - ); + ztest_test_suite( + awf_tests, ztest_unit_test(testAtomicWriteFile), + ztest_unit_test(testAtomicWriteFileAck), + ztest_unit_test(testAtomicWriteFileMalformed)); ztest_run_test_suite(awf_tests); } diff --git a/test/bacnet/bacaddr/src/main.c b/test/bacnet/bacaddr/src/main.c index 808e017b..07dbcd91 100644 --- a/test/bacnet/bacaddr/src/main.c +++ b/test/bacnet/bacaddr/src/main.c @@ -258,7 +258,8 @@ ZTEST_SUITE(bacnet_address_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bacnet_address_tests, ztest_unit_test(test_BACNET_ADDRESS), + ztest_test_suite( + bacnet_address_tests, ztest_unit_test(test_BACNET_ADDRESS), ztest_unit_test(test_BACNET_MAC_ADDRESS), ztest_unit_test(test_BACnetAddress_Codec)); diff --git a/test/bacnet/bacapp/src/main.c b/test/bacnet/bacapp/src/main.c index 0c3c7706..d30ffc35 100644 --- a/test/bacnet/bacapp/src/main.c +++ b/test/bacnet/bacapp/src/main.c @@ -98,81 +98,94 @@ static void test_bacapp_decode_data_len(void) bacapp_decode_data_len(apdu, UINT8_MAX, sizeof(apdu)), 0, NULL); expected_value = (int)(~0U >> 1); /* INT_MAX is not universally defined */ - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_UNSIGNED_INT, UINT32_MAX), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_UNSIGNED_INT, UINT32_MAX), expected_value, NULL); zassert_equal( bacapp_decode_data_len(apdu, BACNET_APPLICATION_TAG_NULL, sizeof(apdu)), 0, NULL); - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_BOOLEAN, sizeof(apdu)), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_BOOLEAN, sizeof(apdu)), 0, NULL); len_value_type = INT32_MAX - 1; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len(apdu, - BACNET_APPLICATION_TAG_UNSIGNED_INT, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_UNSIGNED_INT, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 2; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_SIGNED_INT, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_SIGNED_INT, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 5; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_REAL, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_REAL, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 9; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_DOUBLE, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_DOUBLE, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 13; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len(apdu, - BACNET_APPLICATION_TAG_OCTET_STRING, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_OCTET_STRING, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 17; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len(apdu, - BACNET_APPLICATION_TAG_CHARACTER_STRING, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_CHARACTER_STRING, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 19; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_BIT_STRING, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_BIT_STRING, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 23; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_ENUMERATED, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_ENUMERATED, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 29; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_DATE, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_DATE, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 31; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_TIME, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_TIME, len_value_type), expected_value, NULL); len_value_type = INT32_MAX - 37; expected_value = (int)len_value_type; - zassert_equal(bacapp_decode_data_len( - apdu, BACNET_APPLICATION_TAG_OBJECT_ID, len_value_type), + zassert_equal( + bacapp_decode_data_len( + apdu, BACNET_APPLICATION_TAG_OBJECT_ID, len_value_type), expected_value, NULL); } @@ -216,7 +229,8 @@ static void test_bacapp_copy(void) zassert_equal(result, expected_result, NULL); result = bacapp_same_value(&dest_value, &src_value); if (!result) { - printf("bacapp: same-value of tag=%s[%u]\n", + printf( + "bacapp: same-value of tag=%s[%u]\n", bactext_application_tag_name(tag), tag); } zassert_true(result, NULL); @@ -252,7 +266,8 @@ static void test_bacapp_value_list_init(void) zassert_equal(value[count].tag, BACNET_APPLICATION_TAG_NULL, NULL); zassert_equal(value[count].context_specific, 0, NULL); zassert_equal(value[count].context_tag, 0, NULL); - zassert_equal(value[count].next, + zassert_equal( + value[count].next, ((count + 1 >= max_count) ? NULL : &value[count + 1]), NULL); } } @@ -291,7 +306,8 @@ static void test_bacapp_property_value_list(void) zassert_equal( value[count].propertyArrayIndex, BACNET_ARRAY_ALL, NULL); zassert_equal(value[count].priority, BACNET_NO_PRIORITY, NULL); - zassert_equal(value[count].next, + zassert_equal( + value[count].next, ((count + 1 >= max_count) ? NULL : &value[count + 1]), NULL); } } @@ -316,14 +332,17 @@ static void test_bacapp_property_value_list(void) if (test_len != BACNET_STATUS_ERROR) { /* shorter packet leaves off the OPTIONAL priority */ zassert_equal(len, test_len, "len=%d test_len=%d", len, test_len); - zassert_equal(value[1].priority, BACNET_NO_PRIORITY, "priority=%u", + zassert_equal( + value[1].priority, BACNET_NO_PRIORITY, "priority=%u", (unsigned)value[1].priority); } else { - zassert_equal(test_len, BACNET_STATUS_ERROR, "len=%d test_len=%d", - len, test_len); + zassert_equal( + test_len, BACNET_STATUS_ERROR, "len=%d test_len=%d", len, + test_len); test_len = bacapp_property_value_decode(apdu, len, NULL); - zassert_equal(test_len, BACNET_STATUS_ERROR, "len=%d test_len=%d", - len, test_len); + zassert_equal( + test_len, BACNET_STATUS_ERROR, "len=%d test_len=%d", len, + test_len); } } } @@ -564,7 +583,8 @@ static void testBACnetApplicationData_Safe(void) case BACNET_APPLICATION_TAG_OCTET_STRING: { uint8_t test_octet[5] = { "Karg" }; - octetstring_init(&input_value[i].type.Octet_String, test_octet, + octetstring_init( + &input_value[i].type.Octet_String, test_octet, sizeof(test_octet)); } break; @@ -823,8 +843,8 @@ static void testBACnetApplicationDataLength(void) /** * @brief Test */ -static bool verifyBACnetApplicationDataValue( - BACNET_APPLICATION_DATA_VALUE *value) +static bool +verifyBACnetApplicationDataValue(BACNET_APPLICATION_DATA_VALUE *value) { uint8_t apdu[480] = { 0 }; int apdu_len = 0; @@ -845,10 +865,12 @@ static bool verifyBACnetApplicationDataValue( test_len = bacapp_decode_application_data(&apdu[0], apdu_len, &test_value); if (apdu_len == 0) { - zassert_equal(test_len, 0, "tag=%u apdu_len=%d test_len=%d\n", - value->tag, apdu_len, test_len); + zassert_equal( + test_len, 0, "tag=%u apdu_len=%d test_len=%d\n", value->tag, + apdu_len, test_len); } else { - zassert_equal(test_len, BACNET_STATUS_ERROR, + zassert_equal( + test_len, BACNET_STATUS_ERROR, "tag=%u apdu_len=%d test_len=%d null_len=%d\n", value->tag, apdu_len, test_len, null_len); } @@ -1162,7 +1184,8 @@ static void test_bacapp_context_data(void) apdu_len = bacapp_encode_context_data_value(apdu, context_tag_number, &value); if (apdu_len != null_len) { - printf("bacapp: NULL len=%d != APDU len=%d for tag=%s", null_len, + printf( + "bacapp: NULL len=%d != APDU len=%d for tag=%s", null_len, apdu_len, bactext_application_tag_name(tag)); } zassert_equal(apdu_len, null_len, NULL); @@ -1209,8 +1232,8 @@ ZTEST_SUITE(bacapp_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bacapp_tests, - ztest_unit_test(test_bacapp_decode_application_data), + ztest_test_suite( + bacapp_tests, ztest_unit_test(test_bacapp_decode_application_data), ztest_unit_test(test_bacapp_decode_data_len), ztest_unit_test(test_bacapp_copy), ztest_unit_test(test_bacapp_value_list_init), diff --git a/test/bacnet/bacdcode/src/main.c b/test/bacnet/bacdcode/src/main.c index 22add4ee..089926fc 100644 --- a/test/bacnet/bacdcode/src/main.c +++ b/test/bacnet/bacdcode/src/main.c @@ -41,7 +41,8 @@ static int get_apdu_len(bool extended_tag, uint32_t value) return test_len; } -static void test_bacnet_tag_codec(uint8_t tag_number, +static void test_bacnet_tag_codec( + uint8_t tag_number, bool context_specific, bool opening, bool closing, @@ -448,8 +449,8 @@ static void testBACnetDateRangeDecodes(void) #endif { uint8_t apdu[MAX_APDU]; - uint8_t sample[10] = { 0xa4, 0xff, 0xff, 0xff, 0xff, 0xa4, 0xff, 0xff, 0xff, - 0xff }; + uint8_t sample[10] = { 0xa4, 0xff, 0xff, 0xff, 0xff, + 0xa4, 0xff, 0xff, 0xff, 0xff }; int len; int null_len; int test_len; @@ -515,7 +516,8 @@ static void verifyBACDCodeUnsignedValue(BACNET_UNSIGNED_INTEGER value) len_value = encode_application_unsigned(&array[0], value); len = decode_tag_number_and_value(&array[0], &tag_number, &len_value); len = decode_unsigned(&array[len], len_value, &decoded_value); - zassert_equal(decoded_value, value, "value=%lu decoded_value=%lu\n", + zassert_equal( + decoded_value, value, "value=%lu decoded_value=%lu\n", (unsigned long)value, (unsigned long)decoded_value); encode_application_unsigned(&encoded_array[0], decoded_value); zassert_equal(memcmp(&array[0], &encoded_array[0], sizeof(array)), 0, NULL); @@ -619,8 +621,9 @@ static void testBACnetUnsigned(void) zassert_equal(value, test_value, NULL); #endif null_len = bacnet_unsigned_decode(apdu, apdu_len, len_value, NULL); - zassert_equal(apdu_len, null_len, "apdu_len=%d null_len=%d value=%u", - apdu_len, null_len, value); + zassert_equal( + apdu_len, null_len, "apdu_len=%d null_len=%d value=%u", apdu_len, + null_len, value); test_len = bacnet_unsigned_decode(apdu, apdu_len, len_value, &test_value); zassert_equal(apdu_len, test_len, NULL); @@ -648,8 +651,9 @@ static void testBACDCodeSignedValue(int32_t value) len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); len = decode_signed(&apdu[len], len_value, &decoded_value); zassert_equal(tag_number, BACNET_APPLICATION_TAG_SIGNED_INT, NULL); - zassert_equal(decoded_value, value, "value=%ld decoded_value=%ld\n", - (long)value, (long)decoded_value); + zassert_equal( + decoded_value, value, "value=%ld decoded_value=%ld\n", (long)value, + (long)decoded_value); #endif len = encode_application_signed(&apdu[0], value); null_len = encode_application_signed(NULL, value); @@ -670,9 +674,11 @@ static void testBACDCodeSignedValue(int32_t value) zassert_false(tag.opening, NULL); test_len = bacnet_signed_application_decode(apdu, len, &decoded_value); null_len = bacnet_signed_application_decode(apdu, len, NULL); - zassert_equal(null_len, len, "test_len=%d null_len=%d len=%d", test_len, - null_len, len); - zassert_equal(decoded_value, value, "value=%ld decoded_value=%ld", value, + zassert_equal( + null_len, len, "test_len=%d null_len=%d len=%d", test_len, null_len, + len); + zassert_equal( + decoded_value, value, "value=%ld decoded_value=%ld", value, decoded_value); while (len) { len--; @@ -783,7 +789,8 @@ static void testBACDCodeOctetString(void) zassert_equal(tag_number, BACNET_APPLICATION_TAG_OCTET_STRING, NULL); len += decode_octet_string(&apdu[len], len_value, &test_octet_string); zassert_equal(apdu_len, len, NULL); - diff = memcmp(octetstring_value(&octet_string), &test_value[0], + diff = memcmp( + octetstring_value(&octet_string), &test_value[0], octetstring_length(&octet_string)); zassert_equal(diff, 0, NULL); #endif @@ -799,14 +806,16 @@ static void testBACDCodeOctetString(void) zassert_equal(tag_number, BACNET_APPLICATION_TAG_OCTET_STRING, NULL); len += decode_octet_string(&apdu[len], len_value, &test_octet_string); zassert_equal(apdu_len, len, "test octet string=#%d\n", i); - diff = memcmp(octetstring_value(&octet_string), &test_value[0], + diff = memcmp( + octetstring_value(&octet_string), &test_value[0], octetstring_length(&octet_string)); zassert_equal(diff, 0, "test octet string=#%d\n", i); #endif test_len = bacnet_octet_string_application_decode( apdu, apdu_len, &test_octet_string); - zassert_equal(apdu_len, test_len, "apdu_len=%d test_len=%d i=%d", - apdu_len, test_len, i); + zassert_equal( + apdu_len, test_len, "apdu_len=%d test_len=%d i=%d", apdu_len, + test_len, i); zassert_true( octetstring_value_same(&octet_string, &test_octet_string), NULL); } @@ -843,7 +852,8 @@ static void testBACDCodeCharacterString(void) zassert_equal(tag_number, BACNET_APPLICATION_TAG_CHARACTER_STRING, NULL); len += decode_character_string(&apdu[len], len_value, &test_char_string); zassert_equal(apdu_len, len, NULL); - diff = memcmp(characterstring_value(&char_string), &test_value[0], + diff = memcmp( + characterstring_value(&char_string), &test_value[0], characterstring_length(&char_string)); zassert_equal(diff, 0, NULL); #endif @@ -871,7 +881,8 @@ static void testBACDCodeCharacterString(void) printf("test string=#%d apdu_len=%d len=%d\n", i, apdu_len, len); } zassert_equal(apdu_len, len, NULL); - diff = memcmp(characterstring_value(&char_string), &test_value[0], + diff = memcmp( + characterstring_value(&char_string), &test_value[0], characterstring_length(&char_string)); if (diff) { printf("test string=#%d\n", i); @@ -926,14 +937,16 @@ static void testBACDCodeObject(void) len = encode_context_object_id( &encoded_apdu[0], tag_number, type, instance); zassert_true(len > 0, NULL); - len = bacnet_object_id_context_decode(&encoded_apdu[0], len, - tag_number, &decoded_type, &decoded_instance); + len = bacnet_object_id_context_decode( + &encoded_apdu[0], len, tag_number, &decoded_type, + &decoded_instance); zassert_true(len > 0, NULL); zassert_equal(decoded_type, type, NULL); zassert_equal(decoded_instance, instance, NULL); tag_number = 100; - len = bacnet_object_id_context_decode(&encoded_apdu[0], len, - tag_number, &decoded_type, &decoded_instance); + len = bacnet_object_id_context_decode( + &encoded_apdu[0], len, tag_number, &decoded_type, + &decoded_instance); zassert_equal(len, 0, NULL); } } @@ -946,8 +959,9 @@ static void testBACDCodeObject(void) zassert_true(len > 0, NULL); null_len = encode_context_object_id(NULL, tag_number, type, instance); zassert_equal(len, null_len, NULL); - len = bacnet_object_id_context_decode(&encoded_apdu[0], null_len, - tag_number, &decoded_type, &decoded_instance); + len = bacnet_object_id_context_decode( + &encoded_apdu[0], null_len, tag_number, &decoded_type, + &decoded_instance); zassert_true(len > 0, NULL); zassert_equal(decoded_type, type, NULL); zassert_equal(decoded_instance, instance, NULL); @@ -1043,8 +1057,8 @@ static void testBACDCodeBitString(void) } } -static void test_unsigned_context_codec( - BACNET_UNSIGNED_INTEGER value, uint8_t context_tag) +static void +test_unsigned_context_codec(BACNET_UNSIGNED_INTEGER value, uint8_t context_tag) { uint8_t apdu[MAX_APDU] = { 0 }; int len = 0, test_len = 0, null_len = 0, match_len = 0; @@ -1721,8 +1735,9 @@ static void test_bacnet_array_encode(void) BACNET_TAG tag = { 0 }; /* element zero returns the apdu size */ - apdu_len = bacnet_array_encode(object_instance, apdu_index, - bacnet_apdu_property_element_encode, apdu_size, apdu, sizeof(apdu)); + apdu_len = bacnet_array_encode( + object_instance, apdu_index, bacnet_apdu_property_element_encode, + apdu_size, apdu, sizeof(apdu)); zassert_true(apdu_len > 0, NULL); len = bacnet_tag_decode(apdu, apdu_len, &tag); zassert_true(len > 0, NULL); @@ -1731,34 +1746,40 @@ static void test_bacnet_array_encode(void) &apdu[len], apdu_len - len, tag.len_value_type, &decoded_value); zassert_equal(decoded_value, apdu_size, NULL); /* element zero - APDU too small */ - apdu_len = bacnet_array_encode(object_instance, apdu_index, - bacnet_apdu_property_element_encode, apdu_size, apdu, 1); + apdu_len = bacnet_array_encode( + object_instance, apdu_index, bacnet_apdu_property_element_encode, + apdu_size, apdu, 1); zassert_true(apdu_len == BACNET_STATUS_ABORT, NULL); /* element 1 returns the first element */ apdu_index = 1; - apdu_len = bacnet_array_encode(object_instance, apdu_index, - bacnet_apdu_property_element_encode, apdu_size, apdu, sizeof(apdu)); + apdu_len = bacnet_array_encode( + object_instance, apdu_index, bacnet_apdu_property_element_encode, + apdu_size, apdu, sizeof(apdu)); zassert_true(apdu_len > 0, NULL); len = decode_tag_number_and_value(apdu, &tag_number, &len_value); zassert_true(len > 0, NULL); zassert_equal(tag_number, BACNET_APPLICATION_TAG_OBJECT_ID, NULL); /* element 1 - APDU too small */ - apdu_len = bacnet_array_encode(object_instance, apdu_index, - bacnet_apdu_property_element_encode, apdu_size, apdu, 1); + apdu_len = bacnet_array_encode( + object_instance, apdu_index, bacnet_apdu_property_element_encode, + apdu_size, apdu, 1); zassert_true(apdu_len == BACNET_STATUS_ABORT, NULL); /* element 2, in this test case, returns an error */ apdu_index = 2; - apdu_len = bacnet_array_encode(object_instance, apdu_index, - bacnet_apdu_property_element_encode, apdu_size, apdu, sizeof(apdu)); + apdu_len = bacnet_array_encode( + object_instance, apdu_index, bacnet_apdu_property_element_encode, + apdu_size, apdu, sizeof(apdu)); zassert_true(apdu_len < 0, NULL); /* ALL - fits in APDU */ apdu_index = BACNET_ARRAY_ALL; - apdu_len = bacnet_array_encode(object_instance, apdu_index, - bacnet_apdu_property_element_encode, apdu_size, apdu, sizeof(apdu)); + apdu_len = bacnet_array_encode( + object_instance, apdu_index, bacnet_apdu_property_element_encode, + apdu_size, apdu, sizeof(apdu)); zassert_true(apdu_len == 5, "len=%d", apdu_len); /* ALL - APDU too small */ - apdu_len = bacnet_array_encode(object_instance, apdu_index, - bacnet_apdu_property_element_encode, apdu_size, apdu, 4); + apdu_len = bacnet_array_encode( + object_instance, apdu_index, bacnet_apdu_property_element_encode, + apdu_size, apdu, 4); zassert_true(apdu_len == BACNET_STATUS_ABORT, NULL); } @@ -1771,7 +1792,8 @@ ZTEST_SUITE(bacdcode_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bacdcode_tests, ztest_unit_test(testBACnetTagCodec), + ztest_test_suite( + bacdcode_tests, ztest_unit_test(testBACnetTagCodec), ztest_unit_test(testBACDCodeTags), ztest_unit_test(testBACDCodeReal), ztest_unit_test(testBACDCodeUnsigned), ztest_unit_test(testBACnetUnsigned), diff --git a/test/bacnet/bacdest/src/main.c b/test/bacnet/bacdest/src/main.c index ad356bb5..42b80a81 100644 --- a/test/bacnet/bacdest/src/main.c +++ b/test/bacnet/bacdest/src/main.c @@ -22,9 +22,8 @@ /** * @brief Test */ -static void testBACnetRecipientData( - BACNET_RECIPIENT *data1, - BACNET_RECIPIENT *data2) +static void +testBACnetRecipientData(BACNET_RECIPIENT *data1, BACNET_RECIPIENT *data2) { unsigned i = 0; @@ -34,32 +33,30 @@ static void testBACnetRecipientData( zassert_equal( data1->type.device.type, data2->type.device.type, NULL); zassert_equal( - data1->type.device.instance, - data2->type.device.instance, NULL); + data1->type.device.instance, data2->type.device.instance, NULL); } else if (data1->tag == BACNET_RECIPIENT_TAG_ADDRESS) { zassert_equal( data1->type.address.net, data2->type.address.net, NULL); if (data1->type.address.net == BACNET_BROADCAST_NETWORK) { zassert_equal( - data1->type.address.mac_len, - data2->type.address.mac_len, NULL); + data1->type.address.mac_len, data2->type.address.mac_len, + NULL); } else if (data1->type.address.net) { zassert_equal( - data1->type.address.len, - data2->type.address.len, NULL); + data1->type.address.len, data2->type.address.len, NULL); for (i = 0; i < data1->type.address.len; i++) { zassert_equal( - data1->type.address.adr[i], - data2->type.address.adr[i], NULL); + data1->type.address.adr[i], data2->type.address.adr[i], + NULL); } } else { zassert_equal( - data1->type.address.mac_len, - data2->type.address.mac_len, NULL); + data1->type.address.mac_len, data2->type.address.mac_len, + NULL); for (i = 0; i < data1->type.address.mac_len; i++) { zassert_equal( - data1->type.address.mac[i], - data2->type.address.mac[i], NULL); + data1->type.address.mac[i], data2->type.address.mac[i], + NULL); } } } else { @@ -82,34 +79,28 @@ static void testBACnetDestination(void) null_len = bacnet_destination_encode(NULL, &destination); apdu_len = bacnet_destination_encode(apdu, &destination); zassert_equal(apdu_len, null_len, NULL); - test_len = bacnet_destination_decode(apdu, apdu_len, - &test_destination); + test_len = bacnet_destination_decode(apdu, apdu_len, &test_destination); zassert_equal(apdu_len, test_len, NULL); destination.Recipient.tag = BACNET_RECIPIENT_TAG_ADDRESS; null_len = bacnet_destination_encode(NULL, &destination); apdu_len = bacnet_destination_encode(apdu, &destination); zassert_equal(apdu_len, null_len, NULL); - test_len = bacnet_destination_decode(apdu, apdu_len, - &test_destination); + test_len = bacnet_destination_decode(apdu, apdu_len, &test_destination); zassert_equal(test_len, apdu_len, NULL); null_len = bacnet_destination_encode(NULL, &destination); apdu_len = bacnet_destination_encode(apdu, &destination); zassert_equal(apdu_len, null_len, NULL); - test_len = bacnet_destination_decode(apdu, apdu_len, - &test_destination); + test_len = bacnet_destination_decode(apdu, apdu_len, &test_destination); zassert_equal(test_len, apdu_len, NULL); /* decoding, some negative tests */ - test_len = bacnet_destination_decode(NULL, apdu_len, - &test_destination); + test_len = bacnet_destination_decode(NULL, apdu_len, &test_destination); zassert_equal(test_len, BACNET_STATUS_REJECT, NULL); - test_len = bacnet_destination_decode(apdu, 0, - &test_destination); + test_len = bacnet_destination_decode(apdu, 0, &test_destination); zassert_equal(test_len, BACNET_STATUS_REJECT, NULL); - test_len = bacnet_destination_decode(apdu, apdu_len, - NULL); + test_len = bacnet_destination_decode(apdu, apdu_len, NULL); zassert_equal(test_len, BACNET_STATUS_REJECT, NULL); } /** @@ -117,8 +108,8 @@ static void testBACnetDestination(void) */ /** -* Unit Test for ASCII conversion -*/ + * Unit Test for ASCII conversion + */ #if defined(CONFIG_ZTEST_NEW_API) ZTEST(bacnet_destination_tests, test_BACnetDestination_ASCII) #else @@ -128,13 +119,13 @@ static void test_BACnetDestination_ASCII(void) BACNET_DESTINATION destination = { 0 }, test_destination = { 0 }; int len = 0, test_len = 0; const char *ascii = "(" - "ValidDays=[1,2,3,4,5,6,7];" - "FromTime=0:00:00.0;ToTime=23:59:59.99;" - "Recipient=Device(type=8,instance=4194303);" - "ProcessIdentifier=0;" - "ConfirmedNotify=false;" - "Transitions=[]" - ")"; + "ValidDays=[1,2,3,4,5,6,7];" + "FromTime=0:00:00.0;ToTime=23:59:59.99;" + "Recipient=Device(type=8,instance=4194303);" + "ProcessIdentifier=0;" + "ConfirmedNotify=false;" + "Transitions=[]" + ")"; bool status = false; char *test_ascii = NULL; @@ -148,13 +139,12 @@ static void test_BACnetDestination_ASCII(void) if (len > 0) { test_ascii = calloc(len, 1); if (test_ascii) { - test_len = bacnet_destination_to_ascii( - &test_destination, test_ascii, len); + test_len = + bacnet_destination_to_ascii(&test_destination, test_ascii, len); zassert_equal(len, test_len, NULL); free(test_ascii); } } - } #if defined(CONFIG_ZTEST_NEW_API) @@ -162,10 +152,9 @@ ZTEST_SUITE(bacnet_destination_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bacnet_destination_tests, - ztest_unit_test(testBACnetDestination), - ztest_unit_test(test_BACnetDestination_ASCII) - ); + ztest_test_suite( + bacnet_destination_tests, ztest_unit_test(testBACnetDestination), + ztest_unit_test(test_BACnetDestination_ASCII)); ztest_run_test_suite(bacnet_destination_tests); } diff --git a/test/bacnet/bacdevobjpropref/src/main.c b/test/bacnet/bacdevobjpropref/src/main.c index 4de3d773..07f47fd5 100644 --- a/test/bacnet/bacdevobjpropref/src/main.c +++ b/test/bacnet/bacdevobjpropref/src/main.c @@ -43,8 +43,9 @@ static void testDevObjPropRef(BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *data) bacnet_device_object_property_reference_decode(apdu, len, &test_data); zassert_equal(null_len, len, "null_len=%d len=%d", null_len, len); zassert_equal(test_len, len, "test_len=%d len=%d", test_len, len); - zassert_equal(data->objectIdentifier.instance, - test_data.objectIdentifier.instance, NULL); + zassert_equal( + data->objectIdentifier.instance, test_data.objectIdentifier.instance, + NULL); zassert_equal( data->objectIdentifier.type, test_data.objectIdentifier.type, NULL); zassert_equal(data->propertyIdentifier, test_data.propertyIdentifier, NULL); @@ -54,7 +55,8 @@ static void testDevObjPropRef(BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *data) zassert_equal(test_data.arrayIndex, BACNET_ARRAY_ALL, NULL); } if (data->deviceIdentifier.type == OBJECT_DEVICE) { - zassert_equal(data->deviceIdentifier.instance, + zassert_equal( + data->deviceIdentifier.instance, test_data.deviceIdentifier.instance, NULL); zassert_equal( data->deviceIdentifier.type, test_data.deviceIdentifier.type, NULL); @@ -69,7 +71,8 @@ static void testDevObjPropRef(BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *data) apdu, len, &test_data); if ((len > 0) && (test_data.arrayIndex == BACNET_ARRAY_ALL)) { /* special case when optional portion is exactly missing */ - } else if ((len > 0) && + } else if ( + (len > 0) && (test_data.deviceIdentifier.type == BACNET_NO_DEV_TYPE)) { /* special case when optional portion is exactly missing */ } else { @@ -145,8 +148,9 @@ static void testDevIdRef(void) zassert_equal(test_len, len, NULL); null_len = bacnet_device_object_reference_decode(apdu, len, NULL); zassert_equal(test_len, null_len, NULL); - zassert_equal(data.deviceIdentifier.instance, - test_data.deviceIdentifier.instance, NULL); + zassert_equal( + data.deviceIdentifier.instance, test_data.deviceIdentifier.instance, + NULL); zassert_equal( data.deviceIdentifier.type, test_data.deviceIdentifier.type, NULL); while (--len) { @@ -183,8 +187,9 @@ static void testObjPropRef(void) zassert_equal(test_len, len, NULL); zassert_equal( data.object_identifier.type, test_data.object_identifier.type, NULL); - zassert_equal(data.object_identifier.instance, - test_data.object_identifier.instance, NULL); + zassert_equal( + data.object_identifier.instance, test_data.object_identifier.instance, + NULL); zassert_equal( data.property_identifier, test_data.property_identifier, NULL); zassert_equal( @@ -202,8 +207,9 @@ static void testObjPropRef(void) zassert_equal(test_len, len, "len=%d test_len=%d", len, test_len); zassert_equal( data.object_identifier.type, test_data.object_identifier.type, NULL); - zassert_equal(data.object_identifier.instance, - test_data.object_identifier.instance, NULL); + zassert_equal( + data.object_identifier.instance, test_data.object_identifier.instance, + NULL); zassert_equal( data.property_identifier, test_data.property_identifier, NULL); zassert_equal( @@ -227,7 +233,8 @@ ZTEST_SUITE(bacdevobjpropref_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bacdevobjpropref_tests, ztest_unit_test(testDevIdPropRef), + ztest_test_suite( + bacdevobjpropref_tests, ztest_unit_test(testDevIdPropRef), ztest_unit_test(testDevIdRef), ztest_unit_test(testObjPropRef)); ztest_run_test_suite(bacdevobjpropref_tests); diff --git a/test/bacnet/bacerror/src/main.c b/test/bacnet/bacerror/src/main.c index 0a6cc555..d6e7e0a2 100644 --- a/test/bacnet/bacerror/src/main.c +++ b/test/bacnet/bacerror/src/main.c @@ -17,7 +17,8 @@ * @{ */ -static int bacerror_decode_apdu(uint8_t *apdu, +static int bacerror_decode_apdu( + uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id, BACNET_CONFIRMED_SERVICE *service, @@ -31,8 +32,9 @@ static int bacerror_decode_apdu(uint8_t *apdu, return BACNET_STATUS_ERROR; } apdu_len = 1; - apdu_len = bacerror_decode_service_request(&apdu[apdu_len], - apdu_size - apdu_len, invoke_id, service, error_class, error_code); + apdu_len = bacerror_decode_service_request( + &apdu[apdu_len], apdu_size - apdu_len, invoke_id, service, + error_class, error_code); } return apdu_len; @@ -67,8 +69,9 @@ static void testBACError(void) apdu_len = len; null_len = bacerror_decode_apdu(&apdu[0], apdu_len, NULL, NULL, NULL, NULL); - len = bacerror_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, - &test_service, &test_error_class, &test_error_code); + len = bacerror_decode_apdu( + &apdu[0], apdu_len, &test_invoke_id, &test_service, &test_error_class, + &test_error_code); zassert_not_equal(len, BACNET_STATUS_ERROR, "len=%d", len); zassert_equal(len, null_len, NULL); zassert_equal(test_invoke_id, invoke_id, NULL); @@ -79,22 +82,24 @@ static void testBACError(void) /* test too short lengths */ while (len) { len--; - test_len = - bacerror_decode_apdu(&apdu[0], len, &test_invoke_id, - &test_service, &test_error_class, &test_error_code); + test_len = bacerror_decode_apdu( + &apdu[0], len, &test_invoke_id, &test_service, &test_error_class, + &test_error_code); zassert_equal( test_len, BACNET_STATUS_ERROR, "len=%d test_len=%d", len, test_len); } /* change type to get negative response */ apdu[0] = PDU_TYPE_ABORT; - len = bacerror_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, - &test_service, &test_error_class, &test_error_code); + len = bacerror_decode_apdu( + &apdu[0], apdu_len, &test_invoke_id, &test_service, &test_error_class, + &test_error_code); zassert_true(len <= 0, NULL); /* test NULL APDU */ - len = bacerror_decode_apdu(NULL, apdu_len, &test_invoke_id, - &test_service, &test_error_class, &test_error_code); + len = bacerror_decode_apdu( + NULL, apdu_len, &test_invoke_id, &test_service, &test_error_class, + &test_error_code); zassert_true(len <= 0, NULL); /* check them all... */ @@ -107,9 +112,9 @@ static void testBACError(void) &apdu[0], invoke_id, service, error_class, error_code); apdu_len = len; zassert_not_equal(len, 0, NULL); - len = bacerror_decode_apdu(&apdu[0], apdu_len, - &test_invoke_id, &test_service, &test_error_class, - &test_error_code); + len = bacerror_decode_apdu( + &apdu[0], apdu_len, &test_invoke_id, &test_service, + &test_error_class, &test_error_code); zassert_not_equal(len, -1, NULL); zassert_equal(test_invoke_id, invoke_id, NULL); zassert_equal(test_service, service, NULL); @@ -127,8 +132,9 @@ static void testBACError(void) &apdu[0], invoke_id, service, error_class, error_code); apdu_len = len; zassert_not_equal(len, 0, NULL); - len = bacerror_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, - &test_service, &test_error_class, &test_error_code); + len = bacerror_decode_apdu( + &apdu[0], apdu_len, &test_invoke_id, &test_service, &test_error_class, + &test_error_code); zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); zassert_equal(test_invoke_id, invoke_id, NULL); zassert_equal(test_service, service, NULL); diff --git a/test/bacnet/bacint/src/main.c b/test/bacnet/bacint/src/main.c index 24a20c56..e3e0eca9 100644 --- a/test/bacnet/bacint/src/main.c +++ b/test/bacnet/bacint/src/main.c @@ -37,15 +37,15 @@ static void testBACnetUnsigned16(void) memset(apdu, -1, sizeof(apdu)); len = encode_unsigned16(&apdu[0], value); zassert_equal(len, 2, NULL); - test_value = (uint16_t) ~0U; + test_value = (uint16_t)~0U; len = decode_unsigned16(&apdu[0], &test_value); zassert_equal(len, 2, NULL); zassert_equal(value, test_value, NULL); - for (value = 1; value != 0; value = (value << 1) & ((1UL<<16)-1)) { + for (value = 1; value != 0; value = (value << 1) & ((1UL << 16) - 1)) { len = encode_unsigned16(&apdu[0], value); zassert_equal(len, 2, NULL); - test_value = (uint16_t) ~0U; + test_value = (uint16_t)~0U; len = decode_unsigned16(&apdu[0], &test_value); zassert_equal(value, test_value, NULL); } @@ -77,7 +77,7 @@ static void testBACnetUnsigned24(void) zassert_equal(len, 3, NULL); zassert_equal(value, test_value, NULL); - for (value = 1; value != 0; value = (value << 1) & ((1UL<<24)-1)) { + for (value = 1; value != 0; value = (value << 1) & ((1UL << 24) - 1)) { len = encode_unsigned24(&apdu[0], value); zassert_equal(len, 3, NULL); test_value = ~0U; @@ -148,7 +148,7 @@ static void testBACnetUnsigned40(void) zassert_equal(len, 5, NULL); zassert_equal(value, test_value, NULL); - for (value = 1; value != 0; value = (value << 1) & ((1ULL<<40)-1)) { + for (value = 1; value != 0; value = (value << 1) & ((1ULL << 40) - 1)) { len = encode_unsigned40(&apdu[0], value); zassert_equal(len, 5, NULL); test_value = ~0ULL; @@ -189,7 +189,7 @@ static void testBACnetUnsigned48(void) zassert_equal(len, 6, NULL); zassert_equal(value, test_value, NULL); - for (value = 1; value != 0; value = (value << 1) & ((1ULL<<48)-1)) { + for (value = 1; value != 0; value = (value << 1) & ((1ULL << 48) - 1)) { len = encode_unsigned48(&apdu[0], value); zassert_equal(len, 6, NULL); test_value = ~0ULL; @@ -230,7 +230,7 @@ static void testBACnetUnsigned56(void) zassert_equal(len, 7, NULL); zassert_equal(value, test_value, NULL); - for (value = 1; value != 0; value = (value << 1) & ((1ULL<<56)-1)) { + for (value = 1; value != 0; value = (value << 1) & ((1ULL << 56) - 1)) { len = encode_unsigned56(&apdu[0], value); zassert_equal(len, 7, NULL); test_value = ~0ULL; @@ -299,9 +299,9 @@ static void testBACnetUnsignedLength(void) int bits = (8 * sizeof(BACNET_UNSIGNED_INTEGER)); for (value = ~value; value > 0; value >>= 1) { - len = bacnet_unsigned_length(value); - zassert_equal(len, (bits + 7)/8, NULL); - bits -= 1; + len = bacnet_unsigned_length(value); + zassert_equal(len, (bits + 7) / 8, NULL); + bits -= 1; } len = bacnet_unsigned_length(0); zassert_equal(len, 1, NULL); @@ -461,26 +461,23 @@ static void testBACnetSigned32(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(bacint_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bacint_tests, - ztest_unit_test(testBACnetUnsigned16), - ztest_unit_test(testBACnetUnsigned24), - ztest_unit_test(testBACnetUnsigned32), - ztest_unit_test(testBACnetUnsigned40), - ztest_unit_test(testBACnetUnsigned48), - ztest_unit_test(testBACnetUnsigned56), - ztest_unit_test(testBACnetUnsigned64), - ztest_unit_test(testBACnetUnsignedLength), - ztest_unit_test(testBACnetSigned8), - ztest_unit_test(testBACnetSigned16), - ztest_unit_test(testBACnetSigned24), - ztest_unit_test(testBACnetSigned32) - ); + ztest_test_suite( + bacint_tests, ztest_unit_test(testBACnetUnsigned16), + ztest_unit_test(testBACnetUnsigned24), + ztest_unit_test(testBACnetUnsigned32), + ztest_unit_test(testBACnetUnsigned40), + ztest_unit_test(testBACnetUnsigned48), + ztest_unit_test(testBACnetUnsigned56), + ztest_unit_test(testBACnetUnsigned64), + ztest_unit_test(testBACnetUnsignedLength), + ztest_unit_test(testBACnetSigned8), ztest_unit_test(testBACnetSigned16), + ztest_unit_test(testBACnetSigned24), + ztest_unit_test(testBACnetSigned32)); ztest_run_test_suite(bacint_tests); } diff --git a/test/bacnet/bacreal/main.c b/test/bacnet/bacreal/main.c index 757ff39e..4e4fd82a 100644 --- a/test/bacnet/bacreal/main.c +++ b/test/bacnet/bacreal/main.c @@ -25,7 +25,7 @@ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include #include #include @@ -37,12 +37,10 @@ static void test_setup(void) { - } static void test_cleanup(void) { - } void testBACreal(Test *pTest) @@ -95,4 +93,3 @@ int main(void) return 0; } - diff --git a/test/bacnet/bacreal/src/main.c b/test/bacnet/bacreal/src/main.c index 09bddd3a..4ce9817c 100644 --- a/test/bacnet/bacreal/src/main.c +++ b/test/bacnet/bacreal/src/main.c @@ -60,16 +60,14 @@ static void testBACdouble(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(bacreal_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bacreal_tests, - ztest_unit_test(testBACreal), - ztest_unit_test(testBACdouble) - ); + ztest_test_suite( + bacreal_tests, ztest_unit_test(testBACreal), + ztest_unit_test(testBACdouble)); ztest_run_test_suite(bacreal_tests); } diff --git a/test/bacnet/bacstr/src/main.c b/test/bacnet/bacstr/src/main.c index 34f97b61..7395dcd2 100644 --- a/test/bacnet/bacstr/src/main.c +++ b/test/bacnet/bacstr/src/main.c @@ -69,7 +69,8 @@ static void testBitString(void) /* Set the first bit of bit_string2 and the last bit of bit_string3 to * be different */ bitstring_set_bit(&bit_string2, 0, !bitstring_bit(&bit_string, 0)); - bitstring_set_bit(&bit_string3, max_bit - 1, + bitstring_set_bit( + &bit_string3, max_bit - 1, !bitstring_bit(&bit_string, max_bit - 1)); zassert_false(bitstring_same(&bit_string, &bit_string2), NULL); zassert_false(bitstring_same(&bit_string, &bit_string3), NULL); @@ -80,8 +81,8 @@ static void testBitString(void) zassert_true(status, NULL); status = bitstring_same(&bit_string, &bit_string2); zassert_false(status, NULL); - zassert_equal(bitstring_bits_capacity(&bit_string), - (MAX_BITSTRING_BYTES * 8), NULL); + zassert_equal( + bitstring_bits_capacity(&bit_string), (MAX_BITSTRING_BYTES * 8), NULL); } /** @@ -107,10 +108,11 @@ static void testCharacterString(void) status = characterstring_init(&bacnet_string, CHARACTER_ANSI_X34, NULL, 0); zassert_true(status, NULL); zassert_equal(characterstring_length(&bacnet_string), 0, NULL); - zassert_equal(characterstring_encoding(&bacnet_string), CHARACTER_ANSI_X34, - NULL); + zassert_equal( + characterstring_encoding(&bacnet_string), CHARACTER_ANSI_X34, NULL); /* bounds check */ - status = characterstring_init(&bacnet_string, CHARACTER_ANSI_X34, NULL, + status = characterstring_init( + &bacnet_string, CHARACTER_ANSI_X34, NULL, characterstring_capacity(&bacnet_string) + 1); zassert_false(status, NULL); status = characterstring_truncate( @@ -173,10 +175,10 @@ static void testCharacterString(void) status = characterstring_ansi_same(&bacnet_string, NULL); zassert_true(status, NULL); /* alternate API for init and copy */ - status = characterstring_init_ansi_safe(&bacnet_string, value, - strlen(value)); - status = characterstring_ansi_copy(test_append_string, - sizeof(test_append_string), &bacnet_string); + status = + characterstring_init_ansi_safe(&bacnet_string, value, strlen(value)); + status = characterstring_ansi_copy( + test_append_string, sizeof(test_append_string), &bacnet_string); zassert_equal(strncmp(value, test_append_string, strlen(value)), 0, NULL); } @@ -196,10 +198,10 @@ static void testOctetString(void) uint8_t test_value_twin[MAX_APDU] = "PATRICIA"; uint8_t test_append_value[MAX_APDU] = " and the Kids"; uint8_t test_append_string[MAX_APDU] = ""; - const char * hex_value_valid = "1234567890ABCDEF"; - const char * hex_value_skips = "12:34:56:78:90:AB:CD:EF"; - const char * hex_value_odd = "1234567890ABCDE"; - char hex_value_long[MAX_APDU+MAX_APDU] = ""; + const char *hex_value_valid = "1234567890ABCDEF"; + const char *hex_value_skips = "12:34:56:78:90:AB:CD:EF"; + const char *hex_value_odd = "1234567890ABCDE"; + char hex_value_long[MAX_APDU + MAX_APDU] = ""; bool status = false; size_t length = 0; size_t test_length = 0; @@ -255,8 +257,8 @@ static void testOctetString(void) status = octetstring_init(&bacnet_string, &test_value[0], test_length); zassert_true(status, NULL); test_length = strlen((char *)test_value_twin); - status = octetstring_init(&bacnet_string_twin, &test_value_twin[0], - test_length); + status = + octetstring_init(&bacnet_string_twin, &test_value_twin[0], test_length); zassert_true(status, NULL); status = octetstring_value_same(&bacnet_string, &bacnet_string_twin); zassert_false(status, NULL); @@ -268,7 +270,7 @@ static void testOctetString(void) status = octetstring_value_same(NULL, NULL); zassert_false(status, NULL); /* self-healing length too long */ - bacnet_string.length = MAX_OCTET_STRING_BYTES+1; + bacnet_string.length = MAX_OCTET_STRING_BYTES + 1; length = octetstring_length(&bacnet_string); zassert_equal(length, MAX_OCTET_STRING_BYTES, NULL); /* valid case - empty string */ @@ -277,7 +279,7 @@ static void testOctetString(void) /* valid case - valid hex string */ status = octetstring_init_ascii_hex(&bacnet_string, hex_value_valid); zassert_true(status, NULL); - test_length = strlen(hex_value_valid)/2; + test_length = strlen(hex_value_valid) / 2; length = octetstring_length(&bacnet_string); zassert_equal(length, test_length, NULL); /* valid case - with non-hex characters interspersed */ @@ -290,7 +292,7 @@ static void testOctetString(void) zassert_false(status, NULL); /* invalid case - too long */ memset(hex_value_long, 'F', sizeof(hex_value_long)); - hex_value_long[sizeof(hex_value_long)-1] = 0; + hex_value_long[sizeof(hex_value_long) - 1] = 0; status = octetstring_init_ascii_hex(&bacnet_string, hex_value_long); zassert_false(status, NULL); /* invalid case - null arguments */ @@ -305,17 +307,14 @@ static void testOctetString(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(bacstr_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bacstr_tests, - ztest_unit_test(testBitString), - ztest_unit_test(testCharacterString), - ztest_unit_test(testOctetString) - ); + ztest_test_suite( + bacstr_tests, ztest_unit_test(testBitString), + ztest_unit_test(testCharacterString), ztest_unit_test(testOctetString)); ztest_run_test_suite(bacstr_tests); } diff --git a/test/bacnet/bactimevalue/src/main.c b/test/bacnet/bactimevalue/src/main.c index aeb1cb75..fb17c618 100644 --- a/test/bacnet/bactimevalue/src/main.c +++ b/test/bacnet/bactimevalue/src/main.c @@ -18,7 +18,6 @@ #include "bacnet/datetime.h" #include "bacnet/bacapp.h" - /** * @addtogroup bacnet_tests * @{ @@ -43,23 +42,25 @@ static void test_BACnetTimeValue(BACNET_TIME_VALUE *value) diff = datetime_compare_time(&test_value.Time, &value->Time); zassert_true(diff == 0, NULL); status = bacapp_same_value( - (BACNET_APPLICATION_DATA_VALUE *) &test_value.Value, - (BACNET_APPLICATION_DATA_VALUE *) &value->Value); + (BACNET_APPLICATION_DATA_VALUE *)&test_value.Value, + (BACNET_APPLICATION_DATA_VALUE *)&value->Value); zassert_true(status, NULL); len = bacnet_time_value_context_encode(apdu, tag_number, value); - apdu_len = bacnet_time_value_context_decode(apdu, len, tag_number, &test_value); + apdu_len = + bacnet_time_value_context_decode(apdu, len, tag_number, &test_value); zassert_true(len > 0, NULL); zassert_true(apdu_len > 0, NULL); diff = datetime_compare_time(&test_value.Time, &value->Time); zassert_true(diff == 0, NULL); status = bacapp_same_value( - (BACNET_APPLICATION_DATA_VALUE *) &test_value.Value, - (BACNET_APPLICATION_DATA_VALUE *) &value->Value); + (BACNET_APPLICATION_DATA_VALUE *)&test_value.Value, + (BACNET_APPLICATION_DATA_VALUE *)&value->Value); zassert_true(status, NULL); /* negative testing */ tag_number++; - apdu_len = bacnet_time_value_context_decode(apdu, len, tag_number, &test_value); + apdu_len = + bacnet_time_value_context_decode(apdu, len, tag_number, &test_value); zassert_true(apdu_len < 0, NULL); } @@ -75,12 +76,12 @@ static void test_BACnetTimeValues(void) BACNET_TIME_VALUE time_value = { 0 }; test_BACnetTimeValue(&time_value); - bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, "4.2", - &time_value.Value); + bacapp_parse_application_data( + BACNET_APPLICATION_TAG_REAL, "4.2", &time_value.Value); datetime_time_init_ascii(&time_value.Time, "12:00"); test_BACnetTimeValue(&time_value); - bacapp_parse_application_data(BACNET_APPLICATION_TAG_UNSIGNED_INT, "99999", - &time_value.Value); + bacapp_parse_application_data( + BACNET_APPLICATION_TAG_UNSIGNED_INT, "99999", &time_value.Value); datetime_time_init_ascii(&time_value.Time, "23:59:59"); test_BACnetTimeValue(&time_value); } @@ -93,9 +94,8 @@ ZTEST_SUITE(BACnetTimeValue_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(BACnetTimeValue_tests, - ztest_unit_test(test_BACnetTimeValues) - ); + ztest_test_suite( + BACnetTimeValue_tests, ztest_unit_test(test_BACnetTimeValues)); ztest_run_test_suite(BACnetTimeValue_tests); } diff --git a/test/bacnet/basic/bbmd/main.c b/test/bacnet/basic/bbmd/main.c index e677f9d0..5f4a1c95 100644 --- a/test/bacnet/basic/bbmd/main.c +++ b/test/bacnet/basic/bbmd/main.c @@ -97,7 +97,7 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len) Test_Sent_Message_Length = message_length; bvlc_address_copy(&Test_Sent_Message_Dest, dest); if ((header_len == 4) && (mtu_len >= 4)) { - memcpy(&Test_Sent_Message_Buffer[0], &mtu[4], mtu_len-4); + memcpy(&Test_Sent_Message_Buffer[0], &mtu[4], mtu_len - 4); Test_Sent_Message_Buffer_Length = mtu_len - 4; } else { Test_Sent_Message_Buffer_Length = 0; @@ -151,7 +151,6 @@ static void test_setup(void) static void test_cleanup(void) { - } /** @@ -159,13 +158,13 @@ static void test_cleanup(void) */ static void test_Initiate_Original_Broadcast_NPDU(Test *pTest) { - uint8_t pdu[MAX_MPDU] = {0}; + uint8_t pdu[MAX_MPDU] = { 0 }; int npdu_len = 0; int apdu_len = 0; int pdu_len = 0; - BACNET_ADDRESS dest = {0}; - BACNET_NPDU_DATA npdu_data = {0}; - uint8_t test_pdu[MAX_MPDU] = {0}; + BACNET_ADDRESS dest = { 0 }; + BACNET_NPDU_DATA npdu_data = { 0 }; + uint8_t test_pdu[MAX_MPDU] = { 0 }; uint16_t test_pdu_len = 0; int function_len = 0; @@ -174,23 +173,25 @@ static void test_Initiate_Original_Broadcast_NPDU(Test *pTest) dest.net = BACNET_BROADCAST_NETWORK; npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_len = npdu_encode_pdu(&pdu[0], &dest, &IUT.BACnet_Address, &npdu_data); - apdu_len = iam_encode_apdu(&pdu[npdu_len], IUT.Device_ID, MAX_APDU, - SEGMENTATION_NONE, BACNET_VENDOR_ID); + apdu_len = iam_encode_apdu( + &pdu[npdu_len], IUT.Device_ID, MAX_APDU, SEGMENTATION_NONE, + BACNET_VENDOR_ID); pdu_len = npdu_len + apdu_len; bvlc_send_pdu(&dest, &npdu_data, pdu, pdu_len); /* DA=Link Local Multicast Address */ - ct_test(pTest, !bvlc_address_different(&TD.BIP_Broadcast_Addr, - &Test_Sent_Message_Dest)); + ct_test( + pTest, + !bvlc_address_different( + &TD.BIP_Broadcast_Addr, &Test_Sent_Message_Dest)); /* SA = IUT - done in port layer */ /* Original-Broadcast-NPDU */ - ct_test(pTest, Test_Sent_Message_Type == - BVLC_ORIGINAL_BROADCAST_NPDU); + ct_test(pTest, Test_Sent_Message_Type == BVLC_ORIGINAL_BROADCAST_NPDU); if (Test_Sent_Message_Type == BVLC_ORIGINAL_BROADCAST_NPDU) { function_len = bvlc_decode_original_broadcast( - Test_Sent_Message_Buffer, Test_Sent_Message_Buffer_Length, - test_pdu, sizeof(test_pdu), &test_pdu_len); - printf("len=%u pdu[%u] test_pdu[%u]\n", - (unsigned)function_len, + Test_Sent_Message_Buffer, Test_Sent_Message_Buffer_Length, test_pdu, + sizeof(test_pdu), &test_pdu_len); + printf( + "len=%u pdu[%u] test_pdu[%u]\n", (unsigned)function_len, (unsigned)Test_Sent_Message_Buffer_Length, (unsigned)sizeof(test_pdu)); ct_test(pTest, function_len > 0); @@ -204,13 +205,15 @@ static void test_Initiate_Original_Broadcast_NPDU(Test *pTest) static void test_BBMD_Result(Test *pTest) { int result = 0; - uint16_t result_code[] = { BVLC_RESULT_SUCCESSFUL_COMPLETION, + uint16_t result_code[] = { + BVLC_RESULT_SUCCESSFUL_COMPLETION, BVLC_RESULT_WRITE_BROADCAST_DISTRIBUTION_TABLE_NAK, BVLC_RESULT_READ_BROADCAST_DISTRIBUTION_TABLE_NAK, BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK, BVLC_RESULT_READ_FOREIGN_DEVICE_TABLE_NAK, BVLC_RESULT_DELETE_FOREIGN_DEVICE_TABLE_ENTRY_NAK, - BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK }; + BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK + }; size_t result_code_max = sizeof(result_code) / sizeof(result_code[0]); uint16_t test_result_code = 0; uint8_t test_function_code = 0; diff --git a/test/bacnet/basic/bbmd6/src/main.c b/test/bacnet/basic/bbmd6/src/main.c index eceb886e..f05c613c 100644 --- a/test/bacnet/basic/bbmd6/src/main.c +++ b/test/bacnet/basic/bbmd6/src/main.c @@ -82,7 +82,7 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len) Test_Sent_Message_Length = message_length; bvlc6_address_copy(&Test_Sent_Message_Dest, dest); if ((header_len == 4) && (mtu_len >= 4)) { - memcpy(&Test_Sent_Message_Buffer[0], &mtu[4], mtu_len-4); + memcpy(&Test_Sent_Message_Buffer[0], &mtu[4], mtu_len - 4); Test_Sent_Message_Buffer_Length = mtu_len - 4; } else { Test_Sent_Message_Buffer_Length = 0; @@ -126,22 +126,21 @@ static void test_setup(void) { bvlc6_init(); /* BACnet_IPv6_Multicast_Address is FF02::BAC0 */ - bvlc6_address_set(&TD.BIP6_Broadcast_Addr, - BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0, + bvlc6_address_set( + &TD.BIP6_Broadcast_Addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0, BIP6_MULTICAST_GROUP_ID); - bvlc6_address_set(&TD.BIP6_Addr, - 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 0, + bvlc6_address_set( + &TD.BIP6_Addr, 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 0, BIP6_MULTICAST_GROUP_ID); TD.Device_ID = 12345; bvlc6_vmac_address_set(&TD.BACnet_Address, TD.Device_ID); - /* BACnet_IPv6_Multicast_Address is FF02::BAC0 */ - bvlc6_address_set(&IUT.BIP6_Broadcast_Addr, - BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0, + bvlc6_address_set( + &IUT.BIP6_Broadcast_Addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0, BIP6_MULTICAST_GROUP_ID); - bvlc6_address_set(&IUT.BIP6_Addr, - 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 1, + bvlc6_address_set( + &IUT.BIP6_Addr, 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 1, BIP6_MULTICAST_GROUP_ID); IUT.Device_ID = 54321; bvlc6_vmac_address_set(&IUT.BACnet_Address, IUT.Device_ID); @@ -157,13 +156,13 @@ static void test_cleanup(void) */ static void test_Initiate_Original_Broadcast_NPDU(void) { - uint8_t pdu[MAX_MPDU] = {0}; + uint8_t pdu[MAX_MPDU] = { 0 }; int npdu_len = 0; int apdu_len = 0; int pdu_len = 0; - BACNET_ADDRESS dest = {0}; - BACNET_NPDU_DATA npdu_data = {0}; - uint8_t test_pdu[MAX_MPDU] = {0}; + BACNET_ADDRESS dest = { 0 }; + BACNET_NPDU_DATA npdu_data = { 0 }; + uint8_t test_pdu[MAX_MPDU] = { 0 }; uint16_t test_pdu_len = 0; uint32_t test_vmac_src = 0; int function_len = 0; @@ -173,17 +172,17 @@ static void test_Initiate_Original_Broadcast_NPDU(void) dest.net = BACNET_BROADCAST_NETWORK; npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_len = npdu_encode_pdu(&pdu[0], &dest, &IUT.BACnet_Address, &npdu_data); - apdu_len = iam_encode_apdu(&pdu[npdu_len], IUT.Device_ID, MAX_APDU, - SEGMENTATION_NONE, BACNET_VENDOR_ID); + apdu_len = iam_encode_apdu( + &pdu[npdu_len], IUT.Device_ID, MAX_APDU, SEGMENTATION_NONE, + BACNET_VENDOR_ID); pdu_len = npdu_len + apdu_len; bvlc6_send_pdu(&dest, &npdu_data, pdu, pdu_len); /* DA=Link Local Multicast Address */ - assert(!bvlc6_address_different(&TD.BIP6_Broadcast_Addr, - &Test_Sent_Message_Dest)); + assert(!bvlc6_address_different( + &TD.BIP6_Broadcast_Addr, &Test_Sent_Message_Dest)); /* SA = IUT - done in port layer */ /* Original-Broadcast-NPDU */ - assert(Test_Sent_Message_Type == - BVLC6_ORIGINAL_BROADCAST_NPDU); + assert(Test_Sent_Message_Type == BVLC6_ORIGINAL_BROADCAST_NPDU); if (Test_Sent_Message_Type == BVLC6_ORIGINAL_BROADCAST_NPDU) { function_len = bvlc6_decode_original_broadcast( Test_Sent_Message_Buffer, Test_Sent_Message_Buffer_Length, @@ -203,7 +202,7 @@ static void test_Initiate_Original_Broadcast_NPDU(void) */ static void test_Execute_Virtual_Address_Resolution(void) { - uint8_t mtu[MAX_MPDU] = {0}; + uint8_t mtu[MAX_MPDU] = { 0 }; uint16_t mtu_len = 0; uint32_t test_vmac_src = 0; uint32_t test_vmac_dst = 0; @@ -214,13 +213,11 @@ static void test_Execute_Virtual_Address_Resolution(void) test_setup(); mtu_len = bvlc6_encode_virtual_address_resolution( &mtu[0], sizeof(mtu), TD.Device_ID); - result = bvlc6_bbmd_disabled_handler(&TD.BIP6_Addr, &TD.BACnet_Address, - &mtu[0], mtu_len); + result = bvlc6_bbmd_disabled_handler( + &TD.BIP6_Addr, &TD.BACnet_Address, &mtu[0], mtu_len); assert(result == 0); - assert(bvlc6_get_function_code() == - BVLC6_VIRTUAL_ADDRESS_RESOLUTION); - assert(Test_Sent_Message_Type == - BVLC6_VIRTUAL_ADDRESS_RESOLUTION_ACK); + assert(bvlc6_get_function_code() == BVLC6_VIRTUAL_ADDRESS_RESOLUTION); + assert(Test_Sent_Message_Type == BVLC6_VIRTUAL_ADDRESS_RESOLUTION_ACK); assert(VMAC_Find_By_Key(TD.Device_ID) != NULL); if (Test_Sent_Message_Type == BVLC6_VIRTUAL_ADDRESS_RESOLUTION_ACK) { function_len = bvlc6_decode_virtual_address_resolution_ack( @@ -235,34 +232,31 @@ static void test_Execute_Virtual_Address_Resolution(void) TD.Device_ID += 42; mtu_len = bvlc6_encode_virtual_address_resolution( &mtu[0], sizeof(mtu), TD.Device_ID); - result = bvlc6_bbmd_disabled_handler(&TD.BIP6_Addr, &TD.BACnet_Address, - &mtu[0], mtu_len); + result = bvlc6_bbmd_disabled_handler( + &TD.BIP6_Addr, &TD.BACnet_Address, &mtu[0], mtu_len); assert(result == 0); - assert(bvlc6_get_function_code() == - BVLC6_VIRTUAL_ADDRESS_RESOLUTION); + assert(bvlc6_get_function_code() == BVLC6_VIRTUAL_ADDRESS_RESOLUTION); assert(VMAC_Find_By_Key(TD.Device_ID) != NULL); assert(VMAC_Find_By_Key(old_device_id) == NULL); /* change IPv6 address */ mtu_len = bvlc6_encode_virtual_address_resolution( &mtu[0], sizeof(mtu), TD.Device_ID); - bvlc6_address_set(&TD.BIP6_Addr, - 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 42, + bvlc6_address_set( + &TD.BIP6_Addr, 0x2001, 0x0DBB, 0xAC10, 0xFE01, 0, 0, 42, BIP6_MULTICAST_GROUP_ID); - result = bvlc6_bbmd_disabled_handler(&TD.BIP6_Addr, &TD.BACnet_Address, - &mtu[0], mtu_len); + result = bvlc6_bbmd_disabled_handler( + &TD.BIP6_Addr, &TD.BACnet_Address, &mtu[0], mtu_len); assert(result == 0); - assert(bvlc6_get_function_code() == - BVLC6_VIRTUAL_ADDRESS_RESOLUTION); + assert(bvlc6_get_function_code() == BVLC6_VIRTUAL_ADDRESS_RESOLUTION); assert(VMAC_Find_By_Key(TD.Device_ID) != NULL); /* repeat with same device ID and address */ /* change IPv6 address */ mtu_len = bvlc6_encode_virtual_address_resolution( &mtu[0], sizeof(mtu), TD.Device_ID); - result = bvlc6_bbmd_disabled_handler(&TD.BIP6_Addr, &TD.BACnet_Address, - &mtu[0], mtu_len); + result = bvlc6_bbmd_disabled_handler( + &TD.BIP6_Addr, &TD.BACnet_Address, &mtu[0], mtu_len); assert(result == 0); - assert(bvlc6_get_function_code() == - BVLC6_VIRTUAL_ADDRESS_RESOLUTION); + assert(bvlc6_get_function_code() == BVLC6_VIRTUAL_ADDRESS_RESOLUTION); assert(VMAC_Find_By_Key(TD.Device_ID) != NULL); test_cleanup(); @@ -272,12 +266,14 @@ static void test_BBMD_Result(void) { int result = 0; uint32_t vmac_src = 0x1234; - uint16_t result_code[6] = { BVLC6_RESULT_SUCCESSFUL_COMPLETION, + uint16_t result_code[6] = { + BVLC6_RESULT_SUCCESSFUL_COMPLETION, BVLC6_RESULT_ADDRESS_RESOLUTION_NAK, BVLC6_RESULT_VIRTUAL_ADDRESS_RESOLUTION_NAK, BVLC6_RESULT_REGISTER_FOREIGN_DEVICE_NAK, BVLC6_RESULT_DELETE_FOREIGN_DEVICE_NAK, - BVLC6_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK }; + BVLC6_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK + }; uint16_t test_result_code = 0; uint8_t test_function_code = 0; BACNET_IP6_ADDRESS addr; @@ -286,7 +282,8 @@ static void test_BBMD_Result(void) uint8_t mtu[MAX_MPDU] = { 0 }; uint16_t mtu_len = 0; - bvlc6_address_set(&addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0, + bvlc6_address_set( + &addr, BIP6_MULTICAST_LINK_LOCAL, 0, 0, 0, 0, 0, 0, BIP6_MULTICAST_GROUP_ID); addr.port = 0xBAC0U; bvlc6_vmac_address_set(&src, vmac_src); diff --git a/test/bacnet/basic/binding/address/src/main.c b/test/bacnet/basic/binding/address/src/main.c index ec56f2f3..bb46aaf8 100644 --- a/test/bacnet/basic/binding/address/src/main.c +++ b/test/bacnet/basic/binding/address/src/main.c @@ -44,7 +44,8 @@ static void set_address(unsigned index, BACNET_ADDRESS *dest) } } -static void set_file_address(const char *pFilename, +static void set_file_address( + const char *pFilename, uint32_t device_id, BACNET_ADDRESS *dest, uint16_t max_apdu) @@ -114,7 +115,6 @@ static void testAddressFile(void) address_remove_device(device_id); zassert_equal(address_count(), 0, NULL); - /* create a fake address */ device_id = 55555; src.mac_len = 6; @@ -170,12 +170,14 @@ static void testAddress(void) set_address(i, &src); /* test the lookup by device id */ zassert_true( - address_get_by_device(device_id, &test_max_apdu, &test_address), NULL); + address_get_by_device(device_id, &test_max_apdu, &test_address), + NULL); zassert_equal(test_max_apdu, max_apdu, NULL); zassert_true(bacnet_address_same(&test_address, &src), NULL); zassert_true( address_get_by_index( - i, &test_device_id, &test_max_apdu, &test_address), NULL); + i, &test_device_id, &test_max_apdu, &test_address), + NULL); zassert_equal(test_device_id, device_id, NULL); zassert_equal(test_max_apdu, max_apdu, NULL); zassert_true(bacnet_address_same(&test_address, &src), NULL); @@ -189,7 +191,8 @@ static void testAddress(void) device_id = i * 255; address_remove_device(device_id); zassert_false( - address_get_by_device(device_id, &test_max_apdu, &test_address), NULL); + address_get_by_device(device_id, &test_max_apdu, &test_address), + NULL); count = address_count(); zassert_equal(count, (MAX_ADDRESS_CACHE - i - 1), NULL); } @@ -198,26 +201,21 @@ static void testAddress(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(address_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { #ifdef BACNET_ADDRESS_CACHE_FILE - ztest_test_suite(address_tests, - ztest_unit_test(testAddressFile), - ztest_unit_test(testAddress) - ); + ztest_test_suite( + address_tests, ztest_unit_test(testAddressFile), + ztest_unit_test(testAddress)); ztest_run_test_suite(address_tests); #else - ztest_test_suite(address_tests, - ztest_unit_test(testAddress) - ); + ztest_test_suite(address_tests, ztest_unit_test(testAddress)); ztest_run_test_suite(address_tests); #endif - } #endif diff --git a/test/bacnet/basic/object/acc/src/main.c b/test/bacnet/basic/object/acc/src/main.c index 7edd1868..ce0532da 100644 --- a/test/bacnet/basic/object/acc/src/main.c +++ b/test/bacnet/basic/object/acc/src/main.c @@ -29,8 +29,8 @@ static void test_Accumulator(void) 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}; + BACNET_READ_PROPERTY_DATA rpdata = { 0 }; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *required_property = NULL; BACNET_UNSIGNED_INTEGER unsigned_value = 1; @@ -48,14 +48,16 @@ static void test_Accumulator(void) zassert_true(len >= 0, NULL); if (len >= 0) { if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) { - test_len = bacapp_decode_context_data(rpdata.application_data, - len, &value, rpdata.object_property); + 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", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } zassert_equal(len, test_len, NULL); @@ -68,10 +70,10 @@ static void test_Accumulator(void) Accumulator_Present_Value_Set(0, unsigned_value); len = Accumulator_Read_Property(&rpdata); zassert_not_equal(len, 0, NULL); - test_len = bacapp_decode_application_data(rpdata.application_data, - len, &value); + test_len = bacapp_decode_application_data( + rpdata.application_data, len, &value); zassert_equal(len, test_len, NULL); - unsigned_value |= (unsigned_value<<1); + unsigned_value |= (unsigned_value << 1); } return; @@ -80,15 +82,12 @@ static void test_Accumulator(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(acc_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(acc_tests, - ztest_unit_test(test_Accumulator) - ); + ztest_test_suite(acc_tests, ztest_unit_test(test_Accumulator)); ztest_run_test_suite(acc_tests); } diff --git a/test/bacnet/basic/object/access_credential/src/main.c b/test/bacnet/basic/object/access_credential/src/main.c index c078845b..105a6b2f 100644 --- a/test/bacnet/basic/object/access_credential/src/main.c +++ b/test/bacnet/basic/object/access_credential/src/main.c @@ -49,8 +49,9 @@ static void testAccessCredential(void) zassert_true(len >= 0, NULL); if (len >= 0) { if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) { - test_len = bacapp_decode_context_data(rpdata.application_data, - len, &value, rpdata.object_property); + 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); @@ -61,7 +62,8 @@ static void testAccessCredential(void) } } if (len != test_len) { - fprintf(stderr, "property '%d': failed to decode!\n", + fprintf( + stderr, "property '%d': failed to decode!\n", rpdata.object_property); } zassert_true(len == test_len, NULL); @@ -75,7 +77,6 @@ static void testAccessCredential(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(access_credential_tests, NULL, NULL, NULL, NULL, NULL); #else diff --git a/test/bacnet/basic/object/access_door/src/main.c b/test/bacnet/basic/object/access_door/src/main.c index c5eea483..a7d0d91a 100644 --- a/test/bacnet/basic/object/access_door/src/main.c +++ b/test/bacnet/basic/object/access_door/src/main.c @@ -52,8 +52,9 @@ static void test_object_access_door(void) len = Access_Door_Read_Property(&rpdata); zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); zassert_true(test_len >= 0, NULL); } pRequired++; @@ -64,8 +65,9 @@ static void test_object_access_door(void) len = Access_Door_Read_Property(&rpdata); zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); zassert_true(test_len >= 0, NULL); } pOptional++; @@ -77,7 +79,6 @@ static void test_object_access_door(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(tests_object_access_door, NULL, NULL, NULL, NULL, NULL); #else diff --git a/test/bacnet/basic/object/access_point/src/main.c b/test/bacnet/basic/object/access_point/src/main.c index 683e9ac5..eeaf5cad 100644 --- a/test/bacnet/basic/object/access_point/src/main.c +++ b/test/bacnet/basic/object/access_point/src/main.c @@ -30,7 +30,7 @@ static void testAccessPoint(void) uint8_t apdu[MAX_APDU] = { 0 }; int len = 0, test_len = 0; BACNET_READ_PROPERTY_DATA rpdata = { 0 }; - BACNET_APPLICATION_DATA_VALUE value = {0}; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *required_property = NULL; unsigned count = 0; uint32_t object_instance = 0; @@ -50,10 +50,12 @@ static void testAccessPoint(void) len = Access_Point_Read_Property(&rpdata); if (len >= 0) { zassert_true(len >= 0, NULL); - test_len = bacapp_decode_known_property(rpdata.application_data, - len, &value, rpdata.object_type, rpdata.object_property); + 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", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } if (rpdata.object_property == PROP_ACCESS_DOORS) { @@ -62,7 +64,8 @@ static void testAccessPoint(void) } zassert_equal(len, test_len, NULL); } else { - printf("property '%s': failed to read!\n", + printf( + "property '%s': failed to read!\n", bactext_property_name(rpdata.object_property)); } required_property++; @@ -72,7 +75,6 @@ static void testAccessPoint(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(access_point_tests, NULL, NULL, NULL, NULL, NULL); #else diff --git a/test/bacnet/basic/object/access_rights/src/main.c b/test/bacnet/basic/object/access_rights/src/main.c index 0edcb6d5..39a3b5d2 100644 --- a/test/bacnet/basic/object/access_rights/src/main.c +++ b/test/bacnet/basic/object/access_rights/src/main.c @@ -52,15 +52,12 @@ static void testAccessRights(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(access_rights_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(access_rights_tests, - ztest_unit_test(testAccessRights) - ); + ztest_test_suite(access_rights_tests, ztest_unit_test(testAccessRights)); ztest_run_test_suite(access_rights_tests); } diff --git a/test/bacnet/basic/object/access_user/src/main.c b/test/bacnet/basic/object/access_user/src/main.c index 124b4d7a..9dd1ace0 100644 --- a/test/bacnet/basic/object/access_user/src/main.c +++ b/test/bacnet/basic/object/access_user/src/main.c @@ -52,15 +52,12 @@ static void testAccessUser(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(access_user_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(access_user_tests, - ztest_unit_test(testAccessUser) - ); + ztest_test_suite(access_user_tests, ztest_unit_test(testAccessUser)); ztest_run_test_suite(access_user_tests); } diff --git a/test/bacnet/basic/object/access_zone/src/main.c b/test/bacnet/basic/object/access_zone/src/main.c index e482b255..3c23ec0b 100644 --- a/test/bacnet/basic/object/access_zone/src/main.c +++ b/test/bacnet/basic/object/access_zone/src/main.c @@ -52,15 +52,12 @@ static void testAccessZone(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(access_zone_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(access_zone_tests, - ztest_unit_test(testAccessZone) - ); + ztest_test_suite(access_zone_tests, ztest_unit_test(testAccessZone)); ztest_run_test_suite(access_zone_tests); } diff --git a/test/bacnet/basic/object/ai/src/main.c b/test/bacnet/basic/object/ai/src/main.c index b22b41b0..a374e703 100644 --- a/test/bacnet/basic/object/ai/src/main.c +++ b/test/bacnet/basic/object/ai/src/main.c @@ -37,11 +37,8 @@ static void testAnalogInput(void) test_object_instance = Analog_Input_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_ANALOG_INPUT, - object_instance, - Analog_Input_Property_Lists, - Analog_Input_Read_Property, - Analog_Input_Write_Property, + OBJECT_ANALOG_INPUT, object_instance, Analog_Input_Property_Lists, + Analog_Input_Read_Property, Analog_Input_Write_Property, skip_fail_property_list); status = Analog_Input_Delete(object_instance); zassert_true(status, NULL); @@ -50,15 +47,12 @@ static void testAnalogInput(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(ai_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(ai_tests, - ztest_unit_test(testAnalogInput) - ); + ztest_test_suite(ai_tests, ztest_unit_test(testAnalogInput)); ztest_run_test_suite(ai_tests); } diff --git a/test/bacnet/basic/object/ai/stubs.c b/test/bacnet/basic/object/ai/stubs.c index 5bb693d2..3b2aa854 100644 --- a/test/bacnet/basic/object/ai/stubs.c +++ b/test/bacnet/basic/object/ai/stubs.c @@ -18,7 +18,8 @@ #include "bacnet/get_alarm_sum.h" #include "bacnet/npdu.h" -bool datetime_local(BACNET_DATE *bdate, +bool datetime_local( + BACNET_DATE *bdate, BACNET_TIME *btime, int16_t *utc_offset_minutes, bool *dst_active) diff --git a/test/bacnet/basic/object/ao/src/main.c b/test/bacnet/basic/object/ao/src/main.c index fa53f982..7e887130 100644 --- a/test/bacnet/basic/object/ao/src/main.c +++ b/test/bacnet/basic/object/ao/src/main.c @@ -37,11 +37,8 @@ static void testAnalogOutput(void) test_object_instance = Analog_Output_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_ANALOG_OUTPUT, - object_instance, - Analog_Output_Property_Lists, - Analog_Output_Read_Property, - Analog_Output_Write_Property, + OBJECT_ANALOG_OUTPUT, object_instance, Analog_Output_Property_Lists, + Analog_Output_Read_Property, Analog_Output_Write_Property, skip_fail_property_list); status = Analog_Output_Delete(object_instance); zassert_true(status, NULL); @@ -50,15 +47,12 @@ static void testAnalogOutput(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(ao_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(ao_tests, - ztest_unit_test(testAnalogOutput) - ); + ztest_test_suite(ao_tests, ztest_unit_test(testAnalogOutput)); ztest_run_test_suite(ao_tests); } diff --git a/test/bacnet/basic/object/av/src/main.c b/test/bacnet/basic/object/av/src/main.c index 97e10ab8..b46f4587 100644 --- a/test/bacnet/basic/object/av/src/main.c +++ b/test/bacnet/basic/object/av/src/main.c @@ -37,11 +37,8 @@ static void testAnalog_Value(void) test_object_instance = Analog_Value_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_ANALOG_VALUE, - object_instance, - Analog_Value_Property_Lists, - Analog_Value_Read_Property, - Analog_Value_Write_Property, + OBJECT_ANALOG_VALUE, object_instance, Analog_Value_Property_Lists, + Analog_Value_Read_Property, Analog_Value_Write_Property, skip_fail_property_list); status = Analog_Value_Delete(object_instance); zassert_true(status, NULL); @@ -50,15 +47,12 @@ static void testAnalog_Value(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(av_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(av_tests, - ztest_unit_test(testAnalog_Value) - ); + ztest_test_suite(av_tests, ztest_unit_test(testAnalog_Value)); ztest_run_test_suite(av_tests); } diff --git a/test/bacnet/basic/object/av/stubs.c b/test/bacnet/basic/object/av/stubs.c index 5bb693d2..3b2aa854 100644 --- a/test/bacnet/basic/object/av/stubs.c +++ b/test/bacnet/basic/object/av/stubs.c @@ -18,7 +18,8 @@ #include "bacnet/get_alarm_sum.h" #include "bacnet/npdu.h" -bool datetime_local(BACNET_DATE *bdate, +bool datetime_local( + BACNET_DATE *bdate, BACNET_TIME *btime, int16_t *utc_offset_minutes, bool *dst_active) diff --git a/test/bacnet/basic/object/bacfile/src/main.c b/test/bacnet/basic/object/bacfile/src/main.c index 2f0bad33..c1f67343 100644 --- a/test/bacnet/basic/object/bacfile/src/main.c +++ b/test/bacnet/basic/object/bacfile/src/main.c @@ -29,7 +29,7 @@ static void test_BACnet_File_Object(void) uint8_t apdu[MAX_APDU] = { 0 }; int len = 0, test_len = 0; BACNET_READ_PROPERTY_DATA rpdata = { 0 }; - BACNET_APPLICATION_DATA_VALUE value = {0}; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *required_property = NULL; const uint32_t instance = 1; @@ -46,15 +46,18 @@ static void test_BACnet_File_Object(void) rpdata.object_property = *required_property; len = bacfile_read_property(&rpdata); if (len < 0) { - printf("property %u: failed to read!\n", + 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); + 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", + printf( + "property %u: failed to decode!\n", (unsigned)rpdata.object_property); } zassert_equal(len, test_len, NULL); @@ -68,15 +71,12 @@ static void test_BACnet_File_Object(void) * @} */ - #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_test_suite(bacfile_tests, ztest_unit_test(test_BACnet_File_Object)); ztest_run_test_suite(bacfile_tests); } diff --git a/test/bacnet/basic/object/bi/src/main.c b/test/bacnet/basic/object/bi/src/main.c index abd0bc23..f6d69a2b 100644 --- a/test/bacnet/basic/object/bi/src/main.c +++ b/test/bacnet/basic/object/bi/src/main.c @@ -38,11 +38,8 @@ static void testBinaryInput(void) test_object_instance = Binary_Input_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_BINARY_INPUT, - object_instance, - Binary_Input_Property_Lists, - Binary_Input_Read_Property, - Binary_Input_Write_Property, + OBJECT_BINARY_INPUT, object_instance, Binary_Input_Property_Lists, + Binary_Input_Read_Property, Binary_Input_Write_Property, skip_fail_property_list); status = Binary_Input_Delete(object_instance); zassert_true(status, NULL); @@ -51,15 +48,12 @@ static void testBinaryInput(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(bi_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bi_tests, - ztest_unit_test(testBinaryInput) - ); + ztest_test_suite(bi_tests, ztest_unit_test(testBinaryInput)); ztest_run_test_suite(bi_tests); } diff --git a/test/bacnet/basic/object/blo/src/main.c b/test/bacnet/basic/object/blo/src/main.c index 9de91912..416575d4 100644 --- a/test/bacnet/basic/object/blo/src/main.c +++ b/test/bacnet/basic/object/blo/src/main.c @@ -57,15 +57,17 @@ static void testBinaryLightingOutput(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Binary_Lighting_Output_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len >= 0) { - test_len = bacapp_decode_known_property(rpdata.application_data, - len, &value, rpdata.object_type, rpdata.object_property); + test_len = bacapp_decode_known_property( + rpdata.application_data, len, &value, rpdata.object_type, + rpdata.object_property); if (rpdata.object_property != PROP_PRIORITY_ARRAY) { - zassert_equal(len, test_len, - "property '%s': failed to decode!\n", + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } /* check WriteProperty properties */ @@ -79,8 +81,8 @@ static void testBinaryLightingOutput(void) status = Binary_Lighting_Output_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -91,13 +93,16 @@ static void testBinaryLightingOutput(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Binary_Lighting_Output_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -110,8 +115,8 @@ static void testBinaryLightingOutput(void) status = Binary_Lighting_Output_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -137,7 +142,8 @@ static struct { BACNET_BINARY_LIGHTING_PV pv; uint32_t count; } BLO_Value; -static void Binary_Lighting_Output_Write_Value_Handler(uint32_t object_instance, +static void Binary_Lighting_Output_Write_Value_Handler( + uint32_t object_instance, BACNET_BINARY_LIGHTING_PV old_value, BACNET_BINARY_LIGHTING_PV value) { @@ -210,8 +216,9 @@ static void testBinaryLightingOutputBlink(void) zassert_equal(expect_pv, test_pv, NULL); test_priority = Binary_Lighting_Output_Present_Value_Priority(object_instance); - zassert_equal(wpdata.priority, test_priority, - "priority=%u test_priority=%u", wpdata.priority, test_priority); + zassert_equal( + wpdata.priority, test_priority, "priority=%u test_priority=%u", + wpdata.priority, test_priority); zassert_equal(BLO_Blink.count, 0, NULL); zassert_equal(BLO_Value.count, 1, "count=%u", BLO_Value.count); zassert_equal(BLO_Value.pv, expect_pv, NULL); @@ -232,8 +239,9 @@ static void testBinaryLightingOutputBlink(void) zassert_equal(expect_pv, test_pv, NULL); test_priority = Binary_Lighting_Output_Present_Value_Priority(object_instance); - zassert_equal(wpdata.priority, test_priority, - "priority=%u test_priority=%u", wpdata.priority, test_priority); + zassert_equal( + wpdata.priority, test_priority, "priority=%u test_priority=%u", + wpdata.priority, test_priority); zassert_equal(BLO_Blink.count, 0, NULL); zassert_equal(BLO_Value.count, 2, "count=%u", BLO_Value.count); zassert_equal(BLO_Value.pv, expect_pv, NULL); @@ -254,8 +262,9 @@ static void testBinaryLightingOutputBlink(void) zassert_equal(expect_pv, test_pv, "pv=%u", test_pv); test_priority = Binary_Lighting_Output_Present_Value_Priority(object_instance); - zassert_equal(wpdata.priority, test_priority, - "priority=%u test_priority=%u", wpdata.priority, test_priority); + zassert_equal( + wpdata.priority, test_priority, "priority=%u test_priority=%u", + wpdata.priority, test_priority); zassert_equal(BLO_Blink.count, 0, NULL); zassert_equal(BLO_Value.count, 2, "count=%u", BLO_Value.count); zassert_equal(BLO_Value.pv, expect_pv, NULL); @@ -271,7 +280,8 @@ ZTEST_SUITE(blo_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(blo_tests, ztest_unit_test(testBinaryLightingOutput), + ztest_test_suite( + blo_tests, ztest_unit_test(testBinaryLightingOutput), ztest_unit_test(testBinaryLightingOutputBlink)); ztest_run_test_suite(blo_tests); diff --git a/test/bacnet/basic/object/bo/src/main.c b/test/bacnet/basic/object/bo/src/main.c index b353904b..e878a61b 100644 --- a/test/bacnet/basic/object/bo/src/main.c +++ b/test/bacnet/basic/object/bo/src/main.c @@ -37,11 +37,8 @@ static void testBinaryOutput(void) test_object_instance = Binary_Output_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_BINARY_OUTPUT, - object_instance, - Binary_Output_Property_Lists, - Binary_Output_Read_Property, - Binary_Output_Write_Property, + OBJECT_BINARY_OUTPUT, object_instance, Binary_Output_Property_Lists, + Binary_Output_Read_Property, Binary_Output_Write_Property, skip_fail_property_list); status = Binary_Output_Delete(object_instance); zassert_true(status, NULL); @@ -50,15 +47,12 @@ static void testBinaryOutput(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(bo_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bo_tests, - ztest_unit_test(testBinaryOutput) - ); + ztest_test_suite(bo_tests, ztest_unit_test(testBinaryOutput)); ztest_run_test_suite(bo_tests); } diff --git a/test/bacnet/basic/object/bv/src/main.c b/test/bacnet/basic/object/bv/src/main.c index 84555798..9653b696 100644 --- a/test/bacnet/basic/object/bv/src/main.c +++ b/test/bacnet/basic/object/bv/src/main.c @@ -39,11 +39,8 @@ static void testBinary_Value(void) test_object_instance = Binary_Value_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_BINARY_VALUE, - object_instance, - Binary_Value_Property_Lists, - Binary_Value_Read_Property, - Binary_Value_Write_Property, + OBJECT_BINARY_VALUE, object_instance, Binary_Value_Property_Lists, + Binary_Value_Read_Property, Binary_Value_Write_Property, skip_fail_property_list); status = Binary_Value_Delete(object_instance); zassert_true(status, NULL); @@ -52,15 +49,12 @@ static void testBinary_Value(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(bv_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bv_tests, - ztest_unit_test(testBinary_Value) - ); + ztest_test_suite(bv_tests, ztest_unit_test(testBinary_Value)); ztest_run_test_suite(bv_tests); } diff --git a/test/bacnet/basic/object/calendar/src/main.c b/test/bacnet/basic/object/calendar/src/main.c index af58e18e..6f8f76fb 100644 --- a/test/bacnet/basic/object/calendar/src/main.c +++ b/test/bacnet/basic/object/calendar/src/main.c @@ -29,7 +29,7 @@ static void testCalendar(void) int len = 0, test_len = 0; BACNET_READ_PROPERTY_DATA rpdata = { 0 }; BACNET_WRITE_PROPERTY_DATA wpdata = { 0 }; - BACNET_APPLICATION_DATA_VALUE value = {0}; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *pRequired = NULL; const int *pOptional = NULL; const int *pProprietary = NULL; @@ -57,14 +57,16 @@ static void testCalendar(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Calendar_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len >= 0) { - test_len = bacapp_decode_known_property(rpdata.application_data, - len, &value, rpdata.object_type, rpdata.object_property); - zassert_equal(len, test_len, - "property '%s': failed to decode!\n", + test_len = bacapp_decode_known_property( + rpdata.application_data, len, &value, rpdata.object_type, + rpdata.object_property); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -77,8 +79,8 @@ static void testCalendar(void) status = Calendar_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -89,13 +91,16 @@ static void testCalendar(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Calendar_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -108,8 +113,8 @@ static void testCalendar(void) status = Calendar_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -182,7 +187,7 @@ static void testPresentValue(void) zassert_true(Calendar_Present_Value(instance), NULL); if (date.day > 1) { - value->type.DateRange.startdate.day --; + value->type.DateRange.startdate.day--; value->type.DateRange.enddate.day = date.day; zassert_true(Calendar_Present_Value(instance), NULL); } @@ -214,7 +219,7 @@ static void testPresentValue(void) value->type.WeekNDay.weekofmonth = (date.day - 1) % 7 + 1; zassert_true(Calendar_Present_Value(instance), NULL); value->type.WeekNDay.weekofmonth++; - if (value->type.WeekNDay.weekofmonth >5) + if (value->type.WeekNDay.weekofmonth > 5) value->type.WeekNDay.weekofmonth = 1; zassert_false(Calendar_Present_Value(instance), NULL); value->type.WeekNDay.weekofmonth = 0xff; @@ -241,10 +246,9 @@ ZTEST_SUITE(bacnet_calendar, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(calendar_tests, - ztest_unit_test(testCalendar), - ztest_unit_test(testPresentValue) - ); + ztest_test_suite( + calendar_tests, ztest_unit_test(testCalendar), + ztest_unit_test(testPresentValue)); ztest_run_test_suite(calendar_tests); } diff --git a/test/bacnet/basic/object/calendar/stubs.c b/test/bacnet/basic/object/calendar/stubs.c index b213a96e..feef7194 100644 --- a/test/bacnet/basic/object/calendar/stubs.c +++ b/test/bacnet/basic/object/calendar/stubs.c @@ -11,10 +11,10 @@ #include "bacnet/datetime.h" bool datetime_local( - BACNET_DATE * bdate, - BACNET_TIME * btime, - int16_t * utc_offset_minutes, - bool * dst_active) + BACNET_DATE *bdate, + BACNET_TIME *btime, + int16_t *utc_offset_minutes, + bool *dst_active) { bdate->year = 2023; bdate->month = 6; diff --git a/test/bacnet/basic/object/channel/src/main.c b/test/bacnet/basic/object/channel/src/main.c index 8243c382..9b200fe6 100644 --- a/test/bacnet/basic/object/channel/src/main.c +++ b/test/bacnet/basic/object/channel/src/main.c @@ -55,20 +55,23 @@ static void test_Channel_ReadProperty(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Channel_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); if ((rpdata.object_property == PROP_PRIORITY_ARRAY) || (rpdata.object_property == PROP_CONTROL_GROUPS) || (rpdata.object_property == - PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES)) { + PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES)) { /* FIXME: known fail to decode */ len = test_len; } - zassert_equal(len, test_len, "property '%s': failed to decode!\n", + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -81,8 +84,8 @@ static void test_Channel_ReadProperty(void) status = Channel_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -93,13 +96,16 @@ static void test_Channel_ReadProperty(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Channel_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -112,8 +118,8 @@ static void test_Channel_ReadProperty(void) status = Channel_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } diff --git a/test/bacnet/basic/object/color_object/src/main.c b/test/bacnet/basic/object/color_object/src/main.c index 71d9e918..415f61c4 100644 --- a/test/bacnet/basic/object/color_object/src/main.c +++ b/test/bacnet/basic/object/color_object/src/main.c @@ -55,13 +55,16 @@ static void testColorObject(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Color_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len >= 0) { - test_len = bacapp_decode_known_property(rpdata.application_data, - len, &value, rpdata.object_type, rpdata.object_property); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", + test_len = bacapp_decode_known_property( + rpdata.application_data, len, &value, rpdata.object_type, + rpdata.object_property); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -74,8 +77,8 @@ static void testColorObject(void) status = Color_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -86,13 +89,16 @@ static void testColorObject(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Color_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -105,8 +111,8 @@ static void testColorObject(void) status = Color_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } diff --git a/test/bacnet/basic/object/color_temperature/src/main.c b/test/bacnet/basic/object/color_temperature/src/main.c index a74e0467..caeee6ac 100644 --- a/test/bacnet/basic/object/color_temperature/src/main.c +++ b/test/bacnet/basic/object/color_temperature/src/main.c @@ -10,7 +10,6 @@ #include #include - /** * @addtogroup bacnet_tests * @{ @@ -28,8 +27,8 @@ static void testColorTemperature(void) 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}; + BACNET_READ_PROPERTY_DATA rpdata = { 0 }; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *pRequired = NULL; const int *pOptional = NULL; const int *pProprietary = NULL; @@ -51,14 +50,17 @@ static void testColorTemperature(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Color_Temperature_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len >= 0) { - test_len = bacapp_decode_known_property(rpdata.application_data, - len, &value, rpdata.object_type, rpdata.object_property); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", - bactext_property_name(rpdata.object_property)); + test_len = bacapp_decode_known_property( + rpdata.application_data, len, &value, rpdata.object_type, + rpdata.object_property); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", + bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; wpdata.object_instance = rpdata.object_instance; @@ -70,8 +72,8 @@ static void testColorTemperature(void) status = Color_Temperature_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -82,15 +84,17 @@ static void testColorTemperature(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Color_Temperature_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { test_len = bacapp_decode_application_data( - rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", - bactext_property_name(rpdata.object_property)); + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", + bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; wpdata.object_instance = rpdata.object_instance; @@ -102,8 +106,8 @@ static void testColorTemperature(void) status = Color_Temperature_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -125,15 +129,13 @@ static void testColorTemperature(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(color_temperature_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(color_temperature_tests, - ztest_unit_test(testColorTemperature) - ); + ztest_test_suite( + color_temperature_tests, ztest_unit_test(testColorTemperature)); ztest_run_test_suite(color_temperature_tests); } diff --git a/test/bacnet/basic/object/command/src/main.c b/test/bacnet/basic/object/command/src/main.c index 7aff9576..802dad88 100644 --- a/test/bacnet/basic/object/command/src/main.c +++ b/test/bacnet/basic/object/command/src/main.c @@ -34,12 +34,8 @@ static void test_object_command(void) zassert_true(count > 0, NULL); object_instance = Command_Index_To_Instance(0); bacnet_object_properties_read_write_test( - OBJECT_COMMAND, - object_instance, - Command_Property_Lists, - Command_Read_Property, - Command_Write_Property, - skip_fail_property_list); + OBJECT_COMMAND, object_instance, Command_Property_Lists, + Command_Read_Property, Command_Write_Property, skip_fail_property_list); } /** * @} diff --git a/test/bacnet/basic/object/credential_data_input/src/main.c b/test/bacnet/basic/object/credential_data_input/src/main.c index 22b54997..98b3cce6 100644 --- a/test/bacnet/basic/object/credential_data_input/src/main.c +++ b/test/bacnet/basic/object/credential_data_input/src/main.c @@ -27,37 +27,31 @@ static void testCredentialDataInput(void) { unsigned count = 0; uint32_t object_instance = 0; - const int skip_fail_property_list[] = { - PROP_PRESENT_VALUE, - PROP_UPDATE_TIME, - PROP_SUPPORTED_FORMATS, - -1 }; + const int skip_fail_property_list[] = { PROP_PRESENT_VALUE, + PROP_UPDATE_TIME, + PROP_SUPPORTED_FORMATS, -1 }; Credential_Data_Input_Init(); count = Credential_Data_Input_Count(); zassert_true(count > 0, NULL); object_instance = Credential_Data_Input_Index_To_Instance(0); bacnet_object_properties_read_write_test( - OBJECT_CREDENTIAL_DATA_INPUT, - object_instance, + OBJECT_CREDENTIAL_DATA_INPUT, object_instance, Credential_Data_Input_Property_Lists, Credential_Data_Input_Read_Property, - Credential_Data_Input_Write_Property, - skip_fail_property_list); + Credential_Data_Input_Write_Property, skip_fail_property_list); } /** * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(credential_data_input_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(credential_data_input_tests, - ztest_unit_test(testCredentialDataInput) - ); + ztest_test_suite( + credential_data_input_tests, ztest_unit_test(testCredentialDataInput)); ztest_run_test_suite(credential_data_input_tests); } diff --git a/test/bacnet/basic/object/csv/src/main.c b/test/bacnet/basic/object/csv/src/main.c index 389ca0c2..17556861 100644 --- a/test/bacnet/basic/object/csv/src/main.c +++ b/test/bacnet/basic/object/csv/src/main.c @@ -24,7 +24,7 @@ static void testCharacterString_Value(void) uint8_t apdu[MAX_APDU] = { 0 }; int len = 0, test_len = 0; BACNET_READ_PROPERTY_DATA rpdata = { 0 }; - BACNET_APPLICATION_DATA_VALUE value = {0}; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *pRequired = NULL; const int *pOptional = NULL; const int *pProprietary = NULL; @@ -47,10 +47,12 @@ static void testCharacterString_Value(void) len = CharacterString_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); + 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", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } if (rpdata.object_property == PROP_PRIORITY_ARRAY) { @@ -59,7 +61,8 @@ static void testCharacterString_Value(void) } zassert_equal(len, test_len, NULL); } else { - printf("property '%s': failed to read!\n", + printf( + "property '%s': failed to read!\n", bactext_property_name(rpdata.object_property)); } pRequired++; @@ -70,15 +73,18 @@ static void testCharacterString_Value(void) len = CharacterString_Value_Read_Property(&rpdata); zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); if (len != test_len) { - printf("property '%s': failed to decode!\n", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } zassert_true(test_len >= 0, NULL); } else { - printf("property '%s': failed to read!\n", + printf( + "property '%s': failed to read!\n", bactext_property_name(rpdata.object_property)); } pOptional++; diff --git a/test/bacnet/basic/object/device/src/main.c b/test/bacnet/basic/object/device/src/main.c index 769df022..4e77744d 100644 --- a/test/bacnet/basic/object/device/src/main.c +++ b/test/bacnet/basic/object/device/src/main.c @@ -48,18 +48,21 @@ static void test_Device_Data_Sharing(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Device_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); if ((rpdata.object_property == PROP_PRIORITY_ARRAY) || (rpdata.object_property == PROP_OBJECT_LIST)) { /* FIXME: known fail to decode */ len = test_len; } - zassert_equal(test_len, len, "property '%s': failed to decode!\n", + zassert_equal( + test_len, len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -72,8 +75,8 @@ static void test_Device_Data_Sharing(void) status = Device_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -84,17 +87,21 @@ static void test_Device_Data_Sharing(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Device_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); if (len != test_len) { - printf("property '%s': failed to decode!\n", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } - zassert_equal(test_len, len, "property '%s': failed to decode!\n", + zassert_equal( + test_len, len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -107,8 +114,8 @@ static void test_Device_Data_Sharing(void) status = Device_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -161,9 +168,11 @@ static void testDevice(void) status = Device_Reinitialize_Password_Set(NULL); status = Device_Reinitialize(&rd_data); zassert_true(status, NULL); - zassert_equal(rd_data.error_class, ERROR_CLASS_DEVICE, "error-class=%s", + zassert_equal( + rd_data.error_class, ERROR_CLASS_DEVICE, "error-class=%s", bactext_error_class_name(rd_data.error_class)); - zassert_equal(rd_data.error_code, ERROR_CODE_SUCCESS, "error-code=%s", + zassert_equal( + rd_data.error_code, ERROR_CODE_SUCCESS, "error-code=%s", bactext_error_code_name(rd_data.error_code)); /* Reinitialize with device valid password, service no password */ status = Device_Reinitialize_Password_Set("valid"); @@ -172,19 +181,23 @@ static void testDevice(void) zassert_true(status, NULL); status = Device_Reinitialize(&rd_data); zassert_false(status, NULL); - zassert_equal(rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s", + zassert_equal( + rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s", bactext_error_class_name(rd_data.error_class)); - zassert_equal(rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE, - "error-code=%s", bactext_error_code_name(rd_data.error_code)); + zassert_equal( + rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE, "error-code=%s", + bactext_error_code_name(rd_data.error_code)); /* Reinitialize with device valid password, service invalid password */ status = characterstring_init_ansi(&rd_data.password, "invalid"); zassert_true(status, NULL); status = Device_Reinitialize(&rd_data); zassert_false(status, NULL); - zassert_equal(rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s", + zassert_equal( + rd_data.error_class, ERROR_CLASS_SECURITY, "error-class=%s", bactext_error_class_name(rd_data.error_class)); - zassert_equal(rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE, - "error-code=%s", bactext_error_code_name(rd_data.error_code)); + zassert_equal( + rd_data.error_code, ERROR_CODE_PASSWORD_FAILURE, "error-code=%s", + bactext_error_code_name(rd_data.error_code)); /* Reinitialize with device valid password, service valid password */ characterstring_init_ansi(&rd_data.password, "valid"); status = Device_Reinitialize(&rd_data); @@ -193,20 +206,24 @@ static void testDevice(void) characterstring_init_ansi(&rd_data.password, "abcdefghijklmnopqrstuvwxyz"); status = Device_Reinitialize(&rd_data); zassert_false(status, NULL); - zassert_equal(rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s", + zassert_equal( + rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s", bactext_error_class_name(rd_data.error_class)); - zassert_equal(rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE, - "error-code=%s", bactext_error_code_name(rd_data.error_code)); + zassert_equal( + rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE, "error-code=%s", + bactext_error_code_name(rd_data.error_code)); /* Reinitialize with device no password, unsupported state */ status = Device_Reinitialize_Password_Set(NULL); zassert_true(status, NULL); rd_data.state = BACNET_REINIT_MAX; status = Device_Reinitialize(&rd_data); zassert_false(status, NULL); - zassert_equal(rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s", + zassert_equal( + rd_data.error_class, ERROR_CLASS_SERVICES, "error-class=%s", bactext_error_class_name(rd_data.error_class)); - zassert_equal(rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE, - "error-code=%s", bactext_error_code_name(rd_data.error_code)); + zassert_equal( + rd_data.error_code, ERROR_CODE_PARAMETER_OUT_OF_RANGE, "error-code=%s", + bactext_error_code_name(rd_data.error_code)); return; } @@ -219,7 +236,8 @@ ZTEST_SUITE(device_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(device_tests, ztest_unit_test(testDevice), + ztest_test_suite( + device_tests, ztest_unit_test(testDevice), ztest_unit_test(test_Device_Data_Sharing)); ztest_run_test_suite(device_tests); diff --git a/test/bacnet/basic/object/device/stubs.c b/test/bacnet/basic/object/device/stubs.c index f542650c..21bc7e71 100644 --- a/test/bacnet/basic/object/device/stubs.c +++ b/test/bacnet/basic/object/device/stubs.c @@ -36,22 +36,22 @@ void datetime_init(void) } bool datetime_local( - BACNET_DATE * bdate, - BACNET_TIME * btime, - int16_t * utc_offset_minutes, - bool * dst_active) + BACNET_DATE *bdate, + BACNET_TIME *btime, + int16_t *utc_offset_minutes, + bool *dst_active) { return true; } -void bip_get_my_address(BACNET_ADDRESS * my_address) +void bip_get_my_address(BACNET_ADDRESS *my_address) { } int bip_send_pdu( - BACNET_ADDRESS * dest, - BACNET_NPDU_DATA * npdu_data, - uint8_t * pdu, + BACNET_ADDRESS *dest, + BACNET_NPDU_DATA *npdu_data, + uint8_t *pdu, unsigned pdu_len) { return 0; diff --git a/test/bacnet/basic/object/iv/src/main.c b/test/bacnet/basic/object/iv/src/main.c index acaf7075..12c1fd4b 100644 --- a/test/bacnet/basic/object/iv/src/main.c +++ b/test/bacnet/basic/object/iv/src/main.c @@ -24,7 +24,7 @@ static void testInteger_Value(void) uint8_t apdu[MAX_APDU] = { 0 }; int len = 0, test_len = 0; BACNET_READ_PROPERTY_DATA rpdata = { 0 }; - BACNET_APPLICATION_DATA_VALUE value = {0}; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *pRequired = NULL; const int *pOptional = NULL; const int *pProprietary = NULL; @@ -47,10 +47,12 @@ static void testInteger_Value(void) len = Integer_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); + 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", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } if (rpdata.object_property == PROP_PRIORITY_ARRAY) { @@ -59,7 +61,8 @@ static void testInteger_Value(void) } zassert_equal(len, test_len, NULL); } else { - printf("property '%s': failed to read!\n", + printf( + "property '%s': failed to read!\n", bactext_property_name(rpdata.object_property)); } pRequired++; @@ -70,15 +73,18 @@ static void testInteger_Value(void) len = Integer_Value_Read_Property(&rpdata); zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); if (len != test_len) { - printf("property '%s': failed to decode!\n", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } zassert_true(test_len >= 0, NULL); } else { - printf("property '%s': failed to read!\n", + printf( + "property '%s': failed to read!\n", bactext_property_name(rpdata.object_property)); } pOptional++; diff --git a/test/bacnet/basic/object/lc/src/main.c b/test/bacnet/basic/object/lc/src/main.c index ae3f0616..cdf1622a 100644 --- a/test/bacnet/basic/object/lc/src/main.c +++ b/test/bacnet/basic/object/lc/src/main.c @@ -21,7 +21,6 @@ #define MAX_LOAD_CONTROLS 4 #endif - /** * @addtogroup bacnet_tests * @{ @@ -52,8 +51,8 @@ static void test_Load_Control_Count(void) zassert_equal(Load_Control_Count(), MAX_LOAD_CONTROLS, NULL); } -static void Load_Control_WriteProperty_Request_Shed_Level( - int instance, unsigned level) +static void +Load_Control_WriteProperty_Request_Shed_Level(int instance, unsigned level) { bool status = false; BACNET_APPLICATION_DATA_VALUE value; @@ -75,8 +74,7 @@ static void Load_Control_WriteProperty_Request_Shed_Level( zassert_true(status, NULL); } -static void Load_Control_WriteProperty_Enable( - int instance, bool enable) +static void Load_Control_WriteProperty_Enable(int instance, bool enable) { bool status = false; BACNET_APPLICATION_DATA_VALUE value; @@ -99,8 +97,8 @@ static void Load_Control_WriteProperty_Enable( zassert_true(status, NULL); } -static void Load_Control_WriteProperty_Shed_Duration( - int instance, unsigned duration) +static void +Load_Control_WriteProperty_Shed_Duration(int instance, unsigned duration) { bool status = false; BACNET_APPLICATION_DATA_VALUE value; @@ -122,8 +120,8 @@ static void Load_Control_WriteProperty_Shed_Duration( zassert_true(status, NULL); } -static void Load_Control_WriteProperty_Duty_Window( - int instance, unsigned duration) +static void +Load_Control_WriteProperty_Duty_Window(int instance, unsigned duration) { bool status = false; BACNET_APPLICATION_DATA_VALUE value; @@ -145,8 +143,7 @@ static void Load_Control_WriteProperty_Duty_Window( zassert_true(status, NULL); } -static void Load_Control_WriteProperty_Start_Time_Wildcards( - int instance) +static void Load_Control_WriteProperty_Start_Time_Wildcards(int instance) { int len = 0; bool status = false; @@ -220,18 +217,19 @@ ZTEST(lc_tests, testLoadControlStateMachine) static void testLoadControlStateMachine(void) #endif { -//TODO: unsigned i = 0, j = 0; + // TODO: unsigned i = 0, j = 0; uint8_t level = 0; Load_Control_Init(); -//TODO: /* validate the triggers for each state change */ -//TODO: for (j = 0; j < 20; j++) { -//TODO: Load_Control_State_Machine(0); -//TODO: for (i = 0; i < MAX_LOAD_CONTROLS; i++) { -//TODO: zassert_equal(Load_Control_State[i], SHED_INACTIVE, NULL); -//TODO: } -//TODO: } + // TODO: /* validate the triggers for each state change */ + // TODO: for (j = 0; j < 20; j++) { + // TODO: Load_Control_State_Machine(0); + // TODO: for (i = 0; i < MAX_LOAD_CONTROLS; i++) { + // TODO: zassert_equal(Load_Control_State[i], SHED_INACTIVE, + // NULL); + // TODO: } + // TODO: } /* SHED_REQUEST_PENDING */ /* CancelShed - Start time has wildcards */ @@ -239,20 +237,22 @@ static void testLoadControlStateMachine(void) Load_Control_WriteProperty_Shed_Duration(0, 60); Load_Control_WriteProperty_Start_Time_Wildcards(0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); /* CancelShed - Requested_Shed_Level equal to default value */ Load_Control_Init(); Load_Control_WriteProperty_Request_Shed_Level(0, 0); Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0); Load_Control_WriteProperty_Shed_Duration(0, 5); -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 15, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 15, 0, 0, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); /* CancelShed - Non-default values, but Start time is passed */ Load_Control_Init(); @@ -260,11 +260,12 @@ static void testLoadControlStateMachine(void) Load_Control_WriteProperty_Request_Shed_Level(0, 1); Load_Control_WriteProperty_Shed_Duration(0, 5); Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0); -//TODO: datetime_set_values(&Current_Time, 2007, 2, 28, 15, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 28, 15, 0, 0, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); /* ReconfigurePending - new write received while pending */ Load_Control_Init(); @@ -272,27 +273,35 @@ static void testLoadControlStateMachine(void) Load_Control_WriteProperty_Request_Shed_Level(0, 1); Load_Control_WriteProperty_Shed_Duration(0, 5); Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0); -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_WriteProperty_Request_Shed_Level(0, 2); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_WriteProperty_Shed_Duration(0, 6); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_WriteProperty_Duty_Window(0, 60); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 1); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); /* CannotMeetShed -> FinishedUnsuccessfulShed */ Load_Control_Init(); @@ -300,22 +309,24 @@ static void testLoadControlStateMachine(void) Load_Control_WriteProperty_Request_Shed_Level(0, 1); Load_Control_WriteProperty_Shed_Duration(0, 120); Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0); -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); /* set to lowest value so we cannot meet the shed level */ -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0); Analog_Output_Present_Value_Set(0, 0, 16); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); /* FinishedUnsuccessfulShed */ -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); /* CannotMeetShed -> UnsuccessfulShedReconfigured */ Load_Control_Init(); @@ -323,44 +334,47 @@ static void testLoadControlStateMachine(void) Load_Control_WriteProperty_Request_Shed_Level(0, 1); Load_Control_WriteProperty_Shed_Duration(0, 120); Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 15, 0, 0, 0); -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 5, 0, 0, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); /* set to lowest value so we cannot meet the shed level */ -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 0, 0); Analog_Output_Present_Value_Set(0, 0, 16); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); /* FinishedUnsuccessfulShed */ Load_Control_WriteProperty_Start_Time(0, 2007, 2, 27, 16, 0, 0, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, NULL); -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 1, 0); + // TODO: zassert_equal(Load_Control_State[0], SHED_REQUEST_PENDING, + // NULL); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 1, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_NON_COMPLIANT, NULL); /* CanNowComplyWithShed */ Analog_Output_Present_Value_Set(0, 100, 16); -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 2, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 16, 0, 2, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_COMPLIANT, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_COMPLIANT, NULL); level = Analog_Output_Present_Value(0); -//TODO: Fails: zassert_equal(level, 90, NULL); + // TODO: Fails: zassert_equal(level, 90, NULL); /* FinishedSuccessfulShed */ -//TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0); + // TODO: datetime_set_values(&Current_Time, 2007, 2, 27, 23, 0, 0, 0); Load_Control_State_Machine(0); -//TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); + // TODO: zassert_equal(Load_Control_State[0], SHED_INACTIVE, NULL); level = Analog_Output_Present_Value(0); -//TODO: Fails: zassert_equal(level, 100, NULL); + // TODO: Fails: zassert_equal(level, 100, NULL); (void)level; // TODO: remove when level will be checked } - #ifndef MAX_LOAD_CONTROLS #define MAX_LOAD_CONTROLS (4) #endif @@ -376,12 +390,18 @@ static void test_api_stubs(void) zassert_equal(Load_Control_Count(), MAX_LOAD_CONTROLS, NULL); zassert_false(Load_Control_Valid_Instance(MAX_LOAD_CONTROLS), NULL); - zassert_equal(Load_Control_Index_To_Instance(MAX_LOAD_CONTROLS), Load_Control_Count(), NULL); - zassert_equal(Load_Control_Instance_To_Index(MAX_LOAD_CONTROLS), Load_Control_Count(), NULL); + zassert_equal( + Load_Control_Index_To_Instance(MAX_LOAD_CONTROLS), Load_Control_Count(), + NULL); + zassert_equal( + Load_Control_Instance_To_Index(MAX_LOAD_CONTROLS), Load_Control_Count(), + NULL); zassert_false(Load_Control_Valid_Instance(UINT32_MAX), NULL); - zassert_equal(Load_Control_Index_To_Instance(UINT32_MAX), Load_Control_Count(), NULL); - zassert_equal(Load_Control_Instance_To_Index(UINT32_MAX), Load_Control_Count(), NULL); + zassert_equal( + Load_Control_Index_To_Instance(UINT32_MAX), Load_Control_Count(), NULL); + zassert_equal( + Load_Control_Instance_To_Index(UINT32_MAX), Load_Control_Count(), NULL); zassert_true(Load_Control_Valid_Instance(0), NULL); zassert_equal(Load_Control_Index_To_Instance(0), 0, NULL); @@ -390,7 +410,6 @@ static void test_api_stubs(void) zassert_false(Load_Control_Object_Name(0, NULL), NULL); zassert_false(Load_Control_Object_Name(UINT32_MAX, &object_name_st), NULL); - zassert_true(Load_Control_Object_Name(0, &object_name_st), NULL); zassert_true(characterstring_valid(&object_name_st), NULL); zassert_true(characterstring_printable(&object_name_st), NULL); @@ -414,7 +433,6 @@ static void test_Load_Control_Read_Write_Property(void) unsigned count = 0; uint32_t object_instance = 0; - zassert_equal(Load_Control_Read_Property(NULL), 0, NULL); zassert_false(Load_Control_Write_Property(NULL), NULL); @@ -428,58 +446,57 @@ static void test_Load_Control_Read_Write_Property(void) rpdata.object_instance = object_instance; Load_Control_Property_Lists(&pRequired, &pOptional, &pProprietary); while ((*pRequired) != -1) { - rpdata.object_property = *pRequired; - rpdata.array_index = BACNET_ARRAY_ALL; - len = Load_Control_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); - if (len > 0) { - test_len = bacapp_decode_application_data( - rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_true(test_len >= 0, NULL); - } - pRequired++; + rpdata.object_property = *pRequired; + rpdata.array_index = BACNET_ARRAY_ALL; + len = Load_Control_Read_Property(&rpdata); + zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); + if (len > 0) { + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_true(test_len >= 0, NULL); + } + pRequired++; } while ((*pOptional) != -1) { - rpdata.object_property = *pOptional; - rpdata.array_index = BACNET_ARRAY_ALL; - len = Load_Control_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); - if (len > 0) { - test_len = bacapp_decode_application_data( - rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_true(test_len >= 0, NULL); - } - pOptional++; + rpdata.object_property = *pOptional; + rpdata.array_index = BACNET_ARRAY_ALL; + len = Load_Control_Read_Property(&rpdata); + zassert_not_equal(len, BACNET_STATUS_ERROR, NULL); + if (len > 0) { + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_true(test_len >= 0, NULL); + } + pOptional++; } } static bool init_wp_data_and_value( - BACNET_WRITE_PROPERTY_DATA *wp_data, - BACNET_APPLICATION_DATA_VALUE * value) + BACNET_WRITE_PROPERTY_DATA *wp_data, BACNET_APPLICATION_DATA_VALUE *value) { bool status = false; - if ((wp_data != NULL) && (value != NULL)) - { - memset(value, 0, sizeof(*value)); - memset(wp_data, 0, sizeof(*wp_data)); + if ((wp_data != NULL) && (value != NULL)) { + memset(value, 0, sizeof(*value)); + memset(wp_data, 0, sizeof(*wp_data)); - wp_data->object_type = OBJECT_LOAD_CONTROL; - wp_data->object_instance = 0; - wp_data->array_index = BACNET_ARRAY_ALL; - wp_data->priority = BACNET_NO_PRIORITY; - wp_data->object_property = PROP_SHED_DURATION; - value->context_specific = false; - value->context_tag = 0; - value->tag = BACNET_APPLICATION_TAG_UNSIGNED_INT; - value->type.Unsigned_Int = 0; /* duration */ - wp_data->application_data_len = bacapp_encode_application_data(&wp_data->application_data[0], value); - zassert_true(wp_data->application_data_len >= 0, NULL); - zassert_equal(wp_data->error_class, 0, NULL); - zassert_equal(wp_data->error_code, 0, NULL); + wp_data->object_type = OBJECT_LOAD_CONTROL; + wp_data->object_instance = 0; + wp_data->array_index = BACNET_ARRAY_ALL; + wp_data->priority = BACNET_NO_PRIORITY; + wp_data->object_property = PROP_SHED_DURATION; + value->context_specific = false; + value->context_tag = 0; + value->tag = BACNET_APPLICATION_TAG_UNSIGNED_INT; + value->type.Unsigned_Int = 0; /* duration */ + wp_data->application_data_len = bacapp_encode_application_data( + &wp_data->application_data[0], value); + zassert_true(wp_data->application_data_len >= 0, NULL); + zassert_equal(wp_data->error_class, 0, NULL); + zassert_equal(wp_data->error_code, 0, NULL); - status = true; + status = true; } return status; @@ -513,12 +530,11 @@ static void test_ShedInactive_gets_RcvShedRequests(void) zassert_equal(wp_data.error_class, ERROR_CLASS_PROPERTY, NULL); zassert_equal(wp_data.error_code, ERROR_CODE_VALUE_OUT_OF_RANGE, NULL); - /* Verify calls to dependencies are properly made */ - // object_property == PROP_REQUESTED_SHED_LEVEL calls bacapp_decode_context_data() - // object_property == PROP_START_TIME calls bacapp_decode_application_data() - // object_property == PROP_SHED_DURATION calls nothing - // object_property == PROP_DUTY_WINDOW calls nothing + // object_property == PROP_REQUESTED_SHED_LEVEL calls + // bacapp_decode_context_data() object_property == PROP_START_TIME calls + // bacapp_decode_application_data() object_property == PROP_SHED_DURATION + // calls nothing object_property == PROP_DUTY_WINDOW calls nothing // object_property == PROP_SHED_LEVELS calls nothing // object_property == PROP_ENABLE calls nothing // default returns error @@ -649,30 +665,28 @@ static void test_ShedCommpliant_gets_CanNoLongerComplyWithShed(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(lc_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(lc_tests, - ztest_unit_test(test_api_stubs), - ztest_unit_test(test_Load_Control_Count), - ztest_unit_test(test_Load_Control_Read_Write_Property), - ztest_unit_test(testLoadControlStateMachine), - ztest_unit_test(test_ShedInactive_gets_RcvShedRequests), - ztest_unit_test(test_ShedReqPending_gets_ReconfigPending), - ztest_unit_test(test_ShedReqPending_gets_CancelShed), - ztest_unit_test(test_ShedReqPending_gets_CannotMeetShed), - ztest_unit_test(test_ShedReqPending_gets_PrepareToShed), - ztest_unit_test(test_ShedReqPending_gets_AbleToMeetShed), - ztest_unit_test(test_ShedNonCommpliant_gets_UnsuccessfulShedReconfig), - ztest_unit_test(test_ShedNonCommpliant_gets_FinishedUnsuccessfulShed), - ztest_unit_test(test_ShedNonCommpliant_gets_CanNowComplyWithShed), - ztest_unit_test(test_ShedCommpliant_gets_FinishedSuccessfulShed), - ztest_unit_test(test_ShedCommpliant_gets_SuccessfulShedReconfig), - ztest_unit_test(test_ShedCommpliant_gets_CanNoLongerComplyWithShed) - ); + ztest_test_suite( + lc_tests, ztest_unit_test(test_api_stubs), + ztest_unit_test(test_Load_Control_Count), + ztest_unit_test(test_Load_Control_Read_Write_Property), + ztest_unit_test(testLoadControlStateMachine), + ztest_unit_test(test_ShedInactive_gets_RcvShedRequests), + ztest_unit_test(test_ShedReqPending_gets_ReconfigPending), + ztest_unit_test(test_ShedReqPending_gets_CancelShed), + ztest_unit_test(test_ShedReqPending_gets_CannotMeetShed), + ztest_unit_test(test_ShedReqPending_gets_PrepareToShed), + ztest_unit_test(test_ShedReqPending_gets_AbleToMeetShed), + ztest_unit_test(test_ShedNonCommpliant_gets_UnsuccessfulShedReconfig), + ztest_unit_test(test_ShedNonCommpliant_gets_FinishedUnsuccessfulShed), + ztest_unit_test(test_ShedNonCommpliant_gets_CanNowComplyWithShed), + ztest_unit_test(test_ShedCommpliant_gets_FinishedSuccessfulShed), + ztest_unit_test(test_ShedCommpliant_gets_SuccessfulShedReconfig), + ztest_unit_test(test_ShedCommpliant_gets_CanNoLongerComplyWithShed)); ztest_run_test_suite(lc_tests); } diff --git a/test/bacnet/basic/object/lc/stubs.c b/test/bacnet/basic/object/lc/stubs.c index 9a11a3e1..154332f7 100644 --- a/test/bacnet/basic/object/lc/stubs.c +++ b/test/bacnet/basic/object/lc/stubs.c @@ -35,10 +35,10 @@ void datetime_init(void) } bool datetime_local( - BACNET_DATE * bdate, - BACNET_TIME * btime, - int16_t * utc_offset_minutes, - bool * dst_active) + BACNET_DATE *bdate, + BACNET_TIME *btime, + int16_t *utc_offset_minutes, + bool *dst_active) { return true; } diff --git a/test/bacnet/basic/object/lo/src/main.c b/test/bacnet/basic/object/lo/src/main.c index 367ed8fe..937eef6d 100644 --- a/test/bacnet/basic/object/lo/src/main.c +++ b/test/bacnet/basic/object/lo/src/main.c @@ -29,7 +29,7 @@ static void testLightingOutput(void) uint8_t apdu[MAX_APDU] = { 0 }; int len = 0, test_len = 0; BACNET_READ_PROPERTY_DATA rpdata; - BACNET_APPLICATION_DATA_VALUE value = {0}; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *pRequired = NULL; const int *pOptional = NULL; const int *pProprietary = NULL; @@ -57,15 +57,18 @@ static void testLightingOutput(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Lighting_Output_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len >= 0) { - test_len = bacapp_decode_known_property(rpdata.application_data, - len, &value, rpdata.object_type, rpdata.object_property); + test_len = bacapp_decode_known_property( + rpdata.application_data, len, &value, rpdata.object_type, + rpdata.object_property); if (rpdata.object_property != PROP_PRIORITY_ARRAY) { - zassert_equal(len, test_len, "property '%s': failed to decode!\n", - bactext_property_name(rpdata.object_property)); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", + bactext_property_name(rpdata.object_property)); } /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -78,8 +81,8 @@ static void testLightingOutput(void) status = Lighting_Output_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -90,14 +93,17 @@ static void testLightingOutput(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Lighting_Output_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", - bactext_property_name(rpdata.object_property)); + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", + bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; wpdata.object_instance = rpdata.object_instance; @@ -109,8 +115,8 @@ static void testLightingOutput(void) status = Lighting_Output_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -135,15 +141,12 @@ static void testLightingOutput(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(lo_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(lo_tests, - ztest_unit_test(testLightingOutput) - ); + ztest_test_suite(lo_tests, ztest_unit_test(testLightingOutput)); ztest_run_test_suite(lo_tests); } diff --git a/test/bacnet/basic/object/lsp/src/main.c b/test/bacnet/basic/object/lsp/src/main.c index 39a20f43..fbfe93d3 100644 --- a/test/bacnet/basic/object/lsp/src/main.c +++ b/test/bacnet/basic/object/lsp/src/main.c @@ -58,14 +58,17 @@ static void testLifeSafetyPoint(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Life_Safety_Point_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len >= 0) { - test_len = bacapp_decode_known_property(rpdata.application_data, - len, &value, rpdata.object_type, rpdata.object_property); + 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", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } else { zassert_equal(len, test_len, NULL); @@ -81,8 +84,8 @@ static void testLifeSafetyPoint(void) status = Life_Safety_Point_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -93,13 +96,16 @@ static void testLifeSafetyPoint(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Life_Safety_Point_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -112,8 +118,8 @@ static void testLifeSafetyPoint(void) status = Life_Safety_Point_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -135,15 +141,12 @@ static void testLifeSafetyPoint(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(lsp_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(lsp_tests, - ztest_unit_test(testLifeSafetyPoint) - ); + ztest_test_suite(lsp_tests, ztest_unit_test(testLifeSafetyPoint)); ztest_run_test_suite(lsp_tests); } diff --git a/test/bacnet/basic/object/lsz/src/main.c b/test/bacnet/basic/object/lsz/src/main.c index ac71209a..3595e083 100644 --- a/test/bacnet/basic/object/lsz/src/main.c +++ b/test/bacnet/basic/object/lsz/src/main.c @@ -39,12 +39,9 @@ static void testLifeSafetyZone(void) test_object_instance = Life_Safety_Zone_Index_To_Instance(0); zassert_equal(test_object_instance, object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_LIFE_SAFETY_ZONE, - object_instance, - Life_Safety_Zone_Property_Lists, - Life_Safety_Zone_Read_Property, - Life_Safety_Zone_Write_Property, - skip_fail_property_list); + OBJECT_LIFE_SAFETY_ZONE, object_instance, + Life_Safety_Zone_Property_Lists, Life_Safety_Zone_Read_Property, + Life_Safety_Zone_Write_Property, skip_fail_property_list); } /** * @} @@ -55,9 +52,7 @@ ZTEST_SUITE(testsLifeSafetyZone, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(testsLifeSafetyZone, - ztest_unit_test(testLifeSafetyZone) - ); + ztest_test_suite(testsLifeSafetyZone, ztest_unit_test(testLifeSafetyZone)); ztest_run_test_suite(testsLifeSafetyZone); } diff --git a/test/bacnet/basic/object/mock/device_mock.c b/test/bacnet/basic/object/mock/device_mock.c index 7bfd8417..9577fc21 100644 --- a/test/bacnet/basic/object/mock/device_mock.c +++ b/test/bacnet/basic/object/mock/device_mock.c @@ -10,11 +10,10 @@ #include #include - bool Device_Valid_Object_Name( - BACNET_CHARACTER_STRING * object_name, + BACNET_CHARACTER_STRING *object_name, BACNET_OBJECT_TYPE *object_type, - uint32_t * object_instance) + uint32_t *object_instance) { (void)object_name; (void)object_type; @@ -22,35 +21,28 @@ bool Device_Valid_Object_Name( return true; } -void Device_Inc_Database_Revision( - void) +void Device_Inc_Database_Revision(void) { - } -uint32_t Device_Object_Instance_Number( - void) +uint32_t Device_Object_Instance_Number(void) { return 0; } -bool Device_Write_Property( - BACNET_WRITE_PROPERTY_DATA * wp_data) +bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data) { (void)wp_data; return false; } -void Device_getCurrentDateTime( - BACNET_DATE_TIME * DateTime) +void Device_getCurrentDateTime(BACNET_DATE_TIME *DateTime) { (void)DateTime; } -int Device_Read_Property( - BACNET_READ_PROPERTY_DATA * rpdata) +int Device_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata) { (void)rpdata; return 0; } - diff --git a/test/bacnet/basic/object/mock/tsm_mock.c b/test/bacnet/basic/object/mock/tsm_mock.c index ac4eea21..b984d403 100644 --- a/test/bacnet/basic/object/mock/tsm_mock.c +++ b/test/bacnet/basic/object/mock/tsm_mock.c @@ -11,10 +11,10 @@ bool tsm_get_transaction_pdu( uint8_t invokeID, - BACNET_ADDRESS * dest, - BACNET_NPDU_DATA * ndpu_data, - uint8_t * apdu, - uint16_t * apdu_len) + BACNET_ADDRESS *dest, + BACNET_NPDU_DATA *ndpu_data, + uint8_t *apdu, + uint16_t *apdu_len) { (void)invokeID; (void)dest; diff --git a/test/bacnet/basic/object/ms-input/src/main.c b/test/bacnet/basic/object/ms-input/src/main.c index 161d498b..6f9b854e 100644 --- a/test/bacnet/basic/object/ms-input/src/main.c +++ b/test/bacnet/basic/object/ms-input/src/main.c @@ -38,12 +38,9 @@ static void testMultistateInput(void) test_object_instance = Multistate_Input_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_MULTI_STATE_INPUT, - object_instance, - Multistate_Input_Property_Lists, - Multistate_Input_Read_Property, - Multistate_Input_Write_Property, - skip_fail_property_list); + OBJECT_MULTI_STATE_INPUT, object_instance, + Multistate_Input_Property_Lists, Multistate_Input_Read_Property, + Multistate_Input_Write_Property, skip_fail_property_list); status = Multistate_Input_Delete(object_instance); zassert_true(status, NULL); } @@ -51,15 +48,12 @@ static void testMultistateInput(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(ms_input_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(ms_input_tests, - ztest_unit_test(testMultistateInput) - ); + ztest_test_suite(ms_input_tests, ztest_unit_test(testMultistateInput)); ztest_run_test_suite(ms_input_tests); } diff --git a/test/bacnet/basic/object/mso/src/main.c b/test/bacnet/basic/object/mso/src/main.c index fcb83f18..0a5ca5fc 100644 --- a/test/bacnet/basic/object/mso/src/main.c +++ b/test/bacnet/basic/object/mso/src/main.c @@ -37,12 +37,9 @@ static void testMultistateOutput(void) test_object_instance = Multistate_Output_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_MULTI_STATE_OUTPUT, - object_instance, - Multistate_Output_Property_Lists, - Multistate_Output_Read_Property, - Multistate_Output_Write_Property, - skip_fail_property_list); + OBJECT_MULTI_STATE_OUTPUT, object_instance, + Multistate_Output_Property_Lists, Multistate_Output_Read_Property, + Multistate_Output_Write_Property, skip_fail_property_list); status = Multistate_Output_Delete(object_instance); zassert_true(status, NULL); } @@ -50,15 +47,12 @@ static void testMultistateOutput(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(mso_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(mso_tests, - ztest_unit_test(testMultistateOutput) - ); + ztest_test_suite(mso_tests, ztest_unit_test(testMultistateOutput)); ztest_run_test_suite(mso_tests); } diff --git a/test/bacnet/basic/object/msv/src/main.c b/test/bacnet/basic/object/msv/src/main.c index af196383..efa81eb2 100644 --- a/test/bacnet/basic/object/msv/src/main.c +++ b/test/bacnet/basic/object/msv/src/main.c @@ -38,12 +38,9 @@ static void testMultistateValue(void) test_object_instance = Multistate_Value_Index_To_Instance(0); zassert_equal(object_instance, test_object_instance, NULL); bacnet_object_properties_read_write_test( - OBJECT_MULTI_STATE_VALUE, - object_instance, - Multistate_Value_Property_Lists, - Multistate_Value_Read_Property, - Multistate_Value_Write_Property, - skip_fail_property_list); + OBJECT_MULTI_STATE_VALUE, object_instance, + Multistate_Value_Property_Lists, Multistate_Value_Read_Property, + Multistate_Value_Write_Property, skip_fail_property_list); status = Multistate_Value_Delete(object_instance); zassert_true(status, NULL); } @@ -51,15 +48,12 @@ static void testMultistateValue(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(msv_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(msv_tests, - ztest_unit_test(testMultistateValue) - ); + ztest_test_suite(msv_tests, ztest_unit_test(testMultistateValue)); ztest_run_test_suite(msv_tests); } diff --git a/test/bacnet/basic/object/nc/src/main.c b/test/bacnet/basic/object/nc/src/main.c index b092924a..5883d1cd 100644 --- a/test/bacnet/basic/object/nc/src/main.c +++ b/test/bacnet/basic/object/nc/src/main.c @@ -56,16 +56,19 @@ static void test_Notification_Class(void) rpdata.object_property = *pRequired; rpdata.array_index = BACNET_ARRAY_ALL; len = Notification_Class_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len >= 0) { - test_len = bacapp_decode_known_property(rpdata.application_data, - len, &value, rpdata.object_type, rpdata.object_property); + test_len = bacapp_decode_known_property( + rpdata.application_data, len, &value, rpdata.object_type, + rpdata.object_property); if ((rpdata.object_property != PROP_PRIORITY) && (rpdata.object_property != PROP_RECIPIENT_LIST)) { - zassert_equal(len, test_len, "property '%s': failed to decode!\n", - bactext_property_name(rpdata.object_property)); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", + bactext_property_name(rpdata.object_property)); } /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -78,8 +81,8 @@ static void test_Notification_Class(void) status = Notification_Class_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -90,13 +93,16 @@ static void test_Notification_Class(void) rpdata.object_property = *pOptional; rpdata.array_index = BACNET_ARRAY_ALL; len = Notification_Class_Read_Property(&rpdata); - zassert_not_equal(len, BACNET_STATUS_ERROR, + zassert_not_equal( + len, BACNET_STATUS_ERROR, "property '%s': failed to ReadProperty!\n", bactext_property_name(rpdata.object_property)); if (len > 0) { - test_len = bacapp_decode_application_data(rpdata.application_data, - (uint8_t)rpdata.application_data_len, &value); - zassert_equal(len, test_len, "property '%s': failed to decode!\n", + test_len = bacapp_decode_application_data( + rpdata.application_data, (uint8_t)rpdata.application_data_len, + &value); + zassert_equal( + len, test_len, "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); /* check WriteProperty properties */ wpdata.object_type = rpdata.object_type; @@ -109,8 +115,8 @@ static void test_Notification_Class(void) status = Notification_Class_Write_Property(&wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata.error_code, - ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata.error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(rpdata.object_property)); } @@ -130,15 +136,13 @@ static void test_Notification_Class(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(notification_class_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(notification_class_tests, - ztest_unit_test(test_Notification_Class) - ); + ztest_test_suite( + notification_class_tests, ztest_unit_test(test_Notification_Class)); ztest_run_test_suite(notification_class_tests); } diff --git a/test/bacnet/basic/object/nc/stubs.c b/test/bacnet/basic/object/nc/stubs.c index 319f6112..2355aead 100644 --- a/test/bacnet/basic/object/nc/stubs.c +++ b/test/bacnet/basic/object/nc/stubs.c @@ -27,8 +27,8 @@ int Send_UEvent_Notify( return 0; } -uint8_t Send_CEvent_Notify( - uint32_t device_id, BACNET_EVENT_NOTIFICATION_DATA *data) +uint8_t +Send_CEvent_Notify(uint32_t device_id, BACNET_EVENT_NOTIFICATION_DATA *data) { (void)device_id; (void)data; @@ -42,10 +42,10 @@ void Send_WhoIs(int32_t low_limit, int32_t high_limit) } bool datetime_local( - BACNET_DATE * bdate, - BACNET_TIME * btime, - int16_t * utc_offset_minutes, - bool * dst_active) + BACNET_DATE *bdate, + BACNET_TIME *btime, + int16_t *utc_offset_minutes, + bool *dst_active) { (void)bdate; (void)btime; diff --git a/test/bacnet/basic/object/netport/src/main.c b/test/bacnet/basic/object/netport/src/main.c index e84b14c9..aff2a724 100644 --- a/test/bacnet/basic/object/netport/src/main.c +++ b/test/bacnet/basic/object/netport/src/main.c @@ -29,14 +29,20 @@ static void test_network_port(void) bool status = false; unsigned count = 0; uint32_t object_instance = 0; - uint8_t port_type[] = { PORT_TYPE_ETHERNET, PORT_TYPE_ARCNET, - PORT_TYPE_MSTP, PORT_TYPE_PTP, PORT_TYPE_LONTALK, PORT_TYPE_BIP, - PORT_TYPE_ZIGBEE, PORT_TYPE_VIRTUAL, PORT_TYPE_NON_BACNET, - PORT_TYPE_BIP6, PORT_TYPE_MAX }; - const int known_fail_property_list[] = { PROP_IP_DNS_SERVER, + uint8_t port_type[] = { PORT_TYPE_ETHERNET, PORT_TYPE_ARCNET, + PORT_TYPE_MSTP, PORT_TYPE_PTP, + PORT_TYPE_LONTALK, PORT_TYPE_BIP, + PORT_TYPE_ZIGBEE, PORT_TYPE_VIRTUAL, + PORT_TYPE_NON_BACNET, PORT_TYPE_BIP6, + PORT_TYPE_MAX }; + const int known_fail_property_list[] = { + PROP_IP_DNS_SERVER, PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE, - PROP_BBMD_FOREIGN_DEVICE_TABLE, PROP_FD_BBMD_ADDRESS, - PROP_IPV6_DNS_SERVER, -1 }; + PROP_BBMD_FOREIGN_DEVICE_TABLE, + PROP_FD_BBMD_ADDRESS, + PROP_IPV6_DNS_SERVER, + -1 + }; while (port_type[port] != PORT_TYPE_MAX) { object_instance = 1234; @@ -48,11 +54,8 @@ static void test_network_port(void) count = Network_Port_Count(); zassert_true(count > 0, NULL); bacnet_object_properties_read_write_test( - OBJECT_NETWORK_PORT, - object_instance, - Network_Port_Property_Lists, - Network_Port_Read_Property, - Network_Port_Write_Property, + OBJECT_NETWORK_PORT, object_instance, Network_Port_Property_Lists, + Network_Port_Read_Property, Network_Port_Write_Property, known_fail_property_list); port++; } diff --git a/test/bacnet/basic/object/objects/main.c b/test/bacnet/basic/object/objects/main.c index d73f83aa..113f32cd 100644 --- a/test/bacnet/basic/object/objects/main.c +++ b/test/bacnet/basic/object/objects/main.c @@ -71,8 +71,7 @@ void testBACnetObjects(Test *pTest) for (test_point = 0; test_point < max_test_points; test_point++) { device_id = test_point * (BACNET_MAX_INSTANCE / max_test_points); pDevice = objects_device_data(test_point); - testBACnetObjectsCompare( - pTest, pDevice, objects_device_id(test_point)); + testBACnetObjectsCompare(pTest, pDevice, objects_device_id(test_point)); } for (test_point = 0; test_point < max_test_points; test_point++) { status = objects_device_delete(0); @@ -99,4 +98,3 @@ int main(void) return 0; } - diff --git a/test/bacnet/basic/object/objects/src/main.c b/test/bacnet/basic/object/objects/src/main.c index 8f9a47b0..8811aecc 100644 --- a/test/bacnet/basic/object/objects/src/main.c +++ b/test/bacnet/basic/object/objects/src/main.c @@ -20,13 +20,14 @@ /** * @brief Test */ -static void testBACnetObjectsCompare( - OBJECT_DEVICE_T *pDevice, uint32_t expected_device_id) +static void +testBACnetObjectsCompare(OBJECT_DEVICE_T *pDevice, uint32_t expected_device_id) { zassert_not_null(pDevice, NULL); if (pDevice) { zassert_not_null(pDevice->Object_List, NULL); - zassert_equal(pDevice->Object_Identifier.instance, expected_device_id, NULL); + zassert_equal( + pDevice->Object_Identifier.instance, expected_device_id, NULL); zassert_equal(pDevice->Object_Identifier.type, OBJECT_DEVICE, NULL); zassert_equal(pDevice->Object_Type, OBJECT_DEVICE, NULL); } @@ -43,7 +44,6 @@ static void testBACnetObjects(void) const unsigned max_test_points = 20; OBJECT_DEVICE_T *pDevice; - /* Verify deleting a non-existant object returns the correct value */ zassert_false(objects_device_delete(0), NULL); @@ -53,7 +53,7 @@ static void testBACnetObjects(void) pDevice = objects_device_new(device_id); testBACnetObjectsCompare(pDevice, device_id); - /* Verify the last created device can be fetched by ID */ + /* Verify the last created device can be fetched by ID */ pDevice = objects_device_by_instance(device_id); testBACnetObjectsCompare(pDevice, device_id); } @@ -83,15 +83,12 @@ static void testBACnetObjects(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(objects_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(objects_tests, - ztest_unit_test(testBACnetObjects) - ); + ztest_test_suite(objects_tests, ztest_unit_test(testBACnetObjects)); ztest_run_test_suite(objects_tests); } diff --git a/test/bacnet/basic/object/osv/src/main.c b/test/bacnet/basic/object/osv/src/main.c index 426e8232..7991b372 100644 --- a/test/bacnet/basic/object/osv/src/main.c +++ b/test/bacnet/basic/object/osv/src/main.c @@ -27,7 +27,7 @@ static void testOctetString_Value(void) uint8_t apdu[MAX_APDU] = { 0 }; int len = 0, test_len = 0; BACNET_READ_PROPERTY_DATA rpdata = { 0 }; - BACNET_APPLICATION_DATA_VALUE value = {0}; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *required_property = NULL; const uint32_t instance = 1; @@ -44,10 +44,12 @@ static void testOctetString_Value(void) len = OctetString_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); + 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", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } if (rpdata.object_property == PROP_PRIORITY_ARRAY) { @@ -56,7 +58,8 @@ static void testOctetString_Value(void) } zassert_equal(len, test_len, NULL); } else { - printf("property '%s': failed to read!\n", + printf( + "property '%s': failed to read!\n", bactext_property_name(rpdata.object_property)); } required_property++; @@ -66,15 +69,12 @@ static void testOctetString_Value(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(osv_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(osv_tests, - ztest_unit_test(testOctetString_Value) - ); + ztest_test_suite(osv_tests, ztest_unit_test(testOctetString_Value)); ztest_run_test_suite(osv_tests); } diff --git a/test/bacnet/basic/object/piv/src/main.c b/test/bacnet/basic/object/piv/src/main.c index ac17ba51..7526b487 100644 --- a/test/bacnet/basic/object/piv/src/main.c +++ b/test/bacnet/basic/object/piv/src/main.c @@ -28,7 +28,7 @@ static void testPositiveInteger_Value(void) uint8_t apdu[MAX_APDU] = { 0 }; int len = 0, test_len = 0; BACNET_READ_PROPERTY_DATA rpdata = { 0 }; - BACNET_APPLICATION_DATA_VALUE value = {0}; + BACNET_APPLICATION_DATA_VALUE value = { 0 }; const int *required_property = NULL; const uint32_t instance = 1; @@ -45,10 +45,12 @@ static void testPositiveInteger_Value(void) len = PositiveInteger_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); + 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", + printf( + "property '%s': failed to decode!\n", bactext_property_name(rpdata.object_property)); } if (rpdata.object_property == PROP_PRIORITY_ARRAY) { @@ -64,15 +66,12 @@ static void testPositiveInteger_Value(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(piv_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(piv_tests, - ztest_unit_test(testPositiveInteger_Value) - ); + ztest_test_suite(piv_tests, ztest_unit_test(testPositiveInteger_Value)); ztest_run_test_suite(piv_tests); } diff --git a/test/bacnet/basic/object/property_test.c b/test/bacnet/basic/object/property_test.c index d06fbe5e..4ad227e9 100644 --- a/test/bacnet/basic/object/property_test.c +++ b/test/bacnet/basic/object/property_test.c @@ -21,7 +21,8 @@ * are known to fail to decode after reading * @return true if the property was written successfully, false if not */ -bool bacnet_object_property_write_test(BACNET_WRITE_PROPERTY_DATA *wpdata, +bool bacnet_object_property_write_test( + BACNET_WRITE_PROPERTY_DATA *wpdata, write_property_function write_property, const int *skip_fail_property_list) { @@ -34,7 +35,8 @@ bool bacnet_object_property_write_test(BACNET_WRITE_PROPERTY_DATA *wpdata, status = write_property(wpdata); if (!status) { /* verify WriteProperty property is known */ - zassert_not_equal(wpdata->error_code, ERROR_CODE_UNKNOWN_PROPERTY, + zassert_not_equal( + wpdata->error_code, ERROR_CODE_UNKNOWN_PROPERTY, "property '%s': WriteProperty Unknown!\n", bactext_property_name(wpdata->object_property)); } @@ -75,7 +77,8 @@ void bacnet_object_property_write_parameter_init( * are known to fail to decode after reading * @return length of the property value that was read */ -int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata, +int bacnet_object_property_read_test( + BACNET_READ_PROPERTY_DATA *rpdata, read_property_function read_property, const int *skip_fail_property_list) { @@ -99,8 +102,9 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata, apdu = rpdata->application_data; apdu_len = read_len; while (apdu_len) { - len = bacapp_decode_known_property(apdu, apdu_len, &value, - rpdata->object_type, rpdata->object_property); + len = bacapp_decode_known_property( + apdu, apdu_len, &value, rpdata->object_type, + rpdata->object_property); if (len > 0) { test_len += len; if ((len < apdu_len) && @@ -116,15 +120,16 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata, break; } } else { - printf("property '%s': failed to decode! len=%d\n", - bactext_property_name(rpdata->object_property), - len); + printf( + "property '%s': failed to decode! len=%d\n", + bactext_property_name(rpdata->object_property), len); break; } } if (read_len != test_len) { - printf("property '%s': failed to decode! %d!=%d\n", - bactext_property_name(rpdata->object_property), test_len, + printf( + "property '%s': failed to decode! %d!=%d\n", + bactext_property_name(rpdata->object_property), test_len, read_len); } if (property_list_member( @@ -136,8 +141,8 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata, } else if (read_len == 0) { /* empty response is valid for some properties */ } else { - zassert_not_equal(read_len, BACNET_STATUS_ERROR, - "property '%s': failed to read!\n", + zassert_not_equal( + read_len, BACNET_STATUS_ERROR, "property '%s': failed to read!\n", bactext_property_name(rpdata->object_property)); } @@ -155,7 +160,8 @@ int bacnet_object_property_read_test(BACNET_READ_PROPERTY_DATA *rpdata, * @param skip_fail_property_list The list of properties that * are known to fail to decode after reading */ -void bacnet_object_properties_read_write_test(BACNET_OBJECT_TYPE object_type, +void bacnet_object_properties_read_write_test( + BACNET_OBJECT_TYPE object_type, uint32_t object_instance, rpm_property_lists_function property_list, read_property_function read_property, diff --git a/test/bacnet/basic/object/schedule/src/main.c b/test/bacnet/basic/object/schedule/src/main.c index 4d26b3bc..6872a699 100644 --- a/test/bacnet/basic/object/schedule/src/main.c +++ b/test/bacnet/basic/object/schedule/src/main.c @@ -27,34 +27,29 @@ static void testSchedule(void) { unsigned count = 0; uint32_t object_instance = 0; - const int skip_fail_property_list[] = { - PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES, -1 }; + const int skip_fail_property_list[] = { + PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES, -1 + }; Schedule_Init(); count = Schedule_Count(); zassert_true(count > 0, NULL); object_instance = Schedule_Index_To_Instance(0); bacnet_object_properties_read_write_test( - OBJECT_SCHEDULE, - object_instance, - Schedule_Property_Lists, - Schedule_Read_Property, - Schedule_Write_Property, + OBJECT_SCHEDULE, object_instance, Schedule_Property_Lists, + Schedule_Read_Property, Schedule_Write_Property, skip_fail_property_list); } /** * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(schedule_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(schedule_tests, - ztest_unit_test(testSchedule) - ); + ztest_test_suite(schedule_tests, ztest_unit_test(testSchedule)); ztest_run_test_suite(schedule_tests); } diff --git a/test/bacnet/basic/object/time_value/src/main.c b/test/bacnet/basic/object/time_value/src/main.c index 885c2e8a..a4982b7f 100644 --- a/test/bacnet/basic/object/time_value/src/main.c +++ b/test/bacnet/basic/object/time_value/src/main.c @@ -37,11 +37,8 @@ static void testTimeValue(void) zassert_true(count > 0, NULL); object_instance = Time_Value_Index_To_Instance(0); bacnet_object_properties_read_write_test( - OBJECT_TIME_VALUE, - object_instance, - Time_Value_Property_Lists, - Time_Value_Read_Property, - Time_Value_Write_Property, + OBJECT_TIME_VALUE, object_instance, Time_Value_Property_Lists, + Time_Value_Read_Property, Time_Value_Write_Property, skip_fail_property_list); /* check the delete function */ status = Time_Value_Delete(object_instance); @@ -56,9 +53,7 @@ ZTEST_SUITE(bacnet_tv, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(tv_tests, - ztest_unit_test(testTimeValue) - ); + ztest_test_suite(tv_tests, ztest_unit_test(testTimeValue)); ztest_run_test_suite(tv_tests); } diff --git a/test/bacnet/basic/object/time_value/stubs.c b/test/bacnet/basic/object/time_value/stubs.c index b213a96e..feef7194 100644 --- a/test/bacnet/basic/object/time_value/stubs.c +++ b/test/bacnet/basic/object/time_value/stubs.c @@ -11,10 +11,10 @@ #include "bacnet/datetime.h" bool datetime_local( - BACNET_DATE * bdate, - BACNET_TIME * btime, - int16_t * utc_offset_minutes, - bool * dst_active) + BACNET_DATE *bdate, + BACNET_TIME *btime, + int16_t *utc_offset_minutes, + bool *dst_active) { bdate->year = 2023; bdate->month = 6; diff --git a/test/bacnet/basic/object/trendlog/src/main.c b/test/bacnet/basic/object/trendlog/src/main.c index b7fdfe29..7ce56dd1 100644 --- a/test/bacnet/basic/object/trendlog/src/main.c +++ b/test/bacnet/basic/object/trendlog/src/main.c @@ -33,11 +33,8 @@ static void test_Trend_Log_ReadProperty(void) status = Trend_Log_Valid_Instance(object_instance); zassert_true(status, NULL); bacnet_object_properties_read_write_test( - OBJECT_TRENDLOG, - object_instance, - Trend_Log_Property_Lists, - Trend_Log_Read_Property, - Trend_Log_Write_Property, + OBJECT_TRENDLOG, object_instance, Trend_Log_Property_Lists, + Trend_Log_Read_Property, Trend_Log_Write_Property, known_fail_property_list); } /** @@ -46,8 +43,8 @@ static void test_Trend_Log_ReadProperty(void) void test_main(void) { - ztest_test_suite(trendlog_tests, - ztest_unit_test(test_Trend_Log_ReadProperty)); + ztest_test_suite( + trendlog_tests, ztest_unit_test(test_Trend_Log_ReadProperty)); ztest_run_test_suite(trendlog_tests); } diff --git a/test/bacnet/basic/sys/color_rgb/src/main.c b/test/bacnet/basic/sys/color_rgb/src/main.c index 16c995a3..d3c93bd9 100644 --- a/test/bacnet/basic/sys/color_rgb/src/main.c +++ b/test/bacnet/basic/sys/color_rgb/src/main.c @@ -21,7 +21,7 @@ /** * @brief compare two floating point values to 3 decimal places - * + * * @param x1 - first comparison value * @param x2 - second comparison value * @return true if the value is the same to 3 decimal points @@ -34,7 +34,8 @@ static bool is_float_equal(float x1, float x2) /** * Unit Test for sRGB to CIE xy */ -static void test_color_rgb_xy_gamma_unit(uint8_t red, +static void test_color_rgb_xy_gamma_unit( + uint8_t red, uint8_t green, uint8_t blue, float x_coordinate, @@ -46,22 +47,28 @@ static void test_color_rgb_xy_gamma_unit(uint8_t red, uint8_t test_red = 0, test_green = 0, test_blue = 0; /* functions with gamma correction */ - color_rgb_to_xy_gamma(red, green, blue, &test_x_coordinate, - &test_y_coordinate, &test_brightness); - color_rgb_from_xy_gamma(&test_red, &test_green, &test_blue, x_coordinate, - y_coordinate, brightness); - zassert_true(is_float_equal(x_coordinate, test_x_coordinate), - "(x=%.3f,test_x=%.3f)", x_coordinate, test_x_coordinate); - zassert_true(is_float_equal(y_coordinate, test_y_coordinate), - "(y=%.3f,test_y=%.3f)", y_coordinate, test_y_coordinate); - zassert_equal(brightness, test_brightness, "b=%u, test_b=%u", brightness, + color_rgb_to_xy_gamma( + red, green, blue, &test_x_coordinate, &test_y_coordinate, + &test_brightness); + color_rgb_from_xy_gamma( + &test_red, &test_green, &test_blue, x_coordinate, y_coordinate, + brightness); + zassert_true( + is_float_equal(x_coordinate, test_x_coordinate), "(x=%.3f,test_x=%.3f)", + x_coordinate, test_x_coordinate); + zassert_true( + is_float_equal(y_coordinate, test_y_coordinate), "(y=%.3f,test_y=%.3f)", + y_coordinate, test_y_coordinate); + zassert_equal( + brightness, test_brightness, "b=%u, test_b=%u", brightness, test_brightness); } /** * Unit Test for sRGB to CIE xy */ -static void test_color_rgb_xy_unit(uint8_t red, +static void test_color_rgb_xy_unit( + uint8_t red, uint8_t green, uint8_t blue, float x_coordinate, @@ -72,15 +79,20 @@ static void test_color_rgb_xy_unit(uint8_t red, uint8_t test_brightness = 0; uint8_t test_red = 0, test_green = 0, test_blue = 0; - color_rgb_to_xy(red, green, blue, &test_x_coordinate, &test_y_coordinate, + color_rgb_to_xy( + red, green, blue, &test_x_coordinate, &test_y_coordinate, &test_brightness); - color_rgb_from_xy(&test_red, &test_green, &test_blue, x_coordinate, - y_coordinate, brightness); - zassert_true(is_float_equal(x_coordinate, test_x_coordinate), - "(x=%.3f,test_x=%.3f)", x_coordinate, test_x_coordinate); - zassert_true(is_float_equal(y_coordinate, test_y_coordinate), - "(y=%.3f,test_y=%.3f)", y_coordinate, test_y_coordinate); - zassert_equal(brightness, test_brightness, "b=%u, test_b=%u", brightness, + color_rgb_from_xy( + &test_red, &test_green, &test_blue, x_coordinate, y_coordinate, + brightness); + zassert_true( + is_float_equal(x_coordinate, test_x_coordinate), "(x=%.3f,test_x=%.3f)", + x_coordinate, test_x_coordinate); + zassert_true( + is_float_equal(y_coordinate, test_y_coordinate), "(y=%.3f,test_y=%.3f)", + y_coordinate, test_y_coordinate); + zassert_equal( + brightness, test_brightness, "b=%u, test_b=%u", brightness, test_brightness); } @@ -166,7 +178,8 @@ ZTEST_SUITE(color_rgb_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(color_rgb_tests, ztest_unit_test(test_color_rgb_ascii), + ztest_test_suite( + color_rgb_tests, ztest_unit_test(test_color_rgb_ascii), ztest_unit_test(test_color_rgb_xy)); ztest_run_test_suite(color_rgb_tests); diff --git a/test/bacnet/basic/sys/days/src/main.c b/test/bacnet/basic/sys/days/src/main.c index 2c7f99f6..9c3da8c8 100644 --- a/test/bacnet/basic/sys/days/src/main.c +++ b/test/bacnet/basic/sys/days/src/main.c @@ -17,13 +17,10 @@ */ /** -* Unit Test for the days, checking the epoch conversion -*/ + * Unit Test for the days, checking the epoch conversion + */ static void test_epoch_conversion_date( - uint16_t epoch_year, - uint16_t year, - uint8_t month, - uint8_t day) + uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day) { uint32_t days; uint16_t test_year; @@ -32,8 +29,8 @@ static void test_epoch_conversion_date( /* conversions of day and date */ days = days_since_epoch(epoch_year, year, month, day); - days_since_epoch_to_date(epoch_year, days, &test_year, &test_month, - &test_day); + days_since_epoch_to_date( + epoch_year, days, &test_year, &test_month, &test_day); zassert_equal(year, test_year, NULL); zassert_equal(month, test_month, NULL); zassert_equal(day, test_day, NULL); @@ -61,15 +58,12 @@ static void test_days_epoch_conversion(void) * Unit Test for the days and year to month date year */ static void test_days_of_year_to_month_day_date( - uint16_t year, - uint16_t days, - uint8_t month, - uint8_t day) + uint16_t year, uint16_t days, uint8_t month, uint8_t day) { uint8_t test_month = 0; uint8_t test_day = 0; /* conversions of days and year */ - days_of_year_to_month_day(days , year, &test_month, &test_day); + days_of_year_to_month_day(days, year, &test_month, &test_day); zassert_equal(month, test_month, NULL); zassert_equal(day, test_day, NULL); } @@ -91,11 +85,9 @@ static void test_days_of_year_to_md(void) } /** -* Unit Test for the days, checking the date to see if it is a valid day -*/ -static void test_date_is_valid_day( - uint16_t year, - uint8_t month) + * Unit Test for the days, checking the date to see if it is a valid day + */ +static void test_date_is_valid_day(uint16_t year, uint8_t month) { uint8_t last_day = days_per_month(year, month); @@ -107,8 +99,8 @@ static void test_date_is_valid_day( } /** -* Unit Test for the days, checking the date to see if it is a valid date -*/ + * Unit Test for the days, checking the date to see if it is a valid date + */ #if defined(CONFIG_ZTEST_NEW_API) ZTEST(days_tests, test_days_date_is_valid) #else @@ -143,8 +135,8 @@ static void test_days_date_is_valid(void) } /** -* Unit Test for days apart, checking the dates to see how many days apart -*/ + * Unit Test for days apart, checking the dates to see how many days apart + */ #if defined(CONFIG_ZTEST_NEW_API) ZTEST(days_tests, test_days_apart) #else @@ -163,18 +155,16 @@ static void test_days_apart(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(days_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(days_tests, - ztest_unit_test(test_days_epoch_conversion), - ztest_unit_test(test_days_of_year_to_md), - ztest_unit_test(test_days_date_is_valid), - ztest_unit_test(test_days_apart) - ); + ztest_test_suite( + days_tests, ztest_unit_test(test_days_epoch_conversion), + ztest_unit_test(test_days_of_year_to_md), + ztest_unit_test(test_days_date_is_valid), + ztest_unit_test(test_days_apart)); ztest_run_test_suite(days_tests); } diff --git a/test/bacnet/basic/sys/fifo/src/main.c b/test/bacnet/basic/sys/fifo/src/main.c index 0dadeb10..95c37a61 100644 --- a/test/bacnet/basic/sys/fifo/src/main.c +++ b/test/bacnet/basic/sys/fifo/src/main.c @@ -138,8 +138,8 @@ static void testFIFOBuffer(void) status = FIFO_Add(&test_buffer, add_data, sizeof(add_data)); zassert_true(status, NULL); count = FIFO_Count(&test_buffer); - test_count = FIFO_Peek_Ahead(&test_buffer, &test_add_data[0], count-1); - zassert_equal(count-1, test_count, NULL); + test_count = FIFO_Peek_Ahead(&test_buffer, &test_add_data[0], count - 1); + zassert_equal(count - 1, test_count, NULL); for (index = 0; index < test_count; index++) { zassert_equal(test_add_data[index], add_data[index], NULL); } @@ -150,15 +150,12 @@ static void testFIFOBuffer(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(fifo_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(fifo_tests, - ztest_unit_test(testFIFOBuffer) - ); + ztest_test_suite(fifo_tests, ztest_unit_test(testFIFOBuffer)); ztest_run_test_suite(fifo_tests); } diff --git a/test/bacnet/basic/sys/filename/src/main.c b/test/bacnet/basic/sys/filename/src/main.c index a54d1c94..51d17bed 100644 --- a/test/bacnet/basic/sys/filename/src/main.c +++ b/test/bacnet/basic/sys/filename/src/main.c @@ -49,15 +49,12 @@ static void testFilename(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(filename_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(filename_tests, - ztest_unit_test(testFilename) - ); + ztest_test_suite(filename_tests, ztest_unit_test(testFilename)); ztest_run_test_suite(filename_tests); } diff --git a/test/bacnet/basic/sys/keylist/src/main.c b/test/bacnet/basic/sys/keylist/src/main.c index b44e012e..8bbcc121 100644 --- a/test/bacnet/basic/sys/keylist/src/main.c +++ b/test/bacnet/basic/sys/keylist/src/main.c @@ -349,20 +349,16 @@ static void testKeySample(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(keylist_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(keylist_tests, - ztest_unit_test(testKeyListFIFO), - ztest_unit_test(testKeyListFILO), - ztest_unit_test(testKeyListDataKey), - ztest_unit_test(testKeyListDataIndex), - ztest_unit_test(testKeyListLarge), - ztest_unit_test(testKeySample) - ); + ztest_test_suite( + keylist_tests, ztest_unit_test(testKeyListFIFO), + ztest_unit_test(testKeyListFILO), ztest_unit_test(testKeyListDataKey), + ztest_unit_test(testKeyListDataIndex), + ztest_unit_test(testKeyListLarge), ztest_unit_test(testKeySample)); ztest_run_test_suite(keylist_tests); } diff --git a/test/bacnet/basic/sys/linear/src/main.c b/test/bacnet/basic/sys/linear/src/main.c index 3c2e574a..7ebdc881 100644 --- a/test/bacnet/basic/sys/linear/src/main.c +++ b/test/bacnet/basic/sys/linear/src/main.c @@ -17,8 +17,8 @@ */ /** -* Unit Test for linear interpolation of floating point values, rounded -*/ + * Unit Test for linear interpolation of floating point values, rounded + */ void testLinearInterpolateRound(void) { uint16_t x2 = 0; @@ -82,8 +82,8 @@ void testLinearInterpolateRound(void) } /** -* Unit Test for linear interpolation of integers -*/ + * Unit Test for linear interpolation of integers + */ void testLinearInterpolateInt(void) { uint16_t y2 = 0; @@ -103,7 +103,7 @@ void testLinearInterpolateInt(void) y2 = linear_interpolate_int(1, (65535 / 2), 65535, 1, 100); zassert_equal(y2, 50, NULL); - + y2 = linear_interpolate_int(1, ((65535 * 3) / 4), 65535, 1, 100); zassert_equal(y2, 75, NULL); @@ -126,10 +126,9 @@ ZTEST_SUITE(Linear_Interpolate, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(Linear_Interpolate, - ztest_unit_test(testLinearInterpolateRound), - ztest_unit_test(testLinearInterpolateInt) - ); + ztest_test_suite( + Linear_Interpolate, ztest_unit_test(testLinearInterpolateRound), + ztest_unit_test(testLinearInterpolateInt)); ztest_run_test_suite(Linear_Interpolate); } diff --git a/test/bacnet/basic/sys/ringbuf/src/main.c b/test/bacnet/basic/sys/ringbuf/src/main.c index b41d62f1..d708e45a 100644 --- a/test/bacnet/basic/sys/ringbuf/src/main.c +++ b/test/bacnet/basic/sys/ringbuf/src/main.c @@ -175,7 +175,8 @@ static void testRingBufSizeSmall(void) uint8_t data_element[5]; uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(16)]; - testRingBuf(data_store, data_element, sizeof(data_element), + testRingBuf( + data_store, data_element, sizeof(data_element), sizeof(data_store) / sizeof(data_element)); } @@ -191,7 +192,8 @@ static void testRingBufSizeLarge(void) uint8_t data_element[16]; uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(99)]; - testRingBuf(data_store, data_element, sizeof(data_element), + testRingBuf( + data_store, data_element, sizeof(data_element), sizeof(data_store) / sizeof(data_element)); } @@ -208,10 +210,11 @@ static void testRingBufSizeInvalid(void) uint8_t data_element[16]; uint8_t data_store[sizeof(data_element) * 99]; - zassert_false(Ringbuf_Init(&test_buffer, - data_store, sizeof(data_element), - sizeof(data_store) / sizeof(data_element)), - NULL); + zassert_false( + Ringbuf_Init( + &test_buffer, data_store, sizeof(data_element), + sizeof(data_store) / sizeof(data_element)), + NULL); } #if defined(CONFIG_ZTEST_NEW_API) @@ -344,27 +347,26 @@ static void testRingBufNextElementSizeSmall(void) uint8_t data_element[5]; uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(16)]; - status = testRingBufNextElement(data_store, data_element, - sizeof(data_element), sizeof(data_store) / sizeof(data_element)); + status = testRingBufNextElement( + data_store, data_element, sizeof(data_element), + sizeof(data_store) / sizeof(data_element)); zassert_true(status, NULL); } /** * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(ringbuf_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(ringbuf_tests, - ztest_unit_test(testRingBufPowerOfTwo), - ztest_unit_test(testRingBufSizeSmall), - ztest_unit_test(testRingBufSizeLarge), - ztest_unit_test(testRingBufSizeInvalid), - ztest_unit_test(testRingBufNextElementSizeSmall) - ); + ztest_test_suite( + ringbuf_tests, ztest_unit_test(testRingBufPowerOfTwo), + ztest_unit_test(testRingBufSizeSmall), + ztest_unit_test(testRingBufSizeLarge), + ztest_unit_test(testRingBufSizeInvalid), + ztest_unit_test(testRingBufNextElementSizeSmall)); ztest_run_test_suite(ringbuf_tests); } diff --git a/test/bacnet/basic/sys/sbuf/src/main.c b/test/bacnet/basic/sys/sbuf/src/main.c index ff60f712..3bdf2393 100644 --- a/test/bacnet/basic/sys/sbuf/src/main.c +++ b/test/bacnet/basic/sys/sbuf/src/main.c @@ -78,15 +78,12 @@ static void testStaticBuffer(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(sbuf_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(sbuf_tests, - ztest_unit_test(testStaticBuffer) - ); + ztest_test_suite(sbuf_tests, ztest_unit_test(testStaticBuffer)); ztest_run_test_suite(sbuf_tests); } diff --git a/test/bacnet/cov/src/main.c b/test/bacnet/cov/src/main.c index 2fa49e26..208726c3 100644 --- a/test/bacnet/cov/src/main.c +++ b/test/bacnet/cov/src/main.c @@ -70,7 +70,8 @@ int ucov_notify_decode_apdu( return len; } -static int cov_subscribe_decode_apdu(uint8_t *apdu, +static int cov_subscribe_decode_apdu( + uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id, BACNET_SUBSCRIBE_COV_DATA *data) @@ -98,7 +99,8 @@ static int cov_subscribe_decode_apdu(uint8_t *apdu, return len; } -static int cov_subscribe_property_decode_apdu(uint8_t *apdu, +static int cov_subscribe_property_decode_apdu( + uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id, BACNET_SUBSCRIBE_COV_DATA *data) @@ -132,13 +134,17 @@ static void testCOVNotifyData(BACNET_COV_DATA *data, BACNET_COV_DATA *test_data) BACNET_PROPERTY_VALUE *value = NULL; BACNET_PROPERTY_VALUE *test_value = NULL; - zassert_equal(test_data->subscriberProcessIdentifier, + zassert_equal( + test_data->subscriberProcessIdentifier, data->subscriberProcessIdentifier, NULL); - zassert_equal(test_data->initiatingDeviceIdentifier, - data->initiatingDeviceIdentifier, NULL); - zassert_equal(test_data->monitoredObjectIdentifier.type, + zassert_equal( + test_data->initiatingDeviceIdentifier, data->initiatingDeviceIdentifier, + NULL); + zassert_equal( + test_data->monitoredObjectIdentifier.type, data->monitoredObjectIdentifier.type, NULL); - zassert_equal(test_data->monitoredObjectIdentifier.instance, + zassert_equal( + test_data->monitoredObjectIdentifier.instance, data->monitoredObjectIdentifier.instance, NULL); zassert_equal(test_data->timeRemaining, data->timeRemaining, NULL); /* test the listOfValues in some clever manner */ @@ -147,12 +153,14 @@ static void testCOVNotifyData(BACNET_COV_DATA *data, BACNET_COV_DATA *test_data) while (value) { zassert_not_null(test_value, NULL); if (test_value) { - zassert_equal(test_value->propertyIdentifier, - value->propertyIdentifier, "property=%u test_property=%u", + zassert_equal( + test_value->propertyIdentifier, value->propertyIdentifier, + "property=%u test_property=%u", (unsigned)value->propertyIdentifier, (unsigned)test_value->propertyIdentifier); - zassert_equal(test_value->propertyArrayIndex, - value->propertyArrayIndex, NULL); + zassert_equal( + test_value->propertyArrayIndex, value->propertyArrayIndex, + NULL); zassert_equal(test_value->priority, value->priority, NULL); zassert_true( bacapp_same_value(&test_value->value, &value->value), NULL); @@ -241,11 +249,14 @@ static void testCOVNotify(void) static void testCOVSubscribeData( BACNET_SUBSCRIBE_COV_DATA *data, BACNET_SUBSCRIBE_COV_DATA *test_data) { - zassert_equal(test_data->subscriberProcessIdentifier, + zassert_equal( + test_data->subscriberProcessIdentifier, data->subscriberProcessIdentifier, NULL); - zassert_equal(test_data->monitoredObjectIdentifier.type, + zassert_equal( + test_data->monitoredObjectIdentifier.type, data->monitoredObjectIdentifier.type, NULL); - zassert_equal(test_data->monitoredObjectIdentifier.instance, + zassert_equal( + test_data->monitoredObjectIdentifier.instance, data->monitoredObjectIdentifier.instance, NULL); zassert_equal( test_data->cancellationRequest, data->cancellationRequest, NULL); @@ -253,7 +264,8 @@ static void testCOVSubscribeData( printf("cancellation request failed!\n"); } if (!test_data->cancellationRequest) { - zassert_equal(test_data->issueConfirmedNotifications, + zassert_equal( + test_data->issueConfirmedNotifications, data->issueConfirmedNotifications, NULL); zassert_equal(test_data->lifetime, data->lifetime, NULL); } @@ -263,20 +275,22 @@ static void testCOVSubscribePropertyData( BACNET_SUBSCRIBE_COV_DATA *data, BACNET_SUBSCRIBE_COV_DATA *test_data) { testCOVSubscribeData(data, test_data); - zassert_equal(test_data->monitoredProperty.propertyIdentifier, + zassert_equal( + test_data->monitoredProperty.propertyIdentifier, data->monitoredProperty.propertyIdentifier, NULL); - zassert_equal(test_data->monitoredProperty.propertyArrayIndex, + zassert_equal( + test_data->monitoredProperty.propertyArrayIndex, data->monitoredProperty.propertyArrayIndex, NULL); zassert_equal( test_data->covIncrementPresent, data->covIncrementPresent, NULL); if (test_data->covIncrementPresent) { - zassert_false(islessgreater(test_data->covIncrement, - data->covIncrement), NULL); + zassert_false( + islessgreater(test_data->covIncrement, data->covIncrement), NULL); } } -static void testCOVSubscribeEncoding( - uint8_t invoke_id, BACNET_SUBSCRIBE_COV_DATA *data) +static void +testCOVSubscribeEncoding(uint8_t invoke_id, BACNET_SUBSCRIBE_COV_DATA *data) { uint8_t apdu[480] = { 0 }; int len = 0; @@ -375,7 +389,8 @@ ZTEST_SUITE(cov_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(cov_tests, ztest_unit_test(testCOVNotify), + ztest_test_suite( + cov_tests, ztest_unit_test(testCOVNotify), ztest_unit_test(testCOVSubscribe), ztest_unit_test(testCOVSubscribeProperty)); diff --git a/test/bacnet/create_object/src/main.c b/test/bacnet/create_object/src/main.c index 3214d539..647949a4 100644 --- a/test/bacnet/create_object/src/main.c +++ b/test/bacnet/create_object/src/main.c @@ -107,15 +107,18 @@ static void test_CreateObjectError(void) null_len = create_object_error_ack_service_encode(NULL, &data); apdu_len = create_object_error_ack_service_encode(apdu, &data); zassert_equal(apdu_len, null_len, NULL); - test_len = create_object_error_ack_service_decode(apdu, apdu_len, &test_data); + test_len = + create_object_error_ack_service_decode(apdu, apdu_len, &test_data); zassert_equal(apdu_len, test_len, NULL); zassert_equal(test_data.error_class, data.error_class, NULL); zassert_equal(test_data.error_code, data.error_code, NULL); - zassert_equal(test_data.first_failed_element_number, - data.first_failed_element_number, NULL); + zassert_equal( + test_data.first_failed_element_number, data.first_failed_element_number, + NULL); while (test_len) { test_len--; - len = create_object_error_ack_service_decode(apdu, test_len, &test_data); + len = + create_object_error_ack_service_decode(apdu, test_len, &test_data); zassert_equal( len, BACNET_STATUS_REJECT, "len=%d test_len=%d", len, test_len); } @@ -130,7 +133,8 @@ ZTEST_SUITE(create_object_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(create_object_tests, ztest_unit_test(test_CreateObject), + ztest_test_suite( + create_object_tests, ztest_unit_test(test_CreateObject), ztest_unit_test(test_CreateObjectACK), ztest_unit_test(test_CreateObjectError)); diff --git a/test/bacnet/datalink/automac/src/main.c b/test/bacnet/datalink/automac/src/main.c index 5ffe89ec..9b55dbc7 100644 --- a/test/bacnet/datalink/automac/src/main.c +++ b/test/bacnet/datalink/automac/src/main.c @@ -59,7 +59,7 @@ static void test_automac_init(void) mac = automac_free_address_mac(1); zassert_equal(mac, (MSTP_MAC_SLOTS_OFFSET + 2), NULL); mac = automac_free_address_random(); - options = (mac == (MSTP_MAC_SLOTS_OFFSET + 1)) || + options = (mac == (MSTP_MAC_SLOTS_OFFSET + 1)) || (mac == (MSTP_MAC_SLOTS_OFFSET + 2)); zassert_true(options, NULL); /* test 3 free addresses */ @@ -71,9 +71,8 @@ static void test_automac_init(void) mac = automac_free_address_mac(2); zassert_equal(mac, 126, NULL); mac = automac_free_address_random(); - options = (mac == (MSTP_MAC_SLOTS_OFFSET + 1)) || - (mac == (MSTP_MAC_SLOTS_OFFSET + 2)) || - (mac == 126); + options = (mac == (MSTP_MAC_SLOTS_OFFSET + 1)) || + (mac == (MSTP_MAC_SLOTS_OFFSET + 2)) || (mac == 126); zassert_true(options, NULL); /* test the stored address */ mac = automac_address(); diff --git a/test/bacnet/datalink/bvlc/src/main.c b/test/bacnet/datalink/bvlc/src/main.c index bf54a0ed..fa4de445 100644 --- a/test/bacnet/datalink/bvlc/src/main.c +++ b/test/bacnet/datalink/bvlc/src/main.c @@ -8,7 +8,7 @@ * @brief test BACnet integer encode/decode APIs */ -#include /* For calloc() */ +#include /* For calloc() */ #include #include #include @@ -22,8 +22,7 @@ * @brief Test */ static void test_BVLC_Address( - BACNET_IP_ADDRESS *bip_address_1, - BACNET_IP_ADDRESS *bip_address_2) + BACNET_IP_ADDRESS *bip_address_1, BACNET_IP_ADDRESS *bip_address_2) { zassert_false(bvlc_address_different(bip_address_1, bip_address_2), NULL); } @@ -62,7 +61,7 @@ static void test_BVLC_Foreign_Device_Table_Entry( zassert_equal(fdt_entry_1->ttl_seconds, fdt_entry_2->ttl_seconds, NULL); zassert_equal( fdt_entry_1->ttl_seconds_remaining, - fdt_entry_2->ttl_seconds_remaining, NULL); + fdt_entry_2->ttl_seconds_remaining, NULL); } return; @@ -112,13 +111,15 @@ ZTEST(bvlc_tests, test_BVLC_Result) static void test_BVLC_Result(void) #endif { - uint16_t result_code[] = { BVLC_RESULT_SUCCESSFUL_COMPLETION, + uint16_t result_code[] = { + BVLC_RESULT_SUCCESSFUL_COMPLETION, BVLC_RESULT_WRITE_BROADCAST_DISTRIBUTION_TABLE_NAK, BVLC_RESULT_READ_BROADCAST_DISTRIBUTION_TABLE_NAK, BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK, BVLC_RESULT_READ_FOREIGN_DEVICE_TABLE_NAK, BVLC_RESULT_DELETE_FOREIGN_DEVICE_TABLE_ENTRY_NAK, - BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK }; + BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK + }; unsigned int i = 0; size_t result_code_max = sizeof(result_code) / sizeof(result_code[0]); @@ -127,8 +128,8 @@ static void test_BVLC_Result(void) } } -static void test_BVLC_Original_Unicast_NPDU_Message( - uint8_t *npdu, uint16_t npdu_len) +static void +test_BVLC_Original_Unicast_NPDU_Message(uint8_t *npdu, uint16_t npdu_len) { uint8_t test_npdu[50] = { 0 }; uint8_t pdu[60] = { 0 }; @@ -174,8 +175,8 @@ static void test_BVLC_Original_Unicast_NPDU(void) test_BVLC_Original_Unicast_NPDU_Message(npdu, npdu_len); } -static void test_BVLC_Original_Broadcast_NPDU_Message( - uint8_t *npdu, uint16_t npdu_len) +static void +test_BVLC_Original_Broadcast_NPDU_Message(uint8_t *npdu, uint16_t npdu_len) { uint8_t test_npdu[50] = { 0 }; uint8_t pdu[60] = { 0 }; @@ -222,9 +223,7 @@ static void test_BVLC_Original_Broadcast_NPDU(void) } static void test_BVLC_Forwarded_NPDU_Message( - uint8_t *npdu, - uint16_t npdu_len, - BACNET_IP_ADDRESS *bip_address) + uint8_t *npdu, uint16_t npdu_len, BACNET_IP_ADDRESS *bip_address) { uint8_t test_npdu[50] = { 0 }; uint8_t pdu[75] = { 0 }; @@ -243,8 +242,9 @@ static void test_BVLC_Forwarded_NPDU_Message( zassert_equal(test_len, 4, NULL); zassert_equal(message_type, BVLC_FORWARDED_NPDU, NULL); zassert_equal(length, msg_len, NULL); - test_len += bvlc_decode_forwarded_npdu(&pdu[4], length - 4, - &test_bip_address, test_npdu, sizeof(test_npdu), &test_npdu_len); + test_len += bvlc_decode_forwarded_npdu( + &pdu[4], length - 4, &test_bip_address, test_npdu, sizeof(test_npdu), + &test_npdu_len); zassert_equal(len, test_len, NULL); zassert_equal(msg_len, test_len, NULL); test_BVLC_Address(bip_address, &test_bip_address); @@ -278,8 +278,7 @@ static void test_BVLC_Forwarded_NPDU(void) test_BVLC_Forwarded_NPDU_Message(npdu, npdu_len, &bip_address); } -static void test_BVLC_Register_Foreign_Device_Message( - uint16_t ttl_seconds) +static void test_BVLC_Register_Foreign_Device_Message(uint16_t ttl_seconds) { uint8_t pdu[60] = { 0 }; uint16_t test_ttl_seconds = 0; @@ -338,8 +337,7 @@ static void test_BVLC_Delete_Foreign_Device_Message( if (msg_len != test_len) { printf("msg:%u test:%u\n", msg_len, test_len); } - test_BVLC_Address( - &fdt_entry->dest_address, &test_fdt_entry.dest_address); + test_BVLC_Address(&fdt_entry->dest_address, &test_fdt_entry.dest_address); } #if defined(CONFIG_ZTEST_NEW_API) @@ -364,8 +362,7 @@ static void test_BVLC_Delete_Foreign_Device(void) test_BVLC_Delete_Foreign_Device_Message(&fdt_entry); } -static void test_BVLC_Secure_BVLL_Message( - uint8_t *sbuf, uint16_t sbuf_len) +static void test_BVLC_Secure_BVLL_Message(uint8_t *sbuf, uint16_t sbuf_len) { uint8_t test_sbuf[50] = { 0 }; uint8_t pdu[60] = { 0 }; @@ -524,12 +521,12 @@ static void test_BVLC_Broadcast_Distribution_Table_Encode(void) } zassert_equal(test_count, count, NULL); /* test the encode/decode pair */ - apdu_len = bvlc_broadcast_distribution_table_encode(&apdu[0], - sizeof(apdu), &bdt_list[0]); + apdu_len = bvlc_broadcast_distribution_table_encode( + &apdu[0], sizeof(apdu), &bdt_list[0]); test_count = sizeof(test_bdt_list) / sizeof(test_bdt_list[0]); bvlc_broadcast_distribution_table_link_array(&test_bdt_list[0], test_count); - test_apdu_len = bvlc_broadcast_distribution_table_decode(&apdu[0], - apdu_len, &error_code, &test_bdt_list[0]); + test_apdu_len = bvlc_broadcast_distribution_table_decode( + &apdu[0], apdu_len, &error_code, &test_bdt_list[0]); zassert_equal(test_apdu_len, apdu_len, NULL); count = bvlc_broadcast_distribution_table_count(&test_bdt_list[0]); zassert_equal(test_count, count, NULL); @@ -662,8 +659,7 @@ static void test_BVLC_Read_Foreign_Device_Table_Ack_Message( &pdu[4], length - 4, test_fdt_list); zassert_equal(msg_len, test_len, NULL); for (i = 0; i < count; i++) { - test_BVLC_Foreign_Device_Table_Entry( - &fdt_list[i], &test_fdt_list[i]); + test_BVLC_Foreign_Device_Table_Entry(&fdt_list[i], &test_fdt_list[i]); } } @@ -705,15 +701,13 @@ static void test_BVLC_Read_Foreign_Device_Table_Ack(void) } test_count = bvlc_foreign_device_table_valid_count(fdt_list); zassert_equal(test_count, count, NULL); - test_BVLC_Read_Foreign_Device_Table_Ack_Message( - npdu, npdu_len, fdt_list); + test_BVLC_Read_Foreign_Device_Table_Ack_Message(npdu, npdu_len, fdt_list); /* now with some NPDU data */ for (i = 0; i < sizeof(npdu); i++) { npdu[i] = i; } npdu_len = sizeof(npdu); - test_BVLC_Read_Foreign_Device_Table_Ack_Message( - npdu, npdu_len, fdt_list); + test_BVLC_Read_Foreign_Device_Table_Ack_Message(npdu, npdu_len, fdt_list); /* cleanup */ for (i = 0; i < count; i++) { dest_address.port = test_port_start + i; @@ -824,14 +818,14 @@ static void test_BVLC_Address_Get_Set(void) if (status) { status = bvlc_address_get( &src, &test_octet0, &test_octet1, &test_octet2, &test_octet3); - printf("src:%u.%u.%u.%u\n", (unsigned)test_octet0, - (unsigned)test_octet1, (unsigned)test_octet2, - (unsigned)test_octet3); + printf( + "src:%u.%u.%u.%u\n", (unsigned)test_octet0, (unsigned)test_octet1, + (unsigned)test_octet2, (unsigned)test_octet3); status = bvlc_address_get( &dst, &test_octet0, &test_octet1, &test_octet2, &test_octet3); - printf("dst:%u.%u.%u.%u\n", (unsigned)test_octet0, - (unsigned)test_octet1, (unsigned)test_octet2, - (unsigned)test_octet3); + printf( + "dst:%u.%u.%u.%u\n", (unsigned)test_octet0, (unsigned)test_octet1, + (unsigned)test_octet2, (unsigned)test_octet3); } zassert_false(status, NULL); /* BACnet to IPv4 address conversions */ @@ -887,14 +881,14 @@ static void test_BVLC_BBMD_Address(void) BACNET_ERROR_CODE error_code = ERROR_CODE_SUCCESS; bool status = false; - status = bvlc_address_port_from_ascii( - &bbmd_address, "192.168.0.255", "0xBAC0"); + status = + bvlc_address_port_from_ascii(&bbmd_address, "192.168.0.255", "0xBAC0"); zassert_true(status, NULL); - apdu_len = bvlc_foreign_device_bbmd_host_address_encode(apdu, sizeof(apdu), - &bbmd_address); + apdu_len = bvlc_foreign_device_bbmd_host_address_encode( + apdu, sizeof(apdu), &bbmd_address); zassert_not_equal(apdu_len, 0, NULL); - test_apdu_len = bvlc_foreign_device_bbmd_host_address_decode(apdu, - apdu_len, &error_code, &test_bbmd_address); + test_apdu_len = bvlc_foreign_device_bbmd_host_address_decode( + apdu, apdu_len, &error_code, &test_bbmd_address); if (test_apdu_len < 0) { printf("BVLC: error-code=%s\n", bactext_error_code_name(error_code)); } @@ -910,29 +904,27 @@ static void test_BVLC_BBMD_Address(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(bvlc_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(bvlc_tests, - ztest_unit_test(test_BVLC_Result), - ztest_unit_test(test_BVLC_Write_Broadcast_Distribution_Table), - ztest_unit_test(test_BVLC_Read_Broadcast_Distribution_Table_Message), - ztest_unit_test(test_BVLC_Forwarded_NPDU), - ztest_unit_test(test_BVLC_Register_Foreign_Device), - ztest_unit_test(test_BVLC_Read_Foreign_Device_Table_Ack), - ztest_unit_test(test_BVLC_Delete_Foreign_Device), - ztest_unit_test(test_BVLC_Distribute_Broadcast_To_Network), - ztest_unit_test(test_BVLC_Broadcast_Distribution_Table_Encode), - ztest_unit_test(test_BVLC_Original_Unicast_NPDU), - ztest_unit_test(test_BVLC_Original_Broadcast_NPDU), - ztest_unit_test(test_BVLC_Secure_BVLL), - ztest_unit_test(test_BVLC_Address_Copy), - ztest_unit_test(test_BVLC_Address_Get_Set), - ztest_unit_test(test_BVLC_BBMD_Address) - ); + ztest_test_suite( + bvlc_tests, ztest_unit_test(test_BVLC_Result), + ztest_unit_test(test_BVLC_Write_Broadcast_Distribution_Table), + ztest_unit_test(test_BVLC_Read_Broadcast_Distribution_Table_Message), + ztest_unit_test(test_BVLC_Forwarded_NPDU), + ztest_unit_test(test_BVLC_Register_Foreign_Device), + ztest_unit_test(test_BVLC_Read_Foreign_Device_Table_Ack), + ztest_unit_test(test_BVLC_Delete_Foreign_Device), + ztest_unit_test(test_BVLC_Distribute_Broadcast_To_Network), + ztest_unit_test(test_BVLC_Broadcast_Distribution_Table_Encode), + ztest_unit_test(test_BVLC_Original_Unicast_NPDU), + ztest_unit_test(test_BVLC_Original_Broadcast_NPDU), + ztest_unit_test(test_BVLC_Secure_BVLL), + ztest_unit_test(test_BVLC_Address_Copy), + ztest_unit_test(test_BVLC_Address_Get_Set), + ztest_unit_test(test_BVLC_BBMD_Address)); ztest_run_test_suite(bvlc_tests); } diff --git a/test/bacnet/datalink/cobs/src/main.c b/test/bacnet/datalink/cobs/src/main.c index b97a2a30..2750d55e 100644 --- a/test/bacnet/datalink/cobs/src/main.c +++ b/test/bacnet/datalink/cobs/src/main.c @@ -28,42 +28,40 @@ static void test_COBS_Encode_Decode(void) #endif { uint8_t buffer[MAX_APDU] = { 0x55, 0xff, 0 }; - uint8_t encoded_buffer[COBS_ENCODED_SIZE(MAX_APDU)+ - COBS_ENCODED_CRC_SIZE] = { 0 }; - //uint8_t encoded_buffer[MAX_APDU*2] = { 0 }; + uint8_t + encoded_buffer[COBS_ENCODED_SIZE(MAX_APDU) + COBS_ENCODED_CRC_SIZE] = { + 0 + }; + // uint8_t encoded_buffer[MAX_APDU*2] = { 0 }; uint8_t test_buffer[MAX_APDU] = { 0 }; unsigned i; size_t encoded_buffer_length, test_buffer_length; for (i = 2; i < sizeof(buffer); i++) { - buffer[i] = i%0xff; + buffer[i] = i % 0xff; } - encoded_buffer_length = cobs_frame_encode(encoded_buffer, - sizeof(encoded_buffer), buffer, sizeof(buffer)); - zassert_true(encoded_buffer_length > 0, - "COBS encoded buffer empty!"); - test_buffer_length = cobs_frame_decode(test_buffer, sizeof(test_buffer), - encoded_buffer, encoded_buffer_length); + encoded_buffer_length = cobs_frame_encode( + encoded_buffer, sizeof(encoded_buffer), buffer, sizeof(buffer)); + zassert_true(encoded_buffer_length > 0, "COBS encoded buffer empty!"); + test_buffer_length = cobs_frame_decode( + test_buffer, sizeof(test_buffer), encoded_buffer, + encoded_buffer_length); for (i = 0; i < sizeof(buffer); i++) { - zassert_true(buffer[i] == test_buffer[i], - "COBS encode/decode fail"); + zassert_true(buffer[i] == test_buffer[i], "COBS encode/decode fail"); } - zassert_true(test_buffer_length == sizeof(buffer), - "COBS encode/decode length fail"); + zassert_true( + test_buffer_length == sizeof(buffer), "COBS encode/decode length fail"); } /** * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(cobs_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(cobs_tests, - ztest_unit_test(test_COBS_Encode_Decode) - ); + ztest_test_suite(cobs_tests, ztest_unit_test(test_COBS_Encode_Decode)); ztest_run_test_suite(cobs_tests); } diff --git a/test/bacnet/datalink/crc/src/main.c b/test/bacnet/datalink/crc/src/main.c index 883d929d..7275d1d1 100644 --- a/test/bacnet/datalink/crc/src/main.c +++ b/test/bacnet/datalink/crc/src/main.c @@ -135,18 +135,15 @@ static void testCRC16CreateTable(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(crc_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(crc_tests, - ztest_unit_test(testCRC8), - ztest_unit_test(testCRC16), - ztest_unit_test(testCRC8CreateTable), - ztest_unit_test(testCRC16CreateTable) - ); + ztest_test_suite( + crc_tests, ztest_unit_test(testCRC8), ztest_unit_test(testCRC16), + ztest_unit_test(testCRC8CreateTable), + ztest_unit_test(testCRC16CreateTable)); ztest_run_test_suite(crc_tests); } diff --git a/test/bacnet/datalink/mock/src/arcnet-mock.c b/test/bacnet/datalink/mock/src/arcnet-mock.c index f5733fa3..e1e39f56 100644 --- a/test/bacnet/datalink/mock/src/arcnet-mock.c +++ b/test/bacnet/datalink/mock/src/arcnet-mock.c @@ -23,8 +23,11 @@ bool arcnet_init(char *interface_name) return ztest_get_return_value(); } -int arcnet_send_pdu(BACNET_ADDRESS *dest, BACNET_NPDU_DATA *npdu_data, - uint8_t *pdu, unsigned pdu_len) +int arcnet_send_pdu( + BACNET_ADDRESS *dest, + BACNET_NPDU_DATA *npdu_data, + uint8_t *pdu, + unsigned pdu_len) { ztest_check_expected_value(dest); ztest_check_expected_value(npdu_data); @@ -32,8 +35,8 @@ int arcnet_send_pdu(BACNET_ADDRESS *dest, BACNET_NPDU_DATA *npdu_data, return ztest_get_return_value(); } -uint16_t arcnet_receive(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, - unsigned timeout) +uint16_t arcnet_receive( + BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, unsigned timeout) { ztest_check_expected_value(src); ztest_check_expected_value(timeout); diff --git a/test/bacnet/datalink/mock/src/bip-mock.c b/test/bacnet/datalink/mock/src/bip-mock.c index ae82439a..1a085337 100644 --- a/test/bacnet/datalink/mock/src/bip-mock.c +++ b/test/bacnet/datalink/mock/src/bip-mock.c @@ -44,7 +44,8 @@ void bip_get_my_address(BACNET_ADDRESS *my_address) ztest_copy_return_data(my_address, sizeof(BACNET_ADDRESS)); } -int bip_send_pdu(BACNET_ADDRESS *dest, +int bip_send_pdu( + BACNET_ADDRESS *dest, BACNET_NPDU_DATA *npdu_data, uint8_t *pdu, unsigned pdu_len) @@ -62,8 +63,8 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len) return ztest_get_return_value(); } -uint16_t bip_receive(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, - unsigned timeout) +uint16_t bip_receive( + BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, unsigned timeout) { ztest_check_expected_value(src); ztest_check_expected_value(timeout); diff --git a/test/bacnet/datalink/mock/src/bip6-mock.c b/test/bacnet/datalink/mock/src/bip6-mock.c index 2ed6296e..d1492642 100644 --- a/test/bacnet/datalink/mock/src/bip6-mock.c +++ b/test/bacnet/datalink/mock/src/bip6-mock.c @@ -32,7 +32,8 @@ void bip6_get_my_address(BACNET_ADDRESS *my_address) ztest_copy_return_data(my_address, sizeof(BACNET_ADDRESS)); } -int bip6_send_pdu(BACNET_ADDRESS *dest, +int bip6_send_pdu( + BACNET_ADDRESS *dest, BACNET_NPDU_DATA *npdu_data, uint8_t *pdu, unsigned pdu_len) diff --git a/test/bacnet/datalink/mock/src/dlmstp-mock.c b/test/bacnet/datalink/mock/src/dlmstp-mock.c index 464c8563..dac6c754 100644 --- a/test/bacnet/datalink/mock/src/dlmstp-mock.c +++ b/test/bacnet/datalink/mock/src/dlmstp-mock.c @@ -16,15 +16,18 @@ bool dlmstp_init(char *ifname) } void dlmstp_reset(void) -{ +{ } void dlmstp_cleanup(void) { } -int dlmstp_send_pdu(BACNET_ADDRESS *dest, BACNET_NPDU_DATA *npdu_data, - uint8_t * pdu, unsigned pdu_len) +int dlmstp_send_pdu( + BACNET_ADDRESS *dest, + BACNET_NPDU_DATA *npdu_data, + uint8_t *pdu, + unsigned pdu_len) { ztest_check_expected_value(dest); ztest_check_expected_value(npdu_data); @@ -32,8 +35,8 @@ int dlmstp_send_pdu(BACNET_ADDRESS *dest, BACNET_NPDU_DATA *npdu_data, return ztest_get_return_value(); } -uint16_t dlmstp_receive(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, - unsigned timeout) +uint16_t dlmstp_receive( + BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, unsigned timeout) { ztest_check_expected_value(src); ztest_check_expected_value(timeout); @@ -128,8 +131,7 @@ void dlmstp_set_frame_rx_complete_callback( ztest_check_expected_value(cb_func); } -void dlmstp_set_frame_rx_start_callback( - dlmstp_hook_frame_rx_start_cb cb_func) +void dlmstp_set_frame_rx_start_callback(dlmstp_hook_frame_rx_start_cb cb_func) { ztest_check_expected_value(cb_func); } diff --git a/test/bacnet/datalink/mock/src/ethernet-mock.c b/test/bacnet/datalink/mock/src/ethernet-mock.c index e0c45f23..e2d7bdba 100644 --- a/test/bacnet/datalink/mock/src/ethernet-mock.c +++ b/test/bacnet/datalink/mock/src/ethernet-mock.c @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2020 Legrand North America, LLC. * * SPDX-License-Identifier: MIT @@ -24,8 +24,11 @@ bool ethernet_init(char *interface_name) return ztest_get_return_value(); } -int ethernet_send_pdu(BACNET_ADDRESS *dest, BACNET_NPDU_DATA *npdu_data, - uint8_t *pdu, unsigned pdu_len) +int ethernet_send_pdu( + BACNET_ADDRESS *dest, + BACNET_NPDU_DATA *npdu_data, + uint8_t *pdu, + unsigned pdu_len) { ztest_check_expected_value(dest); ztest_check_expected_value(npdu_data); @@ -33,8 +36,8 @@ int ethernet_send_pdu(BACNET_ADDRESS *dest, BACNET_NPDU_DATA *npdu_data, return ztest_get_return_value(); } -uint16_t ethernet_receive(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, - unsigned timeout) +uint16_t ethernet_receive( + BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, unsigned timeout) { ztest_check_expected_value(src); ztest_check_expected_value(timeout); @@ -42,7 +45,6 @@ uint16_t ethernet_receive(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t max_pdu, return ztest_get_return_value(); } - void ethernet_set_my_address(BACNET_ADDRESS *my_address) { ztest_check_expected_data(my_address, sizeof(BACNET_ADDRESS)); diff --git a/test/bacnet/datalink/mock/src/main.c b/test/bacnet/datalink/mock/src/main.c index c1937fc2..fcda4575 100644 --- a/test/bacnet/datalink/mock/src/main.c +++ b/test/bacnet/datalink/mock/src/main.c @@ -8,7 +8,7 @@ * @brief test BACnet datalink return codes */ -#include /* For calloc() */ +#include /* For calloc() */ #include #include #include "bacnet/apdu.h" @@ -42,15 +42,14 @@ static void test_datalink_arcnet(void) char *iface2 = "bla-bla-bla2"; uint8_t expected_data[] = { 0x5A, 0xA5, 0xDE, 0xAD }; uint8_t data[] = { 0xFF, 0xFF, 0xFF, 0xFF }; - BACNET_ADDRESS addr = { - .mac_len = 6, - .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, - .net = 54, - .len = 7, - .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32 } - }; - BACNET_ADDRESS addr2 = {0}; - BACNET_NPDU_DATA npdu = {0}; + BACNET_ADDRESS addr = { .mac_len = 6, + .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, + .net = 54, + .len = 7, + .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, + 0x32 } }; + BACNET_ADDRESS addr2 = { 0 }; + BACNET_NPDU_DATA npdu = { 0 }; zassert_equal(z_cleanup_mock(), 0, NULL); datalink_set("arcnet"); @@ -71,8 +70,9 @@ static void test_datalink_arcnet(void) ztest_expect_value(arcnet_send_pdu, npdu_data, &npdu); ztest_expect_data(arcnet_send_pdu, pdu, expected_data); ztest_returns_value(arcnet_send_pdu, 4); - zassert_equal(datalink_send_pdu(&addr, &npdu, expected_data, - sizeof(expected_data)), 4, NULL); + zassert_equal( + datalink_send_pdu(&addr, &npdu, expected_data, sizeof(expected_data)), + 4, NULL); zassert_equal(z_cleanup_mock(), 0, NULL); // receive @@ -123,15 +123,14 @@ static void test_datalink_bip(void) char *iface2 = "bla-bla-bla2"; uint8_t expected_data[] = { 0x5A, 0xA5, 0xDE, 0xAD }; uint8_t data[] = { 0xFF, 0xFF, 0xFF, 0xFF }; - BACNET_ADDRESS addr = { - .mac_len = 6, - .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, - .net = 54, - .len = 7, - .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32 } - }; - BACNET_ADDRESS addr2 = {0}; - BACNET_NPDU_DATA npdu = {0}; + BACNET_ADDRESS addr = { .mac_len = 6, + .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, + .net = 54, + .len = 7, + .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, + 0x32 } }; + BACNET_ADDRESS addr2 = { 0 }; + BACNET_NPDU_DATA npdu = { 0 }; zassert_equal(z_cleanup_mock(), 0, NULL); datalink_set("bip"); @@ -152,8 +151,9 @@ static void test_datalink_bip(void) ztest_expect_value(bip_send_pdu, npdu_data, &npdu); ztest_expect_data(bip_send_pdu, pdu, expected_data); ztest_returns_value(bip_send_pdu, 4); - zassert_equal(datalink_send_pdu(&addr, &npdu, expected_data, - sizeof(expected_data)), 4, NULL); + zassert_equal( + datalink_send_pdu(&addr, &npdu, expected_data, sizeof(expected_data)), + 4, NULL); zassert_equal(z_cleanup_mock(), 0, NULL); // receive @@ -207,15 +207,14 @@ static void test_datalink_bip6(void) char *iface2 = "bla-bla-bla2"; uint8_t expected_data[] = { 0x5A, 0xA5, 0xDE, 0xAD }; uint8_t data[] = { 0xFF, 0xFF, 0xFF, 0xFF }; - BACNET_ADDRESS addr = { - .mac_len = 6, - .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, - .net = 54, - .len = 7, - .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32 } - }; - BACNET_ADDRESS addr2 = {0}; - BACNET_NPDU_DATA npdu = {0}; + BACNET_ADDRESS addr = { .mac_len = 6, + .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, + .net = 54, + .len = 7, + .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, + 0x32 } }; + BACNET_ADDRESS addr2 = { 0 }; + BACNET_NPDU_DATA npdu = { 0 }; zassert_equal(z_cleanup_mock(), 0, NULL); datalink_set("bip6"); @@ -236,8 +235,9 @@ static void test_datalink_bip6(void) ztest_expect_value(bip6_send_pdu, npdu_data, &npdu); ztest_expect_data(bip6_send_pdu, pdu, expected_data); ztest_returns_value(bip6_send_pdu, 4); - zassert_equal(datalink_send_pdu(&addr, &npdu, expected_data, - sizeof(expected_data)), 4, NULL); + zassert_equal( + datalink_send_pdu(&addr, &npdu, expected_data, sizeof(expected_data)), + 4, NULL); zassert_equal(z_cleanup_mock(), 0, NULL); // receive @@ -290,15 +290,14 @@ static void test_datalink_dlmstp(void) char *iface2 = "bla-bla-bla2"; uint8_t expected_data[] = { 0x5A, 0xA5, 0xDE, 0xAD }; uint8_t data[] = { 0xFF, 0xFF, 0xFF, 0xFF }; - BACNET_ADDRESS addr = { - .mac_len = 6, - .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, - .net = 54, - .len = 7, - .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32 } - }; - BACNET_ADDRESS addr2 = {0}; - BACNET_NPDU_DATA npdu = {0}; + BACNET_ADDRESS addr = { .mac_len = 6, + .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, + .net = 54, + .len = 7, + .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, + 0x32 } }; + BACNET_ADDRESS addr2 = { 0 }; + BACNET_NPDU_DATA npdu = { 0 }; zassert_equal(z_cleanup_mock(), 0, NULL); datalink_set("mstp"); @@ -319,8 +318,9 @@ static void test_datalink_dlmstp(void) ztest_expect_value(dlmstp_send_pdu, npdu_data, &npdu); ztest_expect_data(dlmstp_send_pdu, pdu, expected_data); ztest_returns_value(dlmstp_send_pdu, 4); - zassert_equal(datalink_send_pdu(&addr, &npdu, expected_data, - sizeof(expected_data)), 4, NULL); + zassert_equal( + datalink_send_pdu(&addr, &npdu, expected_data, sizeof(expected_data)), + 4, NULL); zassert_equal(z_cleanup_mock(), 0, NULL); // receive @@ -371,15 +371,14 @@ static void test_datalink_ethernet(void) char *iface2 = "bla-bla-bla2"; uint8_t expected_data[] = { 0x5A, 0xA5, 0xDE, 0xAD }; uint8_t data[] = { 0xFF, 0xFF, 0xFF, 0xFF }; - BACNET_ADDRESS addr = { - .mac_len = 6, - .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, - .net = 54, - .len = 7, - .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32 } - }; - BACNET_ADDRESS addr2 = {0}; - BACNET_NPDU_DATA npdu = {0}; + BACNET_ADDRESS addr = { .mac_len = 6, + .mac = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE }, + .net = 54, + .len = 7, + .adr = { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, + 0x32 } }; + BACNET_ADDRESS addr2 = { 0 }; + BACNET_NPDU_DATA npdu = { 0 }; zassert_equal(z_cleanup_mock(), 0, NULL); datalink_set("ethernet"); @@ -400,8 +399,9 @@ static void test_datalink_ethernet(void) ztest_expect_value(ethernet_send_pdu, npdu_data, &npdu); ztest_expect_data(ethernet_send_pdu, pdu, expected_data); ztest_returns_value(ethernet_send_pdu, 4); - zassert_equal(datalink_send_pdu(&addr, &npdu, expected_data, - sizeof(expected_data)), 4, NULL); + zassert_equal( + datalink_send_pdu(&addr, &npdu, expected_data, sizeof(expected_data)), + 4, NULL); zassert_equal(z_cleanup_mock(), 0, NULL); // receive @@ -442,7 +442,6 @@ static void test_datalink_ethernet(void) datalink_maintenance_timer(42); } - /** * @} */ @@ -452,13 +451,11 @@ ZTEST_SUITE(datalink_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(datalink_tests, - ztest_unit_test(test_datalink_arcnet), - ztest_unit_test(test_datalink_bip), - ztest_unit_test(test_datalink_bip6), - ztest_unit_test(test_datalink_dlmstp), - ztest_unit_test(test_datalink_ethernet) - ); + ztest_test_suite( + datalink_tests, ztest_unit_test(test_datalink_arcnet), + ztest_unit_test(test_datalink_bip), ztest_unit_test(test_datalink_bip6), + ztest_unit_test(test_datalink_dlmstp), + ztest_unit_test(test_datalink_ethernet)); ztest_run_test_suite(datalink_tests); } diff --git a/test/bacnet/datalink/mstp/src/main.c b/test/bacnet/datalink/mstp/src/main.c index 3920527f..d8da83d7 100644 --- a/test/bacnet/datalink/mstp/src/main.c +++ b/test/bacnet/datalink/mstp/src/main.c @@ -429,8 +429,8 @@ static void testReceiveNodeFSM(void) /* BadCRC in header check */ mstp_port.ReceivedInvalidFrame = false; mstp_port.ReceivedValidFrame = false; - len = MSTP_Create_Frame(buffer, sizeof(buffer), FRAME_TYPE_TOKEN, - 0x10, /* destination */ + len = MSTP_Create_Frame( + buffer, sizeof(buffer), FRAME_TYPE_TOKEN, 0x10, /* destination */ my_mac, /* source */ NULL, /* data */ 0); /* data size */ @@ -444,8 +444,9 @@ static void testReceiveNodeFSM(void) MSTP_Receive_Frame_FSM(&mstp_port); zassert_true(mstp_port.DataAvailable == false, NULL); zassert_true(mstp_port.SilenceTimer(&mstp_port) == 0, NULL); - zassert_true(mstp_port.EventCount == EventCount, "i=%u %u!=%u len=%u", - i, mstp_port.EventCount, EventCount, len); + zassert_true( + mstp_port.EventCount == EventCount, "i=%u %u!=%u len=%u", i, + mstp_port.EventCount, EventCount, len); } zassert_true(mstp_port.ReceivedInvalidFrame == true, NULL); zassert_true(mstp_port.ReceivedValidFrame == false, NULL); @@ -453,8 +454,8 @@ static void testReceiveNodeFSM(void) /* NoData for us */ mstp_port.ReceivedInvalidFrame = false; mstp_port.ReceivedValidFrame = false; - len = MSTP_Create_Frame(buffer, sizeof(buffer), FRAME_TYPE_TOKEN, - my_mac, /* destination */ + len = MSTP_Create_Frame( + buffer, sizeof(buffer), FRAME_TYPE_TOKEN, my_mac, /* destination */ my_mac, /* source */ NULL, /* data */ 0); /* data size */ @@ -474,8 +475,8 @@ static void testReceiveNodeFSM(void) /* FrameTooLong */ mstp_port.ReceivedInvalidFrame = false; mstp_port.ReceivedValidFrame = false; - len = MSTP_Create_Frame(buffer, sizeof(buffer), FRAME_TYPE_TOKEN, - my_mac, /* destination */ + len = MSTP_Create_Frame( + buffer, sizeof(buffer), FRAME_TYPE_TOKEN, my_mac, /* destination */ my_mac, /* source */ NULL, /* data */ 0); /* data size */ @@ -498,8 +499,9 @@ static void testReceiveNodeFSM(void) mstp_port.ReceivedInvalidFrame = false; mstp_port.ReceivedValidFrame = false; memset(data_proprietary, 0, sizeof(data_proprietary)); - len = MSTP_Create_Frame(buffer, sizeof(buffer), FRAME_TYPE_PROPRIETARY_MIN, - my_mac, my_mac, data_proprietary, sizeof(data_proprietary)); + len = MSTP_Create_Frame( + buffer, sizeof(buffer), FRAME_TYPE_PROPRIETARY_MIN, my_mac, my_mac, + data_proprietary, sizeof(data_proprietary)); zassert_true(len > 0, NULL); Load_Input_Buffer(buffer, len); RS485_Check_UART_Data(&mstp_port); @@ -517,8 +519,8 @@ static void testReceiveNodeFSM(void) mstp_port.ReceivedInvalidFrame = false; mstp_port.ReceivedValidFrame = false; memset(data, 0, sizeof(data)); - len = MSTP_Create_Frame(buffer, sizeof(buffer), - FRAME_TYPE_BACNET_EXTENDED_DATA_EXPECTING_REPLY, + len = MSTP_Create_Frame( + buffer, sizeof(buffer), FRAME_TYPE_BACNET_EXTENDED_DATA_EXPECTING_REPLY, my_mac, my_mac, data, Nmin_COBS_length_BACnet); zassert_true(len > 0, NULL); Load_Input_Buffer(buffer, len); @@ -532,15 +534,17 @@ static void testReceiveNodeFSM(void) zassert_true(mstp_port.ReceivedInvalidFrame == false, NULL); zassert_true(mstp_port.ReceivedValidFrame == true, NULL); zassert_true(mstp_port.receive_state == MSTP_RECEIVE_STATE_IDLE, NULL); - zassert_true(mstp_port.FrameType == - FRAME_TYPE_BACNET_EXTENDED_DATA_EXPECTING_REPLY, NULL); + zassert_true( + mstp_port.FrameType == FRAME_TYPE_BACNET_EXTENDED_DATA_EXPECTING_REPLY, + NULL); /* Extended-Data-Not-Expecting-Reply */ mstp_port.ReceivedInvalidFrame = false; mstp_port.ReceivedValidFrame = false; memset(data, 0, sizeof(data)); - len = MSTP_Create_Frame(buffer, sizeof(buffer), - FRAME_TYPE_BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY, - my_mac, my_mac, data, Nmin_COBS_length_BACnet); + len = MSTP_Create_Frame( + buffer, sizeof(buffer), + FRAME_TYPE_BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY, my_mac, my_mac, + data, Nmin_COBS_length_BACnet); zassert_true(len > 0, NULL); Load_Input_Buffer(buffer, len); RS485_Check_UART_Data(&mstp_port); @@ -553,8 +557,10 @@ static void testReceiveNodeFSM(void) zassert_true(mstp_port.ReceivedInvalidFrame == false, NULL); zassert_true(mstp_port.ReceivedValidFrame == true, NULL); zassert_true(mstp_port.receive_state == MSTP_RECEIVE_STATE_IDLE, NULL); - zassert_true(mstp_port.FrameType == - FRAME_TYPE_BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY, NULL); + zassert_true( + mstp_port.FrameType == + FRAME_TYPE_BACNET_EXTENDED_DATA_NOT_EXPECTING_REPLY, + NULL); } static void testMasterNodeFSM(void) @@ -667,8 +673,8 @@ static void testZeroConfigNode_Init(struct mstp_port_struct_t *mstp_port) zassert_true(mstp_port->Zero_Config_Max_Master == 0, NULL); } -static void testZeroConfigNode_No_Events_Timeout( - struct mstp_port_struct_t *mstp_port) +static void +testZeroConfigNode_No_Events_Timeout(struct mstp_port_struct_t *mstp_port) { bool transition_now, non_zero; unsigned slots, silence, i; @@ -696,8 +702,8 @@ static void testZeroConfigNode_Test_Request_Unsupported( mstp_port->This_Station == mstp_port->Zero_Config_Station, NULL); } -static void testZeroConfigNode_Test_Request_Supported( - struct mstp_port_struct_t *mstp_port) +static void +testZeroConfigNode_Test_Request_Supported(struct mstp_port_struct_t *mstp_port) { bool transition_now, non_zero; unsigned slots, silence, i; @@ -716,8 +722,8 @@ static void testZeroConfigNode_Test_Request_Supported( mstp_port->This_Station == mstp_port->Zero_Config_Station, NULL); } -static void testZeroConfigNode_Test_IDLE_InvalidFrame( - struct mstp_port_struct_t *mstp_port) +static void +testZeroConfigNode_Test_IDLE_InvalidFrame(struct mstp_port_struct_t *mstp_port) { bool transition_now, non_zero; unsigned slots, silence, i; @@ -765,8 +771,8 @@ static void testZeroConfigNode_Test_IDLE_ValidFrameTimeout( mstp_port->Zero_Config_State == MSTP_ZERO_CONFIG_STATE_IDLE, NULL); } -static void testZeroConfigNode_Test_IDLE_ValidFrame( - struct mstp_port_struct_t *mstp_port) +static void +testZeroConfigNode_Test_IDLE_ValidFrame(struct mstp_port_struct_t *mstp_port) { bool transition_now, non_zero; unsigned slots, silence, i; @@ -783,8 +789,8 @@ static void testZeroConfigNode_Test_IDLE_ValidFrame( zassert_true(mstp_port->ReceivedValidFrame == true, NULL); } -static void testZeroConfigNode_Test_LURK_AddressInUse( - struct mstp_port_struct_t *mstp_port) +static void +testZeroConfigNode_Test_LURK_AddressInUse(struct mstp_port_struct_t *mstp_port) { bool transition_now, non_zero; unsigned slots, silence, i; @@ -804,7 +810,8 @@ static void testZeroConfigNode_Test_LURK_AddressInUse( zassert_true( mstp_port->Zero_Config_State == MSTP_ZERO_CONFIG_STATE_LURK, NULL); zassert_true(mstp_port->ReceivedValidFrame == false, NULL); - zassert_true(mstp_port->Zero_Config_Station != src, "src=%u zc=%u", src, + zassert_true( + mstp_port->Zero_Config_Station != src, "src=%u zc=%u", src, mstp_port->Zero_Config_Station); } } @@ -832,8 +839,8 @@ static void testZeroConfigNode_Test_LURK_LearnMaxMaster( } } -static void testZeroConfigNode_Test_LURK_Claim( - struct mstp_port_struct_t *mstp_port) +static void +testZeroConfigNode_Test_LURK_Claim(struct mstp_port_struct_t *mstp_port) { bool transition_now, non_zero; unsigned slots, silence, i; @@ -858,8 +865,8 @@ static void testZeroConfigNode_Test_LURK_Claim( zassert_true( mstp_port->Zero_Config_State == MSTP_ZERO_CONFIG_STATE_CLAIM, NULL); - } else if (mstp_port->Zero_Config_State == - MSTP_ZERO_CONFIG_STATE_LURK) { + } else if ( + mstp_port->Zero_Config_State == MSTP_ZERO_CONFIG_STATE_LURK) { zassert_true( mstp_port->Poll_Count == (count + 1), "count=%u", count); zassert_true( @@ -870,9 +877,11 @@ static void testZeroConfigNode_Test_LURK_Claim( } } /* verify the Reply To Poll For Master was sent for confirmation */ - zassert_equal(mstp_port->OutputBuffer[2], FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER, NULL); + zassert_equal( + mstp_port->OutputBuffer[2], FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER, NULL); zassert_equal(mstp_port->OutputBuffer[3], mstp_port->SourceAddress, NULL); - zassert_equal(mstp_port->OutputBuffer[4], mstp_port->Zero_Config_Station, NULL); + zassert_equal( + mstp_port->OutputBuffer[4], mstp_port->Zero_Config_Station, NULL); } static void testZeroConfigNode_Test_LURK_ClaimTokenForUs( @@ -890,11 +899,13 @@ static void testZeroConfigNode_Test_LURK_ClaimTokenForUs( transition_now = MSTP_Master_Node_FSM(mstp_port); zassert_false(transition_now, NULL); zassert_true(mstp_port->ReceivedValidFrame == false, NULL); - zassert_equal(mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_CONFIRM, NULL); + zassert_equal( + mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_CONFIRM, NULL); /* verify the Test Request Frame was sent for confirmation */ zassert_equal(mstp_port->OutputBuffer[2], FRAME_TYPE_TEST_REQUEST, NULL); zassert_equal(mstp_port->OutputBuffer[3], mstp_port->SourceAddress, NULL); - zassert_equal(mstp_port->OutputBuffer[4], mstp_port->Zero_Config_Station, NULL); + zassert_equal( + mstp_port->OutputBuffer[4], mstp_port->Zero_Config_Station, NULL); } static void testZeroConfigNode_Test_LURK_ConfirmationSuccessful( @@ -914,8 +925,10 @@ static void testZeroConfigNode_Test_LURK_ConfirmationSuccessful( transition_now = MSTP_Master_Node_FSM(mstp_port); zassert_true(transition_now, NULL); zassert_true(mstp_port->ReceivedValidFrame == false, NULL); - zassert_equal(mstp_port->This_Station, mstp_port->Zero_Config_Station, NULL); - zassert_equal(mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_USE, NULL); + zassert_equal( + mstp_port->This_Station, mstp_port->Zero_Config_Station, NULL); + zassert_equal( + mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_USE, NULL); } static void testZeroConfigNode_Test_LURK_ConfirmationAddressInUse( @@ -932,7 +945,7 @@ static void testZeroConfigNode_Test_LURK_ConfirmationAddressInUse( mstp_port->FrameType = FRAME_TYPE_PROPRIETARY_MIN; encode_unsigned16(&mstp_port->InputBuffer[0], BACNET_VENDOR_ID); memcpy(&mstp_port->InputBuffer[2], mstp_port->UUID, MSTP_UUID_SIZE); - mstp_port->DataLength = MSTP_UUID_SIZE+2; + mstp_port->DataLength = MSTP_UUID_SIZE + 2; mstp_port->ReceivedValidFrame = true; test_station = mstp_port->Zero_Config_Station + 1; @@ -940,7 +953,8 @@ static void testZeroConfigNode_Test_LURK_ConfirmationAddressInUse( zassert_false(transition_now, NULL); zassert_true(mstp_port->ReceivedValidFrame == false, NULL); zassert_equal(test_station, mstp_port->Zero_Config_Station, NULL); - zassert_equal(mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_LURK, NULL); + zassert_equal( + mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_LURK, NULL); } static void testZeroConfigNode_Test_LURK_ConfirmationUnuccessful_UUID_Size( @@ -956,12 +970,13 @@ static void testZeroConfigNode_Test_LURK_ConfirmationUnuccessful_UUID_Size( mstp_port->FrameType = FRAME_TYPE_TEST_RESPONSE; memcpy(mstp_port->InputBuffer, mstp_port->UUID, MSTP_UUID_SIZE); /* set to an invalid size */ - mstp_port->DataLength = MSTP_UUID_SIZE-1; + mstp_port->DataLength = MSTP_UUID_SIZE - 1; mstp_port->ReceivedValidFrame = true; transition_now = MSTP_Master_Node_FSM(mstp_port); zassert_false(transition_now, NULL); zassert_true(mstp_port->ReceivedValidFrame == false, NULL); - zassert_equal(mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_IDLE, NULL); + zassert_equal( + mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_IDLE, NULL); } static void testZeroConfigNode_Test_LURK_ConfirmationUnuccessful_UUID( @@ -983,7 +998,8 @@ static void testZeroConfigNode_Test_LURK_ConfirmationUnuccessful_UUID( transition_now = MSTP_Master_Node_FSM(mstp_port); zassert_false(transition_now, NULL); zassert_true(mstp_port->ReceivedValidFrame == false, NULL); - zassert_equal(mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_IDLE, NULL); + zassert_equal( + mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_IDLE, NULL); } static void testZeroConfigNode_Test_LURK_ClaimAddressInUse( @@ -1001,7 +1017,8 @@ static void testZeroConfigNode_Test_LURK_ClaimAddressInUse( transition_now = MSTP_Master_Node_FSM(mstp_port); zassert_false(transition_now, NULL); zassert_true(mstp_port->ReceivedValidFrame == false, NULL); - zassert_equal(mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_LURK, NULL); + zassert_equal( + mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_LURK, NULL); zassert_equal(mstp_port->Zero_Config_Station, station + 1, NULL); } @@ -1016,7 +1033,8 @@ static void testZeroConfigNode_Test_LURK_ClaimInvalidFrame( transition_now = MSTP_Master_Node_FSM(mstp_port); zassert_false(transition_now, NULL); zassert_true(mstp_port->ReceivedInvalidFrame == false, NULL); - zassert_equal(mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_CLAIM, NULL); + zassert_equal( + mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_CLAIM, NULL); } static void testZeroConfigNode_Test_LURK_ClaimLostToken( @@ -1030,10 +1048,10 @@ static void testZeroConfigNode_Test_LURK_ClaimLostToken( SilenceTime = mstp_port->Zero_Config_Silence + 1; transition_now = MSTP_Master_Node_FSM(mstp_port); zassert_false(transition_now, NULL); - zassert_equal(mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_IDLE, NULL); + zassert_equal( + mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_IDLE, NULL); } - static void testZeroConfigNodeFSM(void) { struct mstp_port_struct_t MSTP_Port = { 0 }; /* port data */ @@ -1107,7 +1125,8 @@ static void testZeroConfigNodeFSM(void) void test_main(void) { - ztest_test_suite(crc_tests, ztest_unit_test(testReceiveNodeFSM), + ztest_test_suite( + crc_tests, ztest_unit_test(testReceiveNodeFSM), ztest_unit_test(testMasterNodeFSM), ztest_unit_test(testSlaveNodeFSM), ztest_unit_test(testZeroConfigNodeFSM)); diff --git a/test/bacnet/datetime/src/main.c b/test/bacnet/datetime/src/main.c index 56cbdde9..d2d52390 100644 --- a/test/bacnet/datetime/src/main.c +++ b/test/bacnet/datetime/src/main.c @@ -62,7 +62,8 @@ */ static void datetime_print(const char *title, BACNET_DATE_TIME *bdatetime) { - printf("%s: %04u/%02u/%02u %02u:%02u:%02u.%03u\n", title, + printf( + "%s: %04u/%02u/%02u %02u:%02u:%02u.%03u\n", title, (unsigned int)bdatetime->date.year, (unsigned int)bdatetime->date.month, (unsigned int)bdatetime->date.wday, (unsigned int)bdatetime->time.hour, (unsigned int)bdatetime->time.min, (unsigned int)bdatetime->time.sec, @@ -400,14 +401,16 @@ static void testDayOfYear(void) datetime_set_date(&bdate, year, month, day); days = datetime_day_of_year(&bdate); datetime_day_of_year_into_date(days, year, &test_bdate); - zassert_equal(datetime_compare_date(&bdate, &test_bdate), 0, + zassert_equal( + datetime_compare_date(&bdate, &test_bdate), 0, "year=%u month=%u day=%u", year, month, day); } } } } -static void testDateEpochConversionCompare(uint16_t year, +static void testDateEpochConversionCompare( + uint16_t year, uint8_t month, uint8_t day, uint8_t hour, @@ -465,8 +468,9 @@ static void testDateEpoch(void) for (month = 1; month <= 12; month++) { for (day = 1; day <= days_per_month(year, month); day++) { days = days_since_epoch(BACNET_EPOCH_YEAR, year, month, day); - days_since_epoch_to_date(BACNET_EPOCH_YEAR, days, &test_year, - &test_month, &test_day); + days_since_epoch_to_date( + BACNET_EPOCH_YEAR, days, &test_year, &test_month, + &test_day); zassert_equal(year, test_year, NULL); zassert_equal(month, test_month, NULL); zassert_equal(day, test_day, NULL); @@ -559,12 +563,12 @@ static void testDatetimeCodec(void) zassert_equal(diff, 0, NULL); /* test for invalid date tag */ apdu_len = bacapp_encode_datetime(apdu, &datetimeIn); - encode_tag(apdu, BACNET_APPLICATION_TAG_REAL, false, 4); + encode_tag(apdu, BACNET_APPLICATION_TAG_REAL, false, 4); test_len = bacnet_datetime_decode(&apdu[0], apdu_len, &datetimeOut); zassert_equal(test_len, BACNET_STATUS_ERROR, NULL); /* test for invalid time tag */ apdu_len = bacapp_encode_datetime(apdu, &datetimeIn); - encode_tag(&apdu[5], BACNET_APPLICATION_TAG_REAL, false, 4); + encode_tag(&apdu[5], BACNET_APPLICATION_TAG_REAL, false, 4); test_len = bacnet_datetime_decode(apdu, apdu_len, &datetimeOut); zassert_equal(test_len, BACNET_STATUS_ERROR, NULL); /* ERROR too short APDU */ @@ -601,7 +605,8 @@ static void testDatetimeCodec(void) zassert_equal(diff, 0, NULL); } -static void testDatetimeConvertUTCSpecific(BACNET_DATE_TIME *utc_time, +static void testDatetimeConvertUTCSpecific( + BACNET_DATE_TIME *utc_time, BACNET_DATE_TIME *local_time, int16_t utc_offset_minutes, int8_t dst_adjust_minutes) @@ -668,10 +673,9 @@ void test_main(void) ztest_unit_test(testBACnetDateTimeSeconds), ztest_unit_test(testDayOfYear), #endif - ztest_test_suite(bacnet_datetime, - ztest_unit_test(testBACnetDate), - ztest_unit_test(testBACnetTime), - ztest_unit_test(testBACnetDateTime), + ztest_test_suite( + bacnet_datetime, ztest_unit_test(testBACnetDate), + ztest_unit_test(testBACnetTime), ztest_unit_test(testBACnetDateTime), ztest_unit_test(testBACnetDayOfWeek), ztest_unit_test(testDateEpochConversion), ztest_unit_test(testBACnetDateTimeAdd), diff --git a/test/bacnet/dcc/src/main.c b/test/bacnet/dcc/src/main.c index bd46f7e1..de262427 100644 --- a/test/bacnet/dcc/src/main.c +++ b/test/bacnet/dcc/src/main.c @@ -19,7 +19,8 @@ /** * @brief Test */ -static int dcc_decode_apdu(uint8_t *apdu, +static int dcc_decode_apdu( + uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id, uint16_t *timeDuration, @@ -46,8 +47,9 @@ static int dcc_decode_apdu(uint8_t *apdu, return BACNET_STATUS_ERROR; } if (apdu_size > apdu_len) { - len = dcc_decode_service_request(&apdu[apdu_len], apdu_size - apdu_len, - timeDuration, enable_disable, password); + len = dcc_decode_service_request( + &apdu[apdu_len], apdu_size - apdu_len, timeDuration, enable_disable, + password); if (len > 0) { apdu_len += len; } else { @@ -58,7 +60,8 @@ static int dcc_decode_apdu(uint8_t *apdu, return apdu_len; } -static void test_DeviceCommunicationControlData(uint8_t invoke_id, +static void test_DeviceCommunicationControlData( + uint8_t invoke_id, uint16_t timeDuration, BACNET_COMMUNICATION_ENABLE_DISABLE enable_disable, BACNET_CHARACTER_STRING *password) @@ -77,17 +80,18 @@ static void test_DeviceCommunicationControlData(uint8_t invoke_id, zassert_equal(apdu_size, null_len, NULL); zassert_not_equal(apdu_size, 0, NULL); - test_len = dcc_decode_apdu(&apdu[0], apdu_size, &test_invoke_id, - &test_timeDuration, &test_enable_disable, &test_password); + test_len = dcc_decode_apdu( + &apdu[0], apdu_size, &test_invoke_id, &test_timeDuration, + &test_enable_disable, &test_password); zassert_not_equal(test_len, -1, NULL); zassert_equal(test_invoke_id, invoke_id, NULL); zassert_equal(test_timeDuration, timeDuration, NULL); zassert_equal(test_enable_disable, enable_disable, NULL); zassert_true(characterstring_same(&test_password, password), NULL); - test_len = dcc_decode_apdu(apdu, 4, &test_invoke_id, - &test_timeDuration, &test_enable_disable, &test_password); - zassert_true(test_len < 0, "apdu_size=%d test_len=%d", - apdu_size, test_len); + test_len = dcc_decode_apdu( + apdu, 4, &test_invoke_id, &test_timeDuration, &test_enable_disable, + &test_password); + zassert_true(test_len < 0, "apdu_size=%d test_len=%d", apdu_size, test_len); } #if defined(CONFIG_ZTEST_NEW_API) @@ -126,37 +130,43 @@ static void test_DeviceCommunicationControlMalformedData(void) uint8_t payload_1[] = { 0x19, 0x00, 0x2a, 0x00, 0x41 }; /* payload with enable-disable, and password with wrong characterstring * length */ - uint8_t payload_2[] = { 0x19, 0x00, 0x2d, 0x55, 0x00, 0x66, 0x69, 0x73, - 0x74, 0x65, 0x72 }; + uint8_t payload_2[] = { 0x19, 0x00, 0x2d, 0x55, 0x00, 0x66, + 0x69, 0x73, 0x74, 0x65, 0x72 }; /* payload with enable-disable - wrong context tag number for password */ - uint8_t payload_3[] = { 0x19, 0x01, 0x3d, 0x09, 0x00, 0x66, 0x69, 0x73, - 0x74, 0x65, 0x72 }; + uint8_t payload_3[] = { 0x19, 0x01, 0x3d, 0x09, 0x00, 0x66, + 0x69, 0x73, 0x74, 0x65, 0x72 }; /* payload with duration, enable-disable, and password */ - uint8_t payload_4[] = { 0x00, 0x05, 0xf1, 0x11, 0x0a, 0x00, 0x19, 0x00, - 0x2d, 0x09, 0x00, 0x66, 0x69, 0x73, 0x74, 0x65, 0x72 }; + uint8_t payload_4[] = { 0x00, 0x05, 0xf1, 0x11, 0x0a, 0x00, + 0x19, 0x00, 0x2d, 0x09, 0x00, 0x66, + 0x69, 0x73, 0x74, 0x65, 0x72 }; /* payload submitted with bug report */ - uint8_t payload_5[] = { 0x0d, 0xff, 0x80, 0x00, 0x03, 0x1a, 0x0a, 0x19, - 0x00, 0x2a, 0x00, 0x41 }; + uint8_t payload_5[] = { 0x0d, 0xff, 0x80, 0x00, 0x03, 0x1a, + 0x0a, 0x19, 0x00, 0x2a, 0x00, 0x41 }; int len = 0; uint8_t test_invoke_id = 0; uint16_t test_timeDuration = 0; BACNET_COMMUNICATION_ENABLE_DISABLE test_enable_disable; BACNET_CHARACTER_STRING test_password; - len = dcc_decode_apdu(&payload_1[0], sizeof(payload_1), &test_invoke_id, - &test_timeDuration, &test_enable_disable, &test_password); + len = dcc_decode_apdu( + &payload_1[0], sizeof(payload_1), &test_invoke_id, &test_timeDuration, + &test_enable_disable, &test_password); zassert_equal(len, BACNET_STATUS_ERROR, NULL); - len = dcc_decode_apdu(&payload_2[0], sizeof(payload_2), &test_invoke_id, - &test_timeDuration, &test_enable_disable, &test_password); + len = dcc_decode_apdu( + &payload_2[0], sizeof(payload_2), &test_invoke_id, &test_timeDuration, + &test_enable_disable, &test_password); zassert_equal(len, BACNET_STATUS_ERROR, NULL); - len = dcc_decode_apdu(&payload_3[0], sizeof(payload_3), &test_invoke_id, - &test_timeDuration, &test_enable_disable, &test_password); + len = dcc_decode_apdu( + &payload_3[0], sizeof(payload_3), &test_invoke_id, &test_timeDuration, + &test_enable_disable, &test_password); zassert_equal(len, BACNET_STATUS_ERROR, NULL); - len = dcc_decode_apdu(&payload_4[0], sizeof(payload_4), &test_invoke_id, - &test_timeDuration, &test_enable_disable, &test_password); + len = dcc_decode_apdu( + &payload_4[0], sizeof(payload_4), &test_invoke_id, &test_timeDuration, + &test_enable_disable, &test_password); zassert_equal(len, BACNET_STATUS_ABORT, NULL); - len = dcc_decode_apdu(&payload_5[0], sizeof(payload_5), &test_invoke_id, - &test_timeDuration, &test_enable_disable, &test_password); + len = dcc_decode_apdu( + &payload_5[0], sizeof(payload_5), &test_invoke_id, &test_timeDuration, + &test_enable_disable, &test_password); zassert_equal(len, BACNET_STATUS_ERROR, NULL); } /** @@ -168,8 +178,8 @@ ZTEST_SUITE(dcc_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(dcc_tests, - ztest_unit_test(test_DeviceCommunicationControl), + ztest_test_suite( + dcc_tests, ztest_unit_test(test_DeviceCommunicationControl), ztest_unit_test(test_DeviceCommunicationControlMalformedData)); ztest_run_test_suite(dcc_tests); diff --git a/test/bacnet/event/src/main.c b/test/bacnet/event/src/main.c index 62aa9128..42240620 100644 --- a/test/bacnet/event/src/main.c +++ b/test/bacnet/event/src/main.c @@ -25,14 +25,18 @@ static BACNET_EVENT_NOTIFICATION_DATA data2; static void verifyBaseEventState(void) { zassert_equal(data.processIdentifier, data2.processIdentifier, NULL); - zassert_equal(data.initiatingObjectIdentifier.instance, + zassert_equal( + data.initiatingObjectIdentifier.instance, data2.initiatingObjectIdentifier.instance, NULL); - zassert_equal(data.initiatingObjectIdentifier.type, + zassert_equal( + data.initiatingObjectIdentifier.type, data2.initiatingObjectIdentifier.type, NULL); - zassert_equal(data.eventObjectIdentifier.instance, + zassert_equal( + data.eventObjectIdentifier.instance, data2.eventObjectIdentifier.instance, NULL); - zassert_equal(data.eventObjectIdentifier.type, - data2.eventObjectIdentifier.type, NULL); + zassert_equal( + data.eventObjectIdentifier.type, data2.eventObjectIdentifier.type, + NULL); zassert_equal(data.notificationClass, data2.notificationClass, NULL); zassert_equal(data.priority, data2.priority, NULL); zassert_equal(data.notifyType, data2.notifyType, NULL); @@ -53,38 +57,51 @@ static void verifyBaseEventState(void) switch (data.timeStamp.tag) { case TIME_STAMP_SEQUENCE: - zassert_equal(data.timeStamp.value.sequenceNum, + zassert_equal( + data.timeStamp.value.sequenceNum, data2.timeStamp.value.sequenceNum, NULL); break; case TIME_STAMP_DATETIME: - zassert_equal(data.timeStamp.value.dateTime.time.hour, + zassert_equal( + data.timeStamp.value.dateTime.time.hour, data2.timeStamp.value.dateTime.time.hour, NULL); - zassert_equal(data.timeStamp.value.dateTime.time.min, + zassert_equal( + data.timeStamp.value.dateTime.time.min, data2.timeStamp.value.dateTime.time.min, NULL); - zassert_equal(data.timeStamp.value.dateTime.time.sec, + zassert_equal( + data.timeStamp.value.dateTime.time.sec, data2.timeStamp.value.dateTime.time.sec, NULL); - zassert_equal(data.timeStamp.value.dateTime.time.hundredths, + zassert_equal( + data.timeStamp.value.dateTime.time.hundredths, data2.timeStamp.value.dateTime.time.hundredths, NULL); - zassert_equal(data.timeStamp.value.dateTime.date.day, + zassert_equal( + data.timeStamp.value.dateTime.date.day, data2.timeStamp.value.dateTime.date.day, NULL); - zassert_equal(data.timeStamp.value.dateTime.date.month, + zassert_equal( + data.timeStamp.value.dateTime.date.month, data2.timeStamp.value.dateTime.date.month, NULL); - zassert_equal(data.timeStamp.value.dateTime.date.wday, + zassert_equal( + data.timeStamp.value.dateTime.date.wday, data2.timeStamp.value.dateTime.date.wday, NULL); - zassert_equal(data.timeStamp.value.dateTime.date.year, + zassert_equal( + data.timeStamp.value.dateTime.date.year, data2.timeStamp.value.dateTime.date.year, NULL); break; case TIME_STAMP_TIME: - zassert_equal(data.timeStamp.value.time.hour, - data2.timeStamp.value.time.hour, NULL); - zassert_equal(data.timeStamp.value.time.min, - data2.timeStamp.value.time.min, NULL); - zassert_equal(data.timeStamp.value.time.sec, - data2.timeStamp.value.time.sec, NULL); - zassert_equal(data.timeStamp.value.time.hundredths, + zassert_equal( + data.timeStamp.value.time.hour, data2.timeStamp.value.time.hour, + NULL); + zassert_equal( + data.timeStamp.value.time.min, data2.timeStamp.value.time.min, + NULL); + zassert_equal( + data.timeStamp.value.time.sec, data2.timeStamp.value.time.sec, + NULL); + zassert_equal( + data.timeStamp.value.time.hundredths, data2.timeStamp.value.time.hundredths, NULL); break; @@ -132,13 +149,17 @@ static void testEventEventState(void) UNITS_SQUARE_METERS; bitstring_init(&data.notificationParams.changeOfState.statusFlags); - bitstring_set_bit(&data.notificationParams.changeOfState.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.changeOfState.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.changeOfState.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.changeOfState.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); null_len = event_notify_encode_service_request(NULL, &data); @@ -151,13 +172,16 @@ static void testEventEventState(void) apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); - zassert_equal(data.notificationParams.changeOfState.newState.tag, + zassert_equal( + data.notificationParams.changeOfState.newState.tag, data2.notificationParams.changeOfState.newState.tag, NULL); - zassert_equal(data.notificationParams.changeOfState.newState.state.units, + zassert_equal( + data.notificationParams.changeOfState.newState.state.units, data2.notificationParams.changeOfState.newState.state.units, NULL); zassert_true( - bitstring_same(&data.notificationParams.changeOfState.statusFlags, + bitstring_same( + &data.notificationParams.changeOfState.statusFlags, &data2.notificationParams.changeOfState.statusFlags), NULL); @@ -188,9 +212,11 @@ static void testEventEventState(void) zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); - zassert_equal(data.notificationParams.changeOfState.newState.tag, + zassert_equal( + data.notificationParams.changeOfState.newState.tag, data2.notificationParams.changeOfState.newState.tag, NULL); - zassert_equal(data.notificationParams.changeOfState.newState.state.units, + zassert_equal( + data.notificationParams.changeOfState.newState.state.units, data2.notificationParams.changeOfState.newState.state.units, NULL); /* ** Event Type = EVENT_CHANGE_OF_BITSTRING @@ -217,13 +243,17 @@ static void testEventEventState(void) bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags); - bitstring_set_bit(&data.notificationParams.changeOfBitstring.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfBitstring.statusFlags, STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.changeOfBitstring.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfBitstring.statusFlags, STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.changeOfBitstring.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfBitstring.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.changeOfBitstring.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfBitstring.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -247,7 +277,8 @@ static void testEventEventState(void) NULL); zassert_true( - bitstring_same(&data.notificationParams.changeOfBitstring.statusFlags, + bitstring_same( + &data.notificationParams.changeOfBitstring.statusFlags, &data2.notificationParams.changeOfBitstring.statusFlags), NULL); @@ -260,13 +291,17 @@ static void testEventEventState(void) bitstring_init(&data.notificationParams.changeOfValue.statusFlags); - bitstring_set_bit(&data.notificationParams.changeOfValue.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.changeOfValue.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.changeOfValue.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.changeOfValue.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -284,16 +319,20 @@ static void testEventEventState(void) verifyBaseEventState(); zassert_true( - bitstring_same(&data.notificationParams.changeOfValue.statusFlags, + bitstring_same( + &data.notificationParams.changeOfValue.statusFlags, &data2.notificationParams.changeOfValue.statusFlags), NULL); - zassert_equal(data.notificationParams.changeOfValue.tag, + zassert_equal( + data.notificationParams.changeOfValue.tag, data2.notificationParams.changeOfValue.tag, NULL); - zassert_false(islessgreater( - data.notificationParams.changeOfValue.newValue.changeValue, - data2.notificationParams.changeOfValue.newValue.changeValue), NULL); + zassert_false( + islessgreater( + data.notificationParams.changeOfValue.newValue.changeValue, + data2.notificationParams.changeOfValue.newValue.changeValue), + NULL); /* ** Event Type = EVENT_CHANGE_OF_VALUE - bitstring value @@ -322,10 +361,12 @@ static void testEventEventState(void) verifyBaseEventState(); zassert_true( - bitstring_same(&data.notificationParams.changeOfValue.statusFlags, + bitstring_same( + &data.notificationParams.changeOfValue.statusFlags, &data2.notificationParams.changeOfValue.statusFlags), NULL); - zassert_equal(data.notificationParams.changeOfValue.tag, + zassert_equal( + data.notificationParams.changeOfValue.tag, data2.notificationParams.changeOfValue.tag, NULL); zassert_true( bitstring_same( @@ -347,13 +388,17 @@ static void testEventEventState(void) data.notificationParams.commandFailure.feedbackValue.binaryValue = BINARY_ACTIVE; bitstring_init(&data.notificationParams.commandFailure.statusFlags); - bitstring_set_bit(&data.notificationParams.commandFailure.statusFlags, + bitstring_set_bit( + &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.commandFailure.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.commandFailure.statusFlags, + bitstring_set_bit( + &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.commandFailure.statusFlags, + bitstring_set_bit( + &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); null_len = event_notify_encode_service_request(NULL, &data); @@ -379,7 +424,8 @@ static void testEventEventState(void) NULL); zassert_true( - bitstring_same(&data.notificationParams.commandFailure.statusFlags, + bitstring_same( + &data.notificationParams.commandFailure.statusFlags, &data2.notificationParams.commandFailure.statusFlags), NULL); @@ -393,13 +439,17 @@ static void testEventEventState(void) bitstring_init(&data.notificationParams.commandFailure.statusFlags); - bitstring_set_bit(&data.notificationParams.commandFailure.statusFlags, + bitstring_set_bit( + &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.commandFailure.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.commandFailure.statusFlags, + bitstring_set_bit( + &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.commandFailure.statusFlags, + bitstring_set_bit( + &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -427,7 +477,8 @@ static void testEventEventState(void) NULL); zassert_true( - bitstring_same(&data.notificationParams.commandFailure.statusFlags, + bitstring_same( + &data.notificationParams.commandFailure.statusFlags, &data2.notificationParams.commandFailure.statusFlags), NULL); @@ -441,13 +492,17 @@ static void testEventEventState(void) bitstring_init(&data.notificationParams.floatingLimit.statusFlags); - bitstring_set_bit(&data.notificationParams.floatingLimit.statusFlags, + bitstring_set_bit( + &data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.floatingLimit.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.floatingLimit.statusFlags, + bitstring_set_bit( + &data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.floatingLimit.statusFlags, + bitstring_set_bit( + &data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -463,17 +518,24 @@ static void testEventEventState(void) apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); - zassert_false(islessgreater( - data.notificationParams.floatingLimit.referenceValue, - data2.notificationParams.floatingLimit.referenceValue), NULL); - zassert_false(islessgreater( - data.notificationParams.floatingLimit.setPointValue, - data2.notificationParams.floatingLimit.setPointValue), NULL); - zassert_false(islessgreater( - data.notificationParams.floatingLimit.errorLimit, - data2.notificationParams.floatingLimit.errorLimit), NULL); + zassert_false( + islessgreater( + data.notificationParams.floatingLimit.referenceValue, + data2.notificationParams.floatingLimit.referenceValue), + NULL); + zassert_false( + islessgreater( + data.notificationParams.floatingLimit.setPointValue, + data2.notificationParams.floatingLimit.setPointValue), + NULL); + zassert_false( + islessgreater( + data.notificationParams.floatingLimit.errorLimit, + data2.notificationParams.floatingLimit.errorLimit), + NULL); zassert_true( - bitstring_same(&data.notificationParams.floatingLimit.statusFlags, + bitstring_same( + &data.notificationParams.floatingLimit.statusFlags, &data2.notificationParams.floatingLimit.statusFlags), NULL); @@ -487,13 +549,17 @@ static void testEventEventState(void) bitstring_init(&data.notificationParams.outOfRange.statusFlags); - bitstring_set_bit(&data.notificationParams.outOfRange.statusFlags, - STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.outOfRange.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.outOfRange.statusFlags, - STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.outOfRange.statusFlags, + bitstring_set_bit( + &data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_IN_ALARM, + true); + bitstring_set_bit( + &data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, + false); + bitstring_set_bit( + &data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -510,18 +576,27 @@ static void testEventEventState(void) zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); - zassert_false(islessgreater(data.notificationParams.outOfRange.deadband, - data2.notificationParams.outOfRange.deadband), NULL); + zassert_false( + islessgreater( + data.notificationParams.outOfRange.deadband, + data2.notificationParams.outOfRange.deadband), + NULL); - zassert_false(islessgreater( - data.notificationParams.outOfRange.exceededLimit, - data2.notificationParams.outOfRange.exceededLimit), NULL); + zassert_false( + islessgreater( + data.notificationParams.outOfRange.exceededLimit, + data2.notificationParams.outOfRange.exceededLimit), + NULL); - zassert_false(islessgreater( - data.notificationParams.outOfRange.exceedingValue, - data2.notificationParams.outOfRange.exceedingValue), NULL); - zassert_true(bitstring_same(&data.notificationParams.outOfRange.statusFlags, - &data2.notificationParams.outOfRange.statusFlags), + zassert_false( + islessgreater( + data.notificationParams.outOfRange.exceedingValue, + data2.notificationParams.outOfRange.exceedingValue), + NULL); + zassert_true( + bitstring_same( + &data.notificationParams.outOfRange.statusFlags, + &data2.notificationParams.outOfRange.statusFlags), NULL); /* @@ -536,13 +611,17 @@ static void testEventEventState(void) bitstring_init(&data.notificationParams.changeOfLifeSafety.statusFlags); - bitstring_set_bit(&data.notificationParams.changeOfLifeSafety.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfLifeSafety.statusFlags, STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.changeOfLifeSafety.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfLifeSafety.statusFlags, STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.changeOfLifeSafety.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfLifeSafety.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.changeOfLifeSafety.statusFlags, + bitstring_set_bit( + &data.notificationParams.changeOfLifeSafety.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -559,17 +638,21 @@ static void testEventEventState(void) zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); - zassert_equal(data.notificationParams.changeOfLifeSafety.newMode, + zassert_equal( + data.notificationParams.changeOfLifeSafety.newMode, data2.notificationParams.changeOfLifeSafety.newMode, NULL); - zassert_equal(data.notificationParams.changeOfLifeSafety.newState, + zassert_equal( + data.notificationParams.changeOfLifeSafety.newState, data2.notificationParams.changeOfLifeSafety.newState, NULL); - zassert_equal(data.notificationParams.changeOfLifeSafety.operationExpected, + zassert_equal( + data.notificationParams.changeOfLifeSafety.operationExpected, data2.notificationParams.changeOfLifeSafety.operationExpected, NULL); zassert_true( - bitstring_same(&data.notificationParams.changeOfLifeSafety.statusFlags, + bitstring_same( + &data.notificationParams.changeOfLifeSafety.statusFlags, &data2.notificationParams.changeOfLifeSafety.statusFlags), NULL); @@ -582,13 +665,17 @@ static void testEventEventState(void) bitstring_init(&data.notificationParams.unsignedRange.statusFlags); - bitstring_set_bit(&data.notificationParams.unsignedRange.statusFlags, + bitstring_set_bit( + &data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.unsignedRange.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.unsignedRange.statusFlags, + bitstring_set_bit( + &data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.unsignedRange.statusFlags, + bitstring_set_bit( + &data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -605,14 +692,17 @@ static void testEventEventState(void) zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); - zassert_equal(data.notificationParams.unsignedRange.exceedingValue, + zassert_equal( + data.notificationParams.unsignedRange.exceedingValue, data2.notificationParams.unsignedRange.exceedingValue, NULL); - zassert_equal(data.notificationParams.unsignedRange.exceededLimit, + zassert_equal( + data.notificationParams.unsignedRange.exceededLimit, data2.notificationParams.unsignedRange.exceededLimit, NULL); zassert_true( - bitstring_same(&data.notificationParams.unsignedRange.statusFlags, + bitstring_same( + &data.notificationParams.unsignedRange.statusFlags, &data2.notificationParams.unsignedRange.statusFlags), NULL); @@ -648,32 +738,38 @@ static void testEventEventState(void) zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); - zassert_equal(data.notificationParams.bufferReady.previousNotification, + zassert_equal( + data.notificationParams.bufferReady.previousNotification, data2.notificationParams.bufferReady.previousNotification, NULL); - zassert_equal(data.notificationParams.bufferReady.currentNotification, + zassert_equal( + data.notificationParams.bufferReady.currentNotification, data2.notificationParams.bufferReady.currentNotification, NULL); - zassert_equal(data.notificationParams.bufferReady.bufferProperty - .deviceIdentifier.type, + zassert_equal( + data.notificationParams.bufferReady.bufferProperty.deviceIdentifier + .type, data2.notificationParams.bufferReady.bufferProperty.deviceIdentifier .type, NULL); - zassert_equal(data.notificationParams.bufferReady.bufferProperty - .deviceIdentifier.instance, + zassert_equal( + data.notificationParams.bufferReady.bufferProperty.deviceIdentifier + .instance, data2.notificationParams.bufferReady.bufferProperty.deviceIdentifier .instance, NULL); - zassert_equal(data.notificationParams.bufferReady.bufferProperty - .objectIdentifier.instance, + zassert_equal( + data.notificationParams.bufferReady.bufferProperty.objectIdentifier + .instance, data2.notificationParams.bufferReady.bufferProperty.objectIdentifier .instance, NULL); - zassert_equal(data.notificationParams.bufferReady.bufferProperty - .objectIdentifier.type, + zassert_equal( + data.notificationParams.bufferReady.bufferProperty.objectIdentifier + .type, data2.notificationParams.bufferReady.bufferProperty.objectIdentifier .type, NULL); @@ -683,7 +779,8 @@ static void testEventEventState(void) data2.notificationParams.bufferReady.bufferProperty.propertyIdentifier, NULL); - zassert_equal(data.notificationParams.bufferReady.bufferProperty.arrayIndex, + zassert_equal( + data.notificationParams.bufferReady.bufferProperty.arrayIndex, data2.notificationParams.bufferReady.bufferProperty.arrayIndex, NULL); /* @@ -710,13 +807,17 @@ static void testEventEventState(void) AUTHENTICATION_FACTOR_MAX; // omit authenticationFactor bitstring_init(&data.notificationParams.accessEvent.statusFlags); - bitstring_set_bit(&data.notificationParams.accessEvent.statusFlags, - STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.accessEvent.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.accessEvent.statusFlags, + bitstring_set_bit( + &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_IN_ALARM, + true); + bitstring_set_bit( + &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.accessEvent.statusFlags, + bitstring_set_bit( + &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -733,18 +834,22 @@ static void testEventEventState(void) zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); - zassert_equal(data.notificationParams.accessEvent.accessEvent, + zassert_equal( + data.notificationParams.accessEvent.accessEvent, data2.notificationParams.accessEvent.accessEvent, NULL); zassert_true( - bitstring_same(&data.notificationParams.accessEvent.statusFlags, + bitstring_same( + &data.notificationParams.accessEvent.statusFlags, &data2.notificationParams.accessEvent.statusFlags), NULL); - zassert_equal(data.notificationParams.accessEvent.accessEventTag, + zassert_equal( + data.notificationParams.accessEvent.accessEventTag, data2.notificationParams.accessEvent.accessEventTag, NULL); - zassert_equal(data.notificationParams.accessEvent.accessEventTime.tag, + zassert_equal( + data.notificationParams.accessEvent.accessEventTime.tag, data2.notificationParams.accessEvent.accessEventTime.tag, NULL); zassert_equal( @@ -752,26 +857,30 @@ static void testEventEventState(void) data2.notificationParams.accessEvent.accessEventTime.value.sequenceNum, NULL); - zassert_equal(data.notificationParams.accessEvent.accessCredential - .deviceIdentifier.instance, + zassert_equal( + data.notificationParams.accessEvent.accessCredential.deviceIdentifier + .instance, data2.notificationParams.accessEvent.accessCredential.deviceIdentifier .instance, NULL); - zassert_equal(data.notificationParams.accessEvent.accessCredential - .deviceIdentifier.type, + zassert_equal( + data.notificationParams.accessEvent.accessCredential.deviceIdentifier + .type, data2.notificationParams.accessEvent.accessCredential.deviceIdentifier .type, NULL); - zassert_equal(data.notificationParams.accessEvent.accessCredential - .objectIdentifier.instance, + zassert_equal( + data.notificationParams.accessEvent.accessCredential.objectIdentifier + .instance, data2.notificationParams.accessEvent.accessCredential.objectIdentifier .instance, NULL); - zassert_equal(data.notificationParams.accessEvent.accessCredential - .objectIdentifier.type, + zassert_equal( + data.notificationParams.accessEvent.accessCredential.objectIdentifier + .type, data2.notificationParams.accessEvent.accessCredential.objectIdentifier .type, NULL); @@ -802,13 +911,17 @@ static void testEventEventState(void) octetstringValue, 2); bitstring_init(&data.notificationParams.accessEvent.statusFlags); - bitstring_set_bit(&data.notificationParams.accessEvent.statusFlags, - STATUS_FLAG_IN_ALARM, true); - bitstring_set_bit(&data.notificationParams.accessEvent.statusFlags, - STATUS_FLAG_FAULT, false); - bitstring_set_bit(&data.notificationParams.accessEvent.statusFlags, + bitstring_set_bit( + &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_IN_ALARM, + true); + bitstring_set_bit( + &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_FAULT, + false); + bitstring_set_bit( + &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&data.notificationParams.accessEvent.statusFlags, + bitstring_set_bit( + &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(buffer, 0, MAX_APDU); @@ -825,18 +938,22 @@ static void testEventEventState(void) zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); - zassert_equal(data.notificationParams.accessEvent.accessEvent, + zassert_equal( + data.notificationParams.accessEvent.accessEvent, data2.notificationParams.accessEvent.accessEvent, NULL); zassert_true( - bitstring_same(&data.notificationParams.accessEvent.statusFlags, + bitstring_same( + &data.notificationParams.accessEvent.statusFlags, &data2.notificationParams.accessEvent.statusFlags), NULL); - zassert_equal(data.notificationParams.accessEvent.accessEventTag, + zassert_equal( + data.notificationParams.accessEvent.accessEventTag, data2.notificationParams.accessEvent.accessEventTag, NULL); - zassert_equal(data.notificationParams.accessEvent.accessEventTime.tag, + zassert_equal( + data.notificationParams.accessEvent.accessEventTime.tag, data2.notificationParams.accessEvent.accessEventTime.tag, NULL); zassert_equal( @@ -844,26 +961,30 @@ static void testEventEventState(void) data2.notificationParams.accessEvent.accessEventTime.value.sequenceNum, NULL); - zassert_equal(data.notificationParams.accessEvent.accessCredential - .deviceIdentifier.instance, + zassert_equal( + data.notificationParams.accessEvent.accessCredential.deviceIdentifier + .instance, data2.notificationParams.accessEvent.accessCredential.deviceIdentifier .instance, NULL); - zassert_equal(data.notificationParams.accessEvent.accessCredential - .deviceIdentifier.type, + zassert_equal( + data.notificationParams.accessEvent.accessCredential.deviceIdentifier + .type, data2.notificationParams.accessEvent.accessCredential.deviceIdentifier .type, NULL); - zassert_equal(data.notificationParams.accessEvent.accessCredential - .objectIdentifier.instance, + zassert_equal( + data.notificationParams.accessEvent.accessCredential.objectIdentifier + .instance, data2.notificationParams.accessEvent.accessCredential.objectIdentifier .instance, NULL); - zassert_equal(data.notificationParams.accessEvent.accessCredential - .objectIdentifier.type, + zassert_equal( + data.notificationParams.accessEvent.accessCredential.objectIdentifier + .type, data2.notificationParams.accessEvent.accessCredential.objectIdentifier .type, NULL); diff --git a/test/bacnet/getalarm/src/main.c b/test/bacnet/getalarm/src/main.c index b64ea34c..62985c11 100644 --- a/test/bacnet/getalarm/src/main.c +++ b/test/bacnet/getalarm/src/main.c @@ -23,9 +23,8 @@ * @param invoke_id - unique sequence number sent with the message * @return number of bytes decoded */ -static int get_alarm_summary_decode_apdu(uint8_t *apdu, - unsigned apdu_size, - uint8_t *invoke_id) +static int get_alarm_summary_decode_apdu( + uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id) { int len = 0; @@ -55,7 +54,8 @@ static int get_alarm_summary_decode_apdu(uint8_t *apdu, * @param invoke_id - unique sequence number sent with the message * @return number of bytes decoded */ -static int get_alarm_summary_ack_decode_apdu(uint8_t *apdu, +static int get_alarm_summary_ack_decode_apdu( + uint8_t *apdu, int apdu_len, uint8_t *invoke_id, BACNET_GET_ALARM_SUMMARY_DATA *get_alarm_data) @@ -112,8 +112,7 @@ static void testGetAlarmSummaryAck(void) bitstring_set_bit( &alarm_data.acknowledgedTransitions, TRANSITION_TO_NORMAL, false); /* encode the initial service */ - len = get_alarm_summary_ack_encode_apdu_init(&apdu[0], - invoke_id); + len = get_alarm_summary_ack_encode_apdu_init(&apdu[0], invoke_id); zassert_not_equal(len, 0, NULL); zassert_not_equal(len, -1, NULL); apdu_len = len; @@ -123,18 +122,18 @@ static void testGetAlarmSummaryAck(void) zassert_not_equal(len, 0, NULL); zassert_not_equal(len, -1, NULL); apdu_len += len; - len = get_alarm_summary_ack_decode_apdu(&apdu[0], - apdu_len, /* total length of the apdu */ + len = get_alarm_summary_ack_decode_apdu( + &apdu[0], apdu_len, /* total length of the apdu */ &test_invoke_id, &test_alarm_data); zassert_not_equal(len, -1, NULL); zassert_equal(test_invoke_id, invoke_id, NULL); zassert_equal( - alarm_data.objectIdentifier.type, - test_alarm_data.objectIdentifier.type, NULL); + alarm_data.objectIdentifier.type, test_alarm_data.objectIdentifier.type, + NULL); zassert_equal( alarm_data.objectIdentifier.instance, - test_alarm_data.objectIdentifier.instance, NULL); + test_alarm_data.objectIdentifier.instance, NULL); zassert_equal(alarm_data.alarmState, test_alarm_data.alarmState, NULL); } @@ -162,7 +161,6 @@ static void testGetAlarmSummary(void) return; } - /** * Main entry point for testing */ @@ -171,10 +169,9 @@ ZTEST_SUITE(getalarm_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(getalarm_tests, - ztest_unit_test(testGetAlarmSummary), - ztest_unit_test(testGetAlarmSummaryAck) - ); + ztest_test_suite( + getalarm_tests, ztest_unit_test(testGetAlarmSummary), + ztest_unit_test(testGetAlarmSummaryAck)); ztest_run_test_suite(getalarm_tests); } diff --git a/test/bacnet/getevent/src/main.c b/test/bacnet/getevent/src/main.c index 2aa62de8..d6d86c4f 100644 --- a/test/bacnet/getevent/src/main.c +++ b/test/bacnet/getevent/src/main.c @@ -19,7 +19,8 @@ /** * @brief Test */ -static int getevent_decode_apdu(uint8_t *apdu, +static int getevent_decode_apdu( + uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id, BACNET_OBJECT_ID *lastReceivedObjectIdentifier) @@ -44,7 +45,8 @@ static int getevent_decode_apdu(uint8_t *apdu, if (apdu_size > apdu_len) { len = getevent_decode_service_request( - &apdu[apdu_len], apdu_size - apdu_len, lastReceivedObjectIdentifier); + &apdu[apdu_len], apdu_size - apdu_len, + lastReceivedObjectIdentifier); if (len > 0) { apdu_len += len; } else { @@ -55,7 +57,8 @@ static int getevent_decode_apdu(uint8_t *apdu, return apdu_len; } -static int getevent_ack_decode_apdu(uint8_t *apdu, +static int getevent_ack_decode_apdu( + uint8_t *apdu, int apdu_len, /* total length of the apdu */ uint8_t *invoke_id, BACNET_GET_EVENT_INFORMATION_DATA *get_event_data, @@ -136,18 +139,18 @@ static void testGetEventInformationAck(void) zassert_not_equal(len, 0, NULL); zassert_not_equal(len, -1, NULL); apdu_len += len; - len = getevent_ack_decode_apdu(&apdu[0], - apdu_len, /* total length of the apdu */ + len = getevent_ack_decode_apdu( + &apdu[0], apdu_len, /* total length of the apdu */ &test_invoke_id, &test_event_data, &test_moreEvents); zassert_not_equal(len, -1, NULL); zassert_equal(test_invoke_id, invoke_id, NULL); zassert_equal( - event_data.objectIdentifier.type, - test_event_data.objectIdentifier.type, NULL); + event_data.objectIdentifier.type, test_event_data.objectIdentifier.type, + NULL); zassert_equal( event_data.objectIdentifier.instance, - test_event_data.objectIdentifier.instance, NULL); + test_event_data.objectIdentifier.instance, NULL); zassert_equal(event_data.eventState, test_event_data.eventState, NULL); } @@ -167,14 +170,15 @@ static void testGetEventInformation(void) lastReceivedObjectIdentifier.type = OBJECT_BINARY_INPUT; lastReceivedObjectIdentifier.instance = 12345; - null_len = getevent_encode_apdu( - NULL, invoke_id, &lastReceivedObjectIdentifier); + null_len = + getevent_encode_apdu(NULL, invoke_id, &lastReceivedObjectIdentifier); apdu_len = getevent_encode_apdu( &apdu[0], invoke_id, &lastReceivedObjectIdentifier); zassert_equal(apdu_len, null_len, NULL); zassert_not_equal(apdu_len, 0, NULL); - test_len = getevent_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + test_len = getevent_decode_apdu( + &apdu[0], apdu_len, &test_invoke_id, &test_lastReceivedObjectIdentifier); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); @@ -182,10 +186,10 @@ static void testGetEventInformation(void) zassert_equal(test_invoke_id, invoke_id, NULL); zassert_equal( test_lastReceivedObjectIdentifier.type, - lastReceivedObjectIdentifier.type, NULL); + lastReceivedObjectIdentifier.type, NULL); zassert_equal( test_lastReceivedObjectIdentifier.instance, - lastReceivedObjectIdentifier.instance, NULL); + lastReceivedObjectIdentifier.instance, NULL); return; } @@ -193,16 +197,14 @@ static void testGetEventInformation(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(getevent_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(getevent_tests, - ztest_unit_test(testGetEventInformation), - ztest_unit_test(testGetEventInformationAck) - ); + ztest_test_suite( + getevent_tests, ztest_unit_test(testGetEventInformation), + ztest_unit_test(testGetEventInformationAck)); ztest_run_test_suite(getevent_tests); } diff --git a/test/bacnet/hostnport/src/main.c b/test/bacnet/hostnport/src/main.c index 1ffbbefd..7669767f 100644 --- a/test/bacnet/hostnport/src/main.c +++ b/test/bacnet/hostnport/src/main.c @@ -41,10 +41,10 @@ static void test_HostNPortCodec(BACNET_HOST_N_PORT *data) zassert_equal(apdu_len, null_len, NULL); zassert_true(apdu_len != BACNET_STATUS_ERROR, NULL); - null_len = host_n_port_context_decode(apdu, apdu_len, tag_number, - &error_code, NULL); - test_len = host_n_port_context_decode(apdu, apdu_len, tag_number, - &error_code, &test_data); + null_len = host_n_port_context_decode( + apdu, apdu_len, tag_number, &error_code, NULL); + test_len = host_n_port_context_decode( + apdu, apdu_len, tag_number, &error_code, &test_data); zassert_equal(test_len, null_len, NULL); zassert_true(test_len > 0, "test_len=%d", len); status = host_n_port_same(&test_data, data); diff --git a/test/bacnet/iam/src/main.c b/test/bacnet/iam/src/main.c index eec90edd..c535405b 100644 --- a/test/bacnet/iam/src/main.c +++ b/test/bacnet/iam/src/main.c @@ -19,7 +19,8 @@ /** * @brief Test */ -static int iam_decode_apdu(uint8_t *apdu, +static int iam_decode_apdu( + uint8_t *apdu, uint32_t *pDevice_id, unsigned *pMax_apdu, int *pSegmentation, @@ -62,8 +63,9 @@ static void testIAm(void) iam_encode_apdu(&apdu[0], device_id, max_apdu, segmentation, vendor_id); zassert_not_equal(len, 0, NULL); - len = iam_decode_apdu(&apdu[0], &test_device_id, &test_max_apdu, - &test_segmentation, &test_vendor_id); + len = iam_decode_apdu( + &apdu[0], &test_device_id, &test_max_apdu, &test_segmentation, + &test_vendor_id); zassert_not_equal(len, -1, NULL); zassert_equal(test_device_id, device_id, NULL); @@ -75,15 +77,12 @@ static void testIAm(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(iam_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(iam_tests, - ztest_unit_test(testIAm) - ); + ztest_test_suite(iam_tests, ztest_unit_test(testIAm)); ztest_run_test_suite(iam_tests); } diff --git a/test/bacnet/ihave/src/main.c b/test/bacnet/ihave/src/main.c index 08c474b1..42573f13 100644 --- a/test/bacnet/ihave/src/main.c +++ b/test/bacnet/ihave/src/main.c @@ -68,15 +68,12 @@ static void testIHave(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(ihave_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(ihave_tests, - ztest_unit_test(testIHave) - ); + ztest_test_suite(ihave_tests, ztest_unit_test(testIHave)); ztest_run_test_suite(ihave_tests); } diff --git a/test/bacnet/indtext/src/main.c b/test/bacnet/indtext/src/main.c index 549a5154..3b8ae8d9 100644 --- a/test/bacnet/indtext/src/main.c +++ b/test/bacnet/indtext/src/main.c @@ -19,8 +19,9 @@ /** * @brief Test */ -static INDTEXT_DATA data_list[] = { { 1, "Joshua" }, { 2, "Mary" }, - { 3, "Anna" }, { 4, "Christopher" }, { 5, "Patricia" }, { 0, NULL } }; +static INDTEXT_DATA data_list[] = { { 1, "Joshua" }, { 2, "Mary" }, + { 3, "Anna" }, { 4, "Christopher" }, + { 5, "Patricia" }, { 0, NULL } }; #if defined(CONFIG_ZTEST_NEW_API) ZTEST(indtext_tests, testIndexText) @@ -42,7 +43,8 @@ static void testIndexText(void) zassert_true(valid, NULL); zassert_equal(index, i, NULL); zassert_equal( - index, indtext_by_string_default(data_list, pString, index), NULL); + index, indtext_by_string_default(data_list, pString, index), + NULL); } } zassert_equal(indtext_count(data_list), count, NULL); @@ -63,15 +65,12 @@ static void testIndexText(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(indtext_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(indtext_tests, - ztest_unit_test(testIndexText) - ); + ztest_test_suite(indtext_tests, ztest_unit_test(testIndexText)); ztest_run_test_suite(indtext_tests); } diff --git a/test/bacnet/lighting/src/main.c b/test/bacnet/lighting/src/main.c index 4b5f0ebe..49da0e5a 100644 --- a/test/bacnet/lighting/src/main.c +++ b/test/bacnet/lighting/src/main.c @@ -42,9 +42,11 @@ static void testBACnetLightingCommand(BACNET_LIGHTING_COMMAND *data) /* encode/decode */ len = lighting_command_encode(apdu, data); apdu_len = lighting_command_decode(apdu, len, &test_data); - zassert_true(len > 0, "lighting-command[%s] failed to encode!", + zassert_true( + len > 0, "lighting-command[%s] failed to encode!", bactext_lighting_operation_name(data->operation)); - zassert_true(apdu_len > 0, "lighting-command[%s] failed to decode!", + zassert_true( + apdu_len > 0, "lighting-command[%s] failed to decode!", bactext_lighting_operation_name(data->operation)); status = lighting_command_same(&test_data, data); while (len) { @@ -69,7 +71,8 @@ static void testBACnetLightingCommand(BACNET_LIGHTING_COMMAND *data) status = lighting_command_from_ascii(&test_data, command_text); zassert_true(status, NULL); status = lighting_command_same(&test_data, data); - zassert_true(status, "lighting-command[%s] \"%s\" is different!", + zassert_true( + status, "lighting-command[%s] \"%s\" is different!", bactext_lighting_operation_name(data->operation), command_text); } @@ -94,40 +97,41 @@ static void testBACnetLightingCommandAll(void) */ BACNET_LIGHTING_COMMAND test_data[] = { { BACNET_LIGHTS_NONE, false, false, false, false, false, 0.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_FADE_TO, true, false, false, true, true, 100.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_FADE_TO, true, false, false, false, false, 0.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_RAMP_TO, true, true, false, false, true, 0.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_RAMP_TO, true, false, false, false, false, 100.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_STEP_UP, false, false, true, false, true, 100.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_STEP_UP, false, false, true, false, false, 100.0, 100.0, - 2.0, 100, 1 }, + 2.0, 100, 1 }, { BACNET_LIGHTS_STEP_DOWN, false, false, true, false, true, 100.0, - 100.0, 1.0, 100, 1 }, + 100.0, 1.0, 100, 1 }, { BACNET_LIGHTS_STEP_DOWN, false, false, true, false, false, 100.0, - 100.0, 2.0, 100, 1 }, + 100.0, 2.0, 100, 1 }, { BACNET_LIGHTS_STEP_ON, false, false, true, false, true, 100.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_STEP_ON, false, false, true, false, false, 100.0, 100.0, - 2.0, 100, 1 }, + 2.0, 100, 1 }, { BACNET_LIGHTS_STEP_OFF, false, false, true, false, true, 100.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_STEP_OFF, false, false, true, false, false, 100.0, - 100.0, 2.0, 100, 1 }, + 100.0, 2.0, 100, 1 }, { BACNET_LIGHTS_STOP, false, false, false, false, true, 100.0, 100.0, - 1.0, 100, 1 }, + 1.0, 100, 1 }, { BACNET_LIGHTS_STOP, false, false, false, false, false, 100.0, 100.0, - 2.0, 100, 1 }, + 2.0, 100, 1 }, }; unsigned i; for (i = 0; i < ARRAY_SIZE(test_data); i++) { - printf("test-lighting-command[%s]\n", + printf( + "test-lighting-command[%s]\n", bactext_lighting_operation_name(test_data[i].operation)); testBACnetLightingCommand(&test_data[i]); } @@ -157,9 +161,11 @@ static void testBACnetColorCommand(BACNET_COLOR_COMMAND *data) zassert_true(status, NULL); len = color_command_encode(apdu, data); apdu_len = color_command_decode(apdu, len, &error_code, &test_data); - zassert_true(len > 0, "color-command[%s] failed to encode!", + zassert_true( + len > 0, "color-command[%s] failed to encode!", bactext_color_operation_name(data->operation)); - zassert_true(apdu_len > 0, "color-command[%s] failed to decode!", + zassert_true( + apdu_len > 0, "color-command[%s] failed to decode!", bactext_color_operation_name(data->operation)); status = color_command_same(&test_data, data); while (len) { @@ -176,43 +182,43 @@ static void testBACnetColorCommandAll(void) { BACNET_COLOR_COMMAND test_data[] = { { .operation = BACNET_COLOR_OPERATION_NONE, - .target.color_temperature = 0, - .transit.fade_time = 0 }, + .target.color_temperature = 0, + .transit.fade_time = 0 }, { .operation = BACNET_COLOR_OPERATION_STOP, - .target.color_temperature = 0, - .transit.fade_time = 0 }, + .target.color_temperature = 0, + .transit.fade_time = 0 }, { .operation = BACNET_COLOR_OPERATION_FADE_TO_COLOR, - .target.color.x_coordinate = 0.0, - .target.color.y_coordinate = 0.0, - .transit.fade_time = 0 }, + .target.color.x_coordinate = 0.0, + .target.color.y_coordinate = 0.0, + .transit.fade_time = 0 }, { .operation = BACNET_COLOR_OPERATION_FADE_TO_COLOR, - .target.color.x_coordinate = 0.0, - .target.color.y_coordinate = 0.0, - .transit.fade_time = 2000 }, + .target.color.x_coordinate = 0.0, + .target.color.y_coordinate = 0.0, + .transit.fade_time = 2000 }, { .operation = BACNET_COLOR_OPERATION_FADE_TO_CCT, - .target.color_temperature = 1800, - .transit.fade_time = 0 }, + .target.color_temperature = 1800, + .transit.fade_time = 0 }, { .operation = BACNET_COLOR_OPERATION_FADE_TO_CCT, - .target.color_temperature = 1800, - .transit.fade_time = 2000 }, + .target.color_temperature = 1800, + .transit.fade_time = 2000 }, { .operation = BACNET_COLOR_OPERATION_RAMP_TO_CCT, - .target.color_temperature = 1800, - .transit.ramp_rate = 0 }, + .target.color_temperature = 1800, + .transit.ramp_rate = 0 }, { .operation = BACNET_COLOR_OPERATION_RAMP_TO_CCT, - .target.color_temperature = 1800, - .transit.ramp_rate = 20 }, + .target.color_temperature = 1800, + .transit.ramp_rate = 20 }, { .operation = BACNET_COLOR_OPERATION_STEP_UP_CCT, - .target.color_temperature = 1800, - .transit.step_increment = 0 }, + .target.color_temperature = 1800, + .transit.step_increment = 0 }, { .operation = BACNET_COLOR_OPERATION_STEP_UP_CCT, - .target.color_temperature = 1800, - .transit.step_increment = 1 }, + .target.color_temperature = 1800, + .transit.step_increment = 1 }, { .operation = BACNET_COLOR_OPERATION_STEP_DOWN_CCT, - .target.color_temperature = 5000, - .transit.step_increment = 0 }, + .target.color_temperature = 5000, + .transit.step_increment = 0 }, { .operation = BACNET_COLOR_OPERATION_STEP_DOWN_CCT, - .target.color_temperature = 5000, - .transit.step_increment = 1 }, + .target.color_temperature = 5000, + .transit.step_increment = 1 }, }; unsigned i; @@ -263,8 +269,8 @@ ZTEST_SUITE(lighting_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(lighting_tests, - ztest_unit_test(testBACnetLightingCommandAll), + ztest_test_suite( + lighting_tests, ztest_unit_test(testBACnetLightingCommandAll), ztest_unit_test(testBACnetColorCommandAll), ztest_unit_test(testBACnetXYColor)); diff --git a/test/bacnet/list_element/src/main.c b/test/bacnet/list_element/src/main.c index d7bd8c7d..019bfb42 100644 --- a/test/bacnet/list_element/src/main.c +++ b/test/bacnet/list_element/src/main.c @@ -58,8 +58,9 @@ static void test_ListElement(void) test_application_data = list_element.application_data; test_application_data_len = list_element.application_data_len; for (i = 0; i < destination_size; i++) { - test_len = bacnet_destination_decode(test_application_data, - test_application_data_len, &test_destination[i]); + test_len = bacnet_destination_decode( + test_application_data, test_application_data_len, + &test_destination[i]); zassert_true( bacnet_destination_same(&destination[i], &test_destination[i]), NULL); @@ -92,7 +93,8 @@ static void test_ListElementError(void) zassert_equal( test_list_element.error_class, list_element.error_class, NULL); zassert_equal(test_list_element.error_code, list_element.error_code, NULL); - zassert_equal(test_list_element.first_failed_element_number, + zassert_equal( + test_list_element.first_failed_element_number, list_element.first_failed_element_number, NULL); } @@ -101,7 +103,8 @@ ZTEST_SUITE(list_element_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(list_element_tests, ztest_unit_test(test_ListElement), + ztest_test_suite( + list_element_tests, ztest_unit_test(test_ListElement), ztest_unit_test(test_ListElementError)); ztest_run_test_suite(list_element_tests); diff --git a/test/bacnet/lso/src/main.c b/test/bacnet/lso/src/main.c index cc5b37a5..ab428df2 100644 --- a/test/bacnet/lso/src/main.c +++ b/test/bacnet/lso/src/main.c @@ -49,25 +49,25 @@ static void testLSO(void) zassert_equal(data.operation, test_data.operation, NULL); zassert_equal(data.processId, test_data.processId, NULL); zassert_equal(data.use_target, test_data.use_target, NULL); - zassert_equal(data.targetObject.instance, test_data.targetObject.instance, NULL); + zassert_equal( + data.targetObject.instance, test_data.targetObject.instance, NULL); zassert_equal(data.targetObject.type, test_data.targetObject.type, NULL); zassert_equal( - memcmp(data.requestingSrc.value, test_data.requestingSrc.value, - test_data.requestingSrc.length), 0, NULL); + memcmp( + data.requestingSrc.value, test_data.requestingSrc.value, + test_data.requestingSrc.length), + 0, NULL); } /** * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(lso_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(lso_tests, - ztest_unit_test(testLSO) - ); + ztest_test_suite(lso_tests, ztest_unit_test(testLSO)); ztest_run_test_suite(lso_tests); } diff --git a/test/bacnet/memcopy/src/main.c b/test/bacnet/memcopy/src/main.c index 2a2923db..8a7d09af 100644 --- a/test/bacnet/memcopy/src/main.c +++ b/test/bacnet/memcopy/src/main.c @@ -44,15 +44,12 @@ static void test_memcopy(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(memcopy_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(memcopy_tests, - ztest_unit_test(test_memcopy) - ); + ztest_test_suite(memcopy_tests, ztest_unit_test(test_memcopy)); ztest_run_test_suite(memcopy_tests); } diff --git a/test/bacnet/npdu/src/main.c b/test/bacnet/npdu/src/main.c index b73ad6db..87f8dd0b 100644 --- a/test/bacnet/npdu/src/main.c +++ b/test/bacnet/npdu/src/main.c @@ -39,15 +39,15 @@ static void test_NPDU_Network(void) bool network_layer_message = true; uint16_t vendor_id = 0; /* optional, if net message type is > 0x80 */ - npdu_encode_npdu_network(&npdu_data, - network_message_type, - data_expecting_reply, priority); + npdu_encode_npdu_network( + &npdu_data, network_message_type, data_expecting_reply, priority); null_len = bacnet_npdu_encode_pdu(NULL, 0, &dest, &src, &npdu_data); len = bacnet_npdu_encode_pdu(&pdu[0], sizeof(pdu), &dest, &src, &npdu_data); zassert_equal(len, null_len, NULL); zassert_not_equal(len, 0, NULL); /* can we get the info back? */ - test_len = bacnet_npdu_decode(pdu, sizeof(pdu), &npdu_dest, &npdu_src, &npdu_data); + test_len = + bacnet_npdu_decode(pdu, sizeof(pdu), &npdu_dest, &npdu_src, &npdu_data); zassert_not_equal(test_len, 0, NULL); zassert_equal(len, test_len, NULL); zassert_equal(npdu_data.data_expecting_reply, data_expecting_reply, NULL); @@ -58,7 +58,8 @@ static void test_NPDU_Network(void) /* test for invalid short PDU */ while (len) { len--; - test_len = bacnet_npdu_decode(pdu, len, &npdu_dest, &npdu_src, &npdu_data); + test_len = + bacnet_npdu_decode(pdu, len, &npdu_dest, &npdu_src, &npdu_data); if (len == 2) { /* special case with no NPDU options */ zassert_equal(len, test_len, NULL); @@ -116,12 +117,14 @@ static void testNPDU2(void) len = bacnet_npdu_encode_pdu(&pdu[0], sizeof(pdu), &dest, &src, &npdu_data); zassert_not_equal(len, 0, NULL); /* can we get the info back? */ - npdu_len = bacnet_npdu_decode(pdu, sizeof(pdu), &npdu_dest, &npdu_src, &npdu_data); + npdu_len = + bacnet_npdu_decode(pdu, sizeof(pdu), &npdu_dest, &npdu_src, &npdu_data); zassert_not_equal(npdu_len, 0, NULL); zassert_equal(npdu_data.data_expecting_reply, data_expecting_reply, NULL); zassert_equal(npdu_data.network_layer_message, network_layer_message, NULL); if (npdu_data.network_layer_message) { - zassert_equal(npdu_data.network_message_type, network_message_type, NULL); + zassert_equal( + npdu_data.network_message_type, network_message_type, NULL); } zassert_equal(npdu_data.vendor_id, vendor_id, NULL); zassert_equal(npdu_data.priority, priority, NULL); @@ -185,12 +188,14 @@ static void testNPDU1(void) len = bacnet_npdu_encode_pdu(&pdu[0], sizeof(pdu), &dest, &src, &npdu_data); zassert_not_equal(len, 0, NULL); /* can we get the info back? */ - npdu_len = bacnet_npdu_decode(pdu, sizeof(pdu), &npdu_dest, &npdu_src, &npdu_data); + npdu_len = + bacnet_npdu_decode(pdu, sizeof(pdu), &npdu_dest, &npdu_src, &npdu_data); zassert_not_equal(npdu_len, 0, NULL); zassert_equal(npdu_data.data_expecting_reply, data_expecting_reply, NULL); zassert_equal(npdu_data.network_layer_message, network_layer_message, NULL); if (npdu_data.network_layer_message) { - zassert_equal(npdu_data.network_message_type, network_message_type, NULL); + zassert_equal( + npdu_data.network_message_type, network_message_type, NULL); } zassert_equal(npdu_data.vendor_id, vendor_id, NULL); zassert_equal(npdu_data.priority, priority, NULL); @@ -201,17 +206,14 @@ static void testNPDU1(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(npdu_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(npdu_tests, - ztest_unit_test(testNPDU1), - ztest_unit_test(testNPDU2), - ztest_unit_test(test_NPDU_Network) - ); + ztest_test_suite( + npdu_tests, ztest_unit_test(testNPDU1), ztest_unit_test(testNPDU2), + ztest_unit_test(test_NPDU_Network)); ztest_run_test_suite(npdu_tests); } diff --git a/test/bacnet/npdu/stubs.c b/test/bacnet/npdu/stubs.c index d7119449..7ca73d6b 100644 --- a/test/bacnet/npdu/stubs.c +++ b/test/bacnet/npdu/stubs.c @@ -30,11 +30,10 @@ #include "bacnet/bacdef.h" #include "bacnet/datalink/bip.h" - int bip_send_pdu( - BACNET_ADDRESS * dest, - BACNET_NPDU_DATA * npdu_data, - uint8_t * pdu, + BACNET_ADDRESS *dest, + BACNET_NPDU_DATA *npdu_data, + uint8_t *pdu, unsigned pdu_len) { return 0; diff --git a/test/bacnet/property/src/main.c b/test/bacnet/property/src/main.c index f901c87d..542927aa 100644 --- a/test/bacnet/property/src/main.c +++ b/test/bacnet/property/src/main.c @@ -57,28 +57,28 @@ void testPropList(void) property_list_special((BACNET_OBJECT_TYPE)i, &property_list); zassert_true( property_list_member( - property_list.Required.pList, PROP_OBJECT_TYPE), NULL); + property_list.Required.pList, PROP_OBJECT_TYPE), + NULL); zassert_true( property_list_member( - property_list.Required.pList, PROP_OBJECT_IDENTIFIER), NULL); + property_list.Required.pList, PROP_OBJECT_IDENTIFIER), + NULL); zassert_true( property_list_member( - property_list.Required.pList, PROP_OBJECT_NAME), NULL); + property_list.Required.pList, PROP_OBJECT_NAME), + NULL); } } /** * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(property_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(property_tests, - ztest_unit_test(testPropList) - ); + ztest_test_suite(property_tests, ztest_unit_test(testPropList)); ztest_run_test_suite(property_tests); } diff --git a/test/bacnet/ptransfer/src/main.c b/test/bacnet/ptransfer/src/main.c index 4c75fab4..0c915184 100644 --- a/test/bacnet/ptransfer/src/main.c +++ b/test/bacnet/ptransfer/src/main.c @@ -21,7 +21,8 @@ /** * @brief Test */ -static int ptransfer_decode_apdu(uint8_t *apdu, +static int ptransfer_decode_apdu( + uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id, BACNET_PRIVATE_TRANSFER_DATA *private_data) @@ -49,7 +50,8 @@ static int ptransfer_decode_apdu(uint8_t *apdu, return len; } -static int uptransfer_decode_apdu(uint8_t *apdu, +static int uptransfer_decode_apdu( + uint8_t *apdu, unsigned apdu_len, BACNET_PRIVATE_TRANSFER_DATA *private_data) { @@ -75,7 +77,8 @@ static int uptransfer_decode_apdu(uint8_t *apdu, return len; } -static int ptransfer_ack_decode_apdu(uint8_t *apdu, +static int ptransfer_ack_decode_apdu( + uint8_t *apdu, int apdu_len, /* total length of the apdu */ uint8_t *invoke_id, BACNET_PRIVATE_TRANSFER_DATA *private_data) @@ -100,7 +103,8 @@ static int ptransfer_ack_decode_apdu(uint8_t *apdu, return len; } -static int ptransfer_error_decode_apdu(uint8_t *apdu, +static int ptransfer_error_decode_apdu( + uint8_t *apdu, int apdu_len, /* total length of the apdu */ uint8_t *invoke_id, BACNET_ERROR_CLASS *error_class, @@ -120,8 +124,9 @@ static int ptransfer_error_decode_apdu(uint8_t *apdu, return -1; offset = 3; if (apdu_len > offset) { - len = ptransfer_error_decode_service_request(&apdu[offset], - apdu_len - offset, error_class, error_code, private_data); + len = ptransfer_error_decode_service_request( + &apdu[offset], apdu_len - offset, error_class, error_code, + private_data); } return len; @@ -150,8 +155,9 @@ static void test_Private_Transfer_Ack(void) private_data.vendorID = BACNET_VENDOR_ID; private_data.serviceNumber = 1; - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, - &private_data_chunk[0], &data_value); + status = bacapp_parse_application_data( + BACNET_APPLICATION_TAG_OCTET_STRING, &private_data_chunk[0], + &data_value); zassert_true(status, NULL); private_data_len = bacapp_encode_application_data(&test_value[0], &data_value); @@ -170,9 +176,11 @@ static void test_Private_Transfer_Ack(void) zassert_equal(test_data.vendorID, private_data.vendorID, NULL); zassert_equal(test_data.serviceNumber, private_data.serviceNumber, NULL); zassert_equal( - test_data.serviceParametersLen, private_data.serviceParametersLen, NULL); - len = bacapp_decode_application_data(test_data.serviceParameters, - test_data.serviceParametersLen, &test_data_value); + test_data.serviceParametersLen, private_data.serviceParametersLen, + NULL); + len = bacapp_decode_application_data( + test_data.serviceParameters, test_data.serviceParametersLen, + &test_data_value); zassert_true(bacapp_same_value(&data_value, &test_data_value), NULL); } @@ -203,8 +211,9 @@ static void test_Private_Transfer_Error(void) private_data.vendorID = BACNET_VENDOR_ID; private_data.serviceNumber = 1; - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, - &private_data_chunk[0], &data_value); + status = bacapp_parse_application_data( + BACNET_APPLICATION_TAG_OCTET_STRING, &private_data_chunk[0], + &data_value); zassert_true(status, NULL); private_data_len = bacapp_encode_application_data(&test_value[0], &data_value); @@ -216,8 +225,9 @@ static void test_Private_Transfer_Error(void) zassert_not_equal(len, 0, NULL); zassert_not_equal(len, -1, NULL); apdu_len = len; - len = ptransfer_error_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, - &test_error_class, &test_error_code, &test_data); + len = ptransfer_error_decode_apdu( + &apdu[0], apdu_len, &test_invoke_id, &test_error_class, + &test_error_code, &test_data); zassert_not_equal(len, -1, NULL); zassert_equal(test_invoke_id, invoke_id, NULL); zassert_equal(test_data.vendorID, private_data.vendorID, NULL); @@ -225,9 +235,11 @@ static void test_Private_Transfer_Error(void) zassert_equal(test_error_class, error_class, NULL); zassert_equal(test_error_code, error_code, NULL); zassert_equal( - test_data.serviceParametersLen, private_data.serviceParametersLen, NULL); - len = bacapp_decode_application_data(test_data.serviceParameters, - test_data.serviceParametersLen, &test_data_value); + test_data.serviceParametersLen, private_data.serviceParametersLen, + NULL); + len = bacapp_decode_application_data( + test_data.serviceParameters, test_data.serviceParametersLen, + &test_data_value); zassert_true(bacapp_same_value(&data_value, &test_data_value), NULL); } @@ -254,8 +266,9 @@ static void test_Private_Transfer_Request(void) private_data.vendorID = BACNET_VENDOR_ID; private_data.serviceNumber = 1; - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, - &private_data_chunk[0], &data_value); + status = bacapp_parse_application_data( + BACNET_APPLICATION_TAG_OCTET_STRING, &private_data_chunk[0], + &data_value); zassert_true(status, NULL); private_data_len = bacapp_encode_application_data(&test_value[0], &data_value); @@ -271,9 +284,11 @@ static void test_Private_Transfer_Request(void) zassert_equal(test_data.vendorID, private_data.vendorID, NULL); zassert_equal(test_data.serviceNumber, private_data.serviceNumber, NULL); zassert_equal( - test_data.serviceParametersLen, private_data.serviceParametersLen, NULL); - len = bacapp_decode_application_data(test_data.serviceParameters, - test_data.serviceParametersLen, &test_data_value); + test_data.serviceParametersLen, private_data.serviceParametersLen, + NULL); + len = bacapp_decode_application_data( + test_data.serviceParameters, test_data.serviceParametersLen, + &test_data_value); zassert_true(bacapp_same_value(&data_value, &test_data_value), NULL); return; @@ -300,9 +315,9 @@ static void test_Unconfirmed_Private_Transfer_Request(void) private_data.vendorID = BACNET_VENDOR_ID; private_data.serviceNumber = 1; - status = - bacapp_parse_application_data(BACNET_APPLICATION_TAG_CHARACTER_STRING, - &private_data_chunk[0], &data_value); + status = bacapp_parse_application_data( + BACNET_APPLICATION_TAG_CHARACTER_STRING, &private_data_chunk[0], + &data_value); zassert_true(status, NULL); private_data_len = bacapp_encode_application_data(&test_value[0], &data_value); @@ -317,9 +332,11 @@ static void test_Unconfirmed_Private_Transfer_Request(void) zassert_equal(test_data.vendorID, private_data.vendorID, NULL); zassert_equal(test_data.serviceNumber, private_data.serviceNumber, NULL); zassert_equal( - test_data.serviceParametersLen, private_data.serviceParametersLen, NULL); - len = bacapp_decode_application_data(test_data.serviceParameters, - test_data.serviceParametersLen, &test_data_value); + test_data.serviceParametersLen, private_data.serviceParametersLen, + NULL); + len = bacapp_decode_application_data( + test_data.serviceParameters, test_data.serviceParametersLen, + &test_data_value); zassert_true(bacapp_same_value(&data_value, &test_data_value), NULL); return; @@ -328,18 +345,16 @@ static void test_Unconfirmed_Private_Transfer_Request(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(ptransfer_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(ptransfer_tests, - ztest_unit_test(test_Private_Transfer_Request), - ztest_unit_test(test_Private_Transfer_Ack), - ztest_unit_test(test_Private_Transfer_Error), - ztest_unit_test(test_Unconfirmed_Private_Transfer_Request) - ); + ztest_test_suite( + ptransfer_tests, ztest_unit_test(test_Private_Transfer_Request), + ztest_unit_test(test_Private_Transfer_Ack), + ztest_unit_test(test_Private_Transfer_Error), + ztest_unit_test(test_Unconfirmed_Private_Transfer_Request)); ztest_run_test_suite(ptransfer_tests); } diff --git a/test/bacnet/rd/src/main.c b/test/bacnet/rd/src/main.c index 25054bbd..c7be3ad8 100644 --- a/test/bacnet/rd/src/main.c +++ b/test/bacnet/rd/src/main.c @@ -20,7 +20,8 @@ /** * @brief Test */ -static int rd_decode_apdu(uint8_t *apdu, +static int rd_decode_apdu( + uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id, BACNET_REINITIALIZED_STATE *state, @@ -96,7 +97,8 @@ static void Test_ReinitializeDevice_Service( continue; } len = rd_decode_apdu(apdu, apdu_len, NULL, NULL, NULL); - zassert_true(len < 0, "len=%d apdu_len=%d password='%s'", len, apdu_len, + zassert_true( + len < 0, "len=%d apdu_len=%d password='%s'", len, apdu_len, password_string); } } diff --git a/test/bacnet/reject/src/main.c b/test/bacnet/reject/src/main.c index 52ccc292..ca776913 100644 --- a/test/bacnet/reject/src/main.c +++ b/test/bacnet/reject/src/main.c @@ -20,7 +20,8 @@ * @brief Test */ /* decode the whole APDU - mainly used for unit testing */ -static int reject_decode_apdu(uint8_t *apdu, +static int reject_decode_apdu( + uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id, uint8_t *reject_reason) @@ -112,8 +113,8 @@ static void testRejectErrorCode(void) error_code = reject_convert_to_error_code(reject_reason); test_reject_reason = reject_convert_error_code(error_code); if (test_reject_reason != reject_reason) { - printf("Reject: result=%u reject-code=%u\n", - test_reject_reason, + printf( + "Reject: result=%u reject-code=%u\n", test_reject_reason, reject_reason); } zassert_equal(test_reject_reason, reject_reason, NULL); @@ -123,16 +124,14 @@ static void testRejectErrorCode(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(reject_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(reject_tests, - ztest_unit_test(testRejectEncodeDecode), - ztest_unit_test(testRejectErrorCode) - ); + ztest_test_suite( + reject_tests, ztest_unit_test(testRejectEncodeDecode), + ztest_unit_test(testRejectErrorCode)); ztest_run_test_suite(reject_tests); } diff --git a/test/bacnet/rp/src/main.c b/test/bacnet/rp/src/main.c index cb51db1a..59e76b36 100644 --- a/test/bacnet/rp/src/main.c +++ b/test/bacnet/rp/src/main.c @@ -20,7 +20,8 @@ /** * @brief Test */ -static int rp_decode_apdu(uint8_t *apdu, +static int rp_decode_apdu( + uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id, BACNET_READ_PROPERTY_DATA *rpdata) @@ -58,7 +59,8 @@ static int rp_decode_apdu(uint8_t *apdu, return apdu_len; } -static int rp_ack_decode_apdu(uint8_t *apdu, +static int rp_ack_decode_apdu( + uint8_t *apdu, int apdu_size, uint8_t *invoke_id, BACNET_READ_PROPERTY_DATA *rpdata) @@ -209,7 +211,8 @@ ZTEST_SUITE(rp_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(rp_tests, ztest_unit_test(testReadProperty), + ztest_test_suite( + rp_tests, ztest_unit_test(testReadProperty), ztest_unit_test(testReadPropertyAck)); ztest_run_test_suite(rp_tests); diff --git a/test/bacnet/rpm/src/main.c b/test/bacnet/rpm/src/main.c index 841b6dad..f9c72d49 100644 --- a/test/bacnet/rpm/src/main.c +++ b/test/bacnet/rpm/src/main.c @@ -9,7 +9,7 @@ */ #include -#include /* For bacerror_decode_error_class_and_code() */ +#include /* For bacerror_decode_error_class_and_code() */ #include #include @@ -21,7 +21,8 @@ /** * @brief Test */ -static int rpm_ack_decode_apdu(uint8_t *apdu, +static int rpm_ack_decode_apdu( + uint8_t *apdu, int apdu_len, /* total length of the apdu */ uint8_t *invoke_id, uint8_t **service_request, @@ -48,7 +49,8 @@ static int rpm_ack_decode_apdu(uint8_t *apdu, return offset; } -static int rpm_decode_apdu(uint8_t *apdu, +static int rpm_decode_apdu( + uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id, uint8_t **service_request, @@ -126,7 +128,8 @@ static void testReadPropertyMultiple(void) zassert_not_equal(apdu_len, 0, NULL); - test_len = rpm_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + test_len = rpm_decode_apdu( + &apdu[0], apdu_len, &test_invoke_id, &service_request, /* will point to the service request in the apdu */ &service_request_len); zassert_not_equal(test_len, -1, NULL); @@ -242,8 +245,9 @@ static void testReadPropertyMultipleAck(void) application_data[0].type.Object_Id.instance = 123; application_data_buffer_len = bacapp_encode_application_data( &application_data_buffer[0], &application_data[0]); - apdu_len += rpm_ack_encode_apdu_object_property_value(&apdu[apdu_len], - &application_data_buffer[0], application_data_buffer_len); + apdu_len += rpm_ack_encode_apdu_object_property_value( + &apdu[apdu_len], &application_data_buffer[0], + application_data_buffer_len); /* reply property */ apdu_len += rpm_ack_encode_apdu_object_property( &apdu[apdu_len], PROP_OBJECT_TYPE, BACNET_ARRAY_ALL); @@ -252,8 +256,9 @@ static void testReadPropertyMultipleAck(void) application_data[1].type.Enumerated = OBJECT_DEVICE; application_data_buffer_len = bacapp_encode_application_data( &application_data_buffer[0], &application_data[1]); - apdu_len += rpm_ack_encode_apdu_object_property_value(&apdu[apdu_len], - &application_data_buffer[0], application_data_buffer_len); + apdu_len += rpm_ack_encode_apdu_object_property_value( + &apdu[apdu_len], &application_data_buffer[0], + application_data_buffer_len); /* object end */ apdu_len += rpm_ack_encode_apdu_object_end(&apdu[apdu_len]); @@ -269,8 +274,9 @@ static void testReadPropertyMultipleAck(void) application_data[2].type.Real = 0.0; application_data_buffer_len = bacapp_encode_application_data( &application_data_buffer[0], &application_data[2]); - apdu_len += rpm_ack_encode_apdu_object_property_value(&apdu[apdu_len], - &application_data_buffer[0], application_data_buffer_len); + apdu_len += rpm_ack_encode_apdu_object_property_value( + &apdu[apdu_len], &application_data_buffer[0], + application_data_buffer_len); /* reply property */ apdu_len += rpm_ack_encode_apdu_object_property( &apdu[apdu_len], PROP_DEADBAND, BACNET_ARRAY_ALL); @@ -282,7 +288,8 @@ static void testReadPropertyMultipleAck(void) zassert_not_equal(apdu_len, 0, NULL); /****** decode the packet ******/ - test_len = rpm_ack_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + test_len = rpm_ack_decode_apdu( + &apdu[0], apdu_len, &test_invoke_id, &service_request, /* will point to the service request in the apdu */ &service_request_len); zassert_not_equal(test_len, -1, NULL); @@ -297,8 +304,9 @@ static void testReadPropertyMultipleAck(void) zassert_equal(object_instance, 123, NULL); len = test_len; /* extract the property */ - test_len = rpm_ack_decode_object_property(&service_request[len], - service_request_len - len, &object_property, &array_index); + test_len = rpm_ack_decode_object_property( + &service_request[len], service_request_len - len, &object_property, + &array_index); zassert_equal(object_property, PROP_OBJECT_IDENTIFIER, NULL); zassert_equal(array_index, BACNET_ARRAY_ALL, NULL); len += test_len; @@ -308,16 +316,19 @@ static void testReadPropertyMultipleAck(void) /* decode the object property portion of the service request */ /* note: if this was an array, there could have been more than one element to decode */ - test_len = bacapp_decode_application_data(&service_request[len], - service_request_len - len, &test_application_data); + test_len = bacapp_decode_application_data( + &service_request[len], service_request_len - len, + &test_application_data); zassert_true(test_len > 0, NULL); - zassert_true(bacapp_same_value(&application_data[0], &test_application_data), NULL); + zassert_true( + bacapp_same_value(&application_data[0], &test_application_data), NULL); len += test_len; zassert_true(decode_is_closing_tag_number(&service_request[len], 4), NULL); len++; /* see if there is another property */ - test_len = rpm_ack_decode_object_property(&service_request[len], - service_request_len - len, &object_property, &array_index); + test_len = rpm_ack_decode_object_property( + &service_request[len], service_request_len - len, &object_property, + &array_index); zassert_not_equal(test_len, -1, NULL); zassert_equal(object_property, PROP_OBJECT_TYPE, NULL); zassert_equal(array_index, BACNET_ARRAY_ALL, NULL); @@ -326,17 +337,20 @@ static void testReadPropertyMultipleAck(void) zassert_true(decode_is_opening_tag_number(&service_request[len], 4), NULL); len++; /* decode the object property portion of the service request */ - test_len = bacapp_decode_application_data(&service_request[len], - service_request_len - len, &test_application_data); + test_len = bacapp_decode_application_data( + &service_request[len], service_request_len - len, + &test_application_data); zassert_true(test_len > 0, NULL); - zassert_true(bacapp_same_value(&application_data[1], &test_application_data), NULL); + zassert_true( + bacapp_same_value(&application_data[1], &test_application_data), NULL); len += test_len; zassert_true(decode_is_closing_tag_number(&service_request[len], 4), NULL); len++; /* see if there is another property */ /* this time we should fail */ - test_len = rpm_ack_decode_object_property(&service_request[len], - service_request_len - len, &object_property, &array_index); + test_len = rpm_ack_decode_object_property( + &service_request[len], service_request_len - len, &object_property, + &array_index); zassert_equal(test_len, -1, NULL); /* see if it is the end of this object */ test_len = rpm_ack_decode_object_end( @@ -344,15 +358,17 @@ static void testReadPropertyMultipleAck(void) zassert_equal(test_len, 1, NULL); len += test_len; /* try to decode another object id */ - test_len = rpm_ack_decode_object_id(&service_request[len], - service_request_len - len, &object_type, &object_instance); + test_len = rpm_ack_decode_object_id( + &service_request[len], service_request_len - len, &object_type, + &object_instance); zassert_not_equal(test_len, -1, NULL); zassert_equal(object_type, OBJECT_ANALOG_INPUT, NULL); zassert_equal(object_instance, 33, NULL); len += test_len; /* decode the object property portion of the service request only */ - test_len = rpm_ack_decode_object_property(&service_request[len], - service_request_len - len, &object_property, &array_index); + test_len = rpm_ack_decode_object_property( + &service_request[len], service_request_len - len, &object_property, + &array_index); zassert_not_equal(test_len, -1, NULL); zassert_equal(object_property, PROP_PRESENT_VALUE, NULL); zassert_equal(array_index, BACNET_ARRAY_ALL, NULL); @@ -361,16 +377,19 @@ static void testReadPropertyMultipleAck(void) zassert_true(decode_is_opening_tag_number(&service_request[len], 4), NULL); len++; /* decode the object property portion of the service request */ - test_len = bacapp_decode_application_data(&service_request[len], - service_request_len - len, &test_application_data); + test_len = bacapp_decode_application_data( + &service_request[len], service_request_len - len, + &test_application_data); zassert_true(test_len > 0, NULL); - zassert_true(bacapp_same_value(&application_data[2], &test_application_data), NULL); + zassert_true( + bacapp_same_value(&application_data[2], &test_application_data), NULL); len += test_len; zassert_true(decode_is_closing_tag_number(&service_request[len], 4), NULL); len++; /* see if there is another property */ - test_len = rpm_ack_decode_object_property(&service_request[len], - service_request_len - len, &object_property, &array_index); + test_len = rpm_ack_decode_object_property( + &service_request[len], service_request_len - len, &object_property, + &array_index); zassert_not_equal(test_len, -1, NULL); zassert_equal(object_property, PROP_DEADBAND, NULL); zassert_equal(array_index, BACNET_ARRAY_ALL, NULL); @@ -379,8 +398,9 @@ static void testReadPropertyMultipleAck(void) zassert_true(decode_is_opening_tag_number(&service_request[len], 5), NULL); len++; /* it was an error reply */ - test_len = bacerror_decode_error_class_and_code(&service_request[len], - service_request_len - len, &error_class, &error_code); + test_len = bacerror_decode_error_class_and_code( + &service_request[len], service_request_len - len, &error_class, + &error_code); zassert_not_equal(test_len, 0, NULL); zassert_equal(error_class, ERROR_CLASS_PROPERTY, NULL); zassert_equal(error_code, ERROR_CODE_UNKNOWN_PROPERTY, NULL); @@ -388,8 +408,9 @@ static void testReadPropertyMultipleAck(void) zassert_true(decode_is_closing_tag_number(&service_request[len], 5), NULL); len++; /* is there another property? */ - test_len = rpm_ack_decode_object_property(&service_request[len], - service_request_len - len, &object_property, &array_index); + test_len = rpm_ack_decode_object_property( + &service_request[len], service_request_len - len, &object_property, + &array_index); zassert_equal(test_len, -1, NULL); /* got an error -1, is it the end of this object? */ test_len = rpm_ack_decode_object_end( @@ -397,8 +418,9 @@ static void testReadPropertyMultipleAck(void) zassert_equal(test_len, 1, NULL); len += test_len; /* check for another object */ - test_len = rpm_ack_decode_object_id(&service_request[len], - service_request_len - len, &object_type, &object_instance); + test_len = rpm_ack_decode_object_id( + &service_request[len], service_request_len - len, &object_type, + &object_instance); zassert_equal(test_len, 0, NULL); zassert_equal(len, service_request_len, NULL); } @@ -406,16 +428,14 @@ static void testReadPropertyMultipleAck(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(rpm_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(rpm_tests, - ztest_unit_test(testReadPropertyMultiple), - ztest_unit_test(testReadPropertyMultipleAck) - ); + ztest_test_suite( + rpm_tests, ztest_unit_test(testReadPropertyMultiple), + ztest_unit_test(testReadPropertyMultipleAck)); ztest_run_test_suite(rpm_tests); } diff --git a/test/bacnet/specialevent/src/main.c b/test/bacnet/specialevent/src/main.c index fc5e9ed9..76a63d3d 100644 --- a/test/bacnet/specialevent/src/main.c +++ b/test/bacnet/specialevent/src/main.c @@ -91,38 +91,52 @@ static void test_BACnetSpecialEvent_CalendarRef(void) zassert_equal(len, apdu_len, NULL); zassert_equal(in.periodTag, out.periodTag, NULL); - zassert_equal(in.period.calendarReference.instance, + zassert_equal( + in.period.calendarReference.instance, out.period.calendarReference.instance, NULL); - zassert_equal(in.period.calendarReference.type, - out.period.calendarReference.type, NULL); + zassert_equal( + in.period.calendarReference.type, out.period.calendarReference.type, + NULL); zassert_equal(in.timeValues.TV_Count, out.timeValues.TV_Count, NULL); - zassert_equal(in.timeValues.Time_Values[0].Time.hour, + zassert_equal( + in.timeValues.Time_Values[0].Time.hour, out.timeValues.Time_Values[0].Time.hour, NULL); - zassert_equal(in.timeValues.Time_Values[0].Time.min, + zassert_equal( + in.timeValues.Time_Values[0].Time.min, out.timeValues.Time_Values[0].Time.min, NULL); - zassert_equal(in.timeValues.Time_Values[0].Time.sec, + zassert_equal( + in.timeValues.Time_Values[0].Time.sec, out.timeValues.Time_Values[0].Time.sec, NULL); - zassert_equal(in.timeValues.Time_Values[0].Time.hundredths, + zassert_equal( + in.timeValues.Time_Values[0].Time.hundredths, out.timeValues.Time_Values[0].Time.hundredths, NULL); - zassert_equal(in.timeValues.Time_Values[0].Value.tag, + zassert_equal( + in.timeValues.Time_Values[0].Value.tag, out.timeValues.Time_Values[0].Value.tag, NULL); - zassert_equal(in.timeValues.Time_Values[0].Value.type.Unsigned_Int, + zassert_equal( + in.timeValues.Time_Values[0].Value.type.Unsigned_Int, out.timeValues.Time_Values[0].Value.type.Unsigned_Int, NULL); - zassert_equal(in.timeValues.Time_Values[1].Time.hour, + zassert_equal( + in.timeValues.Time_Values[1].Time.hour, out.timeValues.Time_Values[1].Time.hour, NULL); - zassert_equal(in.timeValues.Time_Values[1].Time.min, + zassert_equal( + in.timeValues.Time_Values[1].Time.min, out.timeValues.Time_Values[1].Time.min, NULL); - zassert_equal(in.timeValues.Time_Values[1].Time.sec, + zassert_equal( + in.timeValues.Time_Values[1].Time.sec, out.timeValues.Time_Values[1].Time.sec, NULL); - zassert_equal(in.timeValues.Time_Values[1].Time.hundredths, + zassert_equal( + in.timeValues.Time_Values[1].Time.hundredths, out.timeValues.Time_Values[1].Time.hundredths, NULL); - zassert_equal(in.timeValues.Time_Values[1].Value.tag, + zassert_equal( + in.timeValues.Time_Values[1].Value.tag, out.timeValues.Time_Values[1].Value.tag, NULL); - zassert_equal(in.timeValues.Time_Values[1].Value.type.Unsigned_Int, + zassert_equal( + in.timeValues.Time_Values[1].Value.type.Unsigned_Int, out.timeValues.Time_Values[1].Value.type.Unsigned_Int, NULL); zassert_equal(in.priority, out.priority, NULL); @@ -172,13 +186,17 @@ static void test_BACnetSpecialEvent_Date(void) zassert_equal(in.periodTag, out.periodTag, NULL); zassert_equal( in.period.calendarEntry.tag, out.period.calendarEntry.tag, NULL); - zassert_equal(in.period.calendarEntry.type.Date.wday, + zassert_equal( + in.period.calendarEntry.type.Date.wday, out.period.calendarEntry.type.Date.wday, NULL); - zassert_equal(in.period.calendarEntry.type.Date.year, + zassert_equal( + in.period.calendarEntry.type.Date.year, out.period.calendarEntry.type.Date.year, NULL); - zassert_equal(in.period.calendarEntry.type.Date.month, + zassert_equal( + in.period.calendarEntry.type.Date.month, out.period.calendarEntry.type.Date.month, NULL); - zassert_equal(in.period.calendarEntry.type.Date.day, + zassert_equal( + in.period.calendarEntry.type.Date.day, out.period.calendarEntry.type.Date.day, NULL); zassert_equal(in.timeValues.TV_Count, out.timeValues.TV_Count, NULL); @@ -239,22 +257,30 @@ static void test_BACnetSpecialEvent_DateRange(void) zassert_equal( in.period.calendarEntry.tag, out.period.calendarEntry.tag, NULL); - zassert_equal(in.period.calendarEntry.type.DateRange.startdate.wday, + zassert_equal( + in.period.calendarEntry.type.DateRange.startdate.wday, out.period.calendarEntry.type.DateRange.startdate.wday, NULL); - zassert_equal(in.period.calendarEntry.type.DateRange.startdate.year, + zassert_equal( + in.period.calendarEntry.type.DateRange.startdate.year, out.period.calendarEntry.type.DateRange.startdate.year, NULL); - zassert_equal(in.period.calendarEntry.type.DateRange.startdate.month, + zassert_equal( + in.period.calendarEntry.type.DateRange.startdate.month, out.period.calendarEntry.type.DateRange.startdate.month, NULL); - zassert_equal(in.period.calendarEntry.type.DateRange.startdate.day, + zassert_equal( + in.period.calendarEntry.type.DateRange.startdate.day, out.period.calendarEntry.type.DateRange.startdate.day, NULL); - zassert_equal(in.period.calendarEntry.type.DateRange.enddate.wday, + zassert_equal( + in.period.calendarEntry.type.DateRange.enddate.wday, out.period.calendarEntry.type.DateRange.enddate.wday, NULL); - zassert_equal(in.period.calendarEntry.type.DateRange.enddate.year, + zassert_equal( + in.period.calendarEntry.type.DateRange.enddate.year, out.period.calendarEntry.type.DateRange.enddate.year, NULL); - zassert_equal(in.period.calendarEntry.type.DateRange.enddate.month, + zassert_equal( + in.period.calendarEntry.type.DateRange.enddate.month, out.period.calendarEntry.type.DateRange.enddate.month, NULL); - zassert_equal(in.period.calendarEntry.type.DateRange.enddate.day, + zassert_equal( + in.period.calendarEntry.type.DateRange.enddate.day, out.period.calendarEntry.type.DateRange.enddate.day, NULL); zassert_equal(in.timeValues.TV_Count, out.timeValues.TV_Count, NULL); @@ -305,11 +331,14 @@ static void test_BACnetSpecialEvent_WeekNDate(void) zassert_equal( in.period.calendarEntry.tag, out.period.calendarEntry.tag, NULL); - zassert_equal(in.period.calendarEntry.type.WeekNDay.month, + zassert_equal( + in.period.calendarEntry.type.WeekNDay.month, out.period.calendarEntry.type.WeekNDay.month, NULL); - zassert_equal(in.period.calendarEntry.type.WeekNDay.dayofweek, + zassert_equal( + in.period.calendarEntry.type.WeekNDay.dayofweek, out.period.calendarEntry.type.WeekNDay.dayofweek, NULL); - zassert_equal(in.period.calendarEntry.type.WeekNDay.weekofmonth, + zassert_equal( + in.period.calendarEntry.type.WeekNDay.weekofmonth, out.period.calendarEntry.type.WeekNDay.weekofmonth, NULL); zassert_equal(in.timeValues.TV_Count, out.timeValues.TV_Count, NULL); @@ -325,8 +354,10 @@ static void test_BACnetSpecialEvent_DecodeRealAPDU(void) { int len, apdu_len; BACNET_SPECIAL_EVENT out = { 0 }; - uint8_t sample[18] = { 0x0e, 0x0c, 0xff, 0x0a, 0x1c, 0xff, 0x0f, 0x2e, 0xb4, - 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x2f, 0x39, 0x10 }; + uint8_t sample[18] = { + 0x0e, 0x0c, 0xff, 0x0a, 0x1c, 0xff, 0x0f, 0x2e, 0xb4, + 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x2f, 0x39, 0x10 + }; apdu_len = bacnet_special_event_decode(sample, sizeof(sample), &out); zassert_equal(sizeof(sample), apdu_len, NULL); @@ -348,7 +379,8 @@ static void test_BACnetSpecialEvent_DecodeRealAPDU(void) zassert_equal(out.timeValues.Time_Values[0].Time.sec, 0, NULL); zassert_equal(out.timeValues.Time_Values[0].Time.hundredths, 0, NULL); - zassert_equal(out.timeValues.Time_Values[0].Value.tag, + zassert_equal( + out.timeValues.Time_Values[0].Value.tag, BACNET_APPLICATION_TAG_ENUMERATED, NULL); zassert_equal( out.timeValues.Time_Values[0].Value.type.Unsigned_Int, 0, NULL); @@ -365,7 +397,8 @@ ZTEST_SUITE(BACnetSpecialEvent_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(BACnetSpecialEvent_tests, + ztest_test_suite( + BACnetSpecialEvent_tests, ztest_unit_test(test_BACnetSpecialEvent_CalendarRef), ztest_unit_test(test_BACnetSpecialEvent_Date), ztest_unit_test(test_BACnetSpecialEvent_DateRange), diff --git a/test/bacnet/timestamp/src/main.c b/test/bacnet/timestamp/src/main.c index 1878f73f..2dc7a44b 100644 --- a/test/bacnet/timestamp/src/main.c +++ b/test/bacnet/timestamp/src/main.c @@ -41,8 +41,9 @@ static void testTimestampSequence(void) zassert_equal(len, test_len, NULL); zassert_equal(testTimestampIn.tag, testTimestampOut.tag, NULL); - zassert_equal(testTimestampIn.value.sequenceNum, - testTimestampOut.value.sequenceNum, NULL); + zassert_equal( + testTimestampIn.value.sequenceNum, testTimestampOut.value.sequenceNum, + NULL); } #if defined(CONFIG_ZTEST_NEW_API) @@ -72,13 +73,15 @@ static void testTimestampTime(void) zassert_equal(len, test_len, NULL); zassert_equal(testTimestampIn.tag, testTimestampOut.tag, NULL); - zassert_equal(testTimestampIn.value.time.hour, - testTimestampOut.value.time.hour, NULL); + zassert_equal( + testTimestampIn.value.time.hour, testTimestampOut.value.time.hour, + NULL); zassert_equal( testTimestampIn.value.time.min, testTimestampOut.value.time.min, NULL); zassert_equal( testTimestampIn.value.time.sec, testTimestampOut.value.time.sec, NULL); - zassert_equal(testTimestampIn.value.time.hundredths, + zassert_equal( + testTimestampIn.value.time.hundredths, testTimestampOut.value.time.hundredths, NULL); bacapp_timestamp_to_ascii(str, sizeof(str), &testTimestampIn); @@ -119,12 +122,12 @@ static void testTimestampTimeDate(void) test_len = bacnet_timestamp_decode(buffer, len, &testTimestampOut); zassert_equal(test_len, BACNET_STATUS_ERROR, NULL); } - null_len = bacapp_encode_context_timestamp(NULL, tag_number, &testTimestampIn); + null_len = + bacapp_encode_context_timestamp(NULL, tag_number, &testTimestampIn); len = bacapp_encode_context_timestamp(buffer, tag_number, &testTimestampIn); zassert_equal(null_len, len, NULL); zassert_true(len > 0, NULL); - null_len = bacnet_timestamp_context_decode( - buffer, len, tag_number, NULL); + null_len = bacnet_timestamp_context_decode(buffer, len, tag_number, NULL); test_len = bacnet_timestamp_context_decode( buffer, len, tag_number, &testTimestampOut); zassert_equal(null_len, test_len, NULL); @@ -138,22 +141,30 @@ static void testTimestampTimeDate(void) } /* test for valid values */ zassert_equal(testTimestampIn.tag, testTimestampOut.tag, NULL); - zassert_equal(testTimestampIn.value.dateTime.time.hour, + zassert_equal( + testTimestampIn.value.dateTime.time.hour, testTimestampOut.value.dateTime.time.hour, NULL); - zassert_equal(testTimestampIn.value.dateTime.time.min, + zassert_equal( + testTimestampIn.value.dateTime.time.min, testTimestampOut.value.dateTime.time.min, NULL); - zassert_equal(testTimestampIn.value.dateTime.time.sec, + zassert_equal( + testTimestampIn.value.dateTime.time.sec, testTimestampOut.value.dateTime.time.sec, NULL); - zassert_equal(testTimestampIn.value.dateTime.time.hundredths, + zassert_equal( + testTimestampIn.value.dateTime.time.hundredths, testTimestampOut.value.dateTime.time.hundredths, NULL); - zassert_equal(testTimestampIn.value.dateTime.date.year, + zassert_equal( + testTimestampIn.value.dateTime.date.year, testTimestampOut.value.dateTime.date.year, NULL); - zassert_equal(testTimestampIn.value.dateTime.date.month, + zassert_equal( + testTimestampIn.value.dateTime.date.month, testTimestampOut.value.dateTime.date.month, NULL); - zassert_equal(testTimestampIn.value.dateTime.date.wday, + zassert_equal( + testTimestampIn.value.dateTime.date.wday, testTimestampOut.value.dateTime.date.wday, NULL); - zassert_equal(testTimestampIn.value.dateTime.date.day, + zassert_equal( + testTimestampIn.value.dateTime.date.day, testTimestampOut.value.dateTime.date.day, NULL); } /** @@ -165,7 +176,8 @@ ZTEST_SUITE(timestamp_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(timestamp_tests, ztest_unit_test(testTimestampSequence), + ztest_test_suite( + timestamp_tests, ztest_unit_test(testTimestampSequence), ztest_unit_test(testTimestampTime), ztest_unit_test(testTimestampTimeDate)); diff --git a/test/bacnet/timesync/src/main.c b/test/bacnet/timesync/src/main.c index 6ccde4e4..4bef9b0e 100644 --- a/test/bacnet/timesync/src/main.c +++ b/test/bacnet/timesync/src/main.c @@ -21,8 +21,7 @@ * @brief Test */ static void testTimeSyncRecipientData( - BACNET_RECIPIENT_LIST *recipient1, - BACNET_RECIPIENT_LIST *recipient2) + BACNET_RECIPIENT_LIST *recipient1, BACNET_RECIPIENT_LIST *recipient2) { unsigned i = 0; @@ -30,34 +29,36 @@ static void testTimeSyncRecipientData( zassert_equal(recipient1->tag, recipient2->tag, NULL); if (recipient1->tag == 0) { zassert_equal( - recipient1->type.device.type, recipient2->type.device.type, NULL); + recipient1->type.device.type, recipient2->type.device.type, + NULL); zassert_equal( recipient1->type.device.instance, - recipient2->type.device.instance, NULL); + recipient2->type.device.instance, NULL); } else if (recipient1->tag == 1) { zassert_equal( - recipient1->type.address.net, recipient2->type.address.net, NULL); + recipient1->type.address.net, recipient2->type.address.net, + NULL); if (recipient1->type.address.net == BACNET_BROADCAST_NETWORK) { zassert_equal( recipient1->type.address.mac_len, - recipient2->type.address.mac_len, NULL); + recipient2->type.address.mac_len, NULL); } else if (recipient1->type.address.net) { zassert_equal( - recipient1->type.address.len, - recipient2->type.address.len, NULL); + recipient1->type.address.len, recipient2->type.address.len, + NULL); for (i = 0; i < recipient1->type.address.len; i++) { zassert_equal( recipient1->type.address.adr[i], - recipient2->type.address.adr[i], NULL); + recipient2->type.address.adr[i], NULL); } } else { zassert_equal( recipient1->type.address.mac_len, - recipient2->type.address.mac_len, NULL); + recipient2->type.address.mac_len, NULL); for (i = 0; i < recipient1->type.address.mac_len; i++) { zassert_equal( recipient1->type.address.mac[i], - recipient2->type.address.mac[i], NULL); + recipient2->type.address.mac[i], NULL); } } } else { @@ -122,7 +123,8 @@ static void testTimeSyncRecipient(void) testTimeSyncRecipientData(&recipient[0], &test_recipient[0]); } -static int timesync_decode_apdu_service(uint8_t *apdu, +static int timesync_decode_apdu_service( + uint8_t *apdu, BACNET_UNCONFIRMED_SERVICE service, unsigned apdu_len, BACNET_DATE *my_date, @@ -146,23 +148,26 @@ static int timesync_decode_apdu_service(uint8_t *apdu, return len; } -int timesync_utc_decode_apdu(uint8_t *apdu, +int timesync_utc_decode_apdu( + uint8_t *apdu, unsigned apdu_len, BACNET_DATE *my_date, BACNET_TIME *my_time) { - return timesync_decode_apdu_service(apdu, - SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, apdu_len, my_date, + return timesync_decode_apdu_service( + apdu, SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, apdu_len, my_date, my_time); } -int timesync_decode_apdu(uint8_t *apdu, +int timesync_decode_apdu( + uint8_t *apdu, unsigned apdu_len, BACNET_DATE *my_date, BACNET_TIME *my_time) { - return timesync_decode_apdu_service(apdu, - SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, apdu_len, my_date, my_time); + return timesync_decode_apdu_service( + apdu, SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, apdu_len, my_date, + my_time); } static void testTimeSyncData(BACNET_DATE *my_date, BACNET_TIME *my_time) @@ -215,16 +220,14 @@ static void testTimeSync(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(timesync_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(timesync_tests, - ztest_unit_test(testTimeSync), - ztest_unit_test(testTimeSyncRecipient) - ); + ztest_test_suite( + timesync_tests, ztest_unit_test(testTimeSync), + ztest_unit_test(testTimeSyncRecipient)); ztest_run_test_suite(timesync_tests); } diff --git a/test/bacnet/weeklyschedule/src/main.c b/test/bacnet/weeklyschedule/src/main.c index 9369c38e..1b10c8f6 100644 --- a/test/bacnet/weeklyschedule/src/main.c +++ b/test/bacnet/weeklyschedule/src/main.c @@ -20,7 +20,6 @@ #include "bacnet/datetime.h" #include "bacnet/bacapp.h" - /** * @addtogroup bacnet_tests * @{ @@ -46,30 +45,28 @@ static void test_BACnetWeeklySchedule(void) value.weeklySchedule[0].TV_Count = 2; - value.weeklySchedule[0].Time_Values[0].Time = (BACNET_TIME) { - .hour = 5, - .min = 30 - }; - value.weeklySchedule[0].Time_Values[0].Value = (BACNET_PRIMITIVE_DATA_VALUE) { - .tag = BACNET_APPLICATION_TAG_UNSIGNED_INT, - .type.Unsigned_Int = 123, - }; + value.weeklySchedule[0].Time_Values[0].Time = + (BACNET_TIME) { .hour = 5, .min = 30 }; + value.weeklySchedule[0].Time_Values[0].Value = + (BACNET_PRIMITIVE_DATA_VALUE) { + .tag = BACNET_APPLICATION_TAG_UNSIGNED_INT, + .type.Unsigned_Int = 123, + }; - value.weeklySchedule[0].Time_Values[1].Time = (BACNET_TIME) { - .hour = 15, - .min = 0 - }; - value.weeklySchedule[0].Time_Values[1].Value = (BACNET_PRIMITIVE_DATA_VALUE) { - .tag = BACNET_APPLICATION_TAG_UNSIGNED_INT, - .type.Unsigned_Int = 456, - }; + value.weeklySchedule[0].Time_Values[1].Time = + (BACNET_TIME) { .hour = 15, .min = 0 }; + value.weeklySchedule[0].Time_Values[1].Value = + (BACNET_PRIMITIVE_DATA_VALUE) { + .tag = BACNET_APPLICATION_TAG_UNSIGNED_INT, + .type.Unsigned_Int = 456, + }; value.weeklySchedule[6].TV_Count = 1; - value.weeklySchedule[6].Time_Values[0].Value = (BACNET_PRIMITIVE_DATA_VALUE) { - .tag = BACNET_APPLICATION_TAG_UNSIGNED_INT, - .type.Unsigned_Int = 777, - }; - + value.weeklySchedule[6].Time_Values[0].Value = + (BACNET_PRIMITIVE_DATA_VALUE) { + .tag = BACNET_APPLICATION_TAG_UNSIGNED_INT, + .type.Unsigned_Int = 777, + }; len = bacnet_weeklyschedule_encode(apdu, &value); apdu_len = bacnet_weeklyschedule_decode(apdu, len, &decoded); @@ -82,7 +79,8 @@ static void test_BACnetWeeklySchedule(void) zassert_false(status, NULL); len = bacnet_weeklyschedule_context_encode(apdu, tag_number, &value); - apdu_len = bacnet_weeklyschedule_context_decode(apdu, len, tag_number, &decoded); + apdu_len = + bacnet_weeklyschedule_context_decode(apdu, len, tag_number, &decoded); zassert_true(len > 0, NULL); zassert_true(apdu_len > 0, NULL); status = bacnet_weeklyschedule_same(&value, &decoded); @@ -90,7 +88,8 @@ static void test_BACnetWeeklySchedule(void) /* negative testing - the tag differs */ tag_number++; - apdu_len = bacnet_weeklyschedule_context_decode(apdu, len, tag_number, &decoded); + apdu_len = + bacnet_weeklyschedule_context_decode(apdu, len, tag_number, &decoded); zassert_true(apdu_len < 0, NULL); } @@ -103,9 +102,8 @@ ZTEST_SUITE(BACnetWeeklySchedule_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(BACnetWeeklySchedule_tests, - ztest_unit_test(test_BACnetWeeklySchedule) - ); + ztest_test_suite( + BACnetWeeklySchedule_tests, ztest_unit_test(test_BACnetWeeklySchedule)); ztest_run_test_suite(BACnetWeeklySchedule_tests); } diff --git a/test/bacnet/whohas/src/main.c b/test/bacnet/whohas/src/main.c index 4f2f62e1..cfe733d8 100644 --- a/test/bacnet/whohas/src/main.c +++ b/test/bacnet/whohas/src/main.c @@ -58,15 +58,17 @@ static void testWhoHasData(BACNET_WHO_HAS_DATA *data) /* Object ID */ if (data->is_object_name == false) { zassert_equal( - test_data.object.identifier.type, data->object.identifier.type, NULL); + test_data.object.identifier.type, data->object.identifier.type, + NULL); zassert_equal( test_data.object.identifier.instance, - data->object.identifier.instance, NULL); + data->object.identifier.instance, NULL); } /* Object Name */ else { zassert_true( - characterstring_same(&test_data.object.name, &data->object.name), NULL); + characterstring_same(&test_data.object.name, &data->object.name), + NULL); } } @@ -109,15 +111,12 @@ static void testWhoHas(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(whohas_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(whohas_tests, - ztest_unit_test(testWhoHas) - ); + ztest_test_suite(whohas_tests, ztest_unit_test(testWhoHas)); ztest_run_test_suite(whohas_tests); } diff --git a/test/bacnet/whois/src/main.c b/test/bacnet/whois/src/main.c index e9bcdd3f..8e4dc89c 100644 --- a/test/bacnet/whois/src/main.c +++ b/test/bacnet/whois/src/main.c @@ -107,15 +107,12 @@ static void testWhoIs(void) * @} */ - #if defined(CONFIG_ZTEST_NEW_API) ZTEST_SUITE(whois_tests, NULL, NULL, NULL, NULL, NULL); #else void test_main(void) { - ztest_test_suite(whois_tests, - ztest_unit_test(testWhoIs) - ); + ztest_test_suite(whois_tests, ztest_unit_test(testWhoIs)); ztest_run_test_suite(whois_tests); } diff --git a/test/bacnet/wp/src/main.c b/test/bacnet/wp/src/main.c index 6b955fc2..3de18bb1 100644 --- a/test/bacnet/wp/src/main.c +++ b/test/bacnet/wp/src/main.c @@ -20,7 +20,8 @@ * @brief Decode stub for WriteProperty service * @return number of bytes decoded, or #BACNET_STATUS_ERROR */ -static int wp_decode_apdu(uint8_t *apdu, +static int wp_decode_apdu( + uint8_t *apdu, unsigned apdu_size, uint8_t *invoke_id, BACNET_WRITE_PROPERTY_DATA *wpdata) @@ -48,8 +49,8 @@ static int wp_decode_apdu(uint8_t *apdu, len = 4; apdu_len += len; if (apdu_len < apdu_size) { - len = - wp_decode_service_request(&apdu[apdu_len], apdu_size - apdu_len, wpdata); + len = wp_decode_service_request( + &apdu[apdu_len], apdu_size - apdu_len, wpdata); if (len > 0) { apdu_len += len; } else { @@ -109,8 +110,9 @@ static void testWritePropertyTag(BACNET_APPLICATION_DATA_VALUE *value) len = wp_encode_apdu(&apdu[0], invoke_id, &wpdata); apdu_len = wp_decode_apdu(&apdu[0], len, &test_invoke_id, &test_data); apdu_len = len; - len = bacapp_decode_application_data(test_data.application_data, - test_data.application_data_len, &test_value); + len = bacapp_decode_application_data( + test_data.application_data, test_data.application_data_len, + &test_value); zassert_equal(test_value.tag, value->tag, NULL); status = write_property_type_valid(&wpdata, value, test_value.tag); zassert_equal(status, true, NULL); @@ -129,8 +131,8 @@ static void testWritePropertyTag(BACNET_APPLICATION_DATA_VALUE *value) test_value.type.Signed_Int, value->type.Signed_Int, NULL); break; case BACNET_APPLICATION_TAG_REAL: - zassert_false(islessgreater(test_value.type.Real, value->type.Real), - NULL); + zassert_false( + islessgreater(test_value.type.Real, value->type.Real), NULL); break; case BACNET_APPLICATION_TAG_ENUMERATED: zassert_equal( @@ -150,13 +152,16 @@ static void testWritePropertyTag(BACNET_APPLICATION_DATA_VALUE *value) test_value.type.Time.hour, value->type.Time.hour, NULL); zassert_equal(test_value.type.Time.min, value->type.Time.min, NULL); zassert_equal(test_value.type.Time.sec, value->type.Time.sec, NULL); - zassert_equal(test_value.type.Time.hundredths, - value->type.Time.hundredths, NULL); + zassert_equal( + test_value.type.Time.hundredths, value->type.Time.hundredths, + NULL); break; case BACNET_APPLICATION_TAG_OBJECT_ID: - zassert_equal(test_value.type.Object_Id.type, - value->type.Object_Id.type, NULL); - zassert_equal(test_value.type.Object_Id.instance, + zassert_equal( + test_value.type.Object_Id.type, value->type.Object_Id.type, + NULL); + zassert_equal( + test_value.type.Object_Id.instance, value->type.Object_Id.instance, NULL); break; default: diff --git a/test/bacnet/wpm/src/main.c b/test/bacnet/wpm/src/main.c index 5b76b2ad..bcb34c2e 100644 --- a/test/bacnet/wpm/src/main.c +++ b/test/bacnet/wpm/src/main.c @@ -127,7 +127,8 @@ static void testWritePropertyMultiple(void) &apdu[offset], apdu_len - offset, &wp_data); zassert_not_equal(len, 0, NULL); offset += len; - printf("WPM: type=%lu instance=%lu property=%lu " + printf( + "WPM: type=%lu instance=%lu property=%lu " "priority=%lu index=%ld\n", (unsigned long)wp_data.object_type, (unsigned long)wp_data.object_instance,