]> Creatis software - gdcm.git/commitdiff
Enforce TestValidate, and run it.
authorjpr <jpr>
Fri, 4 Nov 2005 17:05:49 +0000 (17:05 +0000)
committerjpr <jpr>
Fri, 4 Nov 2005 17:05:49 +0000 (17:05 +0000)
(Just to have an overwiew of oddities in the files.
Never breaks the test suite)

Testing/CMakeLists.txt
Testing/TestValidate.cxx

index f5670d92418eccdd5814ef0f39f641f6978b3018..ddf756f25c1af482a30411cb4763e7fbffdfe149 100644 (file)
@@ -20,7 +20,7 @@ SET(TEST_SOURCES
   TestImageSet.cxx
   TestDicomDirElement.cxx
   TestDicomString.cxx
-  #TestValidate.cxx
+
 )
 IF(UNIX)
   SET(TEST_SOURCES ${TEST_SOURCES}
@@ -48,6 +48,7 @@ IF (GDCM_DATA_ROOT)
     TestMakeDicomDir.cxx             # writes a file named "NewDICOMDIR"
     TestSerieHelper.cxx              # uses gdcmData as a default root directory    
     TestAllVM.cxx
+    TestValidate.cxx                 #Just to have on overviews of oddities ...  
   )
   # add test that require VTK:
   IF(GDCM_VTK)
index 721581b4e847d7bea7ef2924388709c1f5d2b659..835d0ec9019f180b6141bde88175d3b41c64d80c 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: 2005/11/04 17:05:49 $
+  Version:   $Revision: 1.4 $
                                                                                 
   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"
 
+//Generated file:
+#include "gdcmDataImages.h"
 
-int TestValidate(int argc, char *argv[])
-{
-  if( argc < 2 )
-  {
-    std::cerr << "ouh les cornes / shame on you" << std::endl;
-    return 1;
-  }
-
-   const char *filename = argv[1];
+int Validate(std::string const &filename);
 
+int Validate(std::string const &filename)
+{
    gdcm::File *input =  gdcm::File::New( );
    input->SetFileName(filename);
    input->Load();
    gdcm::Validator *v = new gdcm::Validator();
    v->SetInput( input );
+   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 this is an 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++;
+   }
+   return 0; // never break the testsuite!
 }