zephyr/tests/bluetooth/host/id/mocks/net_buf_expects.c
Ahmed Moheb 053a7fdd37 tests: bluetooth: host: Add UT for bt_id_set_adv_random_addr()
Unit test project for bt_id_set_adv_random_addr().
This part of subsys/bluetooth/host/id.c unit testing.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2023-01-17 13:13:28 +01:00

52 lines
1.4 KiB
C

/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "mocks/net_buf.h"
#include "mocks/net_buf_expects.h"
#include <zephyr/bluetooth/buf.h>
#include <zephyr/kernel.h>
void expect_single_call_net_buf_unref(struct net_buf *buf)
{
const char *func_name = "net_buf_unref";
zassert_equal(net_buf_unref_fake.call_count, 1, "'%s()' was called more than once",
func_name);
zassert_equal(net_buf_unref_fake.arg0_val, buf,
"'%s()' was called with incorrect '%s' value", func_name, "buf");
}
void expect_not_called_net_buf_unref(void)
{
const char *func_name = "net_buf_unref";
zassert_equal(net_buf_unref_fake.call_count, 0, "'%s()' was called unexpectedly",
func_name);
}
void expect_single_call_net_buf_simple_add(struct net_buf_simple *buf, size_t len)
{
const char *func_name = "net_buf_simple_add";
zassert_equal(net_buf_simple_add_fake.call_count, 1, "'%s()' was called more than once",
func_name);
zassert_equal(net_buf_simple_add_fake.arg0_val, buf,
"'%s()' was called with incorrect '%s' value", func_name, "buf");
zassert_equal(net_buf_simple_add_fake.arg1_val, len,
"'%s()' was called with incorrect '%s' value", func_name, "len");
}
void expect_not_called_net_buf_simple_add(void)
{
const char *func_name = "net_buf_simple_add";
zassert_equal(net_buf_simple_add_fake.call_count, 0, "'%s()' was called unexpectedly",
func_name);
}