1 /*
2 * Copyright (c) 2023 Codecoup
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #ifndef MOCKS_GATT_EXPECTS_H_
8 #define MOCKS_GATT_EXPECTS_H_
9
10 #include <zephyr/bluetooth/gatt.h>
11
12 #include "gatt.h"
13 #include "expects_util.h"
14
15 #define expect_bt_gatt_notify_cb_called_once(_conn, _uuid, _attr, _data, _len) \
16 do { \
17 const char *func_name = "bt_gatt_notify_cb"; \
18 struct bt_gatt_notify_params *params; \
19 \
20 IF_NOT_EMPTY(_conn, ( \
21 zassert_equal_ptr(_conn, mock_bt_gatt_notify_cb_fake.arg0_val, \
22 "'%s()' was called with incorrect '%s' value", \
23 func_name, "conn");)) \
24 \
25 params = mock_bt_gatt_notify_cb_fake.arg1_val; \
26 \
27 /* params->uuid is optional */ \
28 if (params->uuid) { \
29 IF_NOT_EMPTY(_uuid, ( \
30 zassert_true(bt_uuid_cmp(_uuid, params->uuid) == 0, \
31 "'%s()' was called with incorrect '%s' value", \
32 func_name, "params->uuid");)) \
33 } else { \
34 IF_NOT_EMPTY(_attr, ( \
35 zassert_equal_ptr(_attr, params->attr, \
36 "'%s()' was called with incorrect '%s' value", \
37 func_name, "params->attr");)) \
38 } \
39 \
40 /* assert if _data is valid, but _len is empty */ \
41 IF_EMPTY(_len, (IF_NOT_EMPTY(_data, (zassert_unreachable();)))) \
42 \
43 IF_NOT_EMPTY(_len, ( \
44 zassert_equal(_len, params->len, \
45 "'%s()' was called with incorrect '%s' value", \
46 func_name, "params->len"); \
47 expect_data(func_name, "params->data", _data, params->data, _len);)) \
48 } while (0)
49
expect_bt_gatt_notify_cb_not_called(void)50 static inline void expect_bt_gatt_notify_cb_not_called(void)
51 {
52 const char *func_name = "bt_gatt_notify_cb";
53
54 zassert_equal(0, mock_bt_gatt_notify_cb_fake.call_count,
55 "'%s()' was called unexpectedly", func_name);
56 }
57
58 #endif /* MOCKS_GATT_EXPECTS_H_ */
59