3 * Copyright (C) 2012 Olaf Bergmann <bergmann@tzi.org>
5 * This file is part of the CoAP library libcoap. Please see
6 * README for terms of use.
16 coap_pdu_t *pdu; /* Holds the parsed PDU for most tests */
18 /************************************************************************
20 ************************************************************************/
22 void t_parse_pdu1(void)
25 { 0x40, 0x01, 0x93, 0x34 };
28 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
29 CU_ASSERT(result > 0);
31 CU_ASSERT(pdu->length == sizeof(teststr));
32 CU_ASSERT(pdu->hdr->version == 1);
33 CU_ASSERT(pdu->hdr->type == COAP_MESSAGE_CON);
34 CU_ASSERT(pdu->hdr->token_length == 0);
35 CU_ASSERT(pdu->hdr->code == COAP_REQUEST_GET);
36 CU_ASSERT(memcmp(&pdu->hdr->id, teststr + 2, 2) == 0);
37 CU_ASSERT_PTR_NULL(pdu->data);
40 void t_parse_pdu2(void)
43 { 0x55, 0x69, 0x12, 0x34, 't', 'o', 'k', 'e', 'n' };
46 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
47 CU_ASSERT(result > 0);
49 CU_ASSERT(pdu->length == sizeof(teststr));
50 CU_ASSERT(pdu->hdr->version == 1);
51 CU_ASSERT(pdu->hdr->type == COAP_MESSAGE_NON);
52 CU_ASSERT(pdu->hdr->token_length == 5);
53 CU_ASSERT(pdu->hdr->code == 0x69);
54 CU_ASSERT(memcmp(&pdu->hdr->id, teststr + 2, 2) == 0);
55 CU_ASSERT(memcmp(pdu->hdr->token, teststr + 4, 5) == 0);
56 CU_ASSERT_PTR_NULL(pdu->data);
59 void t_parse_pdu3(void)
62 { 0x53, 0x69, 0x12, 0x34, 't', 'o', 'k', 'e', 'n' };
65 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
66 CU_ASSERT(result == 0);
69 void t_parse_pdu4(void)
71 /* illegal token length */
73 { 0x59, 0x69, 0x12, 0x34, 't', 'o', 'k', 'e', 'n', '1', '2', '3', '4' };
76 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
77 CU_ASSERT(result == 0);
81 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
82 CU_ASSERT(result == 0);
85 void t_parse_pdu5(void)
87 /* PDU with options */
89 { 0x55, 0x73, 0x12, 0x34, 't', 'o', 'k', 'e', 'n', 0x00, 0xc1, 0x00 };
92 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
93 CU_ASSERT(result > 0);
95 CU_ASSERT(pdu->length == sizeof(teststr));
96 CU_ASSERT(pdu->hdr->version == 1);
97 CU_ASSERT(pdu->hdr->type == COAP_MESSAGE_NON);
98 CU_ASSERT(pdu->hdr->token_length == 5);
99 CU_ASSERT(pdu->hdr->code == 0x73);
100 CU_ASSERT(memcmp(&pdu->hdr->id, teststr + 2, 2) == 0);
101 CU_ASSERT(memcmp(pdu->hdr->token, teststr + 4, 5) == 0);
102 CU_ASSERT_PTR_NULL(pdu->data);
104 /* FIXME: check options */
107 void t_parse_pdu6(void)
109 /* PDU with options that exceed the PDU */
111 { 0x55, 0x73, 0x12, 0x34, 't', 'o', 'k', 'e', 'n', 0x00, 0xc1, 0x00, 0xae, 0xf0, 0x03 };
114 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
115 CU_ASSERT(result == 0);
118 void t_parse_pdu7(void)
120 /* PDU with options and payload */
122 { 0x55, 0x73, 0x12, 0x34, 't', 'o', 'k', 'e', 'n', 0x00, 0xc1, 0x00, 0xff, 'p', 'a', 'y', 'l',
126 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
127 CU_ASSERT(result > 0);
129 CU_ASSERT(pdu->length == sizeof(teststr));
130 CU_ASSERT(pdu->hdr->version == 1);
131 CU_ASSERT(pdu->hdr->type == COAP_MESSAGE_NON);
132 CU_ASSERT(pdu->hdr->token_length == 5);
133 CU_ASSERT(pdu->hdr->code == 0x73);
134 CU_ASSERT(memcmp(&pdu->hdr->id, teststr + 2, 2) == 0);
135 CU_ASSERT(memcmp(pdu->hdr->token, teststr + 4, 5) == 0);
137 /* FIXME: check options */
139 CU_ASSERT(pdu->data == (unsigned char *) pdu->hdr + 13);
140 CU_ASSERT(memcmp(pdu->data, teststr + 13, 7) == 0);
143 void t_parse_pdu8(void)
145 /* PDU without options but with payload */
147 { 0x50, 0x73, 0x12, 0x34, 0xff, 'p', 'a', 'y', 'l', 'o', 'a', 'd' };
150 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
151 CU_ASSERT(result > 0);
153 CU_ASSERT(pdu->length == sizeof(teststr));
154 CU_ASSERT(pdu->hdr->version == 1);
155 CU_ASSERT(pdu->hdr->type == COAP_MESSAGE_NON);
156 CU_ASSERT(pdu->hdr->token_length == 0);
157 CU_ASSERT(pdu->hdr->code == 0x73);
158 CU_ASSERT(memcmp(&pdu->hdr->id, teststr + 2, 2) == 0);
160 /* FIXME: check options */
162 CU_ASSERT(pdu->data == (unsigned char *) pdu->hdr + 5);
163 CU_ASSERT(memcmp(pdu->data, teststr + 5, 7) == 0);
166 void t_parse_pdu9(void)
168 /* PDU without options and payload but with payload start marker */
170 { 0x70, 0x00, 0x12, 0x34, 0xff };
173 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
174 CU_ASSERT(result == 0);
177 void t_parse_pdu10(void)
179 /* PDU without payload but with options and payload start marker */
181 { 0x53, 0x73, 0x12, 0x34, 't', 'o', 'k', 0x30, 0xc1, 0x00, 0xff };
184 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
185 CU_ASSERT(result == 0);
188 void t_parse_pdu11(void)
191 { 0x60, 0x00, 0x12, 0x34 };
194 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
195 CU_ASSERT(result > 0);
197 CU_ASSERT(pdu->length == sizeof(teststr));
198 CU_ASSERT(pdu->hdr->version == 1);
199 CU_ASSERT(pdu->hdr->type == COAP_MESSAGE_ACK);
200 CU_ASSERT(pdu->hdr->token_length == 0);
201 CU_ASSERT(pdu->hdr->code == 0);
202 CU_ASSERT(memcmp(&pdu->hdr->id, teststr + 2, 2) == 0);
205 void t_parse_pdu12(void)
209 { 0x70, 0x00, 0x12, 0x34 };
212 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
213 CU_ASSERT(result > 0);
215 CU_ASSERT(pdu->length == sizeof(teststr));
216 CU_ASSERT(pdu->hdr->version == 1);
217 CU_ASSERT(pdu->hdr->type == COAP_MESSAGE_RST);
218 CU_ASSERT(pdu->hdr->token_length == 0);
219 CU_ASSERT(pdu->hdr->code == 0);
220 CU_ASSERT(memcmp(&pdu->hdr->id, teststr + 2, 2) == 0);
223 void t_parse_pdu13(void)
225 /* RST with content */
227 { 0x70, 0x00, 0x12, 0x34, 0xff, 'c', 'o', 'n', 't', 'e', 'n', 't' };
230 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
231 CU_ASSERT(result == 0);
234 void t_parse_pdu14(void)
236 /* ACK with content */
238 { 0x60, 0x00, 0x12, 0x34, 0xff, 'c', 'o', 'n', 't', 'e', 'n', 't' };
241 result = coap_pdu_parse((unsigned char *) teststr, sizeof(teststr), pdu);
242 CU_ASSERT(result == 0);
245 /************************************************************************
247 ************************************************************************/
249 void t_encode_pdu1(void)
252 { 0x45, 0x01, 0x12, 0x34, 't', 'o', 'k', 'e', 'n' };
255 coap_pdu_clear(pdu, pdu->max_size);
256 pdu->hdr->type = COAP_MESSAGE_CON;
257 pdu->hdr->code = COAP_REQUEST_GET;
258 pdu->hdr->id = htons(0x1234);
260 result = coap_add_token(pdu, 5, (unsigned char *) "token");
262 CU_ASSERT(result == 1);
263 CU_ASSERT(pdu->length = sizeof(teststr));
264 CU_ASSERT_PTR_NULL(pdu->data);
265 CU_ASSERT(memcmp(pdu->hdr, teststr, sizeof(teststr)) == 0);
268 void t_encode_pdu2(void)
270 size_t old_max = pdu->max_size;
273 coap_pdu_clear(pdu, 7); /* set very small PDU size */
275 pdu->hdr->type = COAP_MESSAGE_CON;
276 pdu->hdr->code = COAP_REQUEST_GET;
277 pdu->hdr->id = htons(0x1234);
279 result = coap_add_token(pdu, 5, (unsigned char *) "token");
281 CU_ASSERT(result == 0);
283 coap_pdu_clear(pdu, old_max); /* restore PDU size */
286 void t_encode_pdu3(void)
290 result = coap_add_token(pdu, 9, (unsigned char *) "123456789");
292 CU_ASSERT(result == 0);
295 void t_encode_pdu4(void)
297 /* PDU with options */
299 { 0x60, 0x99, 0x12, 0x34, 0x3d, 0x05, 0x66, 0x61, 0x6e, 0x63, 0x79, 0x70, 0x72, 0x6f, 0x78,
300 0x79, 0x2e, 0x63, 0x6f, 0x61, 0x70, 0x2e, 0x6d, 0x65, 0x84, 0x70, 0x61, 0x74, 0x68,
301 0x00, 0xe8, 0x1e, 0x28, 0x66, 0x61, 0x6e, 0x63, 0x79, 0x6f, 0x70, 0x74 };
304 coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */
306 pdu->hdr->type = COAP_MESSAGE_ACK;
307 pdu->hdr->code = 0x99;
308 pdu->hdr->id = htons(0x1234);
310 CU_ASSERT(pdu->length == 4);
312 result = coap_add_option(pdu, COAP_OPTION_URI_HOST, 18, (unsigned char *) "fancyproxy.coap.me");
314 CU_ASSERT(result == 20);
315 CU_ASSERT(pdu->max_delta == 3);
316 CU_ASSERT(pdu->length == 24);
317 CU_ASSERT_PTR_NULL(pdu->data);
319 result = coap_add_option(pdu, COAP_OPTION_URI_PATH, 4, (unsigned char *) "path");
321 CU_ASSERT(result == 5);
322 CU_ASSERT(pdu->max_delta == 11);
323 CU_ASSERT(pdu->length == 29);
324 CU_ASSERT_PTR_NULL(pdu->data);
326 result = coap_add_option(pdu, COAP_OPTION_URI_PATH, 0, NULL);
328 CU_ASSERT(result == 1);
329 CU_ASSERT(pdu->max_delta == 11);
330 CU_ASSERT(pdu->length == 30);
331 CU_ASSERT_PTR_NULL(pdu->data);
333 result = coap_add_option(pdu, 8000, 8, (unsigned char *) "fancyopt");
335 CU_ASSERT(result == 11);
336 CU_ASSERT(pdu->max_delta == 8000);
337 CU_ASSERT(pdu->length == 41);
338 CU_ASSERT_PTR_NULL(pdu->data);
340 CU_ASSERT(pdu->length == sizeof(teststr));
341 CU_ASSERT(memcmp(pdu->hdr, teststr, sizeof(teststr)) == 0);
344 void t_encode_pdu5(void)
346 /* PDU with token and options */
348 { 0x68, 0x84, 0x12, 0x34, '1', '2', '3', '4', '5', '6', '7', '8', 0x18, 0x41, 0x42, 0x43, 0x44,
349 0x45, 0x46, 0x47, 0x48, 0xd1, 0x03, 0x12 };
352 coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */
354 pdu->hdr->type = COAP_MESSAGE_ACK;
355 pdu->hdr->code = COAP_RESPONSE_CODE(404);
356 pdu->hdr->id = htons(0x1234);
358 CU_ASSERT(pdu->length == 4);
360 result = coap_add_token(pdu, 8, (unsigned char *) "12345678");
362 CU_ASSERT(pdu->length == 12);
364 result = coap_add_option(pdu, COAP_OPTION_IF_MATCH, 8, (unsigned char *) "ABCDEFGH");
366 CU_ASSERT(result == 9);
367 CU_ASSERT(pdu->max_delta == 1);
368 CU_ASSERT(pdu->length == 21);
369 CU_ASSERT_PTR_NULL(pdu->data);
371 result = coap_add_option(pdu, COAP_OPTION_ACCEPT, 1, (unsigned char *) "\x12");
373 CU_ASSERT(result == 3);
374 CU_ASSERT(pdu->max_delta == 17);
375 CU_ASSERT(pdu->length == 24);
376 CU_ASSERT_PTR_NULL(pdu->data);
378 CU_ASSERT(pdu->length == sizeof(teststr));
379 CU_ASSERT(memcmp(pdu->hdr, teststr, sizeof(teststr)) == 0);
382 void t_encode_pdu6(void)
386 { 0x50, 0x02, 0x12, 0x34, 0xff, '1', '2', '3', '4', '5', '6', '7', '8' };
387 coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */
389 pdu->hdr->type = COAP_MESSAGE_NON;
390 pdu->hdr->code = COAP_REQUEST_POST;
391 pdu->hdr->id = htons(0x1234);
393 CU_ASSERT(pdu->length == 4);
394 CU_ASSERT_PTR_NULL(pdu->data);
396 coap_add_data(pdu, 8, (unsigned char *) "12345678");
398 CU_ASSERT(pdu->length == sizeof(teststr));
399 CU_ASSERT(memcmp(pdu->hdr, teststr, sizeof(teststr)) == 0);
402 void t_encode_pdu7(void)
404 /* PDU with empty data */
406 { 0x40, 0x43, 0x12, 0x34 };
408 coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */
410 pdu->hdr->type = COAP_MESSAGE_CON;
411 pdu->hdr->code = COAP_RESPONSE_CODE(203);
412 pdu->hdr->id = htons(0x1234);
414 CU_ASSERT(pdu->length == 4);
416 result = coap_add_data(pdu, 0, NULL);
418 CU_ASSERT(result > 0);
419 CU_ASSERT(pdu->length == 4);
420 CU_ASSERT_PTR_NULL(pdu->data);
422 CU_ASSERT(pdu->length == sizeof(teststr));
423 CU_ASSERT(memcmp(pdu->hdr, teststr, sizeof(teststr)) == 0);
426 void t_encode_pdu8(void)
428 /* PDU with token and data */
430 { 0x42, 0x43, 0x12, 0x34, 0x00, 0x01, 0xff, 0x00 };
432 coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */
434 pdu->hdr->type = COAP_MESSAGE_CON;
435 pdu->hdr->code = COAP_RESPONSE_CODE(203);
436 pdu->hdr->id = htons(0x1234);
438 CU_ASSERT(pdu->length == 4);
440 result = coap_add_token(pdu, 2, (unsigned char *) "\x00\x01");
442 CU_ASSERT(result > 0);
444 result = coap_add_data(pdu, 1, (unsigned char *) "\0");
446 CU_ASSERT(result > 0);
447 CU_ASSERT(pdu->length == 8);
448 CU_ASSERT(pdu->data == (unsigned char *) pdu->hdr + 7);
450 CU_ASSERT(pdu->length == sizeof(teststr));
451 CU_ASSERT(memcmp(pdu->hdr, teststr, sizeof(teststr)) == 0);
454 void t_encode_pdu9(void)
456 /* PDU with options and data */
458 { 0x60, 0x44, 0x12, 0x34, 0x48, 's', 'o', 'm', 'e', 'e', 't', 'a', 'g', 0x10, 0xdd, 0x11, 0x04,
459 's', 'o', 'm', 'e', 'r', 'a', 't', 'h', 'e', 'r', 'l', 'o', 'n', 'g', 'u', 'r', 'i',
460 0xff, 'd', 'a', 't', 'a' };
463 coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */
465 pdu->hdr->type = COAP_MESSAGE_ACK;
466 pdu->hdr->code = COAP_RESPONSE_CODE(204);
467 pdu->hdr->id = htons(0x1234);
469 CU_ASSERT(pdu->length == 4);
471 result = coap_add_option(pdu, COAP_OPTION_ETAG, 8, (unsigned char *) "someetag");
473 CU_ASSERT(result == 9);
474 CU_ASSERT(pdu->max_delta == 4);
475 CU_ASSERT(pdu->length == 13);
476 CU_ASSERT_PTR_NULL(pdu->data);
478 result = coap_add_option(pdu, COAP_OPTION_IF_NONE_MATCH, 0, NULL);
480 CU_ASSERT(result == 1);
481 CU_ASSERT(pdu->max_delta == 5);
482 CU_ASSERT(pdu->length == 14);
483 CU_ASSERT_PTR_NULL(pdu->data);
485 result = coap_add_option(pdu, COAP_OPTION_PROXY_URI, 17, (unsigned char *) "someratherlonguri");
487 CU_ASSERT(result == 20);
488 CU_ASSERT(pdu->max_delta == 35);
489 CU_ASSERT(pdu->length == 34);
490 CU_ASSERT_PTR_NULL(pdu->data);
492 result = coap_add_data(pdu, 4, (unsigned char *) "data");
494 CU_ASSERT(result > 0);
495 CU_ASSERT(pdu->length == 39);
496 CU_ASSERT(pdu->data == (unsigned char *) pdu->hdr + 35);
498 CU_ASSERT(pdu->length == sizeof(teststr));
499 CU_ASSERT(memcmp(pdu->hdr, teststr, sizeof(teststr)) == 0);
502 void t_encode_pdu10(void)
504 /* PDU with token, options and data */
506 { 0x62, 0x44, 0x12, 0x34, 0x00, 0x00, 0x8d, 0xf2, 'c', 'o', 'a', 'p', ':', '/', '/', 'e', 'x',
507 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm', '/', '1', '2', '3', '4', '5', '/', '%',
508 '3', 'F', 'x', 'y', 'z', '/', '3', '0', '4', '8', '2', '3', '4', '2', '3', '4', '/',
509 '2', '3', '4', '0', '2', '3', '4', '8', '2', '3', '4', '/', '2', '3', '9', '0', '8',
510 '4', '2', '3', '4', '-', '2', '3', '/', '%', 'A', 'B', '%', '3', '0', '%', 'a', 'f',
511 '/', '+', '1', '2', '3', '/', 'h', 'f', 'k', 's', 'd', 'h', '/', '2', '3', '4', '8',
512 '0', '-', '2', '3', '4', '-', '9', '8', '2', '3', '5', '/', '1', '2', '0', '4', '/',
513 '2', '4', '3', '5', '4', '6', '3', '4', '5', '3', '4', '5', '2', '4', '3', '/', '0',
514 '1', '9', '8', 's', 'd', 'n', '3', '-', 'a', '-', '3', '/', '/', '/', 'a', 'f', 'f',
515 '0', '9', '3', '4', '/', '9', '7', 'u', '2', '1', '4', '1', '/', '0', '0', '0', '2',
516 '/', '3', '9', '3', '2', '4', '2', '3', '5', '3', '2', '/', '5', '6', '2', '3', '4',
517 '0', '2', '3', '/', '-', '-', '-', '-', '/', '=', '1', '2', '3', '4', '=', '/', '0',
518 '9', '8', '1', '4', '1', '-', '9', '5', '6', '4', '6', '4', '3', '/', '2', '1', '9',
519 '7', '0', '-', '-', '-', '-', '-', '/', '8', '2', '3', '6', '4', '9', '2', '3', '4',
520 '7', '2', 'w', 'e', 'r', 'e', 'r', 'e', 'w', 'r', '0', '-', '9', '2', '1', '-', '3',
521 '9', '1', '2', '3', '-', '3', '4', '/', 0x0d, 0x01, '/', '/', '4', '9', '2', '4', '0',
522 '3', '-', '-', '0', '9', '8', '/', 0xc1, '*', 0xff, 'd', 'a', 't', 'a' };
525 coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */
527 pdu->hdr->type = COAP_MESSAGE_ACK;
528 pdu->hdr->code = COAP_RESPONSE_CODE(204);
529 pdu->hdr->id = htons(0x1234);
531 CU_ASSERT(pdu->length == 4);
533 result = coap_add_token(pdu, 2, (unsigned char *) "\0\0");
535 CU_ASSERT(result > 0);
537 coap_add_option(pdu, COAP_OPTION_LOCATION_PATH, 255,
538 (unsigned char *) "coap://example.com/12345/%3Fxyz/3048234234/23402348234/239084234-23/%AB%30%af/+123/hfksdh/23480-234-98235/1204/243546345345243/0198sdn3-a-3///aff0934/97u2141/0002/3932423532/56234023/----/=1234=/098141-9564643/21970-----/82364923472wererewr0-921-39123-34/");
540 CU_ASSERT(result == 257);
541 CU_ASSERT(pdu->max_delta == 8);
542 CU_ASSERT(pdu->length == 263);
543 CU_ASSERT_PTR_NULL(pdu->data);
545 result = coap_add_option(pdu, COAP_OPTION_LOCATION_PATH, 14,
546 (unsigned char *) "//492403--098/");
548 CU_ASSERT(result == 16);
549 CU_ASSERT(pdu->max_delta == 8);
550 CU_ASSERT(pdu->length == 279);
551 CU_ASSERT_PTR_NULL(pdu->data);
553 result = coap_add_option(pdu, COAP_OPTION_LOCATION_QUERY, 1, (unsigned char *) "*");
555 CU_ASSERT(result == 2);
556 CU_ASSERT(pdu->max_delta == 20);
557 CU_ASSERT(pdu->length == 281);
558 CU_ASSERT_PTR_NULL(pdu->data);
560 result = coap_add_data(pdu, 4, (unsigned char *) "data");
562 CU_ASSERT(result > 0);
563 CU_ASSERT(pdu->length == 286);
564 CU_ASSERT(pdu->data == (unsigned char *) pdu->hdr + 282);
566 CU_ASSERT(pdu->length == sizeof(teststr));
567 CU_ASSERT(memcmp(pdu->hdr, teststr, sizeof(teststr)) == 0);
570 void t_encode_pdu11(void)
572 /* data too long for PDU */
573 size_t old_max = pdu->max_size;
576 coap_pdu_clear(pdu, 8); /* clear PDU, with small maximum */
578 CU_ASSERT(pdu->data == NULL);
579 result = coap_add_data(pdu, 10, (unsigned char *) "0123456789");
581 CU_ASSERT(result == 0);
582 CU_ASSERT(pdu->data == NULL);
584 pdu->max_size = old_max;
587 int t_pdu_tests_create(void)
589 pdu = coap_pdu_init(0, 0, 0, COAP_MAX_PDU_SIZE);
594 int t_pdu_tests_remove(void)
596 coap_delete_pdu(pdu);
600 CU_pSuite t_init_pdu_tests(void)
604 suite[0] = CU_add_suite("pdu parser", t_pdu_tests_create, t_pdu_tests_remove);
607 fprintf(stderr, "W: cannot add pdu parser test suite (%s)\n", CU_get_error_msg());
612 #define PDU_TEST(s,t) \
613 if (!CU_ADD_TEST(s,t)) { \
614 fprintf(stderr, "W: cannot add pdu parser test (%s)\n", \
615 CU_get_error_msg()); \
618 PDU_TEST(suite[0], t_parse_pdu1);
619 PDU_TEST(suite[0], t_parse_pdu2);
620 PDU_TEST(suite[0], t_parse_pdu3);
621 PDU_TEST(suite[0], t_parse_pdu4);
622 PDU_TEST(suite[0], t_parse_pdu5);
623 PDU_TEST(suite[0], t_parse_pdu6);
624 PDU_TEST(suite[0], t_parse_pdu7);
625 PDU_TEST(suite[0], t_parse_pdu8);
626 PDU_TEST(suite[0], t_parse_pdu9);
627 PDU_TEST(suite[0], t_parse_pdu10);
628 PDU_TEST(suite[0], t_parse_pdu11);
629 PDU_TEST(suite[0], t_parse_pdu12);
630 PDU_TEST(suite[0], t_parse_pdu13);
631 PDU_TEST(suite[0], t_parse_pdu14);
633 suite[1] = CU_add_suite("pdu encoder", t_pdu_tests_create, t_pdu_tests_remove);
636 #define PDU_ENCODER_TEST(s,t) \
637 if (!CU_ADD_TEST(s,t)) { \
638 fprintf(stderr, "W: cannot add pdu encoder test (%s)\n", \
639 CU_get_error_msg()); \
641 PDU_ENCODER_TEST(suite[1], t_encode_pdu1);
642 PDU_ENCODER_TEST(suite[1], t_encode_pdu2);
643 PDU_ENCODER_TEST(suite[1], t_encode_pdu3);
644 PDU_ENCODER_TEST(suite[1], t_encode_pdu4);
645 PDU_ENCODER_TEST(suite[1], t_encode_pdu5);
646 PDU_ENCODER_TEST(suite[1], t_encode_pdu6);
647 PDU_ENCODER_TEST(suite[1], t_encode_pdu7);
648 PDU_ENCODER_TEST(suite[1], t_encode_pdu8);
649 PDU_ENCODER_TEST(suite[1], t_encode_pdu9);
650 PDU_ENCODER_TEST(suite[1], t_encode_pdu10);
651 PDU_ENCODER_TEST(suite[1], t_encode_pdu11);
656 fprintf(stderr, "W: cannot add pdu parser test suite (%s)\n", CU_get_error_msg());