]> Creatis software - gdcm.git/blobdiff - Testing/TestReadWriteReadCompare.cxx
* Test/*DicomDir*.cxx : Verification that DicomDir are readable
[gdcm.git] / Testing / TestReadWriteReadCompare.cxx
index 24a2a763d0d946da0e797528f5984cd000ba3809..cc48edb7bd94bdf1bf46d7df9c7218e8d0c7b859 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestReadWriteReadCompare.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/24 16:39:18 $
-  Version:   $Revision: 1.15 $
+  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
@@ -40,8 +40,8 @@ int CompareInternal(std::string const & filename, std::string const & output)
    //////////////// Step 2:
 
    gdcm::File*  file = new gdcm::File( header );
-   int dataSize    = file->GetImageDataSizeRaw();
-   uint8_t* imageData = file->GetImageDataRaw(); //EXTREMELY IMPORTANT
+   int dataSize    = file->GetImageDataSize();
+   uint8_t* imageData = file->GetImageData(); //EXTREMELY IMPORTANT
           // Sure, it is : It's up to the user to decide if he wants to
           // GetImageData or if he wants to GetImageDataRaw
           // (even if we do it by setting a flag, he will have to decide) 
@@ -83,11 +83,30 @@ int CompareInternal(std::string const & filename, std::string const & output)
    }
    std::cout << "3...";
    // For the next step:
-   int    dataSizeWritten = reread->GetImageDataSizeRaw();
-   uint8_t* imageDataWritten = reread->GetImageDataRaw();
+   int    dataSizeWritten = reread->GetImageDataSize();
+   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 << "Failed" << std::endl
@@ -99,6 +118,7 @@ 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;