Drop main() prototype. Syncs with NetBSD-8
[minix.git] / tests / lib / libbluetooth / t_sdp_get.c
blob3ad8070de728c0ef8109b896f5c1a7ed6e3f3366
1 /* $NetBSD: t_sdp_get.c,v 1.2 2011/04/07 08:29:50 plunky Exp $ */
3 /*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Iain Hibbert.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <atf-c.h>
34 #include <limits.h>
35 #include <sdp.h>
36 #include <string.h>
38 ATF_TC(check_sdp_get_data);
40 ATF_TC_HEAD(check_sdp_get_data, tc)
43 atf_tc_set_md_var(tc, "descr", "Test sdp_get_data results");
46 ATF_TC_BODY(check_sdp_get_data, tc)
48 uint8_t data[] = {
49 0x09, 0x00, 0x00, // uint16 0x0000
50 0x35, 0x05, // seq8(5)
51 0x19, 0x00, 0x00, // uuid16 0x0000
52 0x08, 0x00, // uint8 0x00
53 0x36, 0x00, 0x01, // seq16(1)
54 0x19, // uint16 /* invalid */
55 0x25, 0x04, 0x54, 0x45, // str8(4) "TEST"
56 0x53, 0x54,
58 sdp_data_t test = { data, data + sizeof(data) };
59 sdp_data_t value, seq;
62 * sdp_get_data constructs a new sdp_data_t containing
63 * the next data element, advancing test if successful
65 ATF_REQUIRE(sdp_get_data(&test, &value));
66 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UINT16);
67 ATF_CHECK_EQ(sdp_data_size(&value), 3);
69 ATF_REQUIRE(sdp_get_data(&test, &value));
70 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ8);
71 ATF_CHECK_EQ(sdp_data_size(&value), 7);
73 ATF_REQUIRE(sdp_get_data(&test, &value));
74 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ16);
75 ATF_CHECK_EQ(sdp_data_size(&value), 4);
76 ATF_REQUIRE_EQ(sdp_get_seq(&value, &seq), true);
77 ATF_REQUIRE_EQ(sdp_get_data(&seq, &value), false); /* invalid */
79 ATF_REQUIRE(sdp_get_data(&test, &value));
80 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_STR8);
81 ATF_CHECK_EQ(sdp_data_size(&value), 6);
83 ATF_CHECK_EQ(test.next, test.end);
86 ATF_TC(check_sdp_get_attr);
88 ATF_TC_HEAD(check_sdp_get_attr, tc)
91 atf_tc_set_md_var(tc, "descr", "Test sdp_get_attr results");
94 ATF_TC_BODY(check_sdp_get_attr, tc)
96 uint8_t data[] = {
97 0x09, 0x00, 0x00, // uint16 0x0000
98 0x35, 0x05, // seq8(5)
99 0x19, 0x00, 0x00, // uuid16 0x0000
100 0x08, 0x00, // uint8 0x00
101 0x08, 0x00, // uint8 0x00
102 0x09, 0x00, 0x01, // uint16 0x0001
103 0x19, 0x12, 0x34, // uuid16 0x1234
105 sdp_data_t test = { data, data + sizeof(data) };
106 sdp_data_t value;
107 uint16_t attr;
110 * sdp_get_attr expects a UINT16 followed by any data item
111 * and advances test if successful
113 ATF_REQUIRE(sdp_get_attr(&test, &attr, &value));
114 ATF_CHECK_EQ(attr, 0x0000);
115 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ8);
116 ATF_CHECK_EQ(sdp_data_size(&value), 7);
118 ATF_REQUIRE_EQ(sdp_get_attr(&test, &attr, &value), false);
119 ATF_REQUIRE(sdp_get_data(&test, &value));
120 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UINT8);
121 ATF_CHECK_EQ(sdp_data_size(&value), 2);
123 ATF_REQUIRE(sdp_get_attr(&test, &attr, &value));
124 ATF_CHECK_EQ(attr, 0x0001);
125 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UUID16);
126 ATF_CHECK_EQ(sdp_data_size(&value), 3);
128 ATF_CHECK_EQ(test.next, test.end);
131 ATF_TC(check_sdp_get_uuid);
133 ATF_TC_HEAD(check_sdp_get_uuid, tc)
136 atf_tc_set_md_var(tc, "descr", "Test sdp_get_uuid results");
139 ATF_TC_BODY(check_sdp_get_uuid, tc)
141 uint8_t data[] = {
142 0x19, 0x12, 0x34, // uuid16 0x1234
143 0x1a, 0x11, 0x22, 0x33, // uuid32 0x11223344
144 0x44,
145 0x00, // nil
146 0x1c, // uuid128 0x00112233-4444--5555-6666-778899aabbcc
147 0x00, 0x11, 0x22, 0x33,
148 0x44, 0x44, 0x55, 0x55,
149 0x66, 0x66, 0x77, 0x88,
150 0x99, 0xaa, 0xbb, 0xcc,
152 sdp_data_t test = { data, data + sizeof(data) };
153 uuid_t u16 = {
154 0x00001234,
155 0x0000,
156 0x1000,
157 0x80,
158 0x00,
159 { 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
161 uuid_t u32 = {
162 0x11223344,
163 0x0000,
164 0x1000,
165 0x80,
166 0x00,
167 { 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
169 uuid_t u128 = {
170 0x00112233,
171 0x4444,
172 0x5555,
173 0x66,
174 0x66,
175 { 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc }
177 sdp_data_t nil;
178 uuid_t value;
181 * sdp_get_uuid expects any UUID type returns the full uuid
182 * advancing test if successful
184 ATF_REQUIRE(sdp_get_uuid(&test, &value));
185 ATF_CHECK(uuid_equal(&value, &u16, NULL));
187 ATF_REQUIRE(sdp_get_uuid(&test, &value));
188 ATF_CHECK(uuid_equal(&value, &u32, NULL));
190 ATF_REQUIRE_EQ(sdp_get_uuid(&test, &value), false); /* not uuid */
191 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
192 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
194 ATF_REQUIRE(sdp_get_uuid(&test, &value));
195 ATF_CHECK(uuid_equal(&value, &u128, NULL));
197 ATF_CHECK_EQ(test.next, test.end);
200 ATF_TC(check_sdp_get_bool);
202 ATF_TC_HEAD(check_sdp_get_bool, tc)
205 atf_tc_set_md_var(tc, "descr", "Test sdp_get_bool results");
208 ATF_TC_BODY(check_sdp_get_bool, tc)
210 uint8_t data[] = {
211 0x28, 0x00, // bool false
212 0x00, // nil
213 0x28, 0x01, // bool true
215 sdp_data_t test = { data, data + sizeof(data) };
216 sdp_data_t nil;
217 bool value;
220 * sdp_get_bool expects a BOOL type
221 * advancing test if successful
223 ATF_REQUIRE(sdp_get_bool(&test, &value));
224 ATF_CHECK_EQ(value, false);
226 ATF_REQUIRE_EQ(sdp_get_bool(&test, &value), false); /* not bool */
227 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
228 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
230 ATF_REQUIRE(sdp_get_bool(&test, &value));
231 ATF_CHECK_EQ(value, true);
233 ATF_CHECK_EQ(test.next, test.end);
236 ATF_TC(check_sdp_get_uint);
238 ATF_TC_HEAD(check_sdp_get_uint, tc)
241 atf_tc_set_md_var(tc, "descr", "Test sdp_get_uint results");
244 ATF_TC_BODY(check_sdp_get_uint, tc)
246 uint8_t data[] = {
247 0x08, 0x00, // uint8 0x00
248 0x08, 0xff, // uint8 0xff
249 0x09, 0x01, 0x02, // uint16 0x0102
250 0x09, 0xff, 0xff, // uint16 0xffff
251 0x00, // nil
252 0x0a, 0x01, 0x02, 0x03, // uint32 0x01020304
253 0x04,
254 0x0a, 0xff, 0xff, 0xff, // uint32 0xffffffff
255 0xff,
256 0x0b, 0x01, 0x02, 0x03, // uint64 0x0102030405060708
257 0x04, 0x05, 0x06, 0x07,
258 0x08,
259 0x0b, 0xff, 0xff, 0xff, // uint64 0xffffffffffffffff
260 0xff, 0xff, 0xff, 0xff,
261 0xff,
262 0x0c, 0x00, 0x00, 0x00, // uint128 0x00000000000000000000000000000000
263 0x00, 0x00, 0x00, 0x00,
264 0x00, 0x00, 0x00, 0x00,
265 0x00, 0x00, 0x00, 0x00,
266 0x00,
267 0x0c, 0x00, 0x00, 0x00, // uint128 0x00000000000000010000000000000000
268 0x00, 0x00, 0x00, 0x00,
269 0x01, 0x00, 0x00, 0x00,
270 0x00, 0x00, 0x00, 0x00,
271 0x00,
272 0x0c, 0x00, 0x00, 0x00, // uint128 0x0000000000000000ffffffffffffffff
273 0x00, 0x00, 0x00, 0x00,
274 0x00, 0xff, 0xff, 0xff,
275 0xff, 0xff, 0xff, 0xff,
276 0xff,
278 sdp_data_t test = { data, data + sizeof(data) };
279 sdp_data_t nil;
280 uintmax_t value;
283 * sdp_get_uint expects any UINT type, advancing test if successful
285 ATF_REQUIRE(sdp_get_uint(&test, &value));
286 ATF_CHECK_EQ(value, 0x00);
288 ATF_REQUIRE(sdp_get_uint(&test, &value));
289 ATF_CHECK_EQ(value, UINT8_MAX);
291 ATF_REQUIRE(sdp_get_uint(&test, &value));
292 ATF_CHECK_EQ(value, 0x0102);
294 ATF_REQUIRE(sdp_get_uint(&test, &value));
295 ATF_CHECK_EQ(value, UINT16_MAX);
297 ATF_REQUIRE_EQ(sdp_get_uint(&test, &value), false); /* not uint */
298 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
299 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
301 ATF_REQUIRE(sdp_get_uint(&test, &value));
302 ATF_CHECK_EQ(value, 0x01020304);
304 ATF_REQUIRE(sdp_get_uint(&test, &value));
305 ATF_CHECK_EQ(value, UINT32_MAX);
307 ATF_REQUIRE(sdp_get_uint(&test, &value));
308 ATF_CHECK_EQ(value, 0x0102030405060708);
310 ATF_REQUIRE(sdp_get_uint(&test, &value));
311 ATF_CHECK_EQ(value, UINT64_MAX);
314 * expected failure is that we cannot decode UINT128 values larger than UINT64
316 ATF_REQUIRE(sdp_get_uint(&test, &value));
317 ATF_CHECK_EQ(value, 0x00000000000000000000000000000000);
319 ATF_REQUIRE_EQ(sdp_get_uint(&test, &value), false); /* overflow */
320 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
321 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_UINT128);
323 ATF_REQUIRE(sdp_get_uint(&test, &value));
324 ATF_CHECK_EQ(value, UINT64_MAX);
326 ATF_CHECK_EQ(test.next, test.end);
329 ATF_TC(check_sdp_get_int);
331 ATF_TC_HEAD(check_sdp_get_int, tc)
334 atf_tc_set_md_var(tc, "descr", "Test sdp_get_int results");
337 ATF_TC_BODY(check_sdp_get_int, tc)
339 uint8_t data[] = {
340 0x10, 0x00, // int8 0x00
341 0x10, 0x7f, // int8 0x7f
342 0x10, 0x80, // int8 0x80
343 0x11, 0x01, 0x02, // int16 0x0102
344 0x11, 0x7f, 0xff, // int16 0x7fff
345 0x11, 0x80, 0x00, // int16 0x8000
346 0x00, // nil
347 0x12, 0x01, 0x02, 0x03, // int32 0x01020304
348 0x04,
349 0x12, 0x7f, 0xff, 0xff, // int32 0x7fffffff
350 0xff,
351 0x12, 0x80, 0x00, 0x00, // int32 0x80000000
352 0x00,
353 0x13, 0x01, 0x02, 0x03, // int64 0x0102030405060708
354 0x04, 0x05, 0x06, 0x07,
355 0x08,
356 0x13, 0x7f, 0xff, 0xff, // int64 0x7fffffffffffffff
357 0xff, 0xff, 0xff, 0xff,
358 0xff,
359 0x13, 0x80, 0x00, 0x00, // int64 0x8000000000000000
360 0x00, 0x00, 0x00, 0x00,
361 0x00,
362 0x14, 0x00, 0x00, 0x00, // int128 0x00000000000000000000000000000000
363 0x00, 0x00, 0x00, 0x00,
364 0x00, 0x00, 0x00, 0x00,
365 0x00, 0x00, 0x00, 0x00,
366 0x00,
367 0x14, 0x00, 0x00, 0x00, // int128 0x00000000000000007fffffffffffffff
368 0x00, 0x00, 0x00, 0x00, // (INT64_MAX)
369 0x00, 0x7f, 0xff, 0xff,
370 0xff, 0xff, 0xff, 0xff,
371 0xff,
372 0x14, 0x00, 0x00, 0x00, // int128 0x00000000000000008000000000000000
373 0x00, 0x00, 0x00, 0x00, // (INT64_MAX + 1)
374 0x00, 0x80, 0x00, 0x00,
375 0x00, 0x00, 0x00, 0x00,
376 0x00,
377 0x14, 0xff, 0xff, 0xff, // int128 0xffffffffffffffff8000000000000000
378 0xff, 0xff, 0xff, 0xff, // (INT64_MIN)
379 0xff, 0x80, 0x00, 0x00,
380 0x00, 0x00, 0x00, 0x00,
381 0x00,
382 0x14, 0xff, 0xff, 0xff, // int128 0xffffffffffffffff7fffffffffffffff
383 0xff, 0xff, 0xff, 0xff, // (INT64_MIN - 1)
384 0xff, 0x7f, 0xff, 0xff,
385 0xff, 0xff, 0xff, 0xff,
386 0xff,
388 sdp_data_t test = { data, data + sizeof(data) };
389 sdp_data_t nil;
390 intmax_t value;
393 * sdp_get_int expects any INT type, advancing test if successful
395 ATF_REQUIRE(sdp_get_int(&test, &value));
396 ATF_CHECK_EQ(value, 0);
398 ATF_REQUIRE(sdp_get_int(&test, &value));
399 ATF_CHECK_EQ(value, INT8_MAX);
401 ATF_REQUIRE(sdp_get_int(&test, &value));
402 ATF_CHECK_EQ(value, INT8_MIN);
404 ATF_REQUIRE(sdp_get_int(&test, &value));
405 ATF_CHECK_EQ(value, 0x0102);
407 ATF_REQUIRE(sdp_get_int(&test, &value));
408 ATF_CHECK_EQ(value, INT16_MAX);
410 ATF_REQUIRE(sdp_get_int(&test, &value));
411 ATF_CHECK_EQ(value, INT16_MIN);
413 ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false); /* not int */
414 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
415 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
417 ATF_REQUIRE(sdp_get_int(&test, &value));
418 ATF_CHECK_EQ(value, 0x01020304);
420 ATF_REQUIRE(sdp_get_int(&test, &value));
421 ATF_CHECK_EQ(value, INT32_MAX);
423 ATF_REQUIRE(sdp_get_int(&test, &value));
424 ATF_CHECK_EQ(value, INT32_MIN);
426 ATF_REQUIRE(sdp_get_int(&test, &value));
427 ATF_CHECK_EQ(value, 0x0102030405060708);
429 ATF_REQUIRE(sdp_get_int(&test, &value));
430 ATF_CHECK_EQ(value, INT64_MAX);
432 ATF_REQUIRE(sdp_get_int(&test, &value));
433 ATF_CHECK_EQ(value, INT64_MIN);
436 * expected failure is that we cannot decode INT128 values larger than INT64
438 ATF_REQUIRE(sdp_get_int(&test, &value));
439 ATF_CHECK_EQ(value, 0);
441 ATF_REQUIRE(sdp_get_int(&test, &value));
442 ATF_CHECK_EQ(value, INT64_MAX);
444 ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false); /* overflow */
445 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
446 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_INT128);
448 ATF_REQUIRE(sdp_get_int(&test, &value));
449 ATF_CHECK_EQ(value, INT64_MIN);
451 ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false); /* underflow */
452 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
453 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_INT128);
455 ATF_CHECK_EQ(test.next, test.end);
458 ATF_TC(check_sdp_get_seq);
460 ATF_TC_HEAD(check_sdp_get_seq, tc)
463 atf_tc_set_md_var(tc, "descr", "Test sdp_get_seq results");
466 ATF_TC_BODY(check_sdp_get_seq, tc)
468 uint8_t data[] = {
469 0x35, 0x00, // seq8(0)
470 0x00, // nil
471 0x36, 0x00, 0x00, // seq16(0)
472 0x37, 0x00, 0x00, 0x00, // seq32(0)
473 0x00,
475 sdp_data_t test = { data, data + sizeof(data) };
476 sdp_data_t value;
479 * sdp_get_seq expects a SEQ type
480 * advancing test if successful
482 ATF_REQUIRE(sdp_get_seq(&test, &value));
483 ATF_CHECK_EQ(value.next, value.end);
485 ATF_REQUIRE_EQ(sdp_get_seq(&test, &value), false); /* not seq */
486 ATF_REQUIRE(sdp_get_data(&test, &value)); /* (skip) */
487 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_NIL);
489 ATF_REQUIRE(sdp_get_seq(&test, &value));
490 ATF_CHECK_EQ(value.next, value.end);
492 ATF_REQUIRE(sdp_get_seq(&test, &value));
493 ATF_CHECK_EQ(value.next, value.end);
495 ATF_CHECK_EQ(test.next, test.end);
498 ATF_TC(check_sdp_get_alt);
500 ATF_TC_HEAD(check_sdp_get_alt, tc)
503 atf_tc_set_md_var(tc, "descr", "Test sdp_get_alt results");
506 ATF_TC_BODY(check_sdp_get_alt, tc)
508 uint8_t data[] = {
509 0x3d, 0x00, // alt8(0)
510 0x00, // nil
511 0x3e, 0x00, 0x00, // alt16(0)
512 0x3f, 0x00, 0x00, 0x00, // alt32(0)
513 0x00,
515 sdp_data_t test = { data, data + sizeof(data) };
516 sdp_data_t value;
519 * sdp_get_alt expects a ALT type
520 * advancing test if successful
522 ATF_REQUIRE(sdp_get_alt(&test, &value));
523 ATF_CHECK_EQ(value.next, value.end);
525 ATF_REQUIRE_EQ(sdp_get_alt(&test, &value), false); /* not alt */
526 ATF_REQUIRE(sdp_get_data(&test, &value)); /* (skip) */
527 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_NIL);
529 ATF_REQUIRE(sdp_get_alt(&test, &value));
530 ATF_CHECK_EQ(value.next, value.end);
532 ATF_REQUIRE(sdp_get_alt(&test, &value));
533 ATF_CHECK_EQ(value.next, value.end);
535 ATF_CHECK_EQ(test.next, test.end);
538 ATF_TC(check_sdp_get_str);
540 ATF_TC_HEAD(check_sdp_get_str, tc)
543 atf_tc_set_md_var(tc, "descr", "Test sdp_get_str results");
546 ATF_TC_BODY(check_sdp_get_str, tc)
548 uint8_t data[] = {
549 0x25, 0x04, 0x53, 0x54, // str8(4) "STR8"
550 0x52, 0x38,
551 0x00, // nil
552 0x26, 0x00, 0x05, 0x53, // str16(5) "STR16"
553 0x54, 0x52, 0x31, 0x36,
554 0x27, 0x00, 0x00, 0x00, // str32(5) "STR32"
555 0x05, 0x53, 0x54, 0x52,
556 0x33, 0x32,
558 sdp_data_t test = { data, data + sizeof(data) };
559 sdp_data_t nil;
560 char *str;
561 size_t len;
564 * sdp_get_str expects a STR type
565 * advancing test if successful
567 ATF_REQUIRE(sdp_get_str(&test, &str, &len));
568 ATF_CHECK(len == 4 && strncmp(str, "STR8", 4) == 0);
570 ATF_REQUIRE_EQ(sdp_get_str(&test, &str, &len), false); /* not str */
571 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
572 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
574 ATF_REQUIRE(sdp_get_str(&test, &str, &len));
575 ATF_CHECK(len == 5 && strncmp(str, "STR16", 5) == 0);
577 ATF_REQUIRE(sdp_get_str(&test, &str, &len));
578 ATF_CHECK(len == 5 && strncmp(str, "STR32", 5) == 0);
580 ATF_CHECK_EQ(test.next, test.end);
583 ATF_TC(check_sdp_get_url);
585 ATF_TC_HEAD(check_sdp_get_url, tc)
588 atf_tc_set_md_var(tc, "descr", "Test sdp_get_url results");
591 ATF_TC_BODY(check_sdp_get_url, tc)
593 uint8_t data[] = {
594 0x45, 0x04, 0x55, 0x52, // url8(4) "URL8"
595 0x4c, 0x38,
596 0x00, // nil
597 0x46, 0x00, 0x05, 0x55, // url16(5) "URL16"
598 0x52, 0x4c, 0x31, 0x36,
599 0x47, 0x00, 0x00, 0x00, // url32(5) "URL32"
600 0x05, 0x55, 0x52, 0x4c,
601 0x33, 0x32,
603 sdp_data_t test = { data, data + sizeof(data) };
604 sdp_data_t nil;
605 char *url;
606 size_t len;
609 * sdp_get_url expects a URL type
610 * advancing test if successful
612 ATF_REQUIRE(sdp_get_url(&test, &url, &len));
613 ATF_CHECK(len == 4 && strncmp(url, "URL8", 4) == 0);
615 ATF_REQUIRE_EQ(sdp_get_url(&test, &url, &len), false); /* not url */
616 ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
617 ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
619 ATF_REQUIRE(sdp_get_url(&test, &url, &len));
620 ATF_CHECK(len == 5 && strncmp(url, "URL16", 5) == 0);
622 ATF_REQUIRE(sdp_get_url(&test, &url, &len));
623 ATF_CHECK(len == 5 && strncmp(url, "URL32", 5) == 0);
625 ATF_CHECK_EQ(test.next, test.end);
628 ATF_TP_ADD_TCS(tp)
631 ATF_TP_ADD_TC(tp, check_sdp_get_data);
632 ATF_TP_ADD_TC(tp, check_sdp_get_attr);
633 ATF_TP_ADD_TC(tp, check_sdp_get_uuid);
634 ATF_TP_ADD_TC(tp, check_sdp_get_bool);
635 ATF_TP_ADD_TC(tp, check_sdp_get_uint);
636 ATF_TP_ADD_TC(tp, check_sdp_get_int);
637 ATF_TP_ADD_TC(tp, check_sdp_get_seq);
638 ATF_TP_ADD_TC(tp, check_sdp_get_alt);
639 ATF_TP_ADD_TC(tp, check_sdp_get_str);
640 ATF_TP_ADD_TC(tp, check_sdp_get_url);
642 return atf_no_error();