1*5a4807faSplunky /* $NetBSD: t_sdp_match.c,v 1.2 2011/04/07 08:29:50 plunky Exp $ */
238293af7Splunky
338293af7Splunky /*-
438293af7Splunky * Copyright (c) 2011 The NetBSD Foundation, Inc.
538293af7Splunky * All rights reserved.
638293af7Splunky *
738293af7Splunky * This code is derived from software contributed to The NetBSD Foundation
838293af7Splunky * by Iain Hibbert.
938293af7Splunky *
1038293af7Splunky * Redistribution and use in source and binary forms, with or without
1138293af7Splunky * modification, are permitted provided that the following conditions
1238293af7Splunky * are met:
1338293af7Splunky * 1. Redistributions of source code must retain the above copyright
1438293af7Splunky * notice, this list of conditions and the following disclaimer.
1538293af7Splunky * 2. Redistributions in binary form must reproduce the above copyright
1638293af7Splunky * notice, this list of conditions and the following disclaimer in the
1738293af7Splunky * documentation and/or other materials provided with the distribution.
1838293af7Splunky *
1938293af7Splunky * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2038293af7Splunky * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2138293af7Splunky * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2238293af7Splunky * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2338293af7Splunky * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2438293af7Splunky * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2538293af7Splunky * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2638293af7Splunky * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2738293af7Splunky * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2838293af7Splunky * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2938293af7Splunky * POSSIBILITY OF SUCH DAMAGE.
3038293af7Splunky */
3138293af7Splunky
3238293af7Splunky #include <atf-c.h>
3338293af7Splunky
3438293af7Splunky #include <sdp.h>
3538293af7Splunky
3638293af7Splunky ATF_TC(check_sdp_match_uuid16);
3738293af7Splunky
ATF_TC_HEAD(check_sdp_match_uuid16,tc)3838293af7Splunky ATF_TC_HEAD(check_sdp_match_uuid16, tc)
3938293af7Splunky {
4038293af7Splunky
4138293af7Splunky atf_tc_set_md_var(tc, "descr", "Test sdp_match_uuid16 results");
4238293af7Splunky }
4338293af7Splunky
ATF_TC_BODY(check_sdp_match_uuid16,tc)4438293af7Splunky ATF_TC_BODY(check_sdp_match_uuid16, tc)
4538293af7Splunky {
4638293af7Splunky uint8_t data[] = {
4738293af7Splunky 0x19, 0x11, 0x11, // uuid16 0x1111
4838293af7Splunky 0x00, // nil
4938293af7Splunky 0x19, 0x12, 0x34, // uuid16 0x1234
5038293af7Splunky 0x1a, 0x00, 0x00, 0x34, // uuid32 0x00003456
5138293af7Splunky 0x56,
5238293af7Splunky 0x1c, 0x00, 0x00, 0x43, // uuid128 00004321-0000-1000-8000-00805f9b34fb
5338293af7Splunky 0x21, 0x00, 0x00, 0x10,
5438293af7Splunky 0x00, 0x80, 0x00, 0x00,
5538293af7Splunky 0x80, 0x5f, 0x9b, 0x34,
5638293af7Splunky 0xfb,
5738293af7Splunky };
5838293af7Splunky sdp_data_t test = { data, data + sizeof(data) };
5938293af7Splunky sdp_data_t nil;
6038293af7Splunky
6138293af7Splunky /*
6238293af7Splunky * sdp_match_uuid16 advances if the UUID matches the 16-bit short alias given
6338293af7Splunky */
6438293af7Splunky
6538293af7Splunky ATF_REQUIRE_EQ(sdp_match_uuid16(&test, 0x1100), false); /* mismatch */
6638293af7Splunky ATF_REQUIRE(sdp_match_uuid16(&test, 0x1111));
6738293af7Splunky
6838293af7Splunky ATF_REQUIRE_EQ(sdp_match_uuid16(&test, 0x1234), false); /* not uuid */
6938293af7Splunky ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
7038293af7Splunky ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
7138293af7Splunky ATF_REQUIRE(sdp_match_uuid16(&test, 0x1234));
7238293af7Splunky
7338293af7Splunky ATF_REQUIRE(sdp_match_uuid16(&test, 0x3456));
7438293af7Splunky
7538293af7Splunky ATF_REQUIRE_EQ(sdp_match_uuid16(&test, 0x1234), false); /* mismatch */
7638293af7Splunky ATF_REQUIRE(sdp_match_uuid16(&test, 0x4321));
7738293af7Splunky
7838293af7Splunky ATF_CHECK_EQ(test.next, test.end);
7938293af7Splunky }
8038293af7Splunky
ATF_TP_ADD_TCS(tp)8138293af7Splunky ATF_TP_ADD_TCS(tp)
8238293af7Splunky {
8338293af7Splunky
8438293af7Splunky ATF_TP_ADD_TC(tp, check_sdp_match_uuid16);
8538293af7Splunky
8638293af7Splunky return atf_no_error();
8738293af7Splunky }
88