void Coordinates_test:: t_element() { Coordinates c; c << 1.0 << -2.0; c.at(1)= -3; QCOMPARE(c.at(1), -3.0); QCOMPARE(c.back(), -3.0); QCOMPARE(c.front(), 1.0); c[1]= -2.0; QCOMPARE(c[1],-2.0); QCOMPARE(c.first(), 1.0); c.first()= 2.0; QCOMPARE(c.first(), 2.0); QCOMPARE(c.last(), -2.0); c.last()= 0.0; QCOMPARE(c.first()+c.last(), 2.0); coordT *c4= &c.first(); const coordT *c5= &c.first(); QCOMPARE(c4, c5); coordT *c6= &c.last(); const coordT *c7= &c.last(); QCOMPARE(c6, c7); Coordinates c2= c.mid(1); QCOMPARE(c2.count(), 1); c << 3.0; Coordinates c3= c.mid(1,1); QCOMPARE(c2, c3); QCOMPARE(c3.value(-1, -1.0), -1.0); QCOMPARE(c3.value(3, 4.0), 4.0); QCOMPARE(c.value(2, 4.0), 3.0); }//t_element
void Coordinates_test:: t_readwrite() { Coordinates c; c.clear(); QCOMPARE(c.count(), 0); c << 1.0 << 3.0; c.clear(); QCOMPARE(c.count(), 0); c << 1.0 << 3.0; c.erase(c.begin(), c.end()); QCOMPARE(c.count(), 0); c << 1.0 << 0.0; Coordinates::iterator i= c.erase(c.begin()); QCOMPARE(*i, 0.0); i= c.insert(c.end(), 1.0); QCOMPARE(*i, 1.0); QCOMPARE(c.count(), 2); c.pop_back(); QCOMPARE(c.count(), 1); // 0 QCOMPARE(c[0], 0.0); c.push_back(2.0); QCOMPARE(c.count(), 2); c.append(3.0); QCOMPARE(c.count(), 3); // 0, 2, 3 QCOMPARE(c[2], 3.0); c.insert(0, 4.0); QCOMPARE(c[0], 4.0); QCOMPARE(c[3], 3.0); c.insert(c.count(), 5.0); QCOMPARE(c.count(), 5); // 4, 0, 2, 3, 5 QCOMPARE(c[4], 5.0); c.move(4, 0); QCOMPARE(c.count(), 5); // 5, 4, 0, 2, 3 QCOMPARE(c[0], 5.0); c.pop_front(); QCOMPARE(c.count(), 4); QCOMPARE(c[0], 4.0); c.prepend(6.0); QCOMPARE(c.count(), 5); // 6, 4, 0, 2, 3 QCOMPARE(c[0], 6.0); c.push_front(7.0); QCOMPARE(c.count(), 6); QCOMPARE(c[0], 7.0); c.removeAt(1); QCOMPARE(c.count(), 5); // 7, 4, 0, 2, 3 QCOMPARE(c[1], 4.0); c.removeFirst(); QCOMPARE(c.count(), 4); // 4, 0, 2, 3 QCOMPARE(c[0], 4.0); c.removeLast(); QCOMPARE(c.count(), 3); QCOMPARE(c.last(), 2.0); c.replace(2, 8.0); QCOMPARE(c.count(), 3); // 4, 0, 8 QCOMPARE(c[2], 8.0); c.swap(0, 2); QCOMPARE(c[2], 4.0); double d= c.takeAt(2); QCOMPARE(c.count(), 2); // 8, 0 QCOMPARE(d, 4.0); double d2= c.takeFirst(); QCOMPARE(c.count(), 1); // 0 QCOMPARE(d2, 8.0); double d3= c.takeLast(); QVERIFY(c.isEmpty()); \ QCOMPARE(d3, 0.0); }//t_readwrite