Example #1
0
void Coordinates_test::
t_search()
{
    Coordinates c;
    c << 1.0 << 3.0 << 1.0;
    QVERIFY(c.contains(1.0));
    QVERIFY(c.contains(3.0));
    QVERIFY(!c.contains(0.0));
    QCOMPARE(c.count(1.0), 2);
    QCOMPARE(c.count(3.0), 1);
    QCOMPARE(c.count(0.0), 0);
    QCOMPARE(c.indexOf(1.0), 0);
    QCOMPARE(c.indexOf(3.0), 1);
    QCOMPARE(c.indexOf(1.0, -1), 2);
    QCOMPARE(c.indexOf(3.0, -1), -1);
    QCOMPARE(c.indexOf(3.0, -2), 1);
    QCOMPARE(c.indexOf(1.0, -3), 0);
    QCOMPARE(c.indexOf(1.0, -4), 0);
    QCOMPARE(c.indexOf(1.0, 1), 2);
    QCOMPARE(c.indexOf(3.0, 2), -1);
    QCOMPARE(c.indexOf(1.0, 2), 2);
    QCOMPARE(c.indexOf(1.0, 3), -1);
    QCOMPARE(c.indexOf(1.0, 4), -1);
    QCOMPARE(c.lastIndexOf(1.0), 2);
    QCOMPARE(c.lastIndexOf(3.0), 1);
    QCOMPARE(c.lastIndexOf(1.0, -1), 2);
    QCOMPARE(c.lastIndexOf(3.0, -1), 1);
    QCOMPARE(c.lastIndexOf(3.0, -2), 1);
    QCOMPARE(c.lastIndexOf(1.0, -3), 0);
    QCOMPARE(c.lastIndexOf(1.0, -4), -1);
    QCOMPARE(c.lastIndexOf(1.0, 1), 0);
    QCOMPARE(c.lastIndexOf(3.0, 2), 1);
    QCOMPARE(c.lastIndexOf(1.0, 2), 2);
    QCOMPARE(c.lastIndexOf(1.0, 3), 2);
    QCOMPARE(c.lastIndexOf(1.0, 4), 2);
    c.removeAll(3.0);
    QCOMPARE(c.count(), 2);
    c.removeAll(4.0);
    QCOMPARE(c.count(), 2);
    c.removeAll(1.0);
    QCOMPARE(c.count(), 0);
    c.removeAll(4.0);
    QCOMPARE(c.count(), 0);
}//t_search