mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 14:33:52 +01:00
cbor: compare asserted lengths in unit test
In `test_array`, `test_array` and `test_map` the variable `offset` was written to but not read. The accumulated value should equal the total length of the input. This diff adds this check and fixes the warning in turn. Found via scan-build.
This commit is contained in:
parent
79ac710ee5
commit
11ce199c41
@ -351,6 +351,7 @@ static void test_array(void)
|
||||
TEST_ASSERT_EQUAL_INT(1, i);
|
||||
offset += cbor_deserialize_int(&stream, offset, &i);
|
||||
TEST_ASSERT_EQUAL_INT(2, i);
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(data), offset);
|
||||
}
|
||||
|
||||
cbor_clear(&stream);
|
||||
@ -374,6 +375,7 @@ static void test_array(void)
|
||||
char buffer[1024];
|
||||
offset += cbor_deserialize_byte_string(&stream, offset, buffer, sizeof(buffer));
|
||||
TEST_ASSERT_EQUAL_STRING("a", &(buffer[0]));
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(data), offset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,6 +444,7 @@ static void test_map(void)
|
||||
TEST_ASSERT_EQUAL_INT(2, key);
|
||||
offset += cbor_deserialize_byte_string(&stream, offset, value, sizeof(value));
|
||||
TEST_ASSERT_EQUAL_STRING("2", &(value[0]));
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(data), offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user