Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check There is newer version from clang-format so use that. We do not yet want 18 as that is little bit too new. * Format some thing by hand which clang-format "breaks" Clang-format will format some things little bit off in some cases. Format some things by hand so we get cleaner end result. * Run clang-format with ``` pre-commit run --all-files clang-format ``` We have already in previously checked places where clang-format does not make good format and ignored those (hopefully most of the things). --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -28,16 +28,19 @@ static int abort_decode_apdu(
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu_len > 0) {
|
||||
if ((apdu[0] & 0xF0) != PDU_TYPE_ABORT)
|
||||
if ((apdu[0] & 0xF0) != PDU_TYPE_ABORT) {
|
||||
return -1;
|
||||
if (apdu[0] & 1)
|
||||
}
|
||||
if (apdu[0] & 1) {
|
||||
*server = true;
|
||||
else
|
||||
} else {
|
||||
*server = false;
|
||||
}
|
||||
if (apdu_len > 1) {
|
||||
len = abort_decode_service_request(
|
||||
&apdu[1], apdu_len - 1, invoke_id, abort_reason);
|
||||
|
||||
@@ -45,8 +45,10 @@ static void testAlarmAck(void)
|
||||
data.eventStateAcked = EVENT_STATE_OFFNORMAL;
|
||||
memset(&test_data, 0, sizeof(test_data));
|
||||
|
||||
apdu_len = bacnet_acknowledge_alarm_info_request_encode(apdu, sizeof(apdu), &data);
|
||||
null_len = bacnet_acknowledge_alarm_info_request_encode(NULL, apdu_len, &data);
|
||||
apdu_len =
|
||||
bacnet_acknowledge_alarm_info_request_encode(apdu, sizeof(apdu), &data);
|
||||
null_len =
|
||||
bacnet_acknowledge_alarm_info_request_encode(NULL, apdu_len, &data);
|
||||
zassert_equal(null_len, apdu_len, NULL);
|
||||
test_len = alarm_ack_decode_service_request(apdu, apdu_len, &test_data);
|
||||
|
||||
@@ -93,8 +95,10 @@ static void testAlarmAck(void)
|
||||
status = bacapp_timestamp_init_ascii(&data.eventTimeStamp, "2021/12/31");
|
||||
zassert_true(status, NULL);
|
||||
zassert_equal(data.eventTimeStamp.tag, TIME_STAMP_DATETIME, NULL);
|
||||
apdu_len = bacnet_acknowledge_alarm_info_request_encode(apdu, sizeof(apdu), &data);
|
||||
null_len = bacnet_acknowledge_alarm_info_request_encode(NULL, apdu_len, &data);
|
||||
apdu_len =
|
||||
bacnet_acknowledge_alarm_info_request_encode(apdu, sizeof(apdu), &data);
|
||||
null_len =
|
||||
bacnet_acknowledge_alarm_info_request_encode(NULL, apdu_len, &data);
|
||||
zassert_equal(null_len, apdu_len, NULL);
|
||||
test_len = alarm_ack_decode_service_request(apdu, apdu_len, &test_data);
|
||||
zassert_equal(
|
||||
@@ -103,20 +107,25 @@ static void testAlarmAck(void)
|
||||
status = bacapp_timestamp_init_ascii(&data.eventTimeStamp, "1234");
|
||||
zassert_true(status, NULL);
|
||||
zassert_equal(data.eventTimeStamp.tag, TIME_STAMP_SEQUENCE, NULL);
|
||||
apdu_len = bacnet_acknowledge_alarm_info_request_encode(apdu, sizeof(apdu), &data);
|
||||
null_len = bacnet_acknowledge_alarm_info_request_encode(NULL, apdu_len, &data);
|
||||
apdu_len =
|
||||
bacnet_acknowledge_alarm_info_request_encode(apdu, sizeof(apdu), &data);
|
||||
null_len =
|
||||
bacnet_acknowledge_alarm_info_request_encode(NULL, apdu_len, &data);
|
||||
zassert_equal(null_len, apdu_len, NULL);
|
||||
test_len = alarm_ack_decode_service_request(apdu, apdu_len, &test_data);
|
||||
zassert_equal(
|
||||
apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len);
|
||||
while (--apdu_len) {
|
||||
test_len = bacnet_acknowledge_alarm_info_request_encode(apdu, apdu_len, &data);
|
||||
zassert_equal(test_len, 0, "apdu_len=%d test_len=%d", apdu_len, test_len);
|
||||
test_len =
|
||||
bacnet_acknowledge_alarm_info_request_encode(apdu, apdu_len, &data);
|
||||
zassert_equal(
|
||||
test_len, 0, "apdu_len=%d test_len=%d", apdu_len, test_len);
|
||||
}
|
||||
apdu_len = null_len;
|
||||
while (--apdu_len) {
|
||||
test_len = alarm_ack_decode_service_request(apdu, apdu_len, &data);
|
||||
zassert_true(test_len < 0, "apdu_len=%d test_len=%d", apdu_len, test_len);
|
||||
zassert_true(
|
||||
test_len < 0, "apdu_len=%d test_len=%d", apdu_len, test_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ static void testAtomicWriteFile(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static void testAtomicWriteFileAckAccess(
|
||||
const BACNET_ATOMIC_WRITE_FILE_DATA *data)
|
||||
static void
|
||||
testAtomicWriteFileAckAccess(const BACNET_ATOMIC_WRITE_FILE_DATA *data)
|
||||
{
|
||||
BACNET_ATOMIC_WRITE_FILE_DATA test_data = { 0 };
|
||||
uint8_t apdu[480] = { 0 };
|
||||
|
||||
@@ -1249,10 +1249,8 @@ static void test_bacapp_data(void)
|
||||
/* 1. test encoding matches for NULL and APDU buffer */
|
||||
BACNET_APPLICATION_TAG tag = tag_list[i];
|
||||
value.tag = tag;
|
||||
null_len =
|
||||
bacapp_encode_application_data(NULL, &value);
|
||||
apdu_len =
|
||||
bacapp_encode_application_data(apdu, &value);
|
||||
null_len = bacapp_encode_application_data(NULL, &value);
|
||||
apdu_len = bacapp_encode_application_data(apdu, &value);
|
||||
if (apdu_len != null_len) {
|
||||
printf(
|
||||
"bacapp: NULL len=%d != APDU len=%d for tag=%s", null_len,
|
||||
@@ -1264,8 +1262,7 @@ static void test_bacapp_data(void)
|
||||
test_len = 0;
|
||||
len = encode_opening_tag(apdu, 3);
|
||||
apdu_len += len;
|
||||
len = bacapp_encode_application_data(
|
||||
&apdu[apdu_len], &value);
|
||||
len = bacapp_encode_application_data(&apdu[apdu_len], &value);
|
||||
test_len += len;
|
||||
apdu_len += len;
|
||||
len = encode_closing_tag(&apdu[apdu_len], 3);
|
||||
|
||||
@@ -1230,10 +1230,8 @@ static void testBACDCodeBitString(void)
|
||||
null_len = encode_application_bitstring(NULL, &value);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
/* decode */
|
||||
len = bacnet_bitstring_application_decode(
|
||||
apdu, null_len, &test_value);
|
||||
zassert_equal(
|
||||
bitstring_bits_used(&test_value), (bit + 1), NULL);
|
||||
len = bacnet_bitstring_application_decode(apdu, null_len, &test_value);
|
||||
zassert_equal(bitstring_bits_used(&test_value), (bit + 1), NULL);
|
||||
zassert_true(bitstring_bit(&test_value, bit), NULL);
|
||||
len = bacnet_tag_decode(apdu, len, &tag);
|
||||
zassert_true(len > 0, NULL);
|
||||
@@ -1247,26 +1245,22 @@ static void testBACDCodeBitString(void)
|
||||
zassert_false(bitstring_bit(&value, bit), NULL);
|
||||
/* encode */
|
||||
len = bacnet_bitstring_application_encode(apdu, sizeof(apdu), &value);
|
||||
null_len = bacnet_bitstring_application_encode(NULL, sizeof(apdu), &value);
|
||||
null_len =
|
||||
bacnet_bitstring_application_encode(NULL, sizeof(apdu), &value);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
/* decode */
|
||||
len = bacnet_bitstring_application_decode(
|
||||
apdu, null_len, &test_value);
|
||||
len = bacnet_bitstring_application_decode(apdu, null_len, &test_value);
|
||||
len = bacnet_tag_decode(apdu, len, &tag);
|
||||
zassert_true(len > 0, NULL);
|
||||
zassert_equal(tag.number, BACNET_APPLICATION_TAG_BIT_STRING, NULL);
|
||||
zassert_equal(
|
||||
bitstring_bits_used(&test_value), (bit + 1), NULL);
|
||||
zassert_equal(bitstring_bits_used(&test_value), (bit + 1), NULL);
|
||||
zassert_false(bitstring_bit(&test_value, bit), NULL);
|
||||
}
|
||||
/* test APDU size limits */
|
||||
apdu_len =
|
||||
bacnet_bitstring_application_encode(apdu, sizeof(apdu), &value);
|
||||
null_len =
|
||||
bacnet_bitstring_application_encode(NULL, sizeof(apdu), &value);
|
||||
apdu_len = bacnet_bitstring_application_encode(apdu, sizeof(apdu), &value);
|
||||
null_len = bacnet_bitstring_application_encode(NULL, sizeof(apdu), &value);
|
||||
zassert_equal(apdu_len, null_len, NULL);
|
||||
test_len =
|
||||
bacnet_bitstring_application_decode(apdu, apdu_len, &test_value);
|
||||
test_len = bacnet_bitstring_application_decode(apdu, apdu_len, &test_value);
|
||||
zassert_equal(
|
||||
apdu_len, test_len, "test_len=%d apdu_len=%d", test_len, apdu_len);
|
||||
zassert_true(bitstring_same(&value, &test_value), NULL);
|
||||
@@ -1275,8 +1269,7 @@ static void testBACDCodeBitString(void)
|
||||
zassert_equal(len, BACNET_STATUS_ERROR, NULL);
|
||||
}
|
||||
while (--apdu_len) {
|
||||
len =
|
||||
bacnet_bitstring_application_encode(apdu, apdu_len, &value);
|
||||
len = bacnet_bitstring_application_encode(apdu, apdu_len, &value);
|
||||
zassert_equal(len, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ static void testBACnetDestination(void)
|
||||
zassert_equal(apdu_len, null_len, NULL);
|
||||
test_len = bacnet_destination_decode(apdu, apdu_len, &test_destination);
|
||||
zassert_equal(apdu_len, test_len, NULL);
|
||||
testBACnetRecipientData(&destination.Recipient,
|
||||
&test_destination.Recipient);
|
||||
testBACnetRecipientData(
|
||||
&destination.Recipient, &test_destination.Recipient);
|
||||
|
||||
destination.Recipient.tag = BACNET_RECIPIENT_TAG_ADDRESS;
|
||||
destination.Recipient.type.address.net = 1234;
|
||||
@@ -151,11 +151,12 @@ static void test_BACnetDestination_ASCII(void)
|
||||
if (null_len > 0) {
|
||||
test_ascii = calloc(null_len, 1);
|
||||
if (test_ascii) {
|
||||
test_len =
|
||||
bacnet_destination_to_ascii(&test_destination, test_ascii, null_len);
|
||||
test_len = bacnet_destination_to_ascii(
|
||||
&test_destination, test_ascii, null_len);
|
||||
zassert_equal(null_len, test_len, NULL);
|
||||
while (--test_len) {
|
||||
len = bacnet_destination_to_ascii(&test_destination, test_ascii, test_len);
|
||||
len = bacnet_destination_to_ascii(
|
||||
&test_destination, test_ascii, test_len);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
}
|
||||
free(test_ascii);
|
||||
|
||||
@@ -339,8 +339,9 @@ static void testBACnetSigned8(void)
|
||||
test_value = ~0U;
|
||||
len = decode_signed8(&apdu[0], &test_value);
|
||||
zassert_equal(value, test_value, NULL);
|
||||
if (value == 127)
|
||||
if (value == 127) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,8 +377,9 @@ static void testBACnetSigned16(void)
|
||||
test_value = ~0U;
|
||||
len = decode_signed16(&apdu[0], &test_value);
|
||||
zassert_equal(value, test_value, NULL);
|
||||
if (value == 32767)
|
||||
if (value == 32767) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ static void test_BACnetTimeValue(BACNET_TIME_VALUE *value)
|
||||
}
|
||||
|
||||
len = bacnet_time_value_context_encode(apdu, tag_number, value);
|
||||
null_len = bacnet_time_value_context_encode(NULL,tag_number, value);
|
||||
null_len = bacnet_time_value_context_encode(NULL, tag_number, value);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
apdu_len =
|
||||
bacnet_time_value_context_decode(apdu, len, tag_number, &test_value);
|
||||
@@ -67,7 +67,8 @@ static void test_BACnetTimeValue(BACNET_TIME_VALUE *value)
|
||||
zassert_true(status, NULL);
|
||||
/* apdu too short testing */
|
||||
while (--apdu_len) {
|
||||
len = bacnet_time_value_context_decode(apdu, apdu_len, tag_number, &test_value);
|
||||
len = bacnet_time_value_context_decode(
|
||||
apdu, apdu_len, tag_number, &test_value);
|
||||
zassert_true(len < 0, NULL);
|
||||
}
|
||||
/* negative testing */
|
||||
@@ -162,11 +163,11 @@ static void test_BACnetTimeValues(void)
|
||||
BACNET_APPLICATION_TAG_OBJECT_ID, "8:4194303", &value);
|
||||
zassert_true(status, NULL);
|
||||
rc = bacnet_application_to_primitive_data_value(&time_value.Value, &value);
|
||||
zassert_equal(rc, BACNET_STATUS_ERROR ,"rc=%d", rc);
|
||||
zassert_equal(rc, BACNET_STATUS_ERROR, "rc=%d", rc);
|
||||
rc = bacnet_application_to_primitive_data_value(NULL, &value);
|
||||
zassert_equal(rc, BACNET_STATUS_ERROR ,"rc=%d", rc);
|
||||
zassert_equal(rc, BACNET_STATUS_ERROR, "rc=%d", rc);
|
||||
rc = bacnet_application_to_primitive_data_value(&time_value.Value, NULL);
|
||||
zassert_equal(rc, BACNET_STATUS_ERROR ,"rc=%d", rc);
|
||||
zassert_equal(rc, BACNET_STATUS_ERROR, "rc=%d", rc);
|
||||
rc = bacnet_primitive_to_application_data_value(NULL, &time_value.Value);
|
||||
zassert_equal(rc, BACNET_STATUS_ERROR, NULL);
|
||||
rc = bacnet_primitive_to_application_data_value(&value, NULL);
|
||||
|
||||
@@ -41,9 +41,7 @@ static void testAnalogInput(void)
|
||||
Analog_Input_Read_Property, Analog_Input_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Analog_Input_Name_Set,
|
||||
Analog_Input_Name_ASCII);
|
||||
object_instance, Analog_Input_Name_Set, Analog_Input_Name_ASCII);
|
||||
status = Analog_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
@@ -41,9 +41,7 @@ static void testAnalogOutput(void)
|
||||
Analog_Output_Read_Property, Analog_Output_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Analog_Output_Name_Set,
|
||||
Analog_Output_Name_ASCII);
|
||||
object_instance, Analog_Output_Name_Set, Analog_Output_Name_ASCII);
|
||||
status = Analog_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
@@ -41,9 +41,7 @@ static void testAnalog_Value(void)
|
||||
Analog_Value_Read_Property, Analog_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Analog_Value_Name_Set,
|
||||
Analog_Value_Name_ASCII);
|
||||
object_instance, Analog_Value_Name_Set, Analog_Value_Name_ASCII);
|
||||
status = Analog_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
@@ -42,9 +42,7 @@ static void testBinaryInput(void)
|
||||
Binary_Input_Read_Property, Binary_Input_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Binary_Input_Name_Set,
|
||||
Binary_Input_Name_ASCII);
|
||||
object_instance, Binary_Input_Name_Set, Binary_Input_Name_ASCII);
|
||||
status = Binary_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ static void test_BitString_Value_Object(void)
|
||||
zassert_true(status, NULL);
|
||||
status = BitString_Value_Valid_Instance(instance);
|
||||
zassert_true(status, NULL);
|
||||
status = BitString_Value_Valid_Instance(instance+1);
|
||||
status = BitString_Value_Valid_Instance(instance + 1);
|
||||
zassert_false(status, NULL);
|
||||
test_count = BitString_Value_Count();
|
||||
zassert_equal(test_count, 1, NULL);
|
||||
@@ -53,9 +53,7 @@ static void test_BitString_Value_Object(void)
|
||||
BitString_Value_Read_Property, BitString_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
instance,
|
||||
BitString_Value_Name_Set,
|
||||
BitString_Value_Name_ASCII);
|
||||
instance, BitString_Value_Name_Set, BitString_Value_Name_ASCII);
|
||||
/* test specific WriteProperty values */
|
||||
BitString_Value_Write_Disable(instance);
|
||||
status = BitString_Value_Write_Enabled(instance);
|
||||
@@ -73,24 +71,24 @@ static void test_BitString_Value_Object(void)
|
||||
wpdata.object_property = PROP_PRESENT_VALUE;
|
||||
value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value.type.Bit_String);
|
||||
wpdata.application_data_len = bacapp_encode_application_data(
|
||||
wpdata.application_data, &value);
|
||||
wpdata.application_data_len =
|
||||
bacapp_encode_application_data(wpdata.application_data, &value);
|
||||
status = BitString_Value_Write_Property(&wpdata);
|
||||
zassert_true(status, NULL);
|
||||
/* WP to out-of-service */
|
||||
wpdata.object_property = PROP_OUT_OF_SERVICE;
|
||||
value.tag = BACNET_APPLICATION_TAG_BOOLEAN;
|
||||
value.type.Boolean = false;
|
||||
wpdata.application_data_len = bacapp_encode_application_data(
|
||||
wpdata.application_data, &value);
|
||||
wpdata.application_data_len =
|
||||
bacapp_encode_application_data(wpdata.application_data, &value);
|
||||
status = BitString_Value_Write_Property(&wpdata);
|
||||
zassert_true(status, NULL);
|
||||
/* WP to status-flags - read-only */
|
||||
wpdata.object_property = PROP_STATUS_FLAGS;
|
||||
value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value.type.Bit_String);
|
||||
wpdata.application_data_len = bacapp_encode_application_data(
|
||||
wpdata.application_data, &value);
|
||||
wpdata.application_data_len =
|
||||
bacapp_encode_application_data(wpdata.application_data, &value);
|
||||
status = BitString_Value_Write_Property(&wpdata);
|
||||
zassert_false(status, NULL);
|
||||
zassert_equal(wpdata.error_class, ERROR_CLASS_PROPERTY, NULL);
|
||||
@@ -99,8 +97,8 @@ static void test_BitString_Value_Object(void)
|
||||
wpdata.object_property = PROP_PRESENT_VALUE;
|
||||
value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
wpdata.array_index = 0;
|
||||
wpdata.application_data_len = bacapp_encode_application_data(
|
||||
wpdata.application_data, &value);
|
||||
wpdata.application_data_len =
|
||||
bacapp_encode_application_data(wpdata.application_data, &value);
|
||||
status = BitString_Value_Write_Property(&wpdata);
|
||||
zassert_false(status, NULL);
|
||||
zassert_equal(wpdata.error_class, ERROR_CLASS_PROPERTY, NULL);
|
||||
@@ -114,21 +112,21 @@ static void test_BitString_Value_Object(void)
|
||||
zassert_false(status, NULL);
|
||||
/* set same value */
|
||||
BitString_Value_Change_Of_Value_Clear(instance);
|
||||
status = BitString_Value_Present_Value_Set(instance,
|
||||
&value.type.Bit_String);
|
||||
status =
|
||||
BitString_Value_Present_Value_Set(instance, &value.type.Bit_String);
|
||||
zassert_true(status, NULL);
|
||||
status = BitString_Value_Change_Of_Value(instance);
|
||||
zassert_false(status, NULL);
|
||||
/* set different value */
|
||||
bitstring_set_bit(&value.type.Bit_String, 1, true);
|
||||
status = BitString_Value_Present_Value_Set(instance,
|
||||
&value.type.Bit_String);
|
||||
status =
|
||||
BitString_Value_Present_Value_Set(instance, &value.type.Bit_String);
|
||||
zassert_true(status, NULL);
|
||||
status = BitString_Value_Change_Of_Value(instance);
|
||||
zassert_true(status, NULL);
|
||||
/* COV */
|
||||
cov_property_value_list_link(value_list,
|
||||
sizeof(value_list)/sizeof(value_list[0]));
|
||||
cov_property_value_list_link(
|
||||
value_list, sizeof(value_list) / sizeof(value_list[0]));
|
||||
status = BitString_Value_Encode_Value_List(instance, value_list);
|
||||
zassert_true(status, NULL);
|
||||
/* delete */
|
||||
@@ -149,9 +147,9 @@ ZTEST_SUITE(bitstring_value_object_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bitstring_value_object_tests,
|
||||
ztest_unit_test(test_BitString_Value_Object)
|
||||
);
|
||||
ztest_test_suite(
|
||||
bitstring_value_object_tests,
|
||||
ztest_unit_test(test_BitString_Value_Object));
|
||||
|
||||
ztest_run_test_suite(bitstring_value_object_tests);
|
||||
}
|
||||
|
||||
@@ -41,9 +41,7 @@ static void testBinaryOutput(void)
|
||||
Binary_Output_Read_Property, Binary_Output_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Binary_Output_Name_Set,
|
||||
Binary_Output_Name_ASCII);
|
||||
object_instance, Binary_Output_Name_Set, Binary_Output_Name_ASCII);
|
||||
status = Binary_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
@@ -43,9 +43,7 @@ static void testBinary_Value(void)
|
||||
Binary_Value_Read_Property, Binary_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Binary_Value_Name_Set,
|
||||
Binary_Value_Name_ASCII);
|
||||
object_instance, Binary_Value_Name_Set, Binary_Value_Name_ASCII);
|
||||
status = Binary_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
@@ -230,16 +230,18 @@ 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;
|
||||
|
||||
value->type.WeekNDay.dayofweek = date.wday;
|
||||
zassert_true(Calendar_Present_Value(instance), NULL);
|
||||
value->type.WeekNDay.dayofweek++;
|
||||
if (value->type.WeekNDay.dayofweek > 7)
|
||||
if (value->type.WeekNDay.dayofweek > 7) {
|
||||
value->type.WeekNDay.dayofweek = 1;
|
||||
}
|
||||
zassert_false(Calendar_Present_Value(instance), NULL);
|
||||
|
||||
Calendar_Date_List_Delete_All(instance);
|
||||
|
||||
@@ -255,8 +255,7 @@ static bool Test_Present_Value_Priority_Set(float value, unsigned priority)
|
||||
* @param priority - priority-array index value 1..16
|
||||
* @return true if values are within range and present-value is relinquished.
|
||||
*/
|
||||
static bool Test_Present_Value_Priority_Relinquish(
|
||||
unsigned priority)
|
||||
static bool Test_Present_Value_Priority_Relinquish(unsigned priority)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -615,8 +614,8 @@ static void testLoadControlStateMachine(void)
|
||||
Load_Control_Present_Value(object_instance), BACNET_SHED_COMPLIANT,
|
||||
NULL);
|
||||
level = Test_Present_Value();
|
||||
zassert_true(islessgreater(100.0f, level),
|
||||
"Present Value = %f", (double)level);
|
||||
zassert_true(
|
||||
islessgreater(100.0f, level), "Present Value = %f", (double)level);
|
||||
priority = Test_Present_Value_Priority();
|
||||
zassert_equal(
|
||||
Load_Control_Priority_For_Writing(object_instance), priority, NULL);
|
||||
@@ -658,9 +657,7 @@ static void test_Load_Control_Read_Write_Property(void)
|
||||
Load_Control_Read_Property, Load_Control_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Load_Control_Name_Set,
|
||||
Load_Control_Name_ASCII);
|
||||
object_instance, Load_Control_Name_Set, Load_Control_Name_ASCII);
|
||||
test_teardown(object_instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ static void testLifeSafetyZone(void)
|
||||
zassert_equal(test_name, NULL, NULL);
|
||||
/* cleanup */
|
||||
status = Life_Safety_Zone_Delete(object_instance);
|
||||
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -42,8 +42,7 @@ static void testMultistateInput(void)
|
||||
Multistate_Input_Property_Lists, Multistate_Input_Read_Property,
|
||||
Multistate_Input_Write_Property, skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Multistate_Input_Name_Set,
|
||||
object_instance, Multistate_Input_Name_Set,
|
||||
Multistate_Input_Name_ASCII);
|
||||
status = Multistate_Input_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
|
||||
@@ -41,8 +41,7 @@ static void testMultistateOutput(void)
|
||||
Multistate_Output_Property_Lists, Multistate_Output_Read_Property,
|
||||
Multistate_Output_Write_Property, skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Multistate_Output_Name_Set,
|
||||
object_instance, Multistate_Output_Name_Set,
|
||||
Multistate_Output_Name_ASCII);
|
||||
status = Multistate_Output_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
|
||||
@@ -42,8 +42,7 @@ static void testMultistateValue(void)
|
||||
Multistate_Value_Property_Lists, Multistate_Value_Read_Property,
|
||||
Multistate_Value_Write_Property, skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Multistate_Value_Name_Set,
|
||||
object_instance, Multistate_Value_Name_Set,
|
||||
Multistate_Value_Name_ASCII);
|
||||
status = Multistate_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
|
||||
@@ -58,8 +58,7 @@ static void test_network_port(void)
|
||||
Network_Port_Read_Property, Network_Port_Write_Property,
|
||||
known_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Network_Port_Name_Set,
|
||||
object_instance, Network_Port_Name_Set,
|
||||
Network_Port_Object_Name_ASCII);
|
||||
port++;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,7 @@ static void testSchedule(void)
|
||||
{
|
||||
unsigned count = 0;
|
||||
uint32_t object_instance = 0;
|
||||
const int skip_fail_property_list[] = {
|
||||
-1
|
||||
};
|
||||
const int skip_fail_property_list[] = { -1 };
|
||||
|
||||
Schedule_Init();
|
||||
count = Schedule_Count();
|
||||
|
||||
@@ -41,9 +41,7 @@ static void test_object_structured_view(void)
|
||||
OBJECT_STRUCTURED_VIEW, instance, Structured_View_Property_Lists,
|
||||
Structured_View_Read_Property, NULL, skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
instance,
|
||||
Structured_View_Name_Set,
|
||||
Structured_View_Name_ASCII);
|
||||
instance, Structured_View_Name_Set, Structured_View_Name_ASCII);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -31,8 +31,7 @@ bool datetime_local(
|
||||
return true;
|
||||
}
|
||||
|
||||
void datetime_timesync(
|
||||
BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
|
||||
void datetime_timesync(BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
|
||||
{
|
||||
if (bdate) {
|
||||
datetime_copy_date(&BACnet_Date, bdate);
|
||||
|
||||
@@ -14,10 +14,9 @@
|
||||
#include <bacnet/wp.h>
|
||||
|
||||
/* function API pattern for testing ASCII name get/set */
|
||||
typedef bool (*object_name_ascii_set_function) (uint32_t object_instance,
|
||||
const char *new_name);
|
||||
typedef const char * (*object_name_ascii_function) (
|
||||
uint32_t object_instance);
|
||||
typedef bool (*object_name_ascii_set_function)(
|
||||
uint32_t object_instance, const char *new_name);
|
||||
typedef const char *(*object_name_ascii_function)(uint32_t object_instance);
|
||||
|
||||
void bacnet_object_name_ascii_test(
|
||||
uint32_t object_instance,
|
||||
|
||||
@@ -41,9 +41,7 @@ static void testTimeValue(void)
|
||||
Time_Value_Read_Property, Time_Value_Write_Property,
|
||||
skip_fail_property_list);
|
||||
bacnet_object_name_ascii_test(
|
||||
object_instance,
|
||||
Time_Value_Name_Set,
|
||||
Time_Value_Name_ASCII);
|
||||
object_instance, Time_Value_Name_Set, Time_Value_Name_ASCII);
|
||||
/* check the delete function */
|
||||
status = Time_Value_Delete(object_instance);
|
||||
zassert_true(status, NULL);
|
||||
|
||||
@@ -291,8 +291,9 @@ static void testKeyListLarge(void)
|
||||
const unsigned num_keys = 1024 * 16;
|
||||
|
||||
list = Keylist_Create();
|
||||
if (!list)
|
||||
if (!list) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (key = 0; key < num_keys; key++) {
|
||||
data_list[key] = 42 + key;
|
||||
|
||||
+25
-15
@@ -33,12 +33,14 @@ int ccov_notify_decode_apdu(
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
|
||||
return -2;
|
||||
}
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_COV_NOTIFICATION)
|
||||
if (apdu[3] != SERVICE_CONFIRMED_COV_NOTIFICATION) {
|
||||
return -3;
|
||||
}
|
||||
offset = 4;
|
||||
|
||||
/* optional limits - must be used as a pair */
|
||||
@@ -56,13 +58,16 @@ int ucov_notify_decode_apdu(
|
||||
int len = 0;
|
||||
unsigned offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST) {
|
||||
return -2;
|
||||
if (apdu[1] != SERVICE_UNCONFIRMED_COV_NOTIFICATION)
|
||||
}
|
||||
if (apdu[1] != SERVICE_UNCONFIRMED_COV_NOTIFICATION) {
|
||||
return -3;
|
||||
}
|
||||
/* optional limits - must be used as a pair */
|
||||
offset = 2;
|
||||
if (apdu_len > offset) {
|
||||
@@ -82,15 +87,18 @@ static int cov_subscribe_decode_apdu(
|
||||
int len = 0;
|
||||
unsigned offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
|
||||
return -2;
|
||||
}
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_SUBSCRIBE_COV)
|
||||
if (apdu[3] != SERVICE_CONFIRMED_SUBSCRIBE_COV) {
|
||||
return -3;
|
||||
}
|
||||
offset = 4;
|
||||
|
||||
/* optional limits - must be used as a pair */
|
||||
@@ -111,15 +119,18 @@ static int cov_subscribe_property_decode_apdu(
|
||||
int len = 0;
|
||||
unsigned offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
|
||||
return -2;
|
||||
}
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_SUBSCRIBE_COV_PROPERTY)
|
||||
if (apdu[3] != SERVICE_CONFIRMED_SUBSCRIBE_COV_PROPERTY) {
|
||||
return -3;
|
||||
}
|
||||
offset = 4;
|
||||
|
||||
/* optional limits - must be used as a pair */
|
||||
@@ -132,8 +143,8 @@ static int cov_subscribe_property_decode_apdu(
|
||||
}
|
||||
|
||||
/* dummy function stubs */
|
||||
static void testCOVNotifyData(
|
||||
const BACNET_COV_DATA *data, BACNET_COV_DATA *test_data)
|
||||
static void
|
||||
testCOVNotifyData(const BACNET_COV_DATA *data, BACNET_COV_DATA *test_data)
|
||||
{
|
||||
const BACNET_PROPERTY_VALUE *value = NULL;
|
||||
BACNET_PROPERTY_VALUE *test_value = NULL;
|
||||
@@ -295,8 +306,7 @@ static void testCOVSubscribePropertyData(
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
testCOVSubscribeEncoding(
|
||||
static void testCOVSubscribeEncoding(
|
||||
uint8_t invoke_id, const BACNET_SUBSCRIBE_COV_DATA *data)
|
||||
{
|
||||
uint8_t apdu[480] = { 0 };
|
||||
|
||||
@@ -365,8 +365,8 @@ static void test_BVLC_Delete_Foreign_Device(void)
|
||||
test_BVLC_Delete_Foreign_Device_Message(&fdt_entry);
|
||||
}
|
||||
|
||||
static void test_BVLC_Secure_BVLL_Message(
|
||||
const uint8_t *sbuf, uint16_t sbuf_len)
|
||||
static void
|
||||
test_BVLC_Secure_BVLL_Message(const uint8_t *sbuf, uint16_t sbuf_len)
|
||||
{
|
||||
uint8_t test_sbuf[50] = { 0 };
|
||||
uint8_t pdu[60] = { 0 };
|
||||
|
||||
@@ -96,7 +96,8 @@ bool bip6_set_broadcast_addr(const BACNET_IP6_ADDRESS *addr)
|
||||
return ztest_get_return_value();
|
||||
}
|
||||
|
||||
int bip6_send_mpdu(const BACNET_IP6_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
|
||||
int bip6_send_mpdu(
|
||||
const BACNET_IP6_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
|
||||
{
|
||||
ztest_check_expected_value(dest);
|
||||
ztest_check_expected_data(mtu, mtu_len);
|
||||
|
||||
@@ -1103,23 +1103,27 @@ static void testZeroConfigNodeFSM(void)
|
||||
station = 0;
|
||||
test_station = Nmin_poll_station;
|
||||
next_station = MSTP_Zero_Config_Station_Increment(station);
|
||||
zassert_equal(next_station, test_station, "station=%u next_station=%u",
|
||||
station, next_station);
|
||||
zassert_equal(
|
||||
next_station, test_station, "station=%u next_station=%u", station,
|
||||
next_station);
|
||||
station = Nmin_poll_station;
|
||||
test_station = Nmin_poll_station + 1;
|
||||
next_station = MSTP_Zero_Config_Station_Increment(station);
|
||||
zassert_equal(next_station, test_station, "station=%u next_station=%u",
|
||||
station, next_station);
|
||||
zassert_equal(
|
||||
next_station, test_station, "station=%u next_station=%u", station,
|
||||
next_station);
|
||||
station = Nmax_poll_station - 1;
|
||||
test_station = Nmax_poll_station;
|
||||
next_station = MSTP_Zero_Config_Station_Increment(station);
|
||||
zassert_equal(next_station, test_station,"station=%u next_station=%u",
|
||||
station, next_station);
|
||||
zassert_equal(
|
||||
next_station, test_station, "station=%u next_station=%u", station,
|
||||
next_station);
|
||||
station = Nmax_poll_station;
|
||||
test_station = Nmin_poll_station;
|
||||
next_station = MSTP_Zero_Config_Station_Increment(station);
|
||||
zassert_equal(next_station, test_station, "station=%u next_station=%u",
|
||||
station, next_station);
|
||||
zassert_equal(
|
||||
next_station, test_station, "station=%u next_station=%u", station,
|
||||
next_station);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,14 +67,17 @@ static int getevent_ack_decode_apdu(
|
||||
int len = 0;
|
||||
int offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_COMPLEX_ACK)
|
||||
if (apdu[0] != PDU_TYPE_COMPLEX_ACK) {
|
||||
return -1;
|
||||
}
|
||||
*invoke_id = apdu[1];
|
||||
if (apdu[2] != SERVICE_CONFIRMED_GET_EVENT_INFORMATION)
|
||||
if (apdu[2] != SERVICE_CONFIRMED_GET_EVENT_INFORMATION) {
|
||||
return -1;
|
||||
}
|
||||
offset = 3;
|
||||
if (apdu_len > offset) {
|
||||
len = getevent_ack_decode_service_request(
|
||||
|
||||
@@ -29,13 +29,16 @@ static int iam_decode_apdu(
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
/* valid data? */
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST) {
|
||||
return -1;
|
||||
if (apdu[1] != SERVICE_UNCONFIRMED_I_AM)
|
||||
}
|
||||
if (apdu[1] != SERVICE_UNCONFIRMED_I_AM) {
|
||||
return -1;
|
||||
}
|
||||
apdu_len = iam_decode_service_request(
|
||||
&apdu[2], pDevice_id, pMax_apdu, pSegmentation, pVendor_id);
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (c) 2022 Legrand North America, LLC.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
*
|
||||
* Copyright (c) 2022 Legrand North America, LLC.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
/* ztest mock file */
|
||||
|
||||
#ifndef BACPORT_H
|
||||
#define BACPORT_H
|
||||
|
||||
#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \
|
||||
_index_to_instance, _valid_instance, _object_name, \
|
||||
_read_property, _write_property, _RPM_list, \
|
||||
_RR_info, _iterator, _value_list, _COV, \
|
||||
_COV_clear, _intrinsic_reporting) \
|
||||
while{}(0)
|
||||
#define BACNET_OBJECT_TABLE( \
|
||||
table_name, _type, _init, _count, _index_to_instance, _valid_instance, \
|
||||
_object_name, _read_property, _write_property, _RPM_list, _RR_info, \
|
||||
_iterator, _value_list, _COV, _COV_clear, _intrinsic_reporting) \
|
||||
while { } \
|
||||
(0)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,16 +30,19 @@ static int ptransfer_decode_apdu(
|
||||
int len = 0;
|
||||
unsigned offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
|
||||
return -1;
|
||||
}
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
/* invoke id - filled in by net layer */
|
||||
*invoke_id = apdu[2];
|
||||
if (apdu[3] != SERVICE_CONFIRMED_PRIVATE_TRANSFER)
|
||||
if (apdu[3] != SERVICE_CONFIRMED_PRIVATE_TRANSFER) {
|
||||
return -1;
|
||||
}
|
||||
offset = 4;
|
||||
|
||||
if (apdu_len > offset) {
|
||||
@@ -86,14 +89,17 @@ static int ptransfer_ack_decode_apdu(
|
||||
int len = 0;
|
||||
int offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_COMPLEX_ACK)
|
||||
if (apdu[0] != PDU_TYPE_COMPLEX_ACK) {
|
||||
return -1;
|
||||
}
|
||||
*invoke_id = apdu[1];
|
||||
if (apdu[2] != SERVICE_CONFIRMED_PRIVATE_TRANSFER)
|
||||
if (apdu[2] != SERVICE_CONFIRMED_PRIVATE_TRANSFER) {
|
||||
return -1;
|
||||
}
|
||||
offset = 3;
|
||||
if (apdu_len > offset) {
|
||||
len = ptransfer_decode_service_request(
|
||||
@@ -114,14 +120,17 @@ static int ptransfer_error_decode_apdu(
|
||||
int len = 0;
|
||||
int offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_ERROR)
|
||||
if (apdu[0] != PDU_TYPE_ERROR) {
|
||||
return -1;
|
||||
}
|
||||
*invoke_id = apdu[1];
|
||||
if (apdu[2] != SERVICE_CONFIRMED_PRIVATE_TRANSFER)
|
||||
if (apdu[2] != SERVICE_CONFIRMED_PRIVATE_TRANSFER) {
|
||||
return -1;
|
||||
}
|
||||
offset = 3;
|
||||
if (apdu_len > offset) {
|
||||
len = ptransfer_error_decode_service_request(
|
||||
|
||||
@@ -28,12 +28,14 @@ static int reject_decode_apdu(
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu_len) {
|
||||
if (apdu[0] != PDU_TYPE_REJECT)
|
||||
if (apdu[0] != PDU_TYPE_REJECT) {
|
||||
return -1;
|
||||
}
|
||||
if (apdu_len > 1) {
|
||||
len = reject_decode_service_request(
|
||||
&apdu[1], apdu_len - 1, invoke_id, reject_reason);
|
||||
|
||||
+20
-10
@@ -28,20 +28,25 @@ static int rpm_ack_decode_apdu(
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_COMPLEX_ACK)
|
||||
if (apdu[0] != PDU_TYPE_COMPLEX_ACK) {
|
||||
return -1;
|
||||
}
|
||||
*invoke_id = apdu[1];
|
||||
if (apdu[2] != SERVICE_CONFIRMED_READ_PROP_MULTIPLE)
|
||||
if (apdu[2] != SERVICE_CONFIRMED_READ_PROP_MULTIPLE) {
|
||||
return -1;
|
||||
}
|
||||
offset = 3;
|
||||
if (apdu_len > offset) {
|
||||
if (service_request)
|
||||
if (service_request) {
|
||||
*service_request = &apdu[offset];
|
||||
if (service_request_len)
|
||||
}
|
||||
if (service_request_len) {
|
||||
*service_request_len = apdu_len - offset;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
@@ -56,22 +61,27 @@ static int rpm_decode_apdu(
|
||||
{
|
||||
unsigned offset = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
|
||||
return -1;
|
||||
}
|
||||
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
|
||||
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
|
||||
if (apdu[3] != SERVICE_CONFIRMED_READ_PROP_MULTIPLE)
|
||||
if (apdu[3] != SERVICE_CONFIRMED_READ_PROP_MULTIPLE) {
|
||||
return -1;
|
||||
}
|
||||
offset = 4;
|
||||
|
||||
if (apdu_len > offset) {
|
||||
if (service_request)
|
||||
if (service_request) {
|
||||
*service_request = &apdu[offset];
|
||||
if (service_request_len)
|
||||
}
|
||||
if (service_request_len) {
|
||||
*service_request_len = apdu_len - offset;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
|
||||
@@ -133,13 +133,16 @@ static int timesync_decode_apdu_service(
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST) {
|
||||
return -1;
|
||||
if (apdu[1] != service)
|
||||
}
|
||||
if (apdu[1] != service) {
|
||||
return -1;
|
||||
}
|
||||
/* optional limits - must be used as a pair */
|
||||
if (apdu_len > 2) {
|
||||
len = timesync_decode_service_request(
|
||||
@@ -171,8 +174,8 @@ int timesync_decode_apdu(
|
||||
my_time);
|
||||
}
|
||||
|
||||
static void testTimeSyncData(
|
||||
const BACNET_DATE *my_date, const BACNET_TIME *my_time)
|
||||
static void
|
||||
testTimeSyncData(const BACNET_DATE *my_date, const BACNET_TIME *my_time)
|
||||
{
|
||||
uint8_t apdu[480] = { 0 };
|
||||
int len = 0;
|
||||
|
||||
@@ -22,13 +22,16 @@ int whohas_decode_apdu(
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
if (!apdu)
|
||||
if (!apdu) {
|
||||
return -1;
|
||||
}
|
||||
/* optional checking - most likely was already done prior to this call */
|
||||
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST)
|
||||
if (apdu[0] != PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST) {
|
||||
return -1;
|
||||
if (apdu[1] != SERVICE_UNCONFIRMED_WHO_HAS)
|
||||
}
|
||||
if (apdu[1] != SERVICE_UNCONFIRMED_WHO_HAS) {
|
||||
return -1;
|
||||
}
|
||||
/* optional limits - must be used as a pair */
|
||||
if (apdu_size > 2) {
|
||||
len = whohas_decode_service_request(&apdu[2], apdu_size - 2, data);
|
||||
@@ -82,7 +85,7 @@ static void testWhoHasData(BACNET_WHO_HAS_DATA *data)
|
||||
/* test short APDU buffer */
|
||||
while (--apdu_len) {
|
||||
test_len = bacnet_who_has_service_request_encode(apdu, apdu_len, data);
|
||||
zassert_equal(test_len, 0 , NULL);
|
||||
zassert_equal(test_len, 0, NULL);
|
||||
}
|
||||
/* decoder bounds checking */
|
||||
apdu_len = bacnet_who_has_request_encode(apdu, data);
|
||||
@@ -93,7 +96,7 @@ static void testWhoHasData(BACNET_WHO_HAS_DATA *data)
|
||||
/* test short APDU buffer */
|
||||
while (--apdu_len) {
|
||||
test_len = whohas_decode_service_request(apdu, apdu_len, data);
|
||||
zassert_equal(test_len, BACNET_STATUS_ERROR , NULL);
|
||||
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
/**
|
||||
* @brief Decode service header for WritePropertyMultiple
|
||||
*/
|
||||
static int wpm_decode_apdu(
|
||||
const uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id)
|
||||
static int
|
||||
wpm_decode_apdu(const uint8_t *apdu, unsigned apdu_len, uint8_t *invoke_id)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
|
||||
@@ -86,7 +86,8 @@ DEFINE_FAKE_VALUE_FUNC(int, bacnet_signed_application_decode, uint8_t *, uint16_
|
||||
DEFINE_FAKE_VALUE_FUNC(int, bacnet_enumerated_decode, uint8_t *, uint16_t, uint32_t, uint32_t *);
|
||||
DEFINE_FAKE_VALUE_FUNC(int, bacnet_enumerated_context_decode, uint8_t *, uint16_t, uint8_t, uint32_t *);
|
||||
#endif
|
||||
DEFINE_FAKE_VALUE_FUNC(int, decode_enumerated, const uint8_t *, uint32_t, uint32_t *);
|
||||
DEFINE_FAKE_VALUE_FUNC(
|
||||
int, decode_enumerated, const uint8_t *, uint32_t, uint32_t *);
|
||||
#if 0
|
||||
DEFINE_FAKE_VALUE_FUNC(int, decode_context_enumerated, uint8_t *, uint8_t, uint32_t *);
|
||||
DEFINE_FAKE_VALUE_FUNC(int, encode_bacnet_enumerated, uint8_t *, uint32_t);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
CONTEXTTYPE *const contexts = CONTAINER_OF( \
|
||||
FUNCNAME##_fake.return_val_seq, CONTEXTTYPE, RESULTFIELD); \
|
||||
size_t const seq_idx = (FUNCNAME##_fake.return_val_seq_idx < \
|
||||
FUNCNAME##_fake.return_val_seq_len) \
|
||||
FUNCNAME##_fake.return_val_seq_len) \
|
||||
? FUNCNAME##_fake.return_val_seq_idx++ \
|
||||
: FUNCNAME##_fake.return_val_seq_idx - 1; \
|
||||
CONTEXTTYPE *const CONTEXTPTRNAME = &contexts[seq_idx]; \
|
||||
@@ -54,15 +54,16 @@ struct encode_application_enumerated_custom_fake_context {
|
||||
|
||||
/* Written to client by custom fake */
|
||||
const uint8_t *const encoded_enumerated;
|
||||
int const encoded_enumerated_len;
|
||||
const int encoded_enumerated_len;
|
||||
|
||||
int result;
|
||||
};
|
||||
|
||||
static int encode_application_enumerated_custom_fake(
|
||||
uint8_t *apdu, uint32_t enumerated)
|
||||
static int
|
||||
encode_application_enumerated_custom_fake(uint8_t *apdu, uint32_t enumerated)
|
||||
{
|
||||
RETURN_HANDLED_CONTEXT(encode_application_enumerated,
|
||||
RETURN_HANDLED_CONTEXT(
|
||||
encode_application_enumerated,
|
||||
struct encode_application_enumerated_custom_fake_context,
|
||||
result, /* return field name in _fake_context struct */
|
||||
context, /* Name of context ptr variable used below */
|
||||
@@ -70,7 +71,8 @@ static int encode_application_enumerated_custom_fake(
|
||||
if (context != NULL) {
|
||||
if (context->result == 0) {
|
||||
if (apdu != NULL) {
|
||||
memcpy(apdu, context->encoded_enumerated,
|
||||
memcpy(
|
||||
apdu, context->encoded_enumerated,
|
||||
context->encoded_enumerated_len);
|
||||
}
|
||||
}
|
||||
@@ -86,8 +88,8 @@ struct decode_tag_number_and_value_custom_fake_context {
|
||||
uint8_t *const apdu_expected;
|
||||
|
||||
/* Written to client by custom fake */
|
||||
uint8_t const tag_number;
|
||||
uint32_t const value;
|
||||
const uint8_t tag_number;
|
||||
const uint32_t value;
|
||||
|
||||
int result;
|
||||
};
|
||||
@@ -95,17 +97,20 @@ struct decode_tag_number_and_value_custom_fake_context {
|
||||
static int decode_tag_number_and_value_custom_fake(
|
||||
const uint8_t *apdu, uint8_t *tag_number, uint32_t *value)
|
||||
{
|
||||
RETURN_HANDLED_CONTEXT(decode_tag_number_and_value,
|
||||
RETURN_HANDLED_CONTEXT(
|
||||
decode_tag_number_and_value,
|
||||
struct decode_tag_number_and_value_custom_fake_context,
|
||||
result, /* return field name in _fake_context struct */
|
||||
context, /* Name of context ptr variable used below */
|
||||
{
|
||||
if (context != NULL) {
|
||||
if (context->result > 0) {
|
||||
if (tag_number != NULL)
|
||||
if (tag_number != NULL) {
|
||||
*tag_number = context->tag_number;
|
||||
if (value != NULL)
|
||||
}
|
||||
if (value != NULL) {
|
||||
*value = context->value;
|
||||
}
|
||||
}
|
||||
|
||||
return context->result;
|
||||
@@ -119,7 +124,7 @@ struct decode_enumerated_custom_fake_context {
|
||||
uint8_t *const apdu_expected;
|
||||
|
||||
/* Written to client by custom fake */
|
||||
uint32_t const value;
|
||||
const uint32_t value;
|
||||
|
||||
int result;
|
||||
};
|
||||
@@ -127,15 +132,16 @@ struct decode_enumerated_custom_fake_context {
|
||||
static int decode_enumerated_custom_fake(
|
||||
const uint8_t *apdu, uint32_t len_value, uint32_t *value)
|
||||
{
|
||||
RETURN_HANDLED_CONTEXT(decode_enumerated,
|
||||
struct decode_enumerated_custom_fake_context,
|
||||
RETURN_HANDLED_CONTEXT(
|
||||
decode_enumerated, struct decode_enumerated_custom_fake_context,
|
||||
result, /* return field name in _fake_context struct */
|
||||
context, /* Name of context ptr variable used below */
|
||||
{
|
||||
if (context != NULL) {
|
||||
if (context->result > 0) {
|
||||
if (value != NULL)
|
||||
if (value != NULL) {
|
||||
*value = context->value;
|
||||
}
|
||||
}
|
||||
|
||||
return context->result;
|
||||
@@ -276,7 +282,8 @@ static void test_bacerror_encode_apdu(void)
|
||||
for (int i = 0; i < ARRAY_SIZE(test_cases); ++i) {
|
||||
const struct test_case *const tc = &test_cases[i];
|
||||
|
||||
printk("Checking test_cases[%i]: %s\n", i,
|
||||
printk(
|
||||
"Checking test_cases[%i]: %s\n", i,
|
||||
(tc->description_oneliner != NULL) ? tc->description_oneliner : "");
|
||||
|
||||
/*
|
||||
@@ -296,7 +303,8 @@ static void test_bacerror_encode_apdu(void)
|
||||
*/
|
||||
encode_application_enumerated_fake.return_val =
|
||||
-E2BIG; /* for excessive calls */
|
||||
SET_RETURN_SEQ(encode_application_enumerated,
|
||||
SET_RETURN_SEQ(
|
||||
encode_application_enumerated,
|
||||
&tc->encode_application_enumerated_custom_fake_contexts[0].result,
|
||||
tc->encode_application_enumerated_custom_fake_contexts_len);
|
||||
encode_application_enumerated_fake.custom_fake =
|
||||
@@ -307,8 +315,9 @@ static void test_bacerror_encode_apdu(void)
|
||||
/*
|
||||
* Call code_under_test
|
||||
*/
|
||||
int result = bacerror_encode_apdu(tc->apdu, tc->invoke_id, tc->service,
|
||||
tc->error_class, tc->error_code);
|
||||
int result = bacerror_encode_apdu(
|
||||
tc->apdu, tc->invoke_id, tc->service, tc->error_class,
|
||||
tc->error_code);
|
||||
|
||||
/*
|
||||
* Verify expected behavior of code_under_test:
|
||||
@@ -332,15 +341,18 @@ static void test_bacerror_encode_apdu(void)
|
||||
? 0
|
||||
: tc->encode_application_enumerated_custom_fake_contexts_len - 1;
|
||||
|
||||
zassert_equal(encode_application_enumerated_fake.call_count,
|
||||
zassert_equal(
|
||||
encode_application_enumerated_fake.call_count,
|
||||
encode_application_enumerated_fake_call_count_expected, NULL);
|
||||
for (int j = 0;
|
||||
j < encode_application_enumerated_fake_call_count_expected; ++j) {
|
||||
zassert_equal(encode_application_enumerated_fake.arg0_history[j],
|
||||
zassert_equal(
|
||||
encode_application_enumerated_fake.arg0_history[j],
|
||||
tc->encode_application_enumerated_custom_fake_contexts[j]
|
||||
.apdu_expected,
|
||||
NULL);
|
||||
zassert_equal(encode_application_enumerated_fake.arg1_history[j],
|
||||
zassert_equal(
|
||||
encode_application_enumerated_fake.arg1_history[j],
|
||||
tc->encode_application_enumerated_custom_fake_contexts[j]
|
||||
.value_expected,
|
||||
NULL);
|
||||
@@ -469,7 +481,8 @@ static void test_bacerror_decode_error_class_and_code(void)
|
||||
|
||||
.expected_call_history =
|
||||
(void *[]) {
|
||||
bacnet_enumerated_application_decode, NULL, /* mark end of array */
|
||||
bacnet_enumerated_application_decode,
|
||||
NULL, /* mark end of array */
|
||||
},
|
||||
|
||||
.decode_tag_number_and_value_custom_fake_contexts_len = 2,
|
||||
@@ -983,7 +996,8 @@ static void test_bacerror_decode_error_class_and_code(void)
|
||||
for (int i = 0; i < ARRAY_SIZE(test_cases); ++i) {
|
||||
const struct test_case *const tc = &test_cases[i];
|
||||
|
||||
printk("Checking test_cases[%i]: %s\n", i,
|
||||
printk(
|
||||
"Checking test_cases[%i]: %s\n", i,
|
||||
(tc->description_oneliner != NULL) ? tc->description_oneliner : "");
|
||||
|
||||
/*
|
||||
@@ -1003,14 +1017,16 @@ static void test_bacerror_decode_error_class_and_code(void)
|
||||
*/
|
||||
decode_tag_number_and_value_fake.return_val =
|
||||
-E2BIG; /* for excessive calls */
|
||||
SET_RETURN_SEQ(decode_tag_number_and_value,
|
||||
SET_RETURN_SEQ(
|
||||
decode_tag_number_and_value,
|
||||
&tc->decode_tag_number_and_value_custom_fake_contexts[0].result,
|
||||
tc->decode_tag_number_and_value_custom_fake_contexts_len);
|
||||
decode_tag_number_and_value_fake.custom_fake =
|
||||
decode_tag_number_and_value_custom_fake;
|
||||
|
||||
decode_enumerated_fake.return_val = -E2BIG; /* for excessive calls */
|
||||
SET_RETURN_SEQ(decode_enumerated,
|
||||
SET_RETURN_SEQ(
|
||||
decode_enumerated,
|
||||
&tc->decode_enumerated_custom_fake_contexts[0].result,
|
||||
tc->decode_enumerated_custom_fake_contexts_len);
|
||||
decode_enumerated_fake.custom_fake = decode_enumerated_custom_fake;
|
||||
@@ -1064,11 +1080,13 @@ static void test_bacerror_decode_error_class_and_code(void)
|
||||
? 0
|
||||
: tc->decode_tag_number_and_value_custom_fake_contexts_len - 1;
|
||||
|
||||
zassert_equal(decode_tag_number_and_value_fake.call_count,
|
||||
zassert_equal(
|
||||
decode_tag_number_and_value_fake.call_count,
|
||||
decode_tag_number_and_value_fake_call_count_expected, NULL);
|
||||
for (int j = 0;
|
||||
j < decode_tag_number_and_value_fake_call_count_expected; ++j) {
|
||||
zassert_equal(decode_tag_number_and_value_fake.arg0_history[j],
|
||||
zassert_equal(
|
||||
decode_tag_number_and_value_fake.arg0_history[j],
|
||||
tc->decode_tag_number_and_value_custom_fake_contexts[j]
|
||||
.apdu_expected,
|
||||
NULL);
|
||||
@@ -1083,13 +1101,16 @@ static void test_bacerror_decode_error_class_and_code(void)
|
||||
? 0
|
||||
: tc->decode_enumerated_custom_fake_contexts_len - 1;
|
||||
|
||||
zassert_equal(decode_enumerated_fake.call_count,
|
||||
zassert_equal(
|
||||
decode_enumerated_fake.call_count,
|
||||
decode_enumerated_fake_call_count_expected, NULL);
|
||||
for (int j = 0; j < decode_enumerated_fake_call_count_expected; ++j) {
|
||||
zassert_equal(decode_enumerated_fake.arg0_history[j],
|
||||
zassert_equal(
|
||||
decode_enumerated_fake.arg0_history[j],
|
||||
tc->decode_enumerated_custom_fake_contexts[j].apdu_expected,
|
||||
NULL);
|
||||
zassert_equal(decode_enumerated_fake.arg1_history[j],
|
||||
zassert_equal(
|
||||
decode_enumerated_fake.arg1_history[j],
|
||||
tc->decode_tag_number_and_value_custom_fake_contexts[j].value,
|
||||
NULL);
|
||||
zassert_not_null(decode_enumerated_fake.arg2_history[j], NULL);
|
||||
@@ -1131,8 +1152,8 @@ ZTEST_SUITE(bacnet_error, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bacnet_bacerror,
|
||||
ztest_unit_test(test_bacerror_encode_apdu),
|
||||
ztest_test_suite(
|
||||
bacnet_bacerror, ztest_unit_test(test_bacerror_encode_apdu),
|
||||
ztest_unit_test(test_bacerror_decode_error_class_and_code));
|
||||
ztest_run_test_suite(bacnet_bacerror);
|
||||
}
|
||||
|
||||
+206
-214
@@ -48,8 +48,8 @@ static void test_unsigned16(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[3] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(2, encode_unsigned16(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(2, decode_unsigned16(&apdu[2], &value), NULL);
|
||||
@@ -57,8 +57,8 @@ static void test_unsigned16(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[3] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(2, encode_unsigned16(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(2, decode_unsigned16(&apdu[2], &value), NULL);
|
||||
@@ -67,8 +67,8 @@ static void test_unsigned16(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(2, encode_unsigned16(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(2, decode_unsigned16(&apdu[3], &value), NULL);
|
||||
@@ -76,8 +76,8 @@ static void test_unsigned16(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(2, encode_unsigned16(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(2, decode_unsigned16(&apdu[3], &value), NULL);
|
||||
@@ -122,9 +122,9 @@ static void test_unsigned24(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>16);
|
||||
test_apdu[3] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(3, encode_unsigned24(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(3, decode_unsigned24(&apdu[2], &value), NULL);
|
||||
@@ -132,9 +132,9 @@ static void test_unsigned24(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>16);
|
||||
test_apdu[3] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(3, encode_unsigned24(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(3, decode_unsigned24(&apdu[2], &value), NULL);
|
||||
@@ -143,9 +143,9 @@ static void test_unsigned24(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>16);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(3, encode_unsigned24(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(3, decode_unsigned24(&apdu[3], &value), NULL);
|
||||
@@ -153,9 +153,9 @@ static void test_unsigned24(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>16);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(3, encode_unsigned24(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(3, decode_unsigned24(&apdu[3], &value), NULL);
|
||||
@@ -200,10 +200,10 @@ static void test_unsigned32(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>24);
|
||||
test_apdu[3] = (uint8_t) (test_value >>16);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(4, encode_unsigned32(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(4, decode_unsigned32(&apdu[2], &value), NULL);
|
||||
@@ -211,10 +211,10 @@ static void test_unsigned32(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>24);
|
||||
test_apdu[3] = (uint8_t) (test_value >>16);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(4, encode_unsigned32(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(4, decode_unsigned32(&apdu[2], &value), NULL);
|
||||
@@ -223,10 +223,10 @@ static void test_unsigned32(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>24);
|
||||
test_apdu[4] = (uint8_t) (test_value >>16);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(4, encode_unsigned32(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(4, decode_unsigned32(&apdu[3], &value), NULL);
|
||||
@@ -234,10 +234,10 @@ static void test_unsigned32(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>24);
|
||||
test_apdu[4] = (uint8_t) (test_value >>16);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(4, encode_unsigned32(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(4, decode_unsigned32(&apdu[3], &value), NULL);
|
||||
@@ -283,11 +283,11 @@ static void test_unsigned40(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>32);
|
||||
test_apdu[3] = (uint8_t) (test_value >>24);
|
||||
test_apdu[4] = (uint8_t) (test_value >>16);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(5, encode_unsigned40(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(5, decode_unsigned40(&apdu[2], &value), NULL);
|
||||
@@ -295,11 +295,11 @@ static void test_unsigned40(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>32);
|
||||
test_apdu[3] = (uint8_t) (test_value >>24);
|
||||
test_apdu[4] = (uint8_t) (test_value >>16);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(5, encode_unsigned40(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(5, decode_unsigned40(&apdu[2], &value), NULL);
|
||||
@@ -308,11 +308,11 @@ static void test_unsigned40(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>32);
|
||||
test_apdu[4] = (uint8_t) (test_value >>24);
|
||||
test_apdu[5] = (uint8_t) (test_value >>16);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[7] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(5, encode_unsigned40(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(5, decode_unsigned40(&apdu[3], &value), NULL);
|
||||
@@ -320,11 +320,11 @@ static void test_unsigned40(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>32);
|
||||
test_apdu[4] = (uint8_t) (test_value >>24);
|
||||
test_apdu[5] = (uint8_t) (test_value >>16);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[7] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(5, encode_unsigned40(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(5, decode_unsigned40(&apdu[3], &value), NULL);
|
||||
@@ -377,12 +377,12 @@ static void test_unsigned48(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>40);
|
||||
test_apdu[3] = (uint8_t) (test_value >>32);
|
||||
test_apdu[4] = (uint8_t) (test_value >>24);
|
||||
test_apdu[5] = (uint8_t) (test_value >>16);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[7] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(6, encode_unsigned48(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(6, decode_unsigned48(&apdu[2], &value), NULL);
|
||||
@@ -390,12 +390,12 @@ static void test_unsigned48(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>40);
|
||||
test_apdu[3] = (uint8_t) (test_value >>32);
|
||||
test_apdu[4] = (uint8_t) (test_value >>24);
|
||||
test_apdu[5] = (uint8_t) (test_value >>16);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[7] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(6, encode_unsigned48(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(6, decode_unsigned48(&apdu[2], &value), NULL);
|
||||
@@ -404,12 +404,12 @@ static void test_unsigned48(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>40);
|
||||
test_apdu[4] = (uint8_t) (test_value >>32);
|
||||
test_apdu[5] = (uint8_t) (test_value >>24);
|
||||
test_apdu[6] = (uint8_t) (test_value >>16);
|
||||
test_apdu[7] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[8] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(6, encode_unsigned48(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(6, decode_unsigned48(&apdu[3], &value), NULL);
|
||||
@@ -417,12 +417,12 @@ static void test_unsigned48(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>40);
|
||||
test_apdu[4] = (uint8_t) (test_value >>32);
|
||||
test_apdu[5] = (uint8_t) (test_value >>24);
|
||||
test_apdu[6] = (uint8_t) (test_value >>16);
|
||||
test_apdu[7] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[8] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(6, encode_unsigned48(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(6, decode_unsigned48(&apdu[3], &value), NULL);
|
||||
@@ -475,13 +475,13 @@ static void test_unsigned56(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>48);
|
||||
test_apdu[3] = (uint8_t) (test_value >>40);
|
||||
test_apdu[4] = (uint8_t) (test_value >>32);
|
||||
test_apdu[5] = (uint8_t) (test_value >>24);
|
||||
test_apdu[6] = (uint8_t) (test_value >>16);
|
||||
test_apdu[7] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[8] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 48);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(7, encode_unsigned56(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(7, decode_unsigned56(&apdu[2], &value), NULL);
|
||||
@@ -489,13 +489,13 @@ static void test_unsigned56(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>48);
|
||||
test_apdu[3] = (uint8_t) (test_value >>40);
|
||||
test_apdu[4] = (uint8_t) (test_value >>32);
|
||||
test_apdu[5] = (uint8_t) (test_value >>24);
|
||||
test_apdu[6] = (uint8_t) (test_value >>16);
|
||||
test_apdu[7] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[8] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 48);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(7, encode_unsigned56(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(7, decode_unsigned56(&apdu[2], &value), NULL);
|
||||
@@ -504,13 +504,13 @@ static void test_unsigned56(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>48);
|
||||
test_apdu[4] = (uint8_t) (test_value >>40);
|
||||
test_apdu[5] = (uint8_t) (test_value >>32);
|
||||
test_apdu[6] = (uint8_t) (test_value >>24);
|
||||
test_apdu[7] = (uint8_t) (test_value >>16);
|
||||
test_apdu[8] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[9] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 48);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[9] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(7, encode_unsigned56(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(7, decode_unsigned56(&apdu[3], &value), NULL);
|
||||
@@ -518,13 +518,13 @@ static void test_unsigned56(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>48);
|
||||
test_apdu[4] = (uint8_t) (test_value >>40);
|
||||
test_apdu[5] = (uint8_t) (test_value >>32);
|
||||
test_apdu[6] = (uint8_t) (test_value >>24);
|
||||
test_apdu[7] = (uint8_t) (test_value >>16);
|
||||
test_apdu[8] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[9] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 48);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[9] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(7, encode_unsigned56(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(7, decode_unsigned56(&apdu[3], &value), NULL);
|
||||
@@ -577,14 +577,14 @@ static void test_unsigned64(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>56);
|
||||
test_apdu[3] = (uint8_t) (test_value >>48);
|
||||
test_apdu[4] = (uint8_t) (test_value >>40);
|
||||
test_apdu[5] = (uint8_t) (test_value >>32);
|
||||
test_apdu[6] = (uint8_t) (test_value >>24);
|
||||
test_apdu[7] = (uint8_t) (test_value >>16);
|
||||
test_apdu[8] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[9] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 56);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 48);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[9] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(8, encode_unsigned64(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(8, decode_unsigned64(&apdu[2], &value), NULL);
|
||||
@@ -592,14 +592,14 @@ static void test_unsigned64(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>56);
|
||||
test_apdu[3] = (uint8_t) (test_value >>48);
|
||||
test_apdu[4] = (uint8_t) (test_value >>40);
|
||||
test_apdu[5] = (uint8_t) (test_value >>32);
|
||||
test_apdu[6] = (uint8_t) (test_value >>24);
|
||||
test_apdu[7] = (uint8_t) (test_value >>16);
|
||||
test_apdu[8] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[9] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 56);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 48);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[9] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(8, encode_unsigned64(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(8, decode_unsigned64(&apdu[2], &value), NULL);
|
||||
@@ -608,14 +608,14 @@ static void test_unsigned64(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>56);
|
||||
test_apdu[4] = (uint8_t) (test_value >>48);
|
||||
test_apdu[5] = (uint8_t) (test_value >>40);
|
||||
test_apdu[6] = (uint8_t) (test_value >>32);
|
||||
test_apdu[7] = (uint8_t) (test_value >>24);
|
||||
test_apdu[8] = (uint8_t) (test_value >>16);
|
||||
test_apdu[9] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[10] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 56);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 48);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[9] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[10] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(8, encode_unsigned64(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(8, decode_unsigned64(&apdu[3], &value), NULL);
|
||||
@@ -623,14 +623,14 @@ static void test_unsigned64(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>56);
|
||||
test_apdu[4] = (uint8_t) (test_value >>48);
|
||||
test_apdu[5] = (uint8_t) (test_value >>40);
|
||||
test_apdu[6] = (uint8_t) (test_value >>32);
|
||||
test_apdu[7] = (uint8_t) (test_value >>24);
|
||||
test_apdu[8] = (uint8_t) (test_value >>16);
|
||||
test_apdu[9] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[10] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 56);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 48);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 40);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 32);
|
||||
test_apdu[7] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[8] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[9] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[10] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(8, encode_unsigned64(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(8, decode_unsigned64(&apdu[3], &value), NULL);
|
||||
@@ -659,35 +659,35 @@ static void test_unsigned_length(void)
|
||||
zassert_equal(2, bacnet_unsigned_length(0xFFUL << 8), NULL);
|
||||
zassert_equal(2, bacnet_unsigned_length(0xFFFFUL), NULL);
|
||||
|
||||
zassert_equal(3, bacnet_unsigned_length(1UL <<16), NULL);
|
||||
zassert_equal(3, bacnet_unsigned_length(0x7DUL <<16), NULL);
|
||||
zassert_equal(3, bacnet_unsigned_length(0xFFUL <<16), NULL);
|
||||
zassert_equal(3, bacnet_unsigned_length(1UL << 16), NULL);
|
||||
zassert_equal(3, bacnet_unsigned_length(0x7DUL << 16), NULL);
|
||||
zassert_equal(3, bacnet_unsigned_length(0xFFUL << 16), NULL);
|
||||
zassert_equal(3, bacnet_unsigned_length(0xFFFFFFUL), NULL);
|
||||
|
||||
zassert_equal(4, bacnet_unsigned_length(1UL <<24), NULL);
|
||||
zassert_equal(4, bacnet_unsigned_length(0x7DUL <<24), NULL);
|
||||
zassert_equal(4, bacnet_unsigned_length(0xFFUL <<24), NULL);
|
||||
zassert_equal(4, bacnet_unsigned_length(1UL << 24), NULL);
|
||||
zassert_equal(4, bacnet_unsigned_length(0x7DUL << 24), NULL);
|
||||
zassert_equal(4, bacnet_unsigned_length(0xFFUL << 24), NULL);
|
||||
zassert_equal(4, bacnet_unsigned_length(0xFFFFFFFFUL), NULL);
|
||||
|
||||
#ifdef UINT64_MAX
|
||||
zassert_equal(5, bacnet_unsigned_length(1ULL <<32), NULL);
|
||||
zassert_equal(5, bacnet_unsigned_length(0x7DULL <<32), NULL);
|
||||
zassert_equal(5, bacnet_unsigned_length(0xFFULL <<32), NULL);
|
||||
zassert_equal(5, bacnet_unsigned_length(1ULL << 32), NULL);
|
||||
zassert_equal(5, bacnet_unsigned_length(0x7DULL << 32), NULL);
|
||||
zassert_equal(5, bacnet_unsigned_length(0xFFULL << 32), NULL);
|
||||
zassert_equal(5, bacnet_unsigned_length(0xFFFFFFFFFFULL), NULL);
|
||||
|
||||
zassert_equal(6, bacnet_unsigned_length(1ULL <<40), NULL);
|
||||
zassert_equal(6, bacnet_unsigned_length(0x7DULL <<40), NULL);
|
||||
zassert_equal(6, bacnet_unsigned_length(0xFFULL <<40), NULL);
|
||||
zassert_equal(6, bacnet_unsigned_length(1ULL << 40), NULL);
|
||||
zassert_equal(6, bacnet_unsigned_length(0x7DULL << 40), NULL);
|
||||
zassert_equal(6, bacnet_unsigned_length(0xFFULL << 40), NULL);
|
||||
zassert_equal(6, bacnet_unsigned_length(0xFFFFFFFFFFFFULL), NULL);
|
||||
|
||||
zassert_equal(7, bacnet_unsigned_length(1ULL <<48), NULL);
|
||||
zassert_equal(7, bacnet_unsigned_length(0x7DULL <<48), NULL);
|
||||
zassert_equal(7, bacnet_unsigned_length(0xFFULL <<48), NULL);
|
||||
zassert_equal(7, bacnet_unsigned_length(1ULL << 48), NULL);
|
||||
zassert_equal(7, bacnet_unsigned_length(0x7DULL << 48), NULL);
|
||||
zassert_equal(7, bacnet_unsigned_length(0xFFULL << 48), NULL);
|
||||
zassert_equal(7, bacnet_unsigned_length(0xFFFFFFFFFFFFFFULL), NULL);
|
||||
|
||||
zassert_equal(8, bacnet_unsigned_length(1ULL <<56), NULL);
|
||||
zassert_equal(8, bacnet_unsigned_length(0x7DULL <<56), NULL);
|
||||
zassert_equal(8, bacnet_unsigned_length(0xFFULL <<56), NULL);
|
||||
zassert_equal(8, bacnet_unsigned_length(1ULL << 56), NULL);
|
||||
zassert_equal(8, bacnet_unsigned_length(0x7DULL << 56), NULL);
|
||||
zassert_equal(8, bacnet_unsigned_length(0xFFULL << 56), NULL);
|
||||
zassert_equal(8, bacnet_unsigned_length(0xFFFFFFFFFFFFFFFFULL), NULL);
|
||||
#endif
|
||||
}
|
||||
@@ -731,7 +731,7 @@ static void test_signed8(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(1, encode_signed8(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(1, decode_signed8(&apdu[2], &value), NULL);
|
||||
@@ -739,7 +739,7 @@ static void test_signed8(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(1, encode_signed8(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(1, decode_signed8(&apdu[2], &value), NULL);
|
||||
@@ -748,7 +748,7 @@ static void test_signed8(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(1, encode_signed8(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(1, decode_signed8(&apdu[3], &value), NULL);
|
||||
@@ -756,7 +756,7 @@ static void test_signed8(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(1, encode_signed8(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(1, decode_signed8(&apdu[3], &value), NULL);
|
||||
@@ -809,8 +809,8 @@ static void test_signed16(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[3] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(2, encode_signed16(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(2, decode_signed16(&apdu[2], &value), NULL);
|
||||
@@ -818,8 +818,8 @@ static void test_signed16(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[3] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(2, encode_signed16(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(2, decode_signed16(&apdu[2], &value), NULL);
|
||||
@@ -828,8 +828,8 @@ static void test_signed16(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(2, encode_signed16(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(2, decode_signed16(&apdu[3], &value), NULL);
|
||||
@@ -837,8 +837,8 @@ static void test_signed16(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(2, encode_signed16(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(2, decode_signed16(&apdu[3], &value), NULL);
|
||||
@@ -887,9 +887,9 @@ static void test_signed24(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>16);
|
||||
test_apdu[3] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(3, encode_signed24(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(3, decode_signed24(&apdu[2], &value), NULL);
|
||||
@@ -897,9 +897,9 @@ static void test_signed24(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>16);
|
||||
test_apdu[3] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(3, encode_signed24(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(3, decode_signed24(&apdu[2], &value), NULL);
|
||||
@@ -908,9 +908,9 @@ static void test_signed24(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>16);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(3, encode_signed24(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(3, decode_signed24(&apdu[3], &value), NULL);
|
||||
@@ -918,9 +918,9 @@ static void test_signed24(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>16);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(3, encode_signed24(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(3, decode_signed24(&apdu[3], &value), NULL);
|
||||
@@ -969,10 +969,10 @@ static void test_signed32(void)
|
||||
/* Verify aligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>24);
|
||||
test_apdu[3] = (uint8_t) (test_value >>16);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(4, encode_signed32(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(4, decode_signed32(&apdu[2], &value), NULL);
|
||||
@@ -980,10 +980,10 @@ static void test_signed32(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[2] = (uint8_t) (test_value >>24);
|
||||
test_apdu[3] = (uint8_t) (test_value >>16);
|
||||
test_apdu[4] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[2] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(4, encode_signed32(&apdu[2], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(4, decode_signed32(&apdu[2], &value), NULL);
|
||||
@@ -992,10 +992,10 @@ static void test_signed32(void)
|
||||
/* Verify unaligned access with no extra bytes written */
|
||||
memset(test_apdu, ~0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>24);
|
||||
test_apdu[4] = (uint8_t) (test_value >>16);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(4, encode_signed32(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(4, decode_signed32(&apdu[3], &value), NULL);
|
||||
@@ -1003,10 +1003,10 @@ static void test_signed32(void)
|
||||
|
||||
memset(test_apdu, 0U, sizeof(test_apdu));
|
||||
memcpy(apdu, test_apdu, sizeof(test_apdu));
|
||||
test_apdu[3] = (uint8_t) (test_value >>24);
|
||||
test_apdu[4] = (uint8_t) (test_value >>16);
|
||||
test_apdu[5] = (uint8_t) (test_value >> 8);
|
||||
test_apdu[6] = (uint8_t) (test_value >> 0);
|
||||
test_apdu[3] = (uint8_t)(test_value >> 24);
|
||||
test_apdu[4] = (uint8_t)(test_value >> 16);
|
||||
test_apdu[5] = (uint8_t)(test_value >> 8);
|
||||
test_apdu[6] = (uint8_t)(test_value >> 0);
|
||||
zassert_equal(4, encode_signed32(&apdu[3], test_value), NULL);
|
||||
zassert_mem_equal(test_apdu, apdu, sizeof(test_apdu), NULL);
|
||||
zassert_equal(4, decode_signed32(&apdu[3], &value), NULL);
|
||||
@@ -1051,27 +1051,19 @@ static void test_signed_length(void)
|
||||
#endif /* BACNET_USE_SIGNED */
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_ZTEST_NEW_API
|
||||
ZTEST_SUITE(bacnet_bacint, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bacnet_bacint,
|
||||
ztest_unit_test(test_unsigned16),
|
||||
ztest_unit_test(test_unsigned24),
|
||||
ztest_unit_test(test_unsigned32),
|
||||
ztest_unit_test(test_unsigned40),
|
||||
ztest_unit_test(test_unsigned48),
|
||||
ztest_unit_test(test_unsigned56),
|
||||
ztest_unit_test(test_unsigned64),
|
||||
ztest_unit_test(test_unsigned_length),
|
||||
ztest_unit_test(test_signed8),
|
||||
ztest_unit_test(test_signed16),
|
||||
ztest_unit_test(test_signed24),
|
||||
ztest_unit_test(test_signed32),
|
||||
ztest_unit_test(test_signed_length)
|
||||
);
|
||||
ztest_test_suite(
|
||||
bacnet_bacint, ztest_unit_test(test_unsigned16),
|
||||
ztest_unit_test(test_unsigned24), ztest_unit_test(test_unsigned32),
|
||||
ztest_unit_test(test_unsigned40), ztest_unit_test(test_unsigned48),
|
||||
ztest_unit_test(test_unsigned56), ztest_unit_test(test_unsigned64),
|
||||
ztest_unit_test(test_unsigned_length), ztest_unit_test(test_signed8),
|
||||
ztest_unit_test(test_signed16), ztest_unit_test(test_signed24),
|
||||
ztest_unit_test(test_signed32), ztest_unit_test(test_signed_length));
|
||||
ztest_run_test_suite(bacnet_bacint);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
#undef BIT
|
||||
@@ -20,7 +19,6 @@
|
||||
|
||||
#include "bacnet/basic/sys/bits.h"
|
||||
|
||||
|
||||
/* NOTE: These tests must be compatible with C90, so they do not
|
||||
* verify support for ULL.
|
||||
*/
|
||||
@@ -34,7 +32,7 @@ static void test_BIT(void)
|
||||
unsigned int bitpos = sizeof(unsigned int) * 8;
|
||||
|
||||
do {
|
||||
bitpos -= 1;
|
||||
bitpos -= 1;
|
||||
zassert_true(BIT(bitpos) == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -48,7 +46,7 @@ static void test__BV(void)
|
||||
unsigned int bitpos = sizeof(unsigned int) * 8;
|
||||
|
||||
do {
|
||||
bitpos -= 1;
|
||||
bitpos -= 1;
|
||||
zassert_true(BIT(bitpos) == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -63,8 +61,8 @@ static void test_BIT_SET(void)
|
||||
|
||||
do {
|
||||
unsigned int a = 0U;
|
||||
bitpos -= 1;
|
||||
BIT_SET(a, bitpos);
|
||||
bitpos -= 1;
|
||||
BIT_SET(a, bitpos);
|
||||
zassert_true(a == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -79,8 +77,8 @@ static void test_BIT_CLEAR(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
BIT_CLEAR(a, bitpos);
|
||||
bitpos -= 1;
|
||||
BIT_CLEAR(a, bitpos);
|
||||
zassert_true(~(a) == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -95,16 +93,16 @@ static void test_BIT_FLIP(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
BIT_FLIP(a, bitpos);
|
||||
bitpos -= 1;
|
||||
BIT_FLIP(a, bitpos);
|
||||
zassert_true(a == ~(1U << bitpos), NULL);
|
||||
BIT_FLIP(a, bitpos);
|
||||
BIT_FLIP(a, bitpos);
|
||||
zassert_true(a == ~0U, NULL);
|
||||
|
||||
a = 0U;
|
||||
BIT_FLIP(a, bitpos);
|
||||
a = 0U;
|
||||
BIT_FLIP(a, bitpos);
|
||||
zassert_true(a == (1U << bitpos), NULL);
|
||||
BIT_FLIP(a, bitpos);
|
||||
BIT_FLIP(a, bitpos);
|
||||
zassert_true(a == 0U, NULL);
|
||||
|
||||
} while (bitpos > 0);
|
||||
@@ -120,11 +118,11 @@ static void test_BIT_CHECK(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
zassert_true(BIT_CHECK(a, bitpos), NULL);
|
||||
bitpos -= 1;
|
||||
zassert_true(BIT_CHECK(a, bitpos), NULL);
|
||||
|
||||
a = 0U;
|
||||
zassert_false(BIT_CHECK(a, bitpos), NULL);
|
||||
a = 0U;
|
||||
zassert_false(BIT_CHECK(a, bitpos), NULL);
|
||||
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -139,8 +137,8 @@ static void test_BITMASK_SET(void)
|
||||
|
||||
do {
|
||||
unsigned int a = 0U;
|
||||
bitpos -= 1;
|
||||
BITMASK_SET(a, (1U << bitpos));
|
||||
bitpos -= 1;
|
||||
BITMASK_SET(a, (1U << bitpos));
|
||||
zassert_true(a == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -155,8 +153,8 @@ static void test_BITMASK_CLEAR(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
BITMASK_CLEAR(a, (1U << bitpos));
|
||||
bitpos -= 1;
|
||||
BITMASK_CLEAR(a, (1U << bitpos));
|
||||
zassert_true(~(a) == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -171,16 +169,16 @@ static void test_BITMASK_FLIP(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
bitpos -= 1;
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
zassert_true(a == ~(1U << bitpos), NULL);
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
zassert_true(a == ~0U, NULL);
|
||||
|
||||
a = 0U;
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
a = 0U;
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
zassert_true(a == (1U << bitpos), NULL);
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
zassert_true(a == 0U, NULL);
|
||||
|
||||
} while (bitpos > 0);
|
||||
@@ -196,11 +194,11 @@ static void test_BITMASK_CHECK(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
zassert_true(BITMASK_CHECK(a, (1U << bitpos)), NULL);
|
||||
bitpos -= 1;
|
||||
zassert_true(BITMASK_CHECK(a, (1U << bitpos)), NULL);
|
||||
|
||||
a = 0U;
|
||||
zassert_false(BITMASK_CHECK(a, (1U << bitpos)), NULL);
|
||||
a = 0U;
|
||||
zassert_false(BITMASK_CHECK(a, (1U << bitpos)), NULL);
|
||||
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -210,18 +208,13 @@ ZTEST_SUITE(bacnet_bits, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bacnet_bits,
|
||||
ztest_unit_test(test_BIT),
|
||||
ztest_unit_test(test__BV),
|
||||
ztest_unit_test(test_BIT_SET),
|
||||
ztest_unit_test(test_BIT_CLEAR),
|
||||
ztest_unit_test(test_BIT_FLIP),
|
||||
ztest_unit_test(test_BIT_CHECK),
|
||||
ztest_unit_test(test_BITMASK_SET),
|
||||
ztest_unit_test(test_BITMASK_CLEAR),
|
||||
ztest_unit_test(test_BITMASK_FLIP),
|
||||
ztest_unit_test(test_BITMASK_CHECK)
|
||||
);
|
||||
ztest_test_suite(
|
||||
bacnet_bits, ztest_unit_test(test_BIT), ztest_unit_test(test__BV),
|
||||
ztest_unit_test(test_BIT_SET), ztest_unit_test(test_BIT_CLEAR),
|
||||
ztest_unit_test(test_BIT_FLIP), ztest_unit_test(test_BIT_CHECK),
|
||||
ztest_unit_test(test_BITMASK_SET), ztest_unit_test(test_BITMASK_CLEAR),
|
||||
ztest_unit_test(test_BITMASK_FLIP),
|
||||
ztest_unit_test(test_BITMASK_CHECK));
|
||||
ztest_run_test_suite(bacnet_bits);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user