BOOST_AUTO_TEST_CASE_TEMPLATE( testReplace6, DPQ, both )
{
    DPQ dpq;

    dpq.push( 5 );
    dpq.push( 4 );
    dpq.push( 3 );
    const ID id( dpq.push( 1 ) );
    BOOST_CHECK( dpq.check() );

    BOOST_CHECK_EQUAL( 4, dpq.getSize() );
    BOOST_CHECK_EQUAL( 1, dpq.getTop() );

    dpq.replace( id, 3 );  // 1->3 top down

    BOOST_CHECK( dpq.check() );
    BOOST_CHECK_EQUAL( 4, dpq.getSize() );

    BOOST_CHECK_EQUAL( 3, dpq.getTop() );
    dpq.popTop();
    BOOST_CHECK_EQUAL( 3, dpq.getTop() );
    dpq.popTop();
    BOOST_CHECK_EQUAL( 4, dpq.getTop() );
    dpq.popTop();
    BOOST_CHECK_EQUAL( 5, dpq.getTop() );
    dpq.popTop();

    BOOST_CHECK( dpq.isEmpty() );
    BOOST_CHECK( dpq.check() );
}
Esempio n. 2
0
    void testReplace()
    {
        DPQ dpq;

        dpq.push( 5 );
        const Index id( dpq.push( 4 ) );
        dpq.push( 3 );
        dpq.push( 1 );

        BOOST_CHECK_EQUAL( 1, dpq.getTop() );

        dpq.replace( id, 2 );  // 4->2

        BOOST_CHECK( dpq.checkConsistency() );
        BOOST_CHECK_EQUAL( 1, dpq.getTop() );

        dpq.popTop();
        BOOST_CHECK_EQUAL( 2, dpq.getTop() );
        dpq.popTop();
        BOOST_CHECK_EQUAL( 3, dpq.getTop() );
        dpq.popTop();
        BOOST_CHECK_EQUAL( 5, dpq.getTop() );
        dpq.popTop();

        BOOST_CHECK( dpq.isEmpty() );
        BOOST_CHECK( dpq.checkConsistency() );
    }