]> Creatis software - gdcm.git/blobdiff - Testing/TestAllReadCompareDicom.cxx
* src/TestAllReadCompareDicom.cxx : test the existence of the directory
[gdcm.git] / Testing / TestAllReadCompareDicom.cxx
index 9e10924e584cae4ebed5f213ee06f80d438b181f..a61581d756f8feae867a6d9d1b4a2b1da607b85c 100644 (file)
@@ -4,11 +4,12 @@
 //Generated file:
 #include "gdcmDataImages.h"
 
-int InternalTest(std::string const & filename, std::string const & referenceFileName )
+int InternalTest(std::string const & filename, 
+                 std::string const & referenceFileName )
 {
       std::cout << "   Testing: " << filename << std::endl;
 
-      gdcmFile* tested = new gdcmFile( filename );
+      gdcm::File* tested = new gdcm::File( filename );
       if( !tested->GetHeader()->IsReadable() )
       {
         std::cout << "      Image not gdcm compatible:"
@@ -44,7 +45,7 @@ int InternalTest(std::string const & filename, std::string const & referenceFile
 
       ////// When reference file is not gdcm readable test is failed:
   
-      gdcmFile* reference = new gdcmFile( referenceFileName.c_str() );
+      gdcm::File* reference = new gdcm::File( referenceFileName );
       if( !reference->GetHeader()->IsReadable() )
       {
          std::cout << "      Reference image " << std::endl
@@ -148,6 +149,7 @@ int TestAllReadCompareDicom(int argc, char* argv[])
              << std::endl << std::endl;
 
    int i = 0;
+   int result = 0;
    while( gdcmDataImages[i] != 0 )
    {
       ////// Check for existence of reference baseline directory
@@ -155,7 +157,22 @@ int TestAllReadCompareDicom(int argc, char* argv[])
       std::string baseLineDir = GDCM_DATA_ROOT;
       baseLineDir += "/BaselineDicom/";
 
-      FILE* testFILE = fopen( baseLineDir.c_str(), "r" );
+      std::ifstream* testDIR = new std::ifstream(baseLineDir.c_str(), std::ios::in | std::ios::binary);
+      if (!testDIR )
+      {
+         std::cerr << "   The reference baseline directory " << std::endl
+                   << "      "
+                   << baseLineDir << std::endl
+                   << "   couldn't be opened."
+                   << std::endl;
+         return 1;
+      }
+      else
+      {
+         testDIR->close();
+      }
+
+/*      FILE* testFILE = fopen( baseLineDir.c_str(), "r" );
       if (!testFILE )
       {
          std::cerr << "   The reference baseline directory " << std::endl
@@ -168,7 +185,7 @@ int TestAllReadCompareDicom(int argc, char* argv[])
       else
       {
          fclose( testFILE );
-      }
+      }*/
 
       ////// Step 1 (see above description):
 
@@ -185,9 +202,9 @@ int TestAllReadCompareDicom(int argc, char* argv[])
 
       if( InternalTest( filename, referenceFileName ) != 0 )
       {
-         return 1;
+         result++;
       }
    }
 
-   return 0;
+   return result;
 }