mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 18:07:47 +00:00
[linked-list] change PopAfter() parameter to be a pointer (#4599)
This commit changes `LinkedList::PopAfter()` method to accept a pointer to a previous entry as a parameter. If the previous entry pointer is NULL the entry at the head of the list is popped.
This commit is contained in:
committed by
Jonathan Hui
parent
3560ed06f7
commit
8a5f538e6f
@@ -132,13 +132,13 @@ void TestLinkedList(void)
|
||||
list.Push(e);
|
||||
VerifyLinkedListContent(&list, &e, &c, &a, &d, &b, NULL);
|
||||
|
||||
VerifyOrQuit(list.PopAfter(a) == &d, "LinkedList::PopAfter() failed");
|
||||
VerifyOrQuit(list.PopAfter(&a) == &d, "LinkedList::PopAfter() failed");
|
||||
VerifyLinkedListContent(&list, &e, &c, &a, &b, NULL);
|
||||
|
||||
VerifyOrQuit(list.PopAfter(b) == NULL, "LinkedList::PopAfter() failed");
|
||||
VerifyOrQuit(list.PopAfter(&b) == NULL, "LinkedList::PopAfter() failed");
|
||||
VerifyLinkedListContent(&list, &e, &c, &a, &b, NULL);
|
||||
|
||||
VerifyOrQuit(list.PopAfter(e) == &c, "LinkedList::PopAfter() failed");
|
||||
VerifyOrQuit(list.PopAfter(&e) == &c, "LinkedList::PopAfter() failed");
|
||||
VerifyLinkedListContent(&list, &e, &a, &b, NULL);
|
||||
|
||||
list.PushAfter(c, b);
|
||||
@@ -147,8 +147,15 @@ void TestLinkedList(void)
|
||||
list.PushAfter(d, a);
|
||||
VerifyLinkedListContent(&list, &e, &a, &d, &b, &c, NULL);
|
||||
|
||||
VerifyOrQuit(list.PopAfter(NULL) == &e, "LinkedList::PopAfter() failed");
|
||||
VerifyLinkedListContent(&list, &a, &d, &b, &c, NULL);
|
||||
|
||||
VerifyOrQuit(list.PopAfter(NULL) == &a, "LinkedList::PopAfter() failed");
|
||||
VerifyLinkedListContent(&list, &d, &b, &c, NULL);
|
||||
|
||||
list.Clear();
|
||||
VerifyOrQuit(list.IsEmpty(), "LinkedList::IsEmpty() failed after Clear()");
|
||||
VerifyOrQuit(list.PopAfter(NULL) == NULL, "LinkedList::PopAfter() failed");
|
||||
VerifyLinkedListContent(&list, NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user