Remove building with NOCRYPTO option
[minix.git] / tests / lib / libbluetooth / t_sdp_data.c
blobcff662768c24acf02a43a74462715401effadb87
1 /* $NetBSD: t_sdp_data.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 <sdp.h>
36 ATF_TC(check_sdp_data_type);
38 ATF_TC_HEAD(check_sdp_data_type, tc)
41 atf_tc_set_md_var(tc, "descr", "Test sdp_data_type results");
44 ATF_TC_BODY(check_sdp_data_type, tc)
46 uint8_t data[] = {
47 0x00, // nil
48 0x08, 0x00, // uint8 0x00
50 sdp_data_t test = { data, data + sizeof(data) };
51 sdp_data_t value;
53 ATF_REQUIRE(sdp_get_data(&test, &value));
54 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_NIL);
56 ATF_REQUIRE(sdp_get_data(&test, &value));
57 ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UINT8);
59 ATF_CHECK_EQ(test.next, test.end);
62 ATF_TC(check_sdp_data_size);
64 ATF_TC_HEAD(check_sdp_data_size, tc)
67 atf_tc_set_md_var(tc, "descr", "Test sdp_data_size results");
70 ATF_TC_BODY(check_sdp_data_size, tc)
72 uint8_t data[] = {
73 0x00, // nil
74 0x08, 0x00, // uint8
75 0x11, 0x00, 0x00, // int16
76 0x1a, 0x00, 0x00, 0x00, // uuid32
77 0x00,
78 0x28, 0x00, // bool
79 0x25, 0x00, // str8(0)
80 0x25, 0x02, 0x00, 0x00, // str8(2)
81 0x36, 0x00, 0x00, // seq16(0)
82 0x3e, 0x00, 0x05, 0x00, // alt16(5)
83 0x00, 0x00, 0x00, 0x00,
84 0x37, 0x00, 0x00, 0x00, // seq32(0)
85 0x00,
86 0x47, 0x00, 0x00, 0x00, // url32(7)
87 0x07, 0x00, 0x00, 0x00,
88 0x00, 0x00, 0x00, 0x00,
90 sdp_data_t test = { data, data + sizeof(data) };
91 sdp_data_t value;
93 ATF_REQUIRE(sdp_get_data(&test, &value));
94 ATF_CHECK_EQ(sdp_data_size(&value), 1);
96 ATF_REQUIRE(sdp_get_data(&test, &value));
97 ATF_CHECK_EQ(sdp_data_size(&value), 2);
99 ATF_REQUIRE(sdp_get_data(&test, &value));
100 ATF_CHECK_EQ(sdp_data_size(&value), 3);
102 ATF_REQUIRE(sdp_get_data(&test, &value));
103 ATF_CHECK_EQ(sdp_data_size(&value), 5);
105 ATF_REQUIRE(sdp_get_data(&test, &value));
106 ATF_CHECK_EQ(sdp_data_size(&value), 2);
108 ATF_REQUIRE(sdp_get_data(&test, &value));
109 ATF_CHECK_EQ(sdp_data_size(&value), 2);
111 ATF_REQUIRE(sdp_get_data(&test, &value));
112 ATF_CHECK_EQ(sdp_data_size(&value), 4);
114 ATF_REQUIRE(sdp_get_data(&test, &value));
115 ATF_CHECK_EQ(sdp_data_size(&value), 3);
117 ATF_REQUIRE(sdp_get_data(&test, &value));
118 ATF_CHECK_EQ(sdp_data_size(&value), 8);
120 ATF_REQUIRE(sdp_get_data(&test, &value));
121 ATF_CHECK_EQ(sdp_data_size(&value), 5);
123 ATF_REQUIRE(sdp_get_data(&test, &value));
124 ATF_CHECK_EQ(sdp_data_size(&value), 12);
126 ATF_CHECK_EQ(test.next, test.end);
129 ATF_TP_ADD_TCS(tp)
132 ATF_TP_ADD_TC(tp, check_sdp_data_type);
133 ATF_TP_ADD_TC(tp, check_sdp_data_size);
135 return atf_no_error();