Bug 1201997 - Part 3 - Make internally used methods private. r=froydn

--HG--
extra : rebase_source : 0cf8b2f60b98f6853d495b8caad87117b3e5b9cb
This commit is contained in:
sajitk 2015-10-29 19:57:00 +01:00
Родитель c6255f9679
Коммит 346dbc9c43
2 изменённых файлов: 8 добавлений и 56 удалений

Просмотреть файл

@ -140,11 +140,6 @@ public:
*/
void* ObjectAt(int aIndex) const;
/**
* Remove all items from container without destroying them.
*/
void Empty();
/**
* Remove and delete all items from container.
* Deletes are handled by the deallocator nsDequeFunctor
@ -161,8 +156,6 @@ public:
*/
void ForEach(nsDequeFunctor& aFunctor) const;
void SetDeallocator(nsDequeFunctor* aDeallocator);
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
@ -192,5 +185,11 @@ private:
nsDeque& operator=(const nsDeque& aOther);
bool GrowCapacity();
void SetDeallocator(nsDequeFunctor* aDeallocator);
/**
* Remove all items from container without destroying them.
*/
void Empty();
};
#endif

Просмотреть файл

@ -67,7 +67,7 @@ namespace TestNsDeque {
using namespace TestNsDeque;
TEST(NsDeque, OriginalTest)
TEST(NsDeque, OriginalTest)
{
const int size = 200;
int ints[size];
@ -181,8 +181,6 @@ TEST(NsDeque, OriginalFlaw)
}
}
TEST(NsDeque, TestObjectAt)
{
nsDeque d;
@ -279,27 +277,11 @@ TEST(NsDeque,TestEmpty)
EXPECT_EQ(nullptr, d.ObjectAt(0)) << "Invalid operation should return nullptr";
}
TEST(NsDeque,TestEmptyMethod)
TEST(NsDeque,TestEraseMethod)
{
nsDeque d;
size_t numberOfEntries = 8;
// Fill it up before calling Empty
for (size_t i = 0; i < numberOfEntries; i++) {
d.Push((void*)0xAA);
}
// Call empty
d.Empty();
// Now check it again.
EXPECT_EQ(0, d.GetSize()) <<"Size should be 0";
EXPECT_EQ(nullptr, d.Pop()) <<"Invalid operation should return nullptr";
EXPECT_EQ(nullptr, d.PopFront()) << "Invalid operation should return nullptr";
EXPECT_EQ(nullptr, d.Peek()) << "Invalid operation should return nullptr";
EXPECT_EQ(nullptr, d.PeekFront()) <<"Invalid operation should return nullptr";
EXPECT_EQ(nullptr, d.ObjectAt(0)) << "Invalid operation should return nullptr";
// Fill it up before calling Erase
for (size_t i = 0; i < numberOfEntries; i++) {
d.Push((void*)0xAA);
@ -343,35 +325,6 @@ TEST(NsDeque,TestEraseShouldCallDeallocator)
for (size_t i=0; i < NumTestValues; i++)
{
EXPECT_EQ(-1, *(testArray[i])) << "Erase should call deallocator: " << *(testArray[i]);
}
}
TEST(NsDeque,TestEmptyShouldNotCallDeallocator)
{
nsDeque d(new Deallocator());
const int NumTestValues = 8;
int* testArray[NumTestValues];
for (size_t i=0; i < NumTestValues; i++)
{
testArray[i] = new int();
*(testArray[i]) = i;
d.Push((void*)testArray[i]);
}
d.Empty();
// Now check it again.
EXPECT_EQ(0, d.GetSize()) <<"Size should be 0";
EXPECT_EQ(nullptr, d.Pop()) <<"Invalid operation should return nullptr";
EXPECT_EQ(nullptr, d.PopFront()) << "Invalid operation should return nullptr";
EXPECT_EQ(nullptr, d.Peek()) << "Invalid operation should return nullptr";
EXPECT_EQ(nullptr, d.PeekFront()) <<"Invalid operation should return nullptr";
EXPECT_EQ(nullptr, d.ObjectAt(0)) << "Invalid operation should return nullptr";
for (size_t i=0; i < NumTestValues; i++)
{
EXPECT_EQ(i, *(testArray[i])) << "Empty should not call deallocator";
}
}