]> Creatis software - gdcm.git/blobdiff - Testing/TestValidate.cxx
Fix mistypings
[gdcm.git] / Testing / TestValidate.cxx
index 721581b4e847d7bea7ef2924388709c1f5d2b659..ebe4a32e109092c9211cf0688a03d6ae396bfbb1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestValidate.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/03 16:11:56 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2007/06/21 14:59:06 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmFile.h"
 #include "gdcmValidator.h"
 
+#include "gdcmGlobal.h"
+#include "gdcmDictSet.h"
 
-int TestValidate(int argc, char *argv[])
-{
-  if( argc < 2 )
-  {
-    std::cerr << "ouh les cornes / shame on you" << std::endl;
-    return 1;
-  }
+//Generated file:
+#include "gdcmDataImages.h"
 
-   const char *filename = argv[1];
+int Validate(std::string const &filename);
 
-   gdcm::File *input =  gdcm::File::New( );
+int Validate(std::string const &filename)
+{
+   GDCM_NAME_SPACE::File *input =  GDCM_NAME_SPACE::File::New( );
    input->SetFileName(filename);
    input->Load();
-   gdcm::Validator *v = new gdcm::Validator();
+   GDCM_NAME_SPACE::Validator *v = GDCM_NAME_SPACE::Validator::New();
    v->SetInput( input );
+   input->Delete();
+   v->Delete();
+   return 1; // allways true (we don't want to break the test suite)
+} 
+
+
+int TestValidate(int argc, char *argv[])
+{
+   if ( argc == 2 )
+   {
+      // The test is specified a specific filename, use it instead of looping
+      // over all images
+      const std::string input = argv[1];
+      return Validate( input );
+   }
+   else if ( argc > 2 || argc == 2 )
+   {
+      std::cout << "   Usage: " << argv[0]
+                << " (no arguments needed)." << std::endl;
+      std::cout << "or   Usage: " << argv[0]
+                << " filename.dcm " << std::endl;
+      return 1;
+   }
+   
+   int i =0;
+   int retVal = 0;  //by default : *no* error
+   while( gdcmDataImages[i] != 0 )
+   {
+      std::string filename = GDCM_DATA_ROOT;
+      filename += "/";  //doh!
+      filename += gdcmDataImages[i];
+      std::cout << filename << std::endl;
+      if( Validate( filename ) != 0 )
+      {
+         retVal++;
+      }
 
-   return 0;
+      i++;
+   }
+   retVal = 0; // Never break test suite
+   return retVal;
 }