1 /* main.c - Application main entry point */
2
3 /*
4 * Copyright (c) 2024 Nordic Semiconductor ASA
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9 #include <zephyr/kernel.h>
10 #include <stddef.h>
11 #include <zephyr/ztest.h>
12
13 #include <zephyr/bluetooth/bluetooth.h>
14 #include <zephyr/bluetooth/conn.h>
15 #include <../subsys/bluetooth/host/smp.h>
16
17 ZTEST_SUITE(test_smp, NULL, NULL, NULL, NULL, NULL);
18
ZTEST(test_smp,test_bt_smp_err_to_str)19 ZTEST(test_smp, test_bt_smp_err_to_str)
20 {
21 /* Test a couple of entries */
22 zassert_str_equal(bt_smp_err_to_str(0x00),
23 "BT_SMP_ERR_SUCCESS");
24 zassert_str_equal(bt_smp_err_to_str(0x0a),
25 "BT_SMP_ERR_INVALID_PARAMS");
26 zassert_str_equal(bt_smp_err_to_str(0x0F),
27 "BT_SMP_ERR_KEY_REJECTED");
28
29 /* Test entries that are not used */
30 zassert_mem_equal(bt_smp_err_to_str(0x10),
31 "(unknown)", strlen("(unknown)"));
32 zassert_mem_equal(bt_smp_err_to_str(0xFF),
33 "(unknown)", strlen("(unknown)"));
34
35 for (uint16_t i = 0; i <= UINT8_MAX; i++) {
36 zassert_not_null(bt_smp_err_to_str(i), ": %d", i);
37 }
38 }
39
ZTEST(test_smp,test_bt_security_err_to_str)40 ZTEST(test_smp, test_bt_security_err_to_str)
41 {
42 /* Test a couple of entries */
43 zassert_str_equal(bt_security_err_to_str(BT_SECURITY_ERR_AUTH_FAIL),
44 "BT_SECURITY_ERR_AUTH_FAIL");
45 zassert_str_equal(bt_security_err_to_str(BT_SECURITY_ERR_KEY_REJECTED),
46 "BT_SECURITY_ERR_KEY_REJECTED");
47 zassert_str_equal(bt_security_err_to_str(BT_SECURITY_ERR_UNSPECIFIED),
48 "BT_SECURITY_ERR_UNSPECIFIED");
49
50 /* Test outside range */
51 zassert_str_equal(bt_security_err_to_str(BT_SECURITY_ERR_UNSPECIFIED + 1),
52 "(unknown)");
53
54 for (uint16_t i = 0; i <= UINT8_MAX; i++) {
55 zassert_not_null(bt_security_err_to_str(i), ": %d", i);
56 }
57 }
58