Example #1
0
void tst_Q3ValueList::beginEnd()
{
    Q3ValueList<int> a;
    a.append( 1 );
    a.append( 10 );
    a.append( 100 );

    Q3ValueListConstIterator<int> cit1 = a.begin();
    Q3ValueListConstIterator<int> cit2 = a.end();
    QCOMPARE( *(cit1), 1 );
    QCOMPARE( *(--cit2), 100 );

    Q3ValueListIterator<int> it1 = a.begin();
    Q3ValueListIterator<int> it2 = a.end();
    *(it1) = 2;
    *(--it2) = 200;

    // Using const iterators to verify
    QCOMPARE( *(cit1), 2 );
    QCOMPARE( *(cit2), 200 );

    Q3ValueList<int> b;
    b.append( 1 );
    Q3ValueList<int> b2 = b;
    QVERIFY( b.constBegin() == b2.constBegin() );
    QVERIFY( b.constEnd() == b2.constEnd() );
    b2.append( 2 );
    QVERIFY( b.constBegin() != b2.constBegin() );
    QVERIFY( b2.constBegin() == b2.constBegin() );
}