| 486 | // Main test function for a given data type and writer configuration. |
| 487 | template <typename WriterDataObjectT> |
| 488 | bool 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. |
nothing calls this directly
no test coverage detected