Browse Source

List fix remove() and update testing

sbg
Daniel Agar 6 years ago
parent
commit
aee8f13289
  1. 2
      src/include/containers/BlockingList.hpp
  2. 8
      src/include/containers/List.hpp
  3. 2
      src/systemcmds/tests/test_List.cpp

2
src/include/containers/BlockingList.hpp

@ -68,7 +68,7 @@ public: @@ -68,7 +68,7 @@ public:
return List<T>::remove(removeNode);
}
size_t size() const
size_t size()
{
LockGuard lg{_mutex};
return List<T>::size();

8
src/include/containers/List.hpp

@ -70,7 +70,13 @@ public: @@ -70,7 +70,13 @@ public:
{
// base case
if (removeNode == _head) {
_head = nullptr;
if (_head->getSibling() != nullptr) {
_head = _head->getSibling();
} else {
_head = nullptr;
}
return true;
}

2
src/systemcmds/tests/test_List.cpp

@ -141,6 +141,8 @@ bool ListTest::test_remove() @@ -141,6 +141,8 @@ bool ListTest::test_remove()
for (auto t : list1) {
ut_assert_true(t->i != remove_i);
}
ut_assert_true(list1.size() == 100 - remove_i - 1);
}
// list should now be empty

Loading…
Cancel
Save