1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2015-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include <fwk_assert.h>
9 #include <fwk_id.h>
10 #include <fwk_macros.h>
11 #include <fwk_test.h>
12 
13 #include <stddef.h>
14 
test_module_idx_of_module_id(void)15 static void test_module_idx_of_module_id(void)
16 {
17     fwk_id_t id = FWK_ID_MODULE(42);
18 
19     assert(fwk_id_get_module_idx(id) == 42);
20 }
21 
test_element_idx_of_element_id(void)22 static void test_element_idx_of_element_id(void)
23 {
24     fwk_id_t id = FWK_ID_ELEMENT(42, 45);
25 
26     assert(fwk_id_get_element_idx(id) == 45);
27 }
28 
test_api_idx_of_api_id(void)29 static void test_api_idx_of_api_id(void)
30 {
31     fwk_id_t id = FWK_ID_API(42, 10);
32 
33     assert(fwk_id_get_api_idx(id) == 10);
34 }
35 
test_event_idx_of_event_id(void)36 static void test_event_idx_of_event_id(void)
37 {
38     fwk_id_t id = FWK_ID_EVENT(42, 58);
39 
40     assert(fwk_id_get_event_idx(id) == 58);
41 }
42 
test_notification_idx_of_notification_id(void)43 static void test_notification_idx_of_notification_id(void)
44 {
45     fwk_id_t id = FWK_ID_NOTIFICATION(42, 58);
46 
47     assert(fwk_id_get_notification_idx(id) == 58);
48 }
49 
50 static const struct fwk_test_case_desc test_case_table[] = {
51     FWK_TEST_CASE(test_module_idx_of_module_id),
52     FWK_TEST_CASE(test_element_idx_of_element_id),
53     FWK_TEST_CASE(test_api_idx_of_api_id),
54     FWK_TEST_CASE(test_event_idx_of_event_id),
55     FWK_TEST_CASE(test_notification_idx_of_notification_id),
56 };
57 
58 struct fwk_test_suite_desc test_suite = {
59     .name = "fwk_id_get_idx",
60     .test_case_count = FWK_ARRAY_SIZE(test_case_table),
61     .test_case_table = test_case_table,
62 };
63