32 CPPUNIT_TEST_SUITE(mitkPointSetTestSuite);
40 MITK_TEST(TestSwapPointPositionUpwardsNotPossible);
41 MITK_TEST(TestSwapPointPositionDownwards);
42 MITK_TEST(TestSwapPointPositionDownwardsNotPossible);
44 MITK_TEST(TestInsertPointWithPointSpecification);
49 CPPUNIT_TEST_SUITE_END();
66 pointSet->InsertPoint(2, point2);
67 pointSet->InsertPoint(3, point3);
68 pointSet->InsertPoint(4, point4);
72 pointSet->InsertPoint(1, point1);
76 pointSet->InsertPoint(0, point0);
79 pointSet->SetSelectInfo(2,
true);
82 void tearDown()
override { pointSet =
nullptr; }
86 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check if the PointSet is not empty ",
true, !pointSet->IsEmptyTimeStep(0));
99 void TestSetSelectInfo()
102 pointSet->SetSelectInfo(4,
true);
104 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check SetSelectInfo",
true, pointSet->GetSelectInfo(4));
116 void TestSearchSelectedPoint()
119 CPPUNIT_ASSERT_EQUAL_MESSAGE(
120 "check SearchSelectedPoint ",
true, pointSet->SearchSelectedPoint() == (int)selectedPointId);
132 void TestGetNumberOfSelected()
135 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check GetNumeberOfSelected ",
true, pointSet->GetNumberOfSelected() == 1);
147 void TestGetPointIfExists()
155 pointSet->GetPointIfExists(4, &tmpPoint);
157 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check GetPointIfExists: ",
true, tmpPoint == point4);
168 void TestSwapPointPositionUpwards()
173 point = pointSet->GetPoint(1);
174 pointSet->SwapPointPosition(1,
true);
175 tempPoint = pointSet->GetPoint(0);
177 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check SwapPointPosition upwards",
true, point == tempPoint);
189 void TestSwapPointPositionUpwardsNotPossible()
192 CPPUNIT_ASSERT_EQUAL_MESSAGE(
193 "check SwapPointPosition upwards not possible",
false, pointSet->SwapPointPosition(0,
true));
205 void TestSwapPointPositionDownwards()
210 point = pointSet->GetPoint(0);
211 pointSet->SwapPointPosition(0,
false);
212 tempPoint = pointSet->GetPoint(1);
214 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check SwapPointPosition down",
true, point == tempPoint);
226 void TestSwapPointPositionDownwardsNotPossible()
233 pointSet2->SetPoint(
id, point);
236 CPPUNIT_ASSERT_EQUAL_MESSAGE(
237 "check SwapPointPosition downwards not possible",
false, pointSet2->SwapPointPosition(
id,
false));
249 void TestCreateHoleInThePointIDs()
257 pointSet->InsertPoint(10, p10);
258 pointSet->InsertPoint(11, p11);
259 pointSet->InsertPoint(12, p12);
261 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"add points with id 10, 11, 12: ",
263 (pointSet->IndexExists(10) ==
true) || (pointSet->IndexExists(11) ==
true) ||
264 (pointSet->IndexExists(12) ==
true));
269 pointSet->ExecuteOperation(doOp);
271 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"remove point id 11: ",
false, pointSet->IndexExists(
id));
289 pointSet->ExecuteOperation(doOp);
295 CPPUNIT_ASSERT_EQUAL_MESSAGE(
296 "check PointOperation OpMOVEPOINTUP for point id 12:",
true, ((newP10 == p12) && (newP12 == p10)));
300 pointSet->ExecuteOperation(doOp);
302 newP10 = pointSet->GetPoint(10);
303 newP12 = pointSet->GetPoint(12);
305 CPPUNIT_ASSERT_EQUAL_MESSAGE(
306 "check PointOperation OpMOVEPOINTDOWN for point id 10: ",
true, ((newP10 == p10) && (newP12 == p12)));
309 void TestInsertPointWithPointSpecification()
317 tempPoint = pointSet->GetPoint(5);
319 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"check InsertPoint with PointSpecification",
true, tempPoint == point5);
330 void TestRemovePointInterface()
336 refPsLastRemoved->InsertPoint(0, point0);
338 refPsLastRemoved->InsertPoint(1, point1);
341 refPsLastRemoved->InsertPoint(2, point2);
342 refPsLastRemoved->InsertPoint(3, point3);
345 refPsMiddleRemoved->InsertPoint(0, point0);
346 refPsMiddleRemoved->InsertPoint(1, point1);
347 refPsMiddleRemoved->InsertPoint(3, point3);
350 bool removed = pointSet->RemovePointIfExists(5, 0);
351 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove non-existent point",
false, removed);
355 removed = pointSet->RemovePointIfExists(1, 1);
356 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove non-existent point",
false, removed);
361 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove max id point from non-existent time step",
true, maxIt == pointSet->End(2));
366 maxIt = emptyPS->RemovePointAtEnd(0);
367 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove max id point from non-existent time step",
true, maxIt == emptyPS->End(0));
368 int size = emptyPS->GetSize(0);
369 unsigned int pointSetSeriesSize = emptyPS->GetPointSetSeriesSize();
370 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Nothing added",
true, size == 0 && pointSetSeriesSize == 1);
373 maxIt = pointSet->RemovePointAtEnd(0);
374 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Point id 4 removed",
false, pointSet->IndexExists(4));
384 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Returned iterator pointing at max id",
true,
id == 3 && equal);
387 removed = pointSet->RemovePointIfExists(2, 0);
388 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove point id 2",
true, removed);
392 void TestMaxIdAccess()
396 PointsIteratorType empty;
405 pointSet->SetPoint(0, new1, 2);
406 pointSet->InsertPoint(1, new2, 2);
407 pointSet->InsertPoint(3, new3, 2);
408 pointSet->InsertPoint(6, new4, 2);
410 PointsIteratorType maxIt = pointSet->GetMaxId(1);
411 empty = pointSet->End(1);
412 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check empty time step max id.",
true, maxIt == empty);
414 maxIt = pointSet->GetMaxId(3);
415 empty = pointSet->End(3);
416 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check non-existent time step max id.",
true, maxIt == empty);
418 maxIt = pointSet->GetMaxId(0);
419 empty = pointSet->End(0);
420 IdType maxId = maxIt.Index();
423 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 0 max id iterator.",
false, maxIt == empty);
424 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 0 max id.",
true, maxId == 4);
425 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 0 max id point.",
true, equal);
427 maxIt = pointSet->GetMaxId(2);
428 empty = pointSet->End(2);
429 maxId = maxIt.Index();
430 maxPt = maxIt.Value();
432 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 2 max id iterator.",
false, maxIt == empty);
433 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 2 max id.",
true, maxId == 6);
434 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check time step 2 max id point.",
true, equal);
437 void TestInsertPointAtEnd()
442 PointType new1, new2, new3, new4, refMaxPt;
448 pointSet->SetPoint(1, new1, 2);
449 pointSet->InsertPoint(3, new2, 2);
450 pointSet->InsertPoint(4, new3, 2);
451 pointSet->InsertPoint(6, new4, 2);
453 PointType in1, in2, in3, in4;
460 refPs1->SetPoint(5, in1, 0);
462 refPs2->SetPoint(5, in1, 0);
463 refPs2->SetPoint(0, in2, 1);
465 refPs3->SetPoint(5, in1, 0);
466 refPs3->SetPoint(0, in2, 1);
467 refPs3->SetPoint(7, in3, 2);
469 refPs4->SetPoint(5, in1, 0);
470 refPs4->SetPoint(0, in2, 1);
471 refPs4->SetPoint(7, in3, 2);
472 refPs4->SetPoint(0, in4, 7);
474 pointSet->InsertPoint(in1, 0);
477 pointSet->InsertPoint(in2, 1);
480 pointSet->InsertPoint(in3, 2);
483 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.