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_list.h>
10 #include <fwk_macros.h>
11 #include <fwk_test.h>
12
13 #include <stddef.h>
14
15 static struct fwk_slist slist;
16 static struct fwk_dlist dlist;
17
18 static struct fwk_slist_node snodes[2];
19 static struct fwk_dlist_node dnodes[2];
20
test_case_setup(void)21 static void test_case_setup(void)
22 {
23 fwk_list_init(&slist);
24 fwk_list_init(&dlist);
25 }
26
test_slist_head_empty(void)27 static void test_slist_head_empty(void)
28 {
29 assert(fwk_list_head(&slist) == NULL);
30 }
31
test_dlist_head_empty(void)32 static void test_dlist_head_empty(void)
33 {
34 assert(fwk_list_head(&dlist) == NULL);
35 }
36
test_slist_head_one(void)37 static void test_slist_head_one(void)
38 {
39 fwk_list_push_tail(&slist, &snodes[0]);
40
41 assert(fwk_list_head(&slist) == &snodes[0]);
42 }
43
test_dlist_head_one(void)44 static void test_dlist_head_one(void)
45 {
46 fwk_list_push_tail(&dlist, &dnodes[0]);
47
48 assert(fwk_list_head(&dlist) == &dnodes[0]);
49 }
50
51 static const struct fwk_test_case_desc test_case_table[] = {
52 FWK_TEST_CASE(test_slist_head_empty),
53 FWK_TEST_CASE(test_dlist_head_empty),
54 FWK_TEST_CASE(test_slist_head_one),
55 FWK_TEST_CASE(test_dlist_head_one),
56 };
57
58 struct fwk_test_suite_desc test_suite = {
59 .name = "fwk_list_head",
60 .test_case_setup = test_case_setup,
61 .test_case_count = FWK_ARRAY_SIZE(test_case_table),
62 .test_case_table = test_case_table,
63 };
64