1 /*
2  * Copyright (c) 2022 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include "mocks/net_buf.h"
8 #include "mocks/net_buf_expects.h"
9 
10 #include <zephyr/bluetooth/buf.h>
11 #include <zephyr/kernel.h>
12 
expect_single_call_net_buf_unref(struct net_buf * buf)13 void expect_single_call_net_buf_unref(struct net_buf *buf)
14 {
15 	const char *func_name = "net_buf_unref";
16 
17 	zassert_equal(net_buf_unref_fake.call_count, 1, "'%s()' was called more than once",
18 		      func_name);
19 
20 	zassert_equal(net_buf_unref_fake.arg0_val, buf,
21 		      "'%s()' was called with incorrect '%s' value", func_name, "buf");
22 }
23 
expect_not_called_net_buf_unref(void)24 void expect_not_called_net_buf_unref(void)
25 {
26 	const char *func_name = "net_buf_unref";
27 
28 	zassert_equal(net_buf_unref_fake.call_count, 0, "'%s()' was called unexpectedly",
29 		      func_name);
30 }
31 
expect_single_call_net_buf_simple_add(struct net_buf_simple * buf,size_t len)32 void expect_single_call_net_buf_simple_add(struct net_buf_simple *buf, size_t len)
33 {
34 	const char *func_name = "net_buf_simple_add";
35 
36 	zassert_equal(net_buf_simple_add_fake.call_count, 1, "'%s()' was called more than once",
37 		      func_name);
38 
39 	zassert_equal(net_buf_simple_add_fake.arg0_val, buf,
40 		      "'%s()' was called with incorrect '%s' value", func_name, "buf");
41 	zassert_equal(net_buf_simple_add_fake.arg1_val, len,
42 		      "'%s()' was called with incorrect '%s' value", func_name, "len");
43 }
44 
expect_not_called_net_buf_simple_add(void)45 void expect_not_called_net_buf_simple_add(void)
46 {
47 	const char *func_name = "net_buf_simple_add";
48 
49 	zassert_equal(net_buf_simple_add_fake.call_count, 0, "'%s()' was called unexpectedly",
50 		      func_name);
51 }
52