X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestReadWriteReadCompare.cxx;h=cc48edb7bd94bdf1bf46d7df9c7218e8d0c7b859;hb=5a0d183707a94e875a595036f64d0bd506faf618;hp=6d53cda116f23901ea1096871ae9f139e9d41e03;hpb=3afc179392ebebe610f7685bc8895b690c2a66aa;p=gdcm.git diff --git a/Testing/TestReadWriteReadCompare.cxx b/Testing/TestReadWriteReadCompare.cxx index 6d53cda1..cc48edb7 100644 --- a/Testing/TestReadWriteReadCompare.cxx +++ b/Testing/TestReadWriteReadCompare.cxx @@ -1,3 +1,20 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestReadWriteReadCompare.cxx,v $ + Language: C++ + Date: $Date: 2004/11/30 14:17:52 $ + Version: $Revision: 1.17 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #include "gdcmHeader.h" #include "gdcmFile.h" @@ -18,7 +35,7 @@ int CompareInternal(std::string const & filename, std::string const & output) delete header; return 1; } - std::cout << " step 1 ..."; + std::cout << " step 1..."; //////////////// Step 2: @@ -47,6 +64,7 @@ int CompareInternal(std::string const & filename, std::string const & output) file->SetImageData(imageData, dataSize); + file->SetWriteModeToRGB(); file->WriteDcmExplVR( output ); std::cout << "2..."; @@ -55,7 +73,8 @@ int CompareInternal(std::string const & filename, std::string const & output) gdcm::File* reread = new gdcm::File( output ); if( !reread->GetHeader()->IsReadable() ) { - std::cerr << "Test::TestReadWriteReadCompare: Could not reread image " + std::cerr << "Failed" << std::endl + << "Test::TestReadWriteReadCompare: Could not reread image " << "written:" << filename << std::endl; delete header; delete file; @@ -68,10 +87,29 @@ int CompareInternal(std::string const & filename, std::string const & output) uint8_t* imageDataWritten = reread->GetImageData(); //////////////// Step 4: + // Test the image size + if (header->GetXSize() != reread->GetHeader()->GetXSize() || + header->GetYSize() != reread->GetHeader()->GetYSize() || + header->GetZSize() != reread->GetHeader()->GetZSize()) + { + std::cout << "Failed" << std::endl + << " X Size differs: " + << "X: " << header->GetXSize() << " # " + << reread->GetHeader()->GetXSize() << " | " + << "Y: " << header->GetYSize() << " # " + << reread->GetHeader()->GetYSize() << " | " + << "Z: " << header->GetZSize() << " # " + << reread->GetHeader()->GetZSize() << std::endl; + delete header; + delete file; + delete reread; + return 1; + } + // Test the data size if (dataSize != dataSizeWritten) { - std::cout << std::endl + std::cout << "Failed" << std::endl << " Pixel areas lengths differ: " << dataSize << " # " << dataSizeWritten << std::endl; delete header; @@ -80,10 +118,11 @@ int CompareInternal(std::string const & filename, std::string const & output) return 1; } + // Test the data's content if (int res = memcmp(imageData, imageDataWritten, dataSize) !=0) { (void)res; - std::cout << std::endl + std::cout << "Failed" << std::endl << " Pixel differ (as expanded in memory)." << std::endl; delete header; delete file;