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

Function mitkPointSetReaderTest

Modules/Core/test/mitkPointSetReaderTest.cpp:26–71  ·  view source on GitHub ↗

* Test for the class "mitkPointSetReader". * * 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 data set for the tests (see CMakeLists.txt). */

Source from the content-addressed store, hash-verified

24 * of a test data set for the tests (see CMakeLists.txt).
25 */
26int mitkPointSetReaderTest(int argc, char *argv[])
27{
28 // always start with this!
29 MITK_TEST_BEGIN("PointSetReader")
30 MITK_TEST_CONDITION_REQUIRED(argc == 2, "Testing invocation")
31
32 mitk::FileReaderRegistry readerRegistry;
33
34 // Get PointSet reader(s)
35 std::vector<mitk::IFileReader *> readers =
36 readerRegistry.GetReaders(mitk::FileReaderRegistry::GetMimeTypeForFile("test.mps"));
37 MITK_TEST_CONDITION_REQUIRED(!readers.empty(), "Testing for registered readers")
38
39 for (std::vector<mitk::IFileReader *>::const_iterator iter = readers.begin(), end = readers.end(); iter != end;
40 ++iter)
41 {
42 std::string testName = "test1";
43 mitk::IFileReader *reader = *iter;
44 reader->SetInput(testName);
45 // testing file reading with invalid data
46 MITK_TEST_CONDITION_REQUIRED(reader->GetConfidenceLevel() == mitk::IFileReader::Unsupported,
47 "Testing confidence level with invalid input file name!");
48 CPPUNIT_ASSERT_THROW(reader->Read(), mitk::Exception);
49
50 // testing file reading with valid data
51 std::string filePath = argv[1];
52 reader->SetInput(filePath);
53 MITK_TEST_CONDITION_REQUIRED(reader->GetConfidenceLevel() == mitk::IFileReader::Supported,
54 "Testing confidence level with valid input file name!");
55 std::vector<mitk::BaseData::Pointer> data = reader->Read();
56 MITK_TEST_CONDITION_REQUIRED(!data.empty(), "Testing non-empty data with valid input file name!");
57
58 // evaluate if the read point set is correct
59 mitk::PointSet::Pointer resultPS = dynamic_cast<mitk::PointSet *>(data.front().GetPointer());
60 MITK_TEST_CONDITION_REQUIRED(resultPS.IsNotNull(), "Testing correct BaseData type");
61 MITK_TEST_CONDITION_REQUIRED(
62 resultPS->GetTimeSteps() == 14,
63 "Testing output time step generation!"); // CAVE: Only valid with the specified test data!
64 MITK_TEST_CONDITION_REQUIRED(
65 resultPS->GetPointSet(resultPS->GetTimeSteps() - 1)->GetNumberOfPoints() == 0,
66 "Testing output time step generation with empty time step!"); // CAVE: Only valid with the specified test data!
67 }
68
69 // always end with this!
70 MITK_TEST_END()
71}

Callers

nothing calls this directly

Calls 13

GetReadersMethod · 0.80
GetPointerMethod · 0.80
frontMethod · 0.80
IsNotNullMethod · 0.80
GetTimeStepsMethod · 0.80
GetNumberOfPointsMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
SetInputMethod · 0.45
GetConfidenceLevelMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected