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 static struct fwk_dlist list;
14 static struct fwk_dlist_node node[2];
15
setup(void)16 static void setup(void)
17 {
18 fwk_list_init(&list);
19 }
20
test_list_contains(void)21 static void test_list_contains(void)
22 {
23 node[0].next = node[0].prev = (struct fwk_dlist_node *)0xdead;
24 node[1].next = node[1].prev = (struct fwk_dlist_node *)0xbeef;
25 assert(fwk_list_contains(&list, &node[0]) == false);
26 assert(fwk_list_contains(&list, &node[1]) == false);
27
28 node[0].next = node[0].prev = NULL;
29 fwk_list_push_tail(&list, &node[0]);
30 assert(fwk_list_contains(&list, &node[0]) == true);
31 assert(fwk_list_contains(&list, &node[1]) == false);
32
33 node[1].next = node[1].prev = NULL;
34 fwk_list_push_tail(&list, &node[1]);
35 assert(fwk_list_contains(&list, &node[0]) == true);
36 assert(fwk_list_contains(&list, &node[1]) == true);
37 }
38
39 static const struct fwk_test_case_desc tests[] = {
40 FWK_TEST_CASE(test_list_contains),
41 };
42
43 struct fwk_test_suite_desc test_suite = {
44 .name = "fwk_list_contains",
45 .test_case_setup = setup,
46 .test_case_table = tests,
47 .test_case_count = FWK_ARRAY_SIZE(tests),
48 };
49