MCPcopy Create free account
hub / github.com/Kitware/VTK / TestDataObjectXMLSerialization

Function TestDataObjectXMLSerialization

IO/XML/Testing/Cxx/TestDataObjectXMLIO.cxx:488–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486// Main test function for a given data type and writer configuration.
487template <typename WriterDataObjectT>
488bool TestDataObjectXMLSerialization(const WriterConfig& writerConfig)
489{
490 using ReaderDataObjectT = typename GetReaderDataObjectType<WriterDataObjectT>::Type;
491
492 WriterDataObjectT* const output_data = WriterDataObjectT::New();
493 InitializeData(output_data);
494
495 std::ostringstream filename;
496 filename << TestingData->GetTempDirectory() << "/" << output_data->GetClassName() << "-"
497 << writerConfig.GetCurrentPermutationName();
498
499 vtkXMLDataSetWriter* const writer = vtkXMLDataSetWriter::New();
500 writer->SetInputData(output_data);
501 writer->SetFileName(filename.str().c_str());
502 writerConfig.ApplyCurrentPermutation(writer);
503 writer->Write();
504 writer->Delete();
505
506 vtkXMLGenericDataObjectReader* const reader = vtkXMLGenericDataObjectReader::New();
507 reader->SetFileName(filename.str().c_str());
508 reader->Update();
509
510 vtkDataObject* obj = reader->GetOutput();
511 ReaderDataObjectT* input_data = ReaderDataObjectT::SafeDownCast(obj);
512 if (!input_data)
513 {
514 reader->Delete();
515 output_data->Delete();
516 return false;
517 }
518
519 const bool result = CompareData(output_data, input_data);
520
521 reader->Delete();
522 output_data->Delete();
523
524 if (!result)
525 {
526 std::cerr << "Comparison failed. Filename: " << filename.str() << "\n";
527 }
528
529 return result;
530}
531
532//------------------------------------------------------------------------------
533// Test all permutations of the writer configuration with a given data type.

Callers

nothing calls this directly

Calls 13

GetTempDirectoryMethod · 0.80
InitializeDataFunction · 0.70
CompareDataFunction · 0.70
DeleteMethod · 0.65
NewFunction · 0.50
GetClassNameMethod · 0.45
SetInputDataMethod · 0.45
SetFileNameMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45
WriteMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected