]> Creatis software - gdcm.git/blobdiff - Testing/TestAllVM.cxx
Looping 10000000 times should be enought
[gdcm.git] / Testing / TestAllVM.cxx
index 1dce8206204ea1a16d8749ad6ea56ba45a726ab6..199ac50103f64d372ebcbe1b05112432db82e18d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllVM.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/23 14:53:51 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2005/10/28 15:44:54 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 int DoTheVMTest(std::string const &filename)
 {
-   gdcm::File file;
+   gdcm::File *file = gdcm::File::New();
    // - Do not test unknow VM in shadow groups (if element 0x0000 is present)
    // - Skip Sequences (if they are 'True Length'); loading will be quicker
    //                  (anyway, Sequences are skipped at processing time ...)
-   file.SetLoadMode( gdcm::LD_NOSHADOW | gdcm::LD_NOSEQ );
+   file->SetLoadMode( gdcm::LD_NOSHADOW | gdcm::LD_NOSEQ );
 
-   file.SetFileName( filename );
-   if( !file.Load() ) //would be really bad...
+   file->SetFileName( filename );
+   if( !file->Load() ) //would be really bad...
       return 1;
 
-   gdcm::DocEntry *d = file.GetFirstEntry();
+   gdcm::DocEntry *d = file->GetFirstEntry();
    std::cerr << "Testing file : " << filename << std::endl;
    while(d)
    {
@@ -43,22 +43,28 @@ int DoTheVMTest(std::string const &filename)
          if ( !(de->GetGroup() % 2) ) // Don't check shadow elements. Righ now,
                                       // Private Dictionnary are not dealt with
          {    
-            if( !de->IsValueCountValid() )
-            {
-               std::cerr << "Element: " << de->GetKey() <<
+            // We know OB and OW VM is always 1, whatever the actual
+            //  found value is.
+     
+            if (de->GetVR() != "OB" && de->GetVR() != "OW" )
+               if( !de->IsValueCountValid() )
+               {
+                  std::cerr << "Element: " << de->GetKey() <<
                     " (" << de->GetName() << ") " <<
                     "Contains a wrong VM: " << de->GetValueCount() 
                     << " should be: " << de->GetVM() << std::endl;;
-            }
+               }
          }
       }
       else
       {
           // We skip pb of SQ recursive exploration
       }
-      d = file.GetNextEntry();
+      d = file->GetNextEntry();
    }
-      return 0;
+   file->Delete();
+
+   return 0;
 }
 
 int TestAllVM(int argc, char *argv[])