本文整理汇总了C++中UtlDList::removeAll方法的典型用法代码示例。如果您正苦于以下问题:C++ UtlDList::removeAll方法的具体用法?C++ UtlDList::removeAll怎么用?C++ UtlDList::removeAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UtlDList
的用法示例。
在下文中一共展示了UtlDList::removeAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testIsEmpty
/*!a Test case for the isEmpty() method.
* The test data for this test are :-
* a) When the list has just been created.
* b) When the list has one entry in it
* c) When the list has multiple entries in it.
* d) When all the entries in a list have been removed using get.
* e) When all the entries in a list have been removed using removeAll()
*/
void testIsEmpty()
{
const int testCount = 5 ;
const char* prefix = "Test the isEmpty() method when " ;
const char* Msgs[] = { \
"the list has just been created" , \
"the list has just one entry in it", \
"the list has multiple entries in it", \
"all the list entries have been retreieved using get()", \
"all the list entries have been retreived using removeAll()" \
} ;
UtlDList newList ;
UtlDList secondNewList ;
UtlDList commonList_Clone ;
// first populate a list and then retreive all elements using get
for (int i = 0 ; i < commonEntriesCount ; i++)
{
commonList_Clone.append(commonContainables_Clone[i]) ;
}
for (int j = 0 ; j < commonEntriesCount; j++)
{
commonList_Clone.get();
}
UtlString uS1 = UtlString("Lone Entry") ;
newList.append(&uS1) ;
// populate the second list and then clear all entries.
secondNewList.append(&uS1) ;
UtlInt uI1 = UtlInt(232) ;
secondNewList.append(&uI1) ;
secondNewList.removeAll() ;
UtlDList* testLists[] = { \
&emptyList, &newList, &commonList, &commonList_Clone, &secondNewList \
} ;
bool expectedValue[] = { true, false, false, true, true } ;
for (int k = 0 ; k < testCount; k++)
{
string msg ;
TestUtilities::createMessage(2, &msg, prefix, Msgs[k]) ;
UtlBoolean actual = testLists[k] -> isEmpty() ;
CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), (UtlBoolean)expectedValue[k], \
actual) ;
}
} // testIsEmpty
示例2: testClear
/*!a test the removeAll() method.
*
* The test data for this method is
* a) When the list is empty
* b) When the list has one entry.
* c) When the list multiple entries
* d) When removeAll has been called and entries are added again
* d) When the removeAll is called twice on the list.
*/
void testClear()
{
const int testCount = 5 ;
const char* prefix = "Test the removeAll() method when :- " ;
const char* Msgs[] = { \
"the list is empty", \
"the list has one entry", \
"the list has multiple entries", \
"removeAll() has been called and entries are added again", \
"removeAll() has already been called", \
} ;
const char* suffix = " :- Verify number of entries after removeAll()" ;
UtlDList uSingleList ;
UtlDList uAddAfterClear ;
UtlDList uDoubleClear ;
uSingleList.append(&commonString1) ;
// call removeAll() on a list and then add entries again.
uAddAfterClear.append(&commonInt1) ;
uAddAfterClear.append(&commonString1) ;
uAddAfterClear.removeAll() ;
uAddAfterClear.append(&commonInt2) ;
// call removeAll on a list twice.
uDoubleClear.append(&commonString3) ;
uDoubleClear.append(&commonInt3) ;
uDoubleClear.removeAll() ;
UtlDList* testLists[] = { \
&emptyList, &uSingleList, &commonList, &uAddAfterClear, &uDoubleClear
} ;
int expectedEntries[] = { 0 , 0, 0, 1, 0 } ;
// since we are not calling removeAll for all the data, do it outside the for loop.
emptyList.removeAll() ;
uSingleList.removeAll() ;
commonList.removeAll() ;
// no removeAll() for uAddAfterClear
uDoubleClear.removeAll() ;
for ( int i = 0 ; i < testCount ; i++)
{
string msg ;
TestUtilities::createMessage(3, &msg, prefix, Msgs[i], suffix) ;
CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data() , expectedEntries[i], \
(int)testLists[i]->entries()) ;
}
} //testClear()