tests/zoap: Add test for payload size

Add a test for the available space for the payload, so the problem with
the payload length doesn't regresses.

Change-Id: Ifef541d8428947eb482729aa773a7e9ddd2b6f81
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This commit is contained in:
Vinicius Costa Gomes 2016-12-27 13:53:08 -08:00 committed by Tomasz Bursztyka
parent 909ad359bf
commit c538bb6602
1 changed files with 12 additions and 0 deletions

View File

@ -182,6 +182,18 @@ static int test_build_simple_pdu(void)
goto done;
}
if (buflen != (ZOAP_BUF_SIZE - 4 - strlen(token) - 2 - 1)) {
/*
* The remaining length will be the buffer size less
* 4: basic CoAP header
* strlen(token): token length
* 2: options (content-format)
* 1: payload marker (added by zoap_packet_get_payload())
*/
TC_PRINT("Invalid packet length\n");
goto done;
}
memcpy(appdata, payload, sizeof(payload));
r = zoap_packet_set_used(&pkt, sizeof(payload));