mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-28 07:51:19 +01:00
tests/nanocoap: build request that fills buffer
This commit is contained in:
parent
85a658634f
commit
715b79a1e7
@ -330,6 +330,29 @@ static void test_nanocoap__get_multi_query(void)
|
||||
TEST_ASSERT_EQUAL_STRING((char *)qs, &query[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Builds on get_req test, to test building a PDU that completely fills the
|
||||
* buffer.
|
||||
*/
|
||||
static void test_nanocoap__option_add_buffer_max(void)
|
||||
{
|
||||
uint8_t buf[70]; /* header 4, token 2, path 64 */
|
||||
coap_pkt_t pkt;
|
||||
uint16_t msgid = 0xABCD;
|
||||
uint8_t token[2] = {0xDA, 0xEC};
|
||||
char path[] = "/23456789012345678901234567890123456789012345678901234567890123";
|
||||
|
||||
size_t uri_opt_len = 64; /* option hdr 2, option value 62 */
|
||||
|
||||
size_t len = coap_build_hdr((coap_hdr_t *)&buf[0], COAP_TYPE_NON,
|
||||
&token[0], 2, COAP_METHOD_GET, msgid);
|
||||
|
||||
coap_pkt_init(&pkt, &buf[0], sizeof(buf), len);
|
||||
|
||||
len = coap_opt_add_string(&pkt, COAP_OPT_URI_PATH, &path[0], '/');
|
||||
TEST_ASSERT_EQUAL_INT(uri_opt_len, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper for server_get tests below.
|
||||
* GET Request for nanocoap server example /riot/value resource.
|
||||
@ -531,6 +554,7 @@ Test *tests_nanocoap_tests(void)
|
||||
new_TestFixture(test_nanocoap__get_path_too_long),
|
||||
new_TestFixture(test_nanocoap__get_query),
|
||||
new_TestFixture(test_nanocoap__get_multi_query),
|
||||
new_TestFixture(test_nanocoap__option_add_buffer_max),
|
||||
new_TestFixture(test_nanocoap__server_get_req),
|
||||
new_TestFixture(test_nanocoap__server_reply_simple),
|
||||
new_TestFixture(test_nanocoap__server_get_req_con),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user