当前位置: 首页>>代码示例>>C++>>正文


C++ UtlDList::first方法代码示例

本文整理汇总了C++中UtlDList::first方法的典型用法代码示例。如果您正苦于以下问题:C++ UtlDList::first方法的具体用法?C++ UtlDList::first怎么用?C++ UtlDList::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UtlDList的用法示例。


在下文中一共展示了UtlDList::first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testFirst_And_Last

    /*!a  Test case to test the first() and last() method. 
    *
    *     The test data for this test case is :-
    *     a) Test the first and last element after appending
    *     b) Test the first and last element after insertAt(midlevel)
    *     c) Test the first and last element after insertAt(0) 
    *     d) Test the first and last element after insertAt(last)
    */
    void testFirst_And_Last()
    {
        const char* prefix1 = "Test the first() method "; 
        const char* prefix2 = "Test the last() method " ; 
        string msg ; 
        UtlContainable* uActual ; 
        UtlContainable* uData ; 
        UtlContainable* uExpected ; 

        const char* Msgs[] = { \
               "after appending ", \
               "after insertAt(0) ", \
               "after insertAt(last) ", \
               "after insertAt(mid-level) " \
        } ;

        // Since this testcase requires a different test data 
        // for each of its test data, the regula test-matrix
        // technique is not being used here. 

        // create a new list and append one element to it. 
        UtlDList testList ; 
        uData = commonContainables[0] ; 
        testList.append(uData); 
        
        // Test the first() and last() element immeidately after
        // appending to an empty list. 
        TestUtilities::createMessage(2, &msg, prefix1, Msgs[0]);
        uActual = testList.first() ;
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), uData, uActual) ;
        uActual = testList.last() ;  
        TestUtilities::createMessage(2, &msg, prefix2, Msgs[0]) ; 
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), uData, uActual) ; 

        // insert more values to populate the List
        testList.append(commonContainables[1]) ; 
        testList.append(commonContainables[2]) ; 

        // test the first() / last() methods 
        // after insertAt(0..)
        uData = commonContainables[3] ;
        testList.insertAt(0, uData) ;
        uExpected = commonContainables[3] ;
        uActual = testList.first() ;
        TestUtilities::createMessage(2, &msg, prefix1, Msgs[1]) ;
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), uExpected, uActual) ;
        uExpected = commonContainables[2] ; 
        uActual = testList.last() ;
        TestUtilities::createMessage(2, &msg, prefix2, Msgs[1]) ;
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), uExpected, uActual) ;        

        // test after inserting at the last location
        uData = commonContainables[4] ; 
        testList.insertAt(4, uData) ; 
        uExpected = commonContainables[3] ; 
        uActual = testList.first() ; 
        TestUtilities::createMessage(2, &msg, prefix1, Msgs[2]) ; 
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), uExpected, uActual) ; 
        uExpected = commonContainables[4] ; 
        uActual = testList.last() ; 
        TestUtilities::createMessage(2, &msg, prefix2, Msgs[2]) ; 
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), uExpected, uActual) ; 

        //test after inserting at the midLocation
        uData = commonContainables[5] ; 
        testList.insertAt(2, uData) ; 
        uExpected = commonContainables[3] ; 
        uActual = testList.first() ; 
        TestUtilities::createMessage(2, &msg, prefix1, Msgs[3]) ; 
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), uExpected, uActual) ; 
        uExpected = commonContainables[4] ; 
        uActual = testList.last() ; 
        TestUtilities::createMessage(2, &msg, prefix2, Msgs[3]) ; 
        CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.data(), uExpected, uActual) ; 

    } //testFirst_And_Last
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:84,代码来源:UtlDList.cpp


注:本文中的UtlDList::first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。