Ejemplo n.º 1
0
    /*!a Test case to test the destroy() 
    *    method. 
    */ 
    void testRemoveAndDestroy()
    {
        const char* prefix  = "test the destroy() method " ; 
        
        UtlContainableTestStub uStub(0) ;
        UtlContainableTestStub* uStubPtr ;
        uStubPtr = new UtlContainableTestStub(1) ;
        commonList.append(&uStub) ;
        commonList.append(uStubPtr) ;
        
        int cCountBefore = UtlContainableTestStub :: getCount() ; 

        UtlBoolean returnValue = commonList.destroy(uStubPtr) ; 
        UtlContainable* uLast = commonList.last() ; 
        string msg ; 
        TestUtilities::createMessage(2, &msg, prefix, ":- Verify the return value") ; 
        CPPUNIT_ASSERT_MESSAGE(msg.data(), returnValue) ;
        TestUtilities::createMessage(2, &msg, prefix, ":- Verify that the entry is removed") ; 
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), (void*)&uStub, (void*)uLast) ; 
        // The CollectableTestStub has been implemented such that a static counter gets decremented
        // for every descruction of an object instance. To verify that the object was destroyed, 
        // verify that the static count went down. 
        int cCountAfter = UtlContainableTestStub :: getCount() ;
        TestUtilities::createMessage(2, &msg, prefix, ":- Verify that the object was deleted") ; 
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), cCountBefore -1, cCountAfter) ; 
    }