sys: lists: Add tests for newly-added list len functions

This commit adds tests for the newly added list len APIs to the
corresponding test cases. It is noted that the test functions calculate
equivalent values manually using several different internal list
functions. This has been left unmodified to ensure that the manual ways
using each of the various for_each functions results in the same value
as the new list_len() functions.

Signed-off-by: J M <montytyper@msn.com>
This commit is contained in:
J M 2023-06-11 13:02:00 -07:00 committed by Carles Cufí
commit 9cf437728e
3 changed files with 24 additions and 0 deletions

View file

@ -39,6 +39,10 @@ static inline bool verify_emptyness(sys_dlist_t *list)
return false; return false;
} }
if (sys_dlist_len(list) != 0) {
return false;
}
count = 0; count = 0;
SYS_DLIST_FOR_EACH_NODE(list, node) { SYS_DLIST_FOR_EACH_NODE(list, node) {
count++; count++;
@ -97,6 +101,10 @@ static inline bool verify_content_amount(sys_dlist_t *list, int amount)
return false; return false;
} }
if (sys_dlist_len(list) != amount) {
return false;
}
count = 0; count = 0;
SYS_DLIST_FOR_EACH_NODE(list, node) { SYS_DLIST_FOR_EACH_NODE(list, node) {
count++; count++;

View file

@ -40,6 +40,10 @@ static inline bool verify_emptyness(sys_sflist_t *list)
return false; return false;
} }
if (sys_sflist_len(list) != 0) {
return false;
}
count = 0; count = 0;
SYS_SFLIST_FOR_EACH_NODE(list, node) { SYS_SFLIST_FOR_EACH_NODE(list, node) {
count++; count++;
@ -98,6 +102,10 @@ static inline bool verify_content_amount(sys_sflist_t *list, int amount)
return false; return false;
} }
if (sys_sflist_len(list) != amount) {
return false;
}
count = 0; count = 0;
SYS_SFLIST_FOR_EACH_NODE(list, node) { SYS_SFLIST_FOR_EACH_NODE(list, node) {
count++; count++;

View file

@ -40,6 +40,10 @@ static inline bool verify_emptyness(sys_slist_t *list)
return false; return false;
} }
if (sys_slist_len(list) != 0) {
return false;
}
count = 0; count = 0;
SYS_SLIST_FOR_EACH_NODE(list, node) { SYS_SLIST_FOR_EACH_NODE(list, node) {
count++; count++;
@ -98,6 +102,10 @@ static inline bool verify_content_amount(sys_slist_t *list, int amount)
return false; return false;
} }
if (sys_slist_len(list) != amount) {
return false;
}
count = 0; count = 0;
SYS_SLIST_FOR_EACH_NODE(list, node) { SYS_SLIST_FOR_EACH_NODE(list, node) {
count++; count++;