Fix SkTLList::popTail

Change-Id: Id3e4d10456be6e0e0329600f05641034f3ffdb8b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/434336
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Brian Osman 2021-07-28 15:21:03 -04:00 committed by SkCQ
parent 257ce471d5
commit 7fd83ebd39
2 changed files with 16 additions and 1 deletions

View File

@ -123,7 +123,7 @@ public:
void popTail() {
this->validate();
Node* node = fList.head();
Node* node = fList.tail();
if (node) {
this->removeNode(node);
}

View File

@ -214,6 +214,21 @@ template <unsigned int N> static void test_tllist(skiatest::Reporter* reporter)
list2.reset();
REPORTER_ASSERT(reporter, list1.isEmpty() && list2.isEmpty());
list1.addToTail(ListElement(1));
list1.addToTail(ListElement(2));
list1.addToTail(ListElement(4));
list1.addToTail(ListElement(8));
list1.popHead();
REPORTER_ASSERT(reporter, list1.count() == 3);
REPORTER_ASSERT(reporter, *list1.head() == ListElement(2));
REPORTER_ASSERT(reporter, *list1.tail() == ListElement(8));
list1.popTail();
REPORTER_ASSERT(reporter, list1.count() == 2);
REPORTER_ASSERT(reporter, *list1.head() == ListElement(2));
REPORTER_ASSERT(reporter, *list1.tail() == ListElement(4));
list1.reset();
// randomly perform insertions and deletions on a list and perform tests
int count = 0;
for (int j = 0; j < 100; ++j) {