Fix decode_signed32(); Add unit/bacnet/bacint tests (#392)
Fix decode_signed32() length for -8388608 and NULL apdu handling.
Add comprehensive unit tests for bacint.c functionality.
Verified by:
1. (Pass) From $bacnet-stack/test:
make clean test
2. (Pass) From $workspace (above $bacnet-stack):
west build -p always -b unit_testing \
bacnet-stack/zephyr/tests/unit/bacnet/bacint/ && \
./build/testbinary
3. (Pass) From $workspace (above $bacnet-stack):
./zephyr/scripts/twister -p unit_testing \
-T bacnet-stack/zephyr/tests/unit/bacnet/bacint/
Signed-off-by: Gregory Shue <gregory.shue@legrand.com>
Co-authored-by: Gregory Shue <gregory.shue@legrand.com>
This commit is contained in:
+2
-2
@@ -424,7 +424,7 @@ int encode_signed32(uint8_t *apdu, int32_t value)
|
||||
|
||||
int decode_signed32(uint8_t *apdu, int32_t *value)
|
||||
{
|
||||
if (value) {
|
||||
if (apdu && value) {
|
||||
*value = ((int32_t)((((int32_t)apdu[0]) << 24) & 0xff000000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[1]) << 16) & 0x00ff0000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[2]) << 8) & 0x0000ff00));
|
||||
@@ -448,7 +448,7 @@ int bacnet_signed_length(int32_t value)
|
||||
len = 1;
|
||||
} else if ((value >= -32768) && (value < 32768)) {
|
||||
len = 2;
|
||||
} else if ((value > -8388608) && (value < 8388608)) {
|
||||
} else if ((value >= -8388608) && (value < 8388608)) {
|
||||
len = 3;
|
||||
} else {
|
||||
len = 4;
|
||||
|
||||
Reference in New Issue
Block a user