Ejemplo n.º 1
0
	TEST_F(ListTest, CanRemoveItemFromMiddleOfList)
	{
		auto list = new Utils::List<FooMock>(getMemory(), listCapacity);

		list->emplace();
		list->emplace();
		FooMock& deletedItem = list->emplace();
		list->emplace();
		list->emplace();

		EXPECT_EQ(5, list->size());

		list->eraseAt(2);

		for(auto i = 0; i < list->size(); i++)
		{
			uint32_t number = (*list)[i].Quack();
			EXPECT_EQ(FooMock::fooConst, number);
		}

		EXPECT_EQ(4, list->size());
		EXPECT_EQ(sizeof(FooMock) * list->capacity(), getMemory().getAllocationSize(list->begin()));

		::testing::Mock::VerifyAndClearExpectations(&deletedItem);

		delete list;
	}
Ejemplo n.º 2
0
bool VECTOR<TYPE>::remove(const TYPE&  element)
{
    const int index = getFirstIndexOf(element);
    const bool found = (index >= 0);
    if(found) {
        eraseAt(index);
    }
    return found;
}
Ejemplo n.º 3
0
	TEST_F(ListTest, CanRemoveItemFromList)
	{
		auto list = new Utils::List<FooMock>(getMemory(), listCapacity);

		list->emplace();

		EXPECT_EQ(1, list->size());
		EXPECT_CALL((*list)[0], Die());

		list->eraseAt(0);

		EXPECT_EQ(0, list->size());
		EXPECT_EQ(sizeof(FooMock) * list->capacity(), getMemory().getAllocationSize(list->begin()));

		delete list;
	}
Ejemplo n.º 4
0
const TYPE& VECTOR<TYPE>::pop_front()
{
    return eraseAt(0);
}