mirror of
https://github.com/obgm/libcoap.git
synced 2026-12-01 18:37:10 +03:00
test_options.c: unit test for extended delta
PR #65 reports wrong encoding of option value 269. The new unit test t_encode_option9() tests for correct encoding according to [RFC 7252, Section 3.1](https://tools.ietf.org/html/rfc7252#section-3.1).
This commit is contained in:
1 parent
fa52486030
commit
d7763a295a
1 file changed
+13
@@ -337,6 +337,18 @@ t_encode_option8(void) {
|
||||
CU_ASSERT(result == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
t_encode_option9(void) {
|
||||
uint8_t teststr[] = { 0xe1, 0x00, 0x00 };
|
||||
unsigned char buf[40] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
size_t result;
|
||||
|
||||
result = coap_opt_setheader((coap_opt_t *)buf, sizeof(buf), 269, 1);
|
||||
CU_ASSERT(result == sizeof(teststr));
|
||||
|
||||
CU_ASSERT(memcmp(buf, teststr, result) == 0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
** accessor tests
|
||||
************************************************************************/
|
||||
@@ -929,6 +941,7 @@ t_init_option_tests(void) {
|
||||
OPTION_ENCODER_TEST(6, "encode option #6");
|
||||
OPTION_ENCODER_TEST(7, "encode option #7");
|
||||
OPTION_ENCODER_TEST(8, "encode option #8");
|
||||
OPTION_ENCODER_TEST(9, "encode option #9");
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "W: cannot add option encoder test suite (%s)\n",
|
||||
|
||||
Reference in new issue
Block a user