aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2016-08-31 15:05:22 +0100
committerMichael Brown <mcb30@ipxe.org>2016-08-31 15:06:36 +0100
commit161c80af5bacf52a9f488551361c25be601eabb9 (patch)
tree03930a2f5121bfed2a9436c47998ce385eca2f90 /src/tests
parentff28b22568ebc2cb885beae5d0c95ddcf94dca8a (diff)
downloadipxe-161c80af5bacf52a9f488551361c25be601eabb9.zip
ipxe-161c80af5bacf52a9f488551361c25be601eabb9.tar.gz
ipxe-161c80af5bacf52a9f488551361c25be601eabb9.tar.bz2
[list] Add list_next_entry() and list_prev_entry()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/list_test.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tests/list_test.c b/src/tests/list_test.c
index 352c87d..f016a32 100644
--- a/src/tests/list_test.c
+++ b/src/tests/list_test.c
@@ -396,6 +396,29 @@ static void list_test_exec ( void ) {
ok ( list_first_entry ( list, struct list_test, list ) == NULL );
ok ( list_last_entry ( list, struct list_test, list ) == NULL );
+ /* Test list_next_entry() and list_prev_entry() */
+ INIT_LIST_HEAD ( list );
+ list_add_tail ( &list_tests[5].list, list );
+ list_add_tail ( &list_tests[3].list, list );
+ list_add_tail ( &list_tests[1].list, list );
+ list_add_tail ( &list_tests[7].list, list );
+ ok ( list_prev_entry ( &list_tests[5], list, list ) == NULL );
+ ok ( list_next_entry ( &list_tests[5], list, list ) == &list_tests[3] );
+ ok ( list_prev_entry ( &list_tests[3], list, list ) == &list_tests[5] );
+ ok ( list_next_entry ( &list_tests[3], list, list ) == &list_tests[1] );
+ ok ( list_prev_entry ( &list_tests[1], list, list ) == &list_tests[3] );
+ ok ( list_next_entry ( &list_tests[1], list, list ) == &list_tests[7] );
+ ok ( list_prev_entry ( &list_tests[7], list, list ) == &list_tests[1] );
+ ok ( list_next_entry ( &list_tests[7], list, list ) == NULL );
+ list_del ( &list_tests[7].list );
+ ok ( list_prev_entry ( &list_tests[1], list, list ) == &list_tests[3] );
+ ok ( list_next_entry ( &list_tests[1], list, list ) == NULL );
+ list_del ( &list_tests[3].list );
+ ok ( list_prev_entry ( &list_tests[5], list, list ) == NULL );
+ ok ( list_next_entry ( &list_tests[5], list, list ) == &list_tests[1] );
+ ok ( list_prev_entry ( &list_tests[1], list, list ) == &list_tests[5] );
+ ok ( list_next_entry ( &list_tests[1], list, list ) == NULL );
+
/* Test list_for_each() */
INIT_LIST_HEAD ( list );
list_add_tail ( &list_tests[6].list, list );