From e7d6d57e5faae47196d9255f379a520076e57b77 Mon Sep 17 00:00:00 2001
From: Ken Bannister <kb2ma@runbox.com>
Date: Mon, 19 Dec 2016 12:57:20 -0500
Subject: [PATCH] gcoap: Define length of client token in test to parse
 response.

---
 tests/unittests/tests-gcoap/tests-gcoap.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/unittests/tests-gcoap/tests-gcoap.c b/tests/unittests/tests-gcoap/tests-gcoap.c
index 14444c1bf2..5f4e0015c0 100644
--- a/tests/unittests/tests-gcoap/tests-gcoap.c
+++ b/tests/unittests/tests-gcoap/tests-gcoap.c
@@ -64,13 +64,16 @@ static void test_gcoap__client_get_req(void)
 /*
  * Client GET response success case. Test parsing response.
  * Response for /time resource from libcoap example
+ * Includes 2-byte token
  */
 static void test_gcoap__client_get_resp(void)
 {
     uint8_t buf[GCOAP_PDU_BUF_SIZE];
     coap_pkt_t pdu;
     int res;
-    char exp_payload[] = "Oct 22 10:46:48";
+    size_t hdr_fixed_len = 4;
+    char exp_payload[]   = "Oct 22 10:46:48";
+    size_t exp_tokenlen  = 2;
 
     uint8_t pdu_data[] = {
         0x52, 0x45, 0xe6, 0x02, 0x9b, 0xce, 0xc0, 0x21,
@@ -84,8 +87,8 @@ static void test_gcoap__client_get_resp(void)
 
     TEST_ASSERT_EQUAL_INT(0, res);
     TEST_ASSERT_EQUAL_INT(COAP_CLASS_SUCCESS, coap_get_code_class(&pdu));
-    TEST_ASSERT_EQUAL_INT(GCOAP_TOKENLEN, coap_get_token_len(&pdu));
-    TEST_ASSERT_EQUAL_INT(4 + GCOAP_TOKENLEN, coap_get_total_hdr_len(&pdu));
+    TEST_ASSERT_EQUAL_INT(exp_tokenlen, coap_get_token_len(&pdu));
+    TEST_ASSERT_EQUAL_INT(hdr_fixed_len + exp_tokenlen, coap_get_total_hdr_len(&pdu));
     TEST_ASSERT_EQUAL_INT(COAP_TYPE_NON, coap_get_type(&pdu));
     TEST_ASSERT_EQUAL_INT(strlen(exp_payload), pdu.payload_len);
 
-- 
GitLab