]> Creatis software - gdcm.git/blobdiff - Testing/TestBuildUpDicomDir.cxx
Looping 10000000 times should be enought
[gdcm.git] / Testing / TestBuildUpDicomDir.cxx
index da7c881f31044cb562dbba01092e4ea4d7d6b080..64efd4b0e89217b6f6856c06d88911ab061cd81e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestBuildUpDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:46 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,13 +37,14 @@ int TestBuildUpDicomDir(int argc, char *argv[])
 {
    if (argc) 
    {
-      std::cerr << "Usage: " << argv[0] << " dummy ";
+      std::cerr << "Usage: " << argv[0] << " dummy " << std::endl;
    }
 
+   bool errorFound = false; 
    gdcm::DicomDir *dcmdir;
    std::string dirName;  
 
-   dcmdir = new gdcm::DicomDir();
+   dcmdir = gdcm::DicomDir::New();
 
    gdcm::DicomDirPatient *p1;
    // --- Forget these 4 lines :
@@ -170,7 +171,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
                <<" is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete dcmdir;
+      dcmdir->Delete();
       return 1;
    }
 
@@ -182,10 +183,11 @@ int TestBuildUpDicomDir(int argc, char *argv[])
 
    // Write it on disc
    dcmdir->Write("NewDICOMDIR");
-   delete dcmdir;
+
+   dcmdir->Delete();
 
    // Read the newly written DicomDir
-   gdcm::DicomDir *newDicomDir = new gdcm::DicomDir();
+   gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New();
    newDicomDir->SetFileName("NewDICOMDIR");
    newDicomDir->Load( );
    if( !newDicomDir->IsReadable() )
@@ -194,7 +196,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
                <<" is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete newDicomDir;
+      newDicomDir->Delete();
       return 1;
    }
    // Check some value we are sure
@@ -206,7 +208,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
    {
       std::cout << "A patient is missing in written DicomDir"
           << std::endl;
-      delete newDicomDir;
+      newDicomDir->Delete();
       return 1;
    }
 
@@ -214,7 +216,6 @@ int TestBuildUpDicomDir(int argc, char *argv[])
              << "----------Final Check ---------------------" 
              <<std::endl;
  
-   bool errorFound = false; 
    std::string valueStuff;  
    for (;;) // exit on 'break'
    {
@@ -345,37 +346,24 @@ int TestBuildUpDicomDir(int argc, char *argv[])
          errorFound = true;
          break;
       } 
-/*
-      if ( s1111->GetEntryString(0x0004,0x1500) != "imageFileName1111 " )
-      {
-         errorFound = true;
-         break;
-      }
-*/
+
       if ( (s1112 = s111->GetNextImage()) == 0 )
       {
          std::cout << "missing image S1112" << std::endl;
          errorFound = true;
          break;
       }
-/*
-      if ( s1112->GetEntryString(0x0004,0x1500) != "imageFileName1112 " )
-      {
-         errorFound = true;
-         break;
-      }
-  */
-     break; // No error found. Stop looping
+
+      break; // No error found. Stop looping
    }
 
-   delete newDicomDir;
    if ( errorFound )
    {
       std::cout << "MissWritting / MissReading " << std::endl;
-      std::cout<<std::flush;
-      return(1);
    }
 
    std::cout<<std::flush;
-   return 0;
+   newDicomDir->Delete();
+
+   return errorFound;
 }