Commit 419c540a authored by Aleksander Wasaznik's avatar Aleksander Wasaznik Committed by Carles Cufi
Browse files

Bluetooth: Test: Split up test "uuid"

Create a separate file and test suite for each tested function.

Signed-off-by: default avatarAleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
parent a2bbc422
Loading
Loading
Loading
Loading
+38 −0
Changes for tests/bluetooth/uuid/src/test_bt_uuid_cmp.c: 38 added lines, 0 removed lines.
Original line number Diff line number Diff line
/* Copyright (c) 2019 Intel Corporation
 * SPDX-License-Identifier: Apache-2.0
 */

#include <stdint.h>
#include <zephyr/ztest.h>
#include <zephyr/bluetooth/uuid.h>

static struct bt_uuid_16 uuid_16 = BT_UUID_INIT_16(0xffff);

static struct bt_uuid_128 uuid_128 = BT_UUID_INIT_128(
	0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
	0x00, 0x10, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00);

ZTEST_SUITE(bt_uuid_cmp, NULL, NULL, NULL, NULL, NULL);

ZTEST(bt_uuid_cmp, test_uuid_cmp)
{
	/* Compare UUID 16 bits */
	zassert_false(bt_uuid_cmp(&uuid_16.uuid, BT_UUID_DECLARE_16(0xffff)),
		     "Test UUIDs don't match");

	/* Compare UUID 128 bits */
	zassert_false(bt_uuid_cmp(&uuid_128.uuid, BT_UUID_DECLARE_16(0xffff)),
		     "Test UUIDs don't match");

	/* Compare UUID 16 bits with UUID 128 bits */
	zassert_false(bt_uuid_cmp(&uuid_16.uuid, &uuid_128.uuid),
		     "Test UUIDs don't match");

	/* Compare different UUID 16 bits */
	zassert_true(bt_uuid_cmp(&uuid_16.uuid, BT_UUID_DECLARE_16(0x0000)),
		     "Test UUIDs match");

	/* Compare different UUID 128 bits */
	zassert_true(bt_uuid_cmp(&uuid_128.uuid, BT_UUID_DECLARE_16(0x000)),
		     "Test UUIDs match");
}
+5 −40
Changes for tests/bluetooth/uuid/src/test_bt_uuid_create.c: 5 added lines, 40 removed lines.
Original line number Diff line number Diff line
/* main.c - Application main entry point */

/*
 * Copyright (c) 2019 Intel Corporation
 *
/* Copyright (c) 2019 Intel Corporation
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/zephyr.h>
#include <stddef.h>
#include <ztest.h>

#include <stdint.h>
#include <zephyr/ztest.h>
#include <zephyr/bluetooth/uuid.h>

static struct bt_uuid_16 uuid_16 = BT_UUID_INIT_16(0xffff);

static struct bt_uuid_128 uuid_128 = BT_UUID_INIT_128(
	0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
	0x00, 0x10, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00);

static struct bt_uuid_128 le_128 = BT_UUID_INIT_128(
	0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
	0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00);

ZTEST_SUITE(uuid_tests, NULL, NULL, NULL, NULL, NULL);

ZTEST(uuid_tests, test_uuid_cmp)
{
	/* Compare UUID 16 bits */
	zassert_false(bt_uuid_cmp(&uuid_16.uuid, BT_UUID_DECLARE_16(0xffff)),
		     "Test UUIDs don't match");

	/* Compare UUID 128 bits */
	zassert_false(bt_uuid_cmp(&uuid_128.uuid, BT_UUID_DECLARE_16(0xffff)),
		     "Test UUIDs don't match");

	/* Compare UUID 16 bits with UUID 128 bits */
	zassert_false(bt_uuid_cmp(&uuid_16.uuid, &uuid_128.uuid),
		     "Test UUIDs don't match");

	/* Compare different UUID 16 bits */
	zassert_true(bt_uuid_cmp(&uuid_16.uuid, BT_UUID_DECLARE_16(0x0000)),
		     "Test UUIDs match");

	/* Compare different UUID 128 bits */
	zassert_true(bt_uuid_cmp(&uuid_128.uuid, BT_UUID_DECLARE_16(0x000)),
		     "Test UUIDs match");
}
ZTEST_SUITE(bt_uuid_create, NULL, NULL, NULL, NULL, NULL);

ZTEST(uuid_tests, test_uuid_create)
ZTEST(bt_uuid_create, test_uuid_create)
{
	uint8_t le16[] = { 0x01, 0x00 };
	uint8_t be16[] = { 0x00, 0x01 };