28 CPPUNIT_TEST_SUITE(mitkPointSetTestSuite);
36 MITK_TEST(TestSwapPointPositionUpwardsNotPossible);
37 MITK_TEST(TestSwapPointPositionDownwards);
38 MITK_TEST(TestSwapPointPositionDownwardsNotPossible);
40 MITK_TEST(TestInsertPointWithPointSpecification);
45 CPPUNIT_TEST_SUITE_END();
62 pointSet->InsertPoint(2, point2);
63 pointSet->InsertPoint(3, point3);
64 pointSet->InsertPoint(4, point4);
68 pointSet->InsertPoint(1, point1);
72 pointSet->InsertPoint(0, point0);
75 pointSet->SetSelectInfo(2,
true);
78 void tearDown()
override { pointSet =
nullptr; }
82 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if the PointSet is not empty ",
true, !pointSet->IsEmptyTimeStep(0));
95 void TestSetSelectInfo()
98 pointSet->SetSelectInfo(4,
true);
100 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check SetSelectInfo",
true, pointSet->GetSelectInfo(4));
112 void TestSearchSelectedPoint()
115 CPPUNIT_ASSERT_EQUAL_MESSAGE(
116 "check SearchSelectedPoint ",
true, pointSet->SearchSelectedPoint() == (int)selectedPointId);
128 void TestGetNumberOfSelected()
131 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check GetNumeberOfSelected ",
true, pointSet->GetNumberOfSelected() == 1);
143 void TestGetPointIfExists()
151 pointSet->GetPointIfExists(4, &tmpPoint);
153 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check GetPointIfExists: ",
true, tmpPoint == point4);
164 void TestSwapPointPositionUpwards()
169 point = pointSet->GetPoint(1);
170 pointSet->SwapPointPosition(1,
true);
171 tempPoint = pointSet->GetPoint(0);
173 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check SwapPointPosition upwards",
true, point == tempPoint);
185 void TestSwapPointPositionUpwardsNotPossible()
188 CPPUNIT_ASSERT_EQUAL_MESSAGE(
189 "check SwapPointPosition upwards not possible",
false, pointSet->SwapPointPosition(0,
true));
201 void TestSwapPointPositionDownwards()
206 point = pointSet->GetPoint(0);
207 pointSet->SwapPointPosition(0,
false);
208 tempPoint = pointSet->GetPoint(1);
210 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check SwapPointPosition down",
true, point == tempPoint);
222 void TestSwapPointPositionDownwardsNotPossible()
229 pointSet2->SetPoint(
id, point);
232 CPPUNIT_ASSERT_EQUAL_MESSAGE(
233 "check SwapPointPosition downwards not possible",
false, pointSet2->SwapPointPosition(
id,
false));
245 void TestCreateHoleInThePointIDs()
253 pointSet->InsertPoint(10, p10);
254 pointSet->InsertPoint(11, p11);
255 pointSet->InsertPoint(12, p12);
257 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"add points with id 10, 11, 12: ",
259 (pointSet->IndexExists(10) ==
true) || (pointSet->IndexExists(11) ==
true) ||
260 (pointSet->IndexExists(12) ==
true));
265 pointSet->ExecuteOperation(doOp);
267 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"remove point id 11: ",
false, pointSet->IndexExists(
id));
285 pointSet->ExecuteOperation(doOp);
291 CPPUNIT_ASSERT_EQUAL_MESSAGE(
292 "check PointOperation OpMOVEPOINTUP for point id 12:",
true, ((newP10 == p12) && (newP12 == p10)));
296 pointSet->ExecuteOperation(doOp);
298 newP10 = pointSet->GetPoint(10);
299 newP12 = pointSet->GetPoint(12);
301 CPPUNIT_ASSERT_EQUAL_MESSAGE(
302 "check PointOperation OpMOVEPOINTDOWN for point id 10: ",
true, ((newP10 == p10) && (newP12 == p12)));
305 void TestInsertPointWithPointSpecification()
313 tempPoint = pointSet->GetPoint(5);
315 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check InsertPoint with PointSpecification",
true, tempPoint == point5);
326 void TestRemovePointInterface()
332 refPsLastRemoved->InsertPoint(0, point0);
334 refPsLastRemoved->InsertPoint(1, point1);
337 refPsLastRemoved->InsertPoint(2, point2);
338 refPsLastRemoved->InsertPoint(3, point3);
341 refPsMiddleRemoved->InsertPoint(0, point0);
342 refPsMiddleRemoved->InsertPoint(1, point1);
343 refPsMiddleRemoved->InsertPoint(3, point3);
346 bool removed = pointSet->RemovePointIfExists(5, 0);
347 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove non-existent point",
false, removed);
351 removed = pointSet->RemovePointIfExists(1, 1);
352 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove non-existent point",
false, removed);
357 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove max id point from non-existent time step",
true, maxIt == pointSet->End(2));
362 maxIt = emptyPS->RemovePointAtEnd(0);
363 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove max id point from non-existent time step",
true, maxIt == emptyPS->End(0));
364 int size = emptyPS->GetSize(0);
365 unsigned int pointSetSeriesSize = emptyPS->GetPointSetSeriesSize();
366 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Nothing added",
true, size == 0 && pointSetSeriesSize == 1);
369 maxIt = pointSet->RemovePointAtEnd(0);
370 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Point id 4 removed",
false, pointSet->IndexExists(4));
380 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Returned iterator pointing at max id",
true,
id == 3 && equal);
383 removed = pointSet->RemovePointIfExists(2, 0);
384 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove point id 2",
true, removed);
388 void TestMaxIdAccess()
392 PointsIteratorType empty;
401 pointSet->SetPoint(0, new1, 2);
402 pointSet->InsertPoint(1, new2, 2);
403 pointSet->InsertPoint(3, new3, 2);
404 pointSet->InsertPoint(6, new4, 2);
406 PointsIteratorType maxIt = pointSet->GetMaxId(1);
407 empty = pointSet->End(1);
408 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check empty time step max id.",
true, maxIt == empty);
410 maxIt = pointSet->GetMaxId(3);
411 empty = pointSet->End(3);
412 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check non-existent time step max id.",
true, maxIt == empty);
414 maxIt = pointSet->GetMaxId(0);
415 empty = pointSet->End(0);
416 IdType maxId = maxIt.Index();
419 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 0 max id iterator.",
false, maxIt == empty);
420 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 0 max id.",
true, maxId == 4);
421 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 0 max id point.",
true, equal);
423 maxIt = pointSet->GetMaxId(2);
424 empty = pointSet->End(2);
425 maxId = maxIt.Index();
426 maxPt = maxIt.Value();
428 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 2 max id iterator.",
false, maxIt == empty);
429 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 2 max id.",
true, maxId == 6);
430 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 2 max id point.",
true, equal);
433 void TestInsertPointAtEnd()
437 PointType new1, new2, new3, new4, refMaxPt;
443 pointSet->SetPoint(1, new1, 2);
444 pointSet->InsertPoint(3, new2, 2);
445 pointSet->InsertPoint(4, new3, 2);
446 pointSet->InsertPoint(6, new4, 2);
448 PointType in1, in2, in3, in4;
455 refPs1->SetPoint(5, in1, 0);
457 refPs2->SetPoint(5, in1, 0);
458 refPs2->SetPoint(0, in2, 1);
460 refPs3->SetPoint(5, in1, 0);
461 refPs3->SetPoint(0, in2, 1);
462 refPs3->SetPoint(7, in3, 2);
464 refPs4->SetPoint(5, in1, 0);
465 refPs4->SetPoint(0, in2, 1);
466 refPs4->SetPoint(7, in3, 2);
467 refPs4->SetPoint(0, in4, 7);
469 pointSet->InsertPoint(in1, 0);
472 pointSet->InsertPoint(in2, 1);
475 pointSet->InsertPoint(in3, 2);
478 pointSet->InsertPoint(in4, 7);
DataType::PointsContainerIterator PointsIterator
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
Constants for most interaction classes, due to the generic StateMachines.
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
DataType::PointIdentifier PointIdentifier
Test fixture for parameterized tests.
Operation that handles all actions on one Point.
#define MITK_ASSERT_EQUAL(EXPECTED, ACTUAL, MSG)
Testing macro to test if two objects are equal.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.