MCPcopy Create free account
hub / github.com/MITK/MITK / mitkPointSetWriterTest

Function mitkPointSetWriterTest

Modules/Core/test/mitkPointSetWriterTest.cpp:29–79  ·  view source on GitHub ↗

* Test for the class "mitkPointSetFileWriter". * * argc and argv are the command line parameters which were passed to * the ADD_TEST command in the CMakeLists.txt file. For the automatic * tests, argv is either empty for the simple tests or contains the filename * of a test image for the image tests (see CMakeLists.txt). */

Source from the content-addressed store, hash-verified

27 * of a test image for the image tests (see CMakeLists.txt).
28 */
29int mitkPointSetWriterTest(int /* argc */, char * /*argv*/ [])
30{
31 // always start with this!
32 MITK_TEST_BEGIN("PointSetWriter")
33
34 // create pointSet
35 srand(time(nullptr));
36 mitk::PointSet::Pointer pointSet = mitk::PointSet::New();
37 int numberOfPoints = rand() % 100;
38 for (int i = 0; i <= numberOfPoints + 1; i++)
39 {
40 mitk::Point3D point;
41 point[0] = rand() % 1000;
42 point[1] = rand() % 1000;
43 point[2] = rand() % 1000;
44 pointSet->SetPoint(i, point);
45 }
46
47 MITK_TEST_CONDITION_REQUIRED(pointSet.IsNotNull(), "PointSet creation")
48
49 // Get PointSet writer(s)
50 mitk::FileWriterSelector writerSelector(pointSet.GetPointer());
51 std::vector<mitk::FileWriterSelector::Item> writers = writerSelector.Get();
52 MITK_TEST_CONDITION_REQUIRED(!writers.empty(), "Testing for registered writers")
53
54 for (std::vector<mitk::FileWriterSelector::Item>::const_iterator iter = writers.begin(), end = writers.end();
55 iter != end;
56 ++iter)
57 {
58 // test for exception handling
59 try
60 {
61 mitk::IFileWriter *writer = iter->GetWriter();
62 writer->SetInput(pointSet);
63 writer->SetOutputLocation("/usr/bin");
64 iter->GetWriter()->Write();
65 MITK_TEST_FAILED_MSG(<< "itk::ExceptionObject expected")
66 }
67 catch (const itk::ExceptionObject &)
68 { /* this is expected */
69 }
70 catch (...)
71 {
72 // this means that a wrong exception (i.e. no itk:Exception) has been thrown
73 MITK_TEST_FAILED_MSG(<< "Wrong exception (i.e. no itk:Exception) caught during write [FAILED]")
74 }
75 }
76
77 // always end with this!
78 MITK_TEST_END()
79}

Callers

nothing calls this directly

Calls 12

IsNotNullMethod · 0.80
GetPointerMethod · 0.80
SetOutputLocationMethod · 0.80
NewFunction · 0.50
SetPointMethod · 0.45
GetMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetWriterMethod · 0.45
SetInputMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected