20 using std::ostringstream;
56 QCOMPARE(
c.size(), 0
U);
59 QCOMPARE(
c.count(), 1);
62 QCOMPARE(
c2.count(), 2);
65 QCOMPARE(c3.
count(), 2);
66 QCOMPARE(c3[0]+c3[1], 3.0);
68 std::vector<coordT> vc;
72 QCOMPARE(c4[0]+c4[1], 7.0);
85 QCOMPARE(
c.data()[1], 3.0);
89 std::vector<coordT> vc=
c.toStdVector();
90 QCOMPARE((
size_t)vc.size(),
c.size());
91 for(
int k= (
int)vc.size(); k--; ){
92 QCOMPARE(vc[k],
c[k]);
94 QList<coordT> qc=
c.toQList();
95 QCOMPARE(qc.count(),
c.count());
96 for(
int k= qc.count(); k--; ){
97 QCOMPARE(qc[k],
c[k]);
100 c4= std::vector<double>(2, 0.0);
101 QCOMPARE(c4.
back(), 0.0);
113 QCOMPARE(
c.at(1), -3.0);
114 QCOMPARE(
c.back(), -3.0);
115 QCOMPARE(
c.front(), 1.0);
118 QCOMPARE(
c.first(), 1.0);
120 QCOMPARE(
c.first(), 2.0);
121 QCOMPARE(
c.last(), -2.0);
123 QCOMPARE(
c.first()+
c.last(), 2.0);
131 QCOMPARE(
c2.count(), 1);
135 QCOMPARE(c3.
value(-1, -1.0), -1.0);
136 QCOMPARE(c3.
value(3, 4.0), 4.0);
137 QCOMPARE(
c.value(2, 4.0), 3.0);
144 QCOMPARE(
c.size(), 0u);
145 QCOMPARE(
c.count(), 0);
146 QVERIFY(
c.isEmpty());
148 QCOMPARE(
c.size(), 2u);
149 QCOMPARE(
c.count(), 2);
150 QVERIFY(!
c.isEmpty());
169 QCOMPARE(c3.
count(), 2);
170 QCOMPARE(c3[0], 0.0);
171 QCOMPARE(c3[1], 1.0);
173 QCOMPARE(c3.
count(), 4);
174 QCOMPARE(c3[2], 0.0);
175 QCOMPARE(c3[3], 1.0);
177 QCOMPARE(c3[4], 1.0);
179 QCOMPARE(c3.
count(), 6);
180 QCOMPARE(c3[5], 5.0);
188 QCOMPARE(
c.begin(),
c.end());
200 QCOMPARE(*(i+1), 3.0);
202 QCOMPARE(*(i-1), 1.0);
204 QVERIFY(i==
c.begin());
205 QVERIFY(i==
c.constBegin());
207 QVERIFY(i!=
c.constEnd());
209 QVERIFY(i>=
c.begin());
210 QVERIFY(i+1<=
c.end());
211 QVERIFY(i+1>
c.begin());
215 QCOMPARE(i3[1], 3.0);
222 QCOMPARE(
c.begin(),
c.end());
231 QCOMPARE(i[1], -3.0);
239 QCOMPARE(*(i+1), 3.0);
241 QCOMPARE(*(i-1), 1.0);
243 QVERIFY(i==
c.begin());
244 QVERIFY(i==
c.constBegin());
246 QVERIFY(i!=
c.constEnd());
248 QVERIFY(i>=
c.begin());
249 QVERIFY(i+1<=
c.end());
250 QVERIFY(i+1>
c.begin());
293 QCOMPARE(i.
next(), 1.0);
295 QCOMPARE(i.
next(), 3.0);
298 QCOMPARE(i.
next(), 1.0);
342 QCOMPARE(i.
next(), 1.0);
344 QCOMPARE(i.
next(), 3.0);
347 QCOMPARE(i.
next(), 1.0);
353 QCOMPARE((i.
next()= 1.0), 1.0);
356 QCOMPARE(
c.count(), 1);
358 QCOMPARE(
c.count(), 1);
362 QCOMPARE(
c.count(), 3);
371 QCOMPARE(
c.count(), 3);
374 QCOMPARE(
c.count(), 3);
377 QCOMPARE(
c.count(), 3);
379 QCOMPARE(
c.count(), 4);
380 QCOMPARE(i.
value(), 0.0);
383 QCOMPARE(
c.count(), 4);
391 QCOMPARE(i.
value(), 1.0);
409 QCOMPARE(
c.count(), 0);
412 QCOMPARE(
c.count(), 0);
413 coordT c2[4]= { 0.0, 1.0, 2.0, 3.0};
415 QCOMPARE(
c.count(), 4);
421 c.erase(
c.begin(),
c.end());
422 QCOMPARE(
c.count(), 0);
426 i=
c.insert(
c.end(), 1.0);
428 QCOMPARE(
c.count(), 2);
430 QCOMPARE(
c.count(), 1);
433 QCOMPARE(
c.count(), 2);
435 QCOMPARE(
c.count(), 3);
440 c.insert(
c.count(), 5.0);
441 QCOMPARE(
c.count(), 5);
444 QCOMPARE(
c.count(), 5);
447 QCOMPARE(
c.count(), 4);
450 QCOMPARE(
c.count(), 5);
453 QCOMPARE(
c.count(), 6);
456 QCOMPARE(
c.count(), 5);
459 QCOMPARE(
c.count(), 4);
462 QCOMPARE(
c.count(), 3);
463 QCOMPARE(
c.last(), 2.0);
465 QCOMPARE(
c.count(), 3);
469 double d=
c.takeAt(2);
470 QCOMPARE(
c.count(), 2);
472 double d2=
c.takeFirst();
473 QCOMPARE(
c.count(), 1);
475 double d3=
c.takeLast();
476 QVERIFY(
c.isEmpty()); \
484 c << 1.0 << 3.0 << 1.0;
485 QVERIFY(
c.contains(1.0));
486 QVERIFY(
c.contains(3.0));
487 QVERIFY(!
c.contains(0.0));
488 QCOMPARE(
c.count(1.0), 2);
489 QCOMPARE(
c.count(3.0), 1);
490 QCOMPARE(
c.count(0.0), 0);
491 QCOMPARE(
c.indexOf(1.0), 0);
492 QCOMPARE(
c.indexOf(3.0), 1);
493 QCOMPARE(
c.indexOf(1.0, -1), 2);
494 QCOMPARE(
c.indexOf(3.0, -1), -1);
495 QCOMPARE(
c.indexOf(3.0, -2), 1);
496 QCOMPARE(
c.indexOf(1.0, -3), 0);
497 QCOMPARE(
c.indexOf(1.0, -4), 0);
498 QCOMPARE(
c.indexOf(1.0, 1), 2);
499 QCOMPARE(
c.indexOf(3.0, 2), -1);
500 QCOMPARE(
c.indexOf(1.0, 2), 2);
501 QCOMPARE(
c.indexOf(1.0, 3), -1);
502 QCOMPARE(
c.indexOf(1.0, 4), -1);
503 QCOMPARE(
c.lastIndexOf(1.0), 2);
504 QCOMPARE(
c.lastIndexOf(3.0), 1);
505 QCOMPARE(
c.lastIndexOf(1.0, -1), 2);
506 QCOMPARE(
c.lastIndexOf(3.0, -1), 1);
507 QCOMPARE(
c.lastIndexOf(3.0, -2), 1);
508 QCOMPARE(
c.lastIndexOf(1.0, -3), 0);
509 QCOMPARE(
c.lastIndexOf(1.0, -4), -1);
510 QCOMPARE(
c.lastIndexOf(1.0, 1), 0);
511 QCOMPARE(
c.lastIndexOf(3.0, 2), 1);
512 QCOMPARE(
c.lastIndexOf(1.0, 2), 2);
513 QCOMPARE(
c.lastIndexOf(1.0, 3), 2);
514 QCOMPARE(
c.lastIndexOf(1.0, 4), 2);
516 QCOMPARE(
c.count(), 2);
518 QCOMPARE(
c.count(), 2);
520 QCOMPARE(
c.count(), 0);
522 QCOMPARE(
c.count(), 0);
529 c << 1.0 << 2.0 << 3.0;
531 os <<
"Coordinates 1-2-3\n" <<
c;
533 QString s= QString::fromStdString(os.str());
534 QCOMPARE(s.count(
"2"), 2);
539 #include "moc/Coordinates_test.moc"