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.
13 #include "test_options.h"
15 /************************************************************************
17 ************************************************************************/
19 void t_parse_option1(void)
21 /* delta == 0, length == 0, value == 0 */
23 { 1, (unsigned char *) "" };
28 /* result = coap_opt_parse(teststr.s, teststr.s + teststr.length, &option); */
29 result = coap_opt_parse(teststr.s, teststr.length, &option);
30 CU_ASSERT(result == 1);
31 CU_ASSERT(option.delta == 0);
32 CU_ASSERT(option.length == 0);
36 void t_parse_option2(void)
38 /* delta == 12, length == 1, value == 0 */
40 { 2, (unsigned char *) "\xc1" };
45 result = coap_opt_parse(teststr.s, teststr.length, &option);
46 CU_ASSERT(result == 2);
47 CU_ASSERT(option.delta == 12);
48 CU_ASSERT(option.length == 1);
49 CU_ASSERT(option.value == teststr.s + 1);
52 void t_parse_option3(void)
54 /* delta == 3, length == 12, value == 0 */
56 { 13, (unsigned char *) "\x3c\x00\x01\x02\x03\x04"
57 "\x05\x06\x07\x08\x09\x0a\x0b" };
62 result = coap_opt_parse(teststr.s, teststr.length, &option);
63 CU_ASSERT(result == 13);
64 CU_ASSERT(option.delta == 3);
65 CU_ASSERT(option.length == 12);
66 CU_ASSERT(option.value == teststr.s + 1);
67 /* CU_ASSERT(memcmp(option.value, teststr.s + 1, 12) == 0); */
70 void t_parse_option4(void)
72 /* delta == 15, length == 3, value == 0 */
74 { 2, (unsigned char *) "\xf3" };
79 result = coap_opt_parse(teststr.s, teststr.length, &option);
80 CU_ASSERT(result == 0);
83 void t_parse_option5(void)
85 /* delta == 3, length == 15, value == 0 */
87 { 2, (unsigned char *) "\x3f" };
92 result = coap_opt_parse(teststr.s, teststr.length, &option);
93 CU_ASSERT(result == 0);
96 void t_parse_option6(void)
98 /* delta == 15, length == 15 */
100 { 1, (unsigned char *) "\xff" };
103 coap_option_t option;
105 result = coap_opt_parse(teststr.s, teststr.length, &option);
106 CU_ASSERT(result == 0);
109 void t_parse_option7(void)
111 /* delta == 20, length == 0 */
113 { 2, (unsigned char *) "\xd0\x07" };
116 coap_option_t option;
118 result = coap_opt_parse(teststr.s, teststr.length, &option);
119 CU_ASSERT(result == 2);
120 CU_ASSERT(option.delta == 20);
121 CU_ASSERT(option.length == 0);
124 void t_parse_option8(void)
126 /* delta == 780, length == 0 */
128 { 3, (unsigned char *) "\xe0\x01\xff" };
131 coap_option_t option;
133 result = coap_opt_parse(teststr.s, teststr.length, &option);
134 CU_ASSERT(result == 3);
135 CU_ASSERT(option.delta == 780);
136 CU_ASSERT(option.length == 0);
139 void t_parse_option9(void)
141 /* delta == 65535, length == 0 */
143 { 3, (unsigned char *) "\xe0\xfe\xf2" };
146 coap_option_t option;
148 result = coap_opt_parse(teststr.s, teststr.length, &option);
149 CU_ASSERT(result == 3);
150 CU_ASSERT(option.delta == 65535);
153 void t_parse_option10(void)
155 /* delta > 65535 (illegal), length == 0 */
157 { 3, (unsigned char *) "\xe0\xff\xff" };
160 coap_option_t option;
162 result = coap_opt_parse(teststr.s, teststr.length, &option);
163 CU_ASSERT(result == 0);
166 void t_parse_option11(void)
168 /* illegal delta value (option too short) */
170 { 1, (unsigned char *) "\xd0" };
173 coap_option_t option;
175 result = coap_opt_parse(teststr.s, teststr.length, &option);
176 CU_ASSERT(result == 0);
179 void t_parse_option12(void)
181 /* delta == 280, length == 500 */
183 { 3, (unsigned char *) "\xee\xff\x0b" };
186 coap_option_t option;
188 result = coap_opt_parse(teststr.s, teststr.length, &option);
189 CU_ASSERT(result == 0);
192 void t_parse_option13(void)
194 /* delta == 280, length == 500 */
195 unsigned char _data[505];
197 { sizeof(_data), _data };
205 coap_option_t option;
207 result = coap_opt_parse(teststr.s, teststr.length, &option);
208 CU_ASSERT(result == sizeof(_data));
209 CU_ASSERT(option.delta == 280);
210 CU_ASSERT(option.length == 500);
211 CU_ASSERT(option.value == &_data[5]);
214 void t_parse_option14(void)
216 /* delta == 268, length == 65535 */
218 unsigned int length = 4 + 65535;
220 data = (unsigned char *) malloc(length);
223 CU_FAIL("internal error in test framework -- insufficient memory\n");
233 coap_option_t option;
235 result = coap_opt_parse(data, length, &option);
236 CU_ASSERT(result == length);
237 CU_ASSERT(option.delta == 268);
238 CU_ASSERT(option.length == 65535);
239 CU_ASSERT(option.value == &data[4]);
242 /************************************************************************
244 ************************************************************************/
246 void t_encode_option1(void)
250 unsigned char buf[40];
253 result = coap_opt_setheader((coap_opt_t *) buf, sizeof(buf), 0, 0);
254 CU_ASSERT(result == sizeof(teststr));
256 CU_ASSERT(memcmp(buf, teststr, result) == 0);
259 void t_encode_option2(void)
263 unsigned char buf[40];
266 result = coap_opt_setheader((coap_opt_t *) buf, sizeof(buf), 5, 268);
267 CU_ASSERT(result == sizeof(teststr));
269 CU_ASSERT(memcmp(buf, teststr, result) == 0);
272 void t_encode_option3(void)
276 unsigned char buf[40];
279 result = coap_opt_setheader((coap_opt_t *) buf, sizeof(buf), 14, 1);
280 CU_ASSERT(result == sizeof(teststr));
282 CU_ASSERT(memcmp(buf, teststr, result) == 0);
285 void t_encode_option4(void)
288 { 0xdd, 0xff, 0xab };
289 unsigned char buf[40];
292 result = coap_opt_setheader((coap_opt_t *) buf, sizeof(buf), 268, 184);
293 CU_ASSERT(result == sizeof(teststr));
295 CU_ASSERT(memcmp(buf, teststr, result) == 0);
298 void t_encode_option5(void)
301 { 0xed, 0x13, 0x00, 0xff };
302 unsigned char buf[40];
305 result = coap_opt_setheader((coap_opt_t *) buf, sizeof(buf), 5133, 268);
306 CU_ASSERT(result == sizeof(teststr));
308 CU_ASSERT(memcmp(buf, teststr, result) == 0);
311 void t_encode_option6(void)
314 { 0xee, 0xfe, 0xf2, 0xfe, 0xf2 };
315 unsigned char buf[40];
318 result = coap_opt_setheader((coap_opt_t *) buf, sizeof(buf), 65535, 65535);
319 CU_ASSERT(result == sizeof(teststr));
321 CU_ASSERT(memcmp(buf, teststr, result) == 0);
324 void t_encode_option7(void)
327 { 0x35, 'v', 'a', 'l', 'u', 'e' };
328 const size_t valoff = 1;
329 unsigned char buf[40];
332 result = coap_opt_encode((coap_opt_t *) buf, sizeof(buf), 3, (unsigned char *) teststr + valoff,
333 sizeof(teststr) - valoff);
335 CU_ASSERT(result == sizeof(teststr));
337 CU_ASSERT(memcmp(buf, teststr, result) == 0);
340 void t_encode_option8(void)
342 /* value does not fit in message buffer */
343 unsigned char buf[40];
346 result = coap_opt_encode((coap_opt_t *) buf, 8, 15, (unsigned char *) "something", 9);
348 CU_ASSERT(result == 0);
350 result = coap_opt_encode((coap_opt_t *) buf, 1, 15, (unsigned char *) "something", 9);
352 CU_ASSERT(result == 0);
355 /************************************************************************
357 ************************************************************************/
359 void t_access_option1(void)
361 const char teststr[] =
364 CU_ASSERT(coap_opt_delta((coap_opt_t *) teststr) == 1);
365 CU_ASSERT(coap_opt_length((coap_opt_t *) teststr) == 2);
366 CU_ASSERT_PTR_EQUAL(coap_opt_value((coap_opt_t *) teststr), teststr + 1);
367 CU_ASSERT(coap_opt_size((coap_opt_t *) teststr) == sizeof(teststr));
370 void t_access_option2(void)
372 const char teststr[] =
373 { 0xe2, 0x18, 0xfd, 'a', 'b' };
375 CU_ASSERT(coap_opt_delta((coap_opt_t *) teststr) == 6666);
376 CU_ASSERT(coap_opt_length((coap_opt_t *) teststr) == 2);
377 CU_ASSERT_PTR_EQUAL(coap_opt_value((coap_opt_t *) teststr), teststr + 3);
378 CU_ASSERT(coap_opt_size((coap_opt_t *) teststr) == sizeof(teststr));
381 void t_access_option3(void)
383 const char teststr[] =
384 { 0xed, 0x18, 0x0a, 0x00, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm' };
386 CU_ASSERT(coap_opt_delta((coap_opt_t *) teststr) == 6423);
387 CU_ASSERT(coap_opt_length((coap_opt_t *) teststr) == 13);
388 CU_ASSERT_PTR_EQUAL(coap_opt_value((coap_opt_t *) teststr), teststr + 4);
389 CU_ASSERT(coap_opt_size((coap_opt_t *) teststr) == sizeof(teststr));
392 void t_access_option4(void)
394 const char teststr[] =
395 { 0xde, 0xff, 0xfe, 0xf2, 'a', 'b', 'c' };
397 CU_ASSERT(coap_opt_delta((coap_opt_t *) teststr) == 268);
398 CU_ASSERT(coap_opt_length((coap_opt_t *) teststr) == 65535);
399 CU_ASSERT_PTR_EQUAL(coap_opt_value((coap_opt_t *) teststr), teststr + 4);
400 CU_ASSERT(coap_opt_size((coap_opt_t *) teststr) == 65535 + 4);
403 void t_access_option5(void)
405 const char teststr[] =
406 { 0xee, 0xfe, 0xf2, 0x00, 0xdd, 'a', 'b', 'c' };
408 CU_ASSERT(coap_opt_delta((coap_opt_t *) teststr) == 65535);
409 CU_ASSERT(coap_opt_length((coap_opt_t *) teststr) == 490);
410 CU_ASSERT_PTR_EQUAL(coap_opt_value((coap_opt_t *) teststr), teststr + 5);
411 CU_ASSERT(coap_opt_size((coap_opt_t *) teststr) == 495);
414 void t_access_option6(void)
416 const char teststr[] =
419 CU_ASSERT(coap_opt_delta((coap_opt_t *) teststr) == 0);
420 CU_ASSERT(coap_opt_length((coap_opt_t *) teststr) == 0);
421 CU_ASSERT_PTR_EQUAL(coap_opt_value((coap_opt_t *) teststr), NULL);
422 CU_ASSERT(coap_opt_size((coap_opt_t *) teststr) == 0);
425 void t_access_option7(void)
427 const char teststr[] =
430 CU_ASSERT(coap_opt_delta((coap_opt_t *) teststr) == 2);
431 CU_ASSERT(coap_opt_length((coap_opt_t *) teststr) == 0);
432 CU_ASSERT_PTR_EQUAL(coap_opt_value((coap_opt_t *) teststr), NULL);
433 CU_ASSERT(coap_opt_size((coap_opt_t *) teststr) == 0);
436 /************************************************************************
438 ************************************************************************/
440 #define TEST_MAX_SIZE 1000
442 void t_iterate_option1(void)
444 /* CoAP PDU without token, options, or data */
445 char teststr[] __attribute__ ((aligned (8))) =
446 { 0x00, 0x00, 0x00, 0x00 };
449 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
450 coap_opt_iterator_t oi, *result;
453 result = coap_option_iterator_init(&pdu, &oi, COAP_OPT_ALL);
455 CU_ASSERT(result == NULL);
456 CU_ASSERT(oi.bad == 1);
458 option = coap_option_next(&oi);
459 CU_ASSERT(oi.bad == 1);
460 CU_ASSERT(option == NULL);
463 void t_iterate_option2(void)
465 /* CoAP PDU with token but without options and data */
466 char teststr[] __attribute__ ((aligned (8))) =
467 { 0x03, 0x00, 0x00, 0x00, 't', 'o', 'k' };
470 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
471 coap_opt_iterator_t oi, *result;
474 result = coap_option_iterator_init(&pdu, &oi, COAP_OPT_ALL);
476 CU_ASSERT(result == NULL);
477 CU_ASSERT(oi.bad == 1);
479 option = coap_option_next(&oi);
480 CU_ASSERT(oi.bad == 1);
481 CU_ASSERT(option == NULL);
484 void t_iterate_option3(void)
486 /* CoAP PDU with token and options */
487 char teststr[] __attribute__ ((aligned (8))) =
488 { 0x03, 0x00, 0x00, 0x00, 't', 'o', 'k', 0x13, 'o', 'p', 't', 0x00, 0xd1, 0x10, 'x' };
491 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
492 coap_opt_iterator_t oi, *result;
495 result = coap_option_iterator_init(&pdu, &oi, COAP_OPT_ALL);
497 CU_ASSERT_PTR_EQUAL(result, &oi);
498 CU_ASSERT(oi.bad == 0);
500 option = coap_option_next(&oi);
501 CU_ASSERT(oi.bad == 0);
502 CU_ASSERT(oi.type == 1);
503 CU_ASSERT_PTR_EQUAL(option, teststr + 7);
505 option = coap_option_next(&oi);
506 CU_ASSERT(oi.bad == 0);
507 CU_ASSERT(oi.type == 1);
508 CU_ASSERT_PTR_EQUAL(option, teststr + 11);
510 option = coap_option_next(&oi);
511 CU_ASSERT(oi.bad == 0);
512 CU_ASSERT(oi.type == 30);
513 CU_ASSERT_PTR_EQUAL(option, teststr + 12);
515 option = coap_option_next(&oi);
516 CU_ASSERT(oi.bad == 1);
517 CU_ASSERT_PTR_EQUAL(option, NULL);
520 void t_iterate_option4(void)
522 /* CoAP PDU with token, options, and data */
523 char teststr[] __attribute__ ((aligned (8))) =
524 { 0x03, 0x00, 0x00, 0x00, 't', 'o', 'k', 0x13, 'o', 'p', 't', 0x00, 0xd1, 0x10, 'x', 0xff, 'd',
528 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
529 coap_opt_iterator_t oi, *result;
532 result = coap_option_iterator_init(&pdu, &oi, COAP_OPT_ALL);
534 CU_ASSERT_PTR_EQUAL(result, &oi);
535 CU_ASSERT(oi.bad == 0);
537 option = coap_option_next(&oi);
538 CU_ASSERT(oi.bad == 0);
539 CU_ASSERT(oi.type == 1);
540 CU_ASSERT_PTR_EQUAL(option, teststr + 7);
542 option = coap_option_next(&oi);
543 CU_ASSERT(oi.bad == 0);
544 CU_ASSERT(oi.type == 1);
545 CU_ASSERT_PTR_EQUAL(option, teststr + 11);
547 option = coap_option_next(&oi);
548 CU_ASSERT(oi.bad == 0);
549 CU_ASSERT(oi.type == 30);
550 CU_ASSERT_PTR_EQUAL(option, teststr + 12);
552 option = coap_option_next(&oi);
553 CU_ASSERT(oi.bad == 1);
554 CU_ASSERT_PTR_EQUAL(option, NULL);
557 void t_iterate_option5(void)
559 /* CoAP PDU with malformed option */
560 char teststr[] __attribute__ ((aligned (8))) =
561 { 0x00, 0x00, 0x00, 0x00, 0x52, 'o', 'p', 0xee, 0x12, 0x03, 0x00 };
564 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
565 coap_opt_iterator_t oi, *result;
568 result = coap_option_iterator_init(&pdu, &oi, COAP_OPT_ALL);
570 CU_ASSERT_PTR_EQUAL(result, &oi);
571 CU_ASSERT(oi.bad == 0);
573 option = coap_option_next(&oi);
574 CU_ASSERT(oi.bad == 0);
575 CU_ASSERT(oi.type == 5);
576 CU_ASSERT_PTR_EQUAL(option, teststr + 4);
578 option = coap_option_next(&oi);
579 CU_ASSERT(oi.bad == 1);
580 CU_ASSERT_PTR_EQUAL(option, NULL);
583 void t_iterate_option6(void)
586 /* CoAP PDU with token, options, and data */
587 char teststr[] __attribute__ ((aligned (8))) =
588 { 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0xc0, 0x00 };
591 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
592 coap_opt_iterator_t oi, *result;
594 coap_opt_filter_t filter;
596 coap_option_filter_clear(filter);
597 coap_option_setb(filter, 10); /* option nr 10 only */
598 result = coap_option_iterator_init(&pdu, &oi, filter);
600 CU_ASSERT_PTR_EQUAL(result, &oi);
601 CU_ASSERT(oi.bad == 0);
603 option = coap_option_next(&oi);
604 CU_ASSERT(oi.bad == 0);
605 CU_ASSERT(oi.type == 10);
606 CU_ASSERT_PTR_EQUAL(option, teststr + 5);
608 option = coap_option_next(&oi);
609 CU_ASSERT(oi.bad == 0);
610 CU_ASSERT(oi.type == 10);
611 CU_ASSERT_PTR_EQUAL(option, teststr + 6);
613 option = coap_option_next(&oi);
614 CU_ASSERT(oi.bad == 0);
615 CU_ASSERT(oi.type == 10);
616 CU_ASSERT_PTR_EQUAL(option, teststr + 7);
618 option = coap_option_next(&oi);
619 CU_ASSERT(oi.bad == 1);
620 CU_ASSERT_PTR_EQUAL(option, NULL);
623 void t_iterate_option7(void)
626 char teststr[] __attribute__ ((aligned (8))) =
627 { 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0xc0, 0x00, 0x10, 0x10, 0x00 };
630 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
631 coap_opt_iterator_t oi, *result;
633 coap_opt_filter_t filter;
635 /* search options nr 8 and 22 */
636 coap_option_filter_clear(filter);
637 coap_option_setb(filter, 8);
638 coap_option_setb(filter, 22);
639 result = coap_option_iterator_init(&pdu, &oi, filter);
641 CU_ASSERT_PTR_EQUAL(result, &oi);
642 CU_ASSERT(oi.bad == 0);
644 option = coap_option_next(&oi);
645 CU_ASSERT(oi.bad == 0);
646 CU_ASSERT(oi.type == 8);
647 CU_ASSERT_PTR_EQUAL(option, teststr + 4);
649 option = coap_option_next(&oi);
650 CU_ASSERT(oi.bad == 0);
651 CU_ASSERT(oi.type == 22);
652 CU_ASSERT_PTR_EQUAL(option, teststr + 8);
654 option = coap_option_next(&oi);
655 CU_ASSERT(oi.bad == 0);
656 CU_ASSERT(oi.type == 22);
657 CU_ASSERT_PTR_EQUAL(option, teststr + 9);
659 option = coap_option_next(&oi);
660 CU_ASSERT(oi.bad == 1);
661 CU_ASSERT_PTR_EQUAL(option, NULL);
664 void t_iterate_option8(void)
667 char teststr[] __attribute__ ((aligned (8))) =
668 { 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0xc0, 0x00, 0x10, 0x10, 0x00 };
671 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
672 coap_opt_iterator_t oi, *result;
674 coap_opt_filter_t filter;
676 /* search option nr 36 */
677 coap_option_filter_clear(filter);
678 coap_option_setb(filter, 36);
679 result = coap_option_iterator_init(&pdu, &oi, filter);
681 CU_ASSERT_PTR_EQUAL(result, &oi);
682 CU_ASSERT(oi.bad == 0);
684 option = coap_option_next(&oi);
685 CU_ASSERT(oi.bad == 1);
686 CU_ASSERT_PTR_EQUAL(option, NULL);
689 void t_iterate_option9(void)
691 /* options filter: option number too large for filter */
692 char teststr[] __attribute__ ((aligned (8))) =
693 { 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0xc0, 0x00, 0x10, 0x10, 0x00 };
696 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
697 coap_opt_iterator_t oi, *result;
699 coap_opt_filter_t filter;
701 /* search option nr 100 */
702 coap_option_filter_clear(filter);
703 coap_option_setb(filter, 100);
704 result = coap_option_iterator_init(&pdu, &oi, filter);
706 CU_ASSERT_PTR_EQUAL(result, &oi);
707 CU_ASSERT(oi.bad == 0);
709 option = coap_option_next(&oi);
710 CU_ASSERT(oi.bad == 1);
711 CU_ASSERT_PTR_EQUAL(option, NULL);
714 void t_iterate_option10(void)
716 /* options filter: option numbers in PDU exceed filter size */
717 char teststr[] __attribute__ ((aligned (8))) =
718 { 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0xd0, 0x26, 0xe0, 0x10, 0x00 };
721 { .max_size = TEST_MAX_SIZE, .hdr = (coap_hdr_t *) teststr, .length = sizeof(teststr) };
722 coap_opt_iterator_t oi, *result;
724 coap_opt_filter_t filter;
726 /* search option nr 61 */
727 coap_option_filter_clear(filter);
728 coap_option_setb(filter, 61);
729 result = coap_option_iterator_init(&pdu, &oi, filter);
731 CU_ASSERT_PTR_EQUAL(result, &oi);
732 CU_ASSERT(oi.bad == 0);
734 option = coap_option_next(&oi);
735 CU_ASSERT(oi.bad == 0);
736 CU_ASSERT_PTR_EQUAL(option, teststr + 8);
738 option = coap_option_next(&oi);
739 CU_ASSERT(oi.bad == 1);
740 CU_ASSERT_PTR_EQUAL(option, NULL);
743 /************************************************************************
745 ************************************************************************/
747 CU_pSuite t_init_option_tests(void)
751 suite[0] = CU_add_suite("option parser", NULL, NULL);
754 fprintf(stderr, "W: cannot add option parser test suite (%s)\n", CU_get_error_msg());
759 #define OPTION_TEST(n,s) \
760 if (!CU_add_test(suite[0], s, t_parse_option##n)) { \
761 fprintf(stderr, "W: cannot add option parser test (%s)\n", \
762 CU_get_error_msg()); \
765 OPTION_TEST(1, "parse option #1");
766 OPTION_TEST(2, "parse option #2");
767 OPTION_TEST(3, "parse option #3");
768 OPTION_TEST(4, "parse option #4");
769 OPTION_TEST(5, "parse option #5");
770 OPTION_TEST(6, "parse option #6");
771 OPTION_TEST(7, "parse option #7");
772 OPTION_TEST(8, "parse option #8");
773 OPTION_TEST(9, "parse option #9");
774 OPTION_TEST(10, "parse option #10");
775 OPTION_TEST(11, "parse option #11");
776 OPTION_TEST(12, "parse option #12");
777 OPTION_TEST(13, "parse option #13");
778 OPTION_TEST(14, "parse option #14");
780 if ((suite[1] = CU_add_suite("option encoder", NULL, NULL)))
782 #define OPTION_ENCODER_TEST(n,s) \
783 if (!CU_add_test(suite[1], s, t_encode_option##n)) { \
784 fprintf(stderr, "W: cannot add option encoder test (%s)\n", \
785 CU_get_error_msg()); \
788 OPTION_ENCODER_TEST(1, "encode option #1");
789 OPTION_ENCODER_TEST(2, "encode option #2");
790 OPTION_ENCODER_TEST(3, "encode option #3");
791 OPTION_ENCODER_TEST(4, "encode option #4");
792 OPTION_ENCODER_TEST(5, "encode option #5");
793 OPTION_ENCODER_TEST(6, "encode option #6");
794 OPTION_ENCODER_TEST(7, "encode option #7");
795 OPTION_ENCODER_TEST(8, "encode option #8");
800 fprintf(stderr, "W: cannot add option encoder test suite (%s)\n", CU_get_error_msg());
803 if ((suite[2] = CU_add_suite("option accessors", NULL, NULL)))
805 #define OPTION_ACCESSOR_TEST(n,s) \
806 if (!CU_add_test(suite[2], s, t_access_option##n)) { \
807 fprintf(stderr, "W: cannot add option accessor function test (%s)\n", \
808 CU_get_error_msg()); \
811 OPTION_ACCESSOR_TEST(1, "access option #1");
812 OPTION_ACCESSOR_TEST(2, "access option #2");
813 OPTION_ACCESSOR_TEST(3, "access option #3");
814 OPTION_ACCESSOR_TEST(4, "access option #4");
815 OPTION_ACCESSOR_TEST(5, "access option #5");
816 OPTION_ACCESSOR_TEST(6, "access option #6");
817 OPTION_ACCESSOR_TEST(7, "access option #7");
822 fprintf(stderr, "W: cannot add option acessor function test suite (%s)\n",
826 if ((suite[3] = CU_add_suite("option iterator", NULL, NULL)))
828 #define OPTION_ITERATOR_TEST(n,s) \
829 if (!CU_add_test(suite[3], s, t_iterate_option##n)) { \
830 fprintf(stderr, "W: cannot add option iterator test (%s)\n", \
831 CU_get_error_msg()); \
834 OPTION_ITERATOR_TEST(1, "option iterator #1");
835 OPTION_ITERATOR_TEST(2, "option iterator #2");
836 OPTION_ITERATOR_TEST(3, "option iterator #3");
837 OPTION_ITERATOR_TEST(4, "option iterator #4");
838 OPTION_ITERATOR_TEST(5, "option iterator #5");
839 OPTION_ITERATOR_TEST(6, "option iterator #6");
840 OPTION_ITERATOR_TEST(7, "option iterator #7");
841 OPTION_ITERATOR_TEST(8, "option iterator #8");
842 OPTION_ITERATOR_TEST(9, "option iterator #9");
843 OPTION_ITERATOR_TEST(10, "option iterator #10");
848 fprintf(stderr, "W: cannot add option iterator test suite (%s)\n", CU_get_error_msg());