Ejemplo n.º 1
0
    /*!a Test case for the get() method. 
    * 
    *    The test data for this test is :-
    *       1) The first entry is a CollectableString
    *       2) The first entry is a CollectableInt
    *       3) The List has only one entry
    *       4) The List has no entries
    */ 
    void testGet()
    {
        const int testCount = 4 ;
        const char* prefix = "Verify the get() method for a list when " ; 
        const char* Msgs[] = { \
                     "the first entry is a CollectableString", \
                     "the first entry is a CollectableInt", \
                     "when the list has only one entry", \
                     "when the list is empty" \
        } ; 
        const char* suffix1 = ":- verify return value" ; 
        const char* suffix2 = ":- verify the number of entries in the list" ; 
        UtlDList testList ; 
        testList.append(&commonString1) ; 
        testList.append(&commonInt1) ; 
        testList.append(&commonString2) ; 

        UtlContainable* expectedValue[] = { \
                          &commonString1 , &commonInt1, &commonString2, NULL \
        } ; 
        int entryCount[]  = { 2, 1, 0, 0 } ; 
        for (int i = 0 ; i < testCount ; i++)
        {
            UtlContainable* actual = testList.get() ; 
            string msg ; 
            TestUtilities::createMessage(3, &msg, prefix, Msgs[i], suffix1) ; 
            CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), expectedValue[i], actual) ; 
            TestUtilities::createMessage(3, &msg, prefix, Msgs[i], suffix2) ; 
            CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), entryCount[i], (int)testList.entries()) ;
        }
    } //testGet()