Various TLV enhancements:
- New API function: tlv_append(); - Added unit tests for tlv_append(); - New internal functions: tlv_record_length(), tlv_next(), tlv_sequence_length(); - Rework tlv_decode() to use new internal functions.
This commit is contained in:
parent
efe5bbad9e
commit
335eef3e2f
3 changed files with 119 additions and 14 deletions
|
|
@ -130,3 +130,20 @@ test_tlv_rfu (void)
|
|||
|
||||
free (data);
|
||||
}
|
||||
|
||||
void
|
||||
test_tlv_append (void)
|
||||
{
|
||||
const uint8_t a[] = { 0xde, 0xad, 0xbe, 0xef };
|
||||
const uint8_t b[] = { 0x42 };
|
||||
|
||||
uint8_t ndef_ab_ref[] = { 0x03, 0x04, 0xde, 0xad, 0xbe, 0xef, 0x03, 0x01, 0x42, 0xfe };
|
||||
|
||||
uint8_t *ndef_a = tlv_encode (3, a, 4, NULL);
|
||||
uint8_t *ndef_b = tlv_encode (3, b, 1, NULL);
|
||||
ndef_a = tlv_append (ndef_a, ndef_b);
|
||||
cut_assert_equal_memory (ndef_ab_ref, sizeof (ndef_ab_ref), ndef_a, sizeof (ndef_ab_ref), cut_message ("Wrong appended data"));
|
||||
|
||||
free (ndef_a);
|
||||
free (ndef_b);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue