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

Function mitkFileWriterRegistryTest

Modules/Core/test/mitkFileWriterRegistryTest.cpp:157–282  ·  view source on GitHub ↗

* TODO */

Source from the content-addressed store, hash-verified

155 * TODO
156 */
157int mitkFileWriterRegistryTest(int /*argc*/, char * /*argv*/ [])
158{
159 // always start with this!
160 MITK_TEST_BEGIN("FileWriterRegistry");
161
162 TestStreamMethods();
163
164 // mitk::FileWriterRegistry::Pointer frm = mitk::FileWriterRegistry::New();
165 // MITK_TEST_CONDITION_REQUIRED(argc == 2,"Testing FileWriterRegistry instantiation");
166
167 DummyWriter testDR("testdata", "test", 1);
168 DummyWriter otherDR("testdata", "other", 1);
169
170 // MITK_TEST_CONDITION_REQUIRED(testDR->CanWrite("/this/is/a/folder/file.test"),"Positive test of default CanRead()
171 // implementation");
172 // MITK_TEST_CONDITION_REQUIRED(!testDR->CanWrite("/this/is/a/folder/file.tes"),"Negative test of default CanRead()
173 // implementation");
174
175 mitk::FileWriterRegistry *writerRegistry = new mitk::FileWriterRegistry;
176 mitk::IFileWriter *returned = writerRegistry->GetWriter("", "test");
177
178 MITK_TEST_CONDITION_REQUIRED(returned && &static_cast<mitk::IFileWriter &>(testDR) != returned,
179 "Testing correct retrieval of FileWriter 1/2");
180
181 returned = writerRegistry->GetWriter("", "other");
182
183 MITK_TEST_CONDITION_REQUIRED(returned && &static_cast<mitk::IFileWriter &>(otherDR) != returned,
184 "Testing correct retrieval of FileWriter 2/2");
185
186 DummyWriter mediocreTestDR("testdata", "test", 20);
187 DummyWriter prettyFlyTestDR("testdata", "test", 50);
188 DummyWriter2 awesomeTestDR("testdata", "test", 100);
189
190 returned = writerRegistry->GetWriter("test");
191 MITK_TEST_CONDITION_REQUIRED(dynamic_cast<DummyWriter2 *>(returned),
192 "Testing correct prioritized retrieval of FileWriter: Best Writer");
193
194 // Now to give those Writers some options, then we will try again
195 mitk::IFileWriter::OptionList options;
196 options.push_back(std::make_pair("isANiceGuy", true));
197 mediocreTestDR.SetOptions(options);
198 options.clear();
199 options.push_back(std::make_pair("canFly", true));
200 prettyFlyTestDR.SetOptions(options);
201 options.push_back(std::make_pair("isAwesome", true));
202 awesomeTestDR.SetOptions(options); // note: awesomeWriter canFly and isAwesome
203
204 // Reset Options, use to define what we want the Writer to do
205 mitk::IFileWriter::OptionNames optionFilter;
206 optionFilter.push_back("canFly");
207 returned = writerRegistry->GetWriter("", "test", optionFilter);
208 MITK_TEST_CONDITION_REQUIRED(returned && &static_cast<mitk::IFileWriter &>(awesomeTestDR) != returned,
209 "Testing correct retrieval of FileWriter with Options: Best Writer with options");
210
211 optionFilter.push_back("isAwesome");
212 returned = writerRegistry->GetWriter("", "test", optionFilter);
213 MITK_TEST_CONDITION_REQUIRED(
214 returned && &static_cast<mitk::IFileWriter &>(awesomeTestDR) != returned,

Callers

nothing calls this directly

Calls 8

TestStreamMethodsFunction · 0.85
GetWritersMethod · 0.80
frontMethod · 0.80
GetWriterMethod · 0.45
SetOptionsMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected