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/hci.h>
14 
15 ZTEST_SUITE(test_hci, NULL, NULL, NULL, NULL, NULL);
16 
ZTEST(test_hci,test_bt_hci_err_to_str)17 ZTEST(test_hci, test_bt_hci_err_to_str)
18 {
19 	/* Test a couple of entries */
20 	zassert_mem_equal(bt_hci_err_to_str(BT_HCI_ERR_CONN_TIMEOUT),
21 			  "BT_HCI_ERR_CONN_TIMEOUT", strlen("BT_HCI_ERR_CONN_TIMEOUT"));
22 	zassert_mem_equal(bt_hci_err_to_str(BT_HCI_ERR_REMOTE_USER_TERM_CONN),
23 			  "BT_HCI_ERR_REMOTE_USER_TERM_CONN",
24 			  strlen("BT_HCI_ERR_REMOTE_USER_TERM_CONN"));
25 	zassert_mem_equal(bt_hci_err_to_str(BT_HCI_ERR_TOO_EARLY),
26 			  "BT_HCI_ERR_TOO_EARLY", strlen("BT_HCI_ERR_TOO_EARLY"));
27 
28 	/* Test a entries that is not used */
29 	zassert_mem_equal(bt_hci_err_to_str(0x2b),
30 			  "(unknown)", strlen("(unknown)"));
31 	zassert_mem_equal(bt_hci_err_to_str(0xFF),
32 			  "(unknown)", strlen("(unknown)"));
33 
34 	for (uint16_t i = 0; i <= UINT8_MAX; i++) {
35 		zassert_not_null(bt_hci_err_to_str(i), ": %d", i);
36 	}
37 }
38