mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-07-06 22:10:34 +08:00
Improve unit tests for mbedtls_asn1_store_named_data
Every time we check found->val.p we should also check found->val.len. Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
2df7ab7c0c
commit
12df5f3a16
@ -550,6 +550,9 @@ void store_named_data_val_found(int old_len, int new_len)
|
||||
}
|
||||
if (new_len == 0) {
|
||||
TEST_ASSERT(found->val.p == NULL);
|
||||
/* If new_len != 0, then new_val != NULL and the length has been checked
|
||||
* above by TEST_MEMORY_COMPARE(). But not here, so we need to check. */
|
||||
TEST_EQUAL(found->val.len, 0);
|
||||
} else if (new_len == old_len) {
|
||||
TEST_ASSERT(found->val.p == old_val);
|
||||
} else {
|
||||
@ -583,8 +586,10 @@ void store_named_data_val_new(int new_len, int set_new_val)
|
||||
TEST_MEMORY_COMPARE(found->oid.p, found->oid.len, oid, oid_len);
|
||||
if (new_len == 0) {
|
||||
TEST_ASSERT(found->val.p == NULL);
|
||||
TEST_EQUAL(found->val.len, 0);
|
||||
} else if (new_val == NULL) {
|
||||
TEST_ASSERT(found->val.p != NULL);
|
||||
TEST_EQUAL(found->val.len, new_len);
|
||||
} else {
|
||||
TEST_ASSERT(found->val.p != new_val);
|
||||
TEST_MEMORY_COMPARE(found->val.p, found->val.len,
|
||||
|
Loading…
x
Reference in New Issue
Block a user