]> Creatis software - gdcm.git/commitdiff
Allow user to run the tests on a single file
authorjpr <jpr>
Fri, 7 Apr 2006 10:58:51 +0000 (10:58 +0000)
committerjpr <jpr>
Fri, 7 Apr 2006 10:58:51 +0000 (10:58 +0000)
Testing/TestBug.cxx
Testing/TestDataEntry.cxx
Testing/TestFileAccessors.cxx
Testing/TestPrintAllDocument.cxx
Testing/TestWriteSimple.cxx

index 976756089daa31447b4fd92db363d384846edb73..db95841aaf5f597b12410f955b615814ac511289 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestBug.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 14:52:30 $
-  Version:   $Revision: 1.21 $
+  Date:      $Date: 2006/04/07 10:58:51 $
+  Version:   $Revision: 1.22 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -34,8 +34,10 @@ int TestBug(int argc, char *argv[])
       f->SetFileName( filename.c_str() );
    }
    f->Load( );
-   
+   f->Print();
+   std::cout << "-------------End of Print file ------------" << std::cout;   
    f->GetPubDict()->Print();
+   std::cout << "-------------End of Print Dict ------------" << std::cout;   
    f->Delete();
 
    return 0;
index ccfe73a5dcb997d4756cb0300cec2fb53fa54e4e..bca594cb7b75af2648502457e008c4755afc3dfc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/22 13:20:36 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2006/04/07 10:58:51 $
+  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
@@ -42,6 +42,10 @@ int TestDataEntry(int , char *[])
    gdcm::DataEntry *entry;
 
    //------------------------------------------------------------------
+   
+   /* Most of the tests are out of date! 
+   (we don't use any longer DictEntry to build a DocEntry!
+   
    dict = gdcm::DictEntry::New(0x0003,0x0004);
    // SetVR *before* making the DataEntry!
    dict->SetVR("US");   
@@ -571,5 +575,6 @@ int TestDataEntry(int , char *[])
 
    //------------------------------------------------------------------
    std::cout<<std::flush;
+   */
    return 0;
 }
index 36117b861045df6aeaf40e6f880143395e55741b..0318eda06b89ab84c91c03ad092fc44d5b2068b1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestFileAccessors.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/17 14:33:54 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2006/04/07 10:58:51 $
+  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
 //Generated file:
 #include "gdcmDataImages.h"
 
-#define TestMethodMacro(mode,obj,name) \
-   try \
-   { \
-      std::cout << "   " << #name << "() : "      << mode << obj->name() << std::endl; \
-   } \
-   catch(...) \
-   { \
-      std::cout << "   --> Can't access to the '" << #name << "' method !" << std::endl; \
-      f->Delete(); \
-      return 1; \
+#define TestMethodMacro(mode,obj,name)                \
+   try                                                \
+   {                                                  \
+      std::cout <<"   "<< #name << "() : "            \
+                << std::endl;                         \
+      std::cout << "                     "            \
+                << mode << obj->name() << std::endl;  \
+   }                                                  \
+   catch(...)                                         \
+   {                                                  \
+      std::cout << "   --> Can't access to the '"     \
+                << #name << "' method !" << std::endl;\
+      f->Delete();                                    \
+      return 1;                                       \
    }
 
-
-int TestFileAccessors(int, char *[])
+int TestFileAccessors(int argc, char *argv[])
 {
    int i = 0;
 
    float iop[6];
 
+  // gdcm::Debug::DebugOn();
+   
    while( gdcmDataImages[i] != 0 )
    {
    
@@ -65,13 +70,23 @@ int TestFileAccessors(int, char *[])
      // if (gdcmDataImages[i] == "00191113.dcm" )
      //    gdcm::Debug::DebugOn();
      // else
-         gdcm::Debug::DebugOff();
+     //    gdcm::Debug::DebugOff();
 
-      std::string filename = GDCM_DATA_ROOT;
-      filename += "/";  //doh!
-      filename += gdcmDataImages[i];
+      std::string filename;      
+      if (argc ==2)
+      {
+         filename = argv[1];
+      }
+      else
+      {
+         filename = GDCM_DATA_ROOT;
+         filename += "/";  //doh!      
+         filename += gdcmDataImages[i];
+      }
       
-      std::cout << "Begin with " << filename << std::endl;
+      std::cout << " ----------------------------------------------"
+                << "Begin with " << filename << std::endl;
+
       gdcm::File *f= gdcm::File::New( );
       f->SetFileName( filename );
       f->Load( );
@@ -146,9 +161,11 @@ int TestFileAccessors(int, char *[])
          f->Delete();
          return 1;
       }
-
       f->Delete();
-      std::cout << "End with " << filename << std::endl;
+
+      if (argc ==2)
+         break; // user asked to check a single file.
+
       i++;
    }
    return 0;
index 165518018a1736d6403089c274d040e32dbee52b..1b19d7949119d86f5ad1f0449dc826fa048bca12 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestPrintAllDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/01/19 11:00:28 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2006/04/07 10:58:51 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -38,7 +38,7 @@
 //Generated file:
 #include "gdcmDataImages.h"
 
-int TestPrintAllDocument(int, char *[])
+int TestPrintAllDocument(int argc, char *argv[])
 {
    //std::ostringstream s;
    int i = 0;
@@ -47,11 +47,25 @@ int TestPrintAllDocument(int, char *[])
    std::string pixelType, photomInterp;
    int l;
    l = strlen("PALETTE COLOR ");
+   
+   //gdcm::Debug::DebugOn();
+   
    while( gdcmDataImages[i] != 0 )
    {
-      std::string filename = GDCM_DATA_ROOT;
-      filename += "/";  //doh!
-      filename += gdcmDataImages[i];
+      std::string filename;      
+      if (argc ==2)
+      {
+         filename = argv[1];
+      }
+      else
+      {
+         filename = GDCM_DATA_ROOT;
+         filename += "/";  //doh!      
+         filename += gdcmDataImages[i];
+      }
+      
+      std::cout << " ----------------------------------------------"
+                << "Begin with " << filename << std::endl;
 
       gdcm::File *f= gdcm::File::New( );
       f->SetFileName( filename );
@@ -59,8 +73,7 @@ int TestPrintAllDocument(int, char *[])
 
       f->SetPrintLevel(2);
       f->Print();
-      // just to be able to grep the display result, for some usefull info
+      
       //s.setf(std::ios::left);
       //s << std::setw(60-filename.length()) << " ";
       //std::cout << s.str() << gdcmDataImages[i];
@@ -122,6 +135,10 @@ int TestPrintAllDocument(int, char *[])
          return 1;
       }
       f->Delete();
+      
+      if (argc ==2)
+         break; // user asked to check a single file.      
+      
       i++;
    }
    return 0;
index 3c0dbafd6a00afa8046f38a916f90745a72ac07e..116525891bf50388ce698615c391c063f7cc657b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/28 13:16:48 $
-  Version:   $Revision: 1.46 $
+  Date:      $Date: 2006/04/07 10:58:51 $
+  Version:   $Revision: 1.47 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -25,6 +25,8 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDebug.h"
+#include "gdcmGlobal.h"
+#include "gdcmDictSet.h"
 
 #include <iostream>
 #include <sstream>
@@ -45,16 +47,17 @@ typedef struct
 } Image;
 
 Image Images [] = {
-
    {128, 128, 1, 1, 8,  8,  0, 'e'},
+   {256, 128, 1, 1, 8,  8,  0, 'a'},
+   {128, 128, 1, 1, 8,  8,  0, 'i'},
+
+   {128, 128, 1, 1, 8,  8,  0, 'a'},    
+   {256, 128, 1, 1, 8,  8,  0, 'i'},
+     
+
    {256, 128, 1, 1, 8,  8,  0, 'e'},
    {128, 128, 1, 1, 16, 16, 0, 'e'},      
    {128, 256, 1, 1, 16, 16, 0, 'e'},   
-        
-   {128, 128, 1, 1, 8,  8,  0, 'i'},
-   {256, 128, 1, 1, 8,  8,  0, 'i'},
-   {256, 128, 1, 1, 8,  8,  0, 'a'},
-   {128, 128, 1, 1, 8,  8,  0, 'a'},
    
    {128, 256, 1, 1, 8,  8,  0, 'e'},
    {128, 256, 1, 1, 8,  8,  0, 'i'},
@@ -63,7 +66,7 @@ Image Images [] = {
    {128, 256, 1, 1, 16, 16, 0, 'i'},
    {128, 256, 1, 1, 16, 16, 0, 'i'},
    {128, 256, 1, 1, 16, 16, 0, 'a'},
-   {128, 256, 1, 1, 16, 16, 0, 'a'},  
+   {128, 256, 1, 1, 16, 16, 0, 'a'},
 
    {256, 128, 10, 1, 8, 8,  0, 'e'},
    {256, 128, 10, 3, 8, 8,  0, 'e'},
@@ -106,6 +109,8 @@ const unsigned int MAX_NUMBER_OF_DIFFERENCE = 10;
 
 int WriteSimple(Image &img)
 {
+   
+   std::cout << "======================= WriteSimple =========(begin of processing current image)" << std::endl;
    std::ostringstream fileName;
    fileName.str("");
    fileName << "TestWriteSimple";
@@ -212,9 +217,9 @@ int WriteSimple(Image &img)
    fileH->SetImageData(imageData,size);
 
 // Step 4 : Set the writting mode and write the image
-   std::cout << "4...";
 
    fileH->SetWriteModeToRaw();
+   std::cout << "4'...";   
    switch (img.writeMode)
    {
       case 'a' : // Write an ACR file
@@ -238,10 +243,13 @@ int WriteSimple(Image &img)
          return 1;
    }
 
+   std::cout << std::endl;
+   fileToBuild->Print();
+
    if( !fileH->Write(fileName.str()) )
    {
       std::cout << "Failed for [" << fileName.str() << "]\n"
-                << "           File is unwrittable\n";
+                << "           File is unwrittable" << std::endl;
 
       fileH->Delete();
 
@@ -250,20 +258,28 @@ int WriteSimple(Image &img)
    }
 
 // Step 5 : Read the written image
-   std::cout << "5...";
+   std::cout << "5..." << std::endl;
    // old form.
    //gdcm::FileHelper *reread = new gdcm::FileHelper( fileName.str() );
    // Better use :
-   gdcm::FileHelper *reread = gdcm::FileHelper::New( );
-   reread->SetFileName( fileName.str() );
-   reread->SetLoadMode(gdcm::LD_ALL); // Load everything
+   gdcm::File *f = gdcm::File::New( );
+   f->SetLoadMode(gdcm::LD_ALL);
+   f->SetFileName( fileName.str() );
+   
+   //reread->SetFileName( fileName.str() );
+   //reread->SetLoadMode(gdcm::LD_ALL); // Load everything
                            // Possible values are 
                            //              gdcm::LD_ALL, 
                            //              gdcm::LD_NOSEQ, 
                            //              gdcm::LD_NOSHADOW,
                            //              gdcm::LD_NOSEQ|gdcm::LD_NOSHADOW, 
                            //              gdcm::LD_NOSHADOWSEQ
-   reread->Load();
+   
+   f->Load();
+  // reread->Load();
+   gdcm::FileHelper *reread = gdcm::FileHelper::New( f );  
+
+   reread->Print();
 
    if( !reread->GetFile()->IsReadable() )
    {
@@ -277,7 +293,7 @@ int WriteSimple(Image &img)
    }
 
 // Step 6 : Compare to the written image
-   std::cout << "6...";
+   std::cout << "6..." << std::endl;
    size_t dataSizeWritten = reread->GetImageDataSize();
    uint8_t *imageDataWritten = reread->GetImageData();
 
@@ -331,7 +347,7 @@ int WriteSimple(Image &img)
       return 1;
    }
 
-   // Test the data's content
+   // Test the data content
    if ( memcmp(imageData, imageDataWritten, size) !=0 )
    {
       std::cout << "Failed" << std::endl
@@ -361,12 +377,9 @@ int WriteSimple(Image &img)
       return 1;
    }
 
-   std::cout << "OK" << std::endl;
-
    fileH->Delete();
    reread->Delete();
    delete[] imageData;
-
    return 0;
 }
 
@@ -380,15 +393,16 @@ int TestWriteSimple(int argc, char *argv[])
       return 1;
    }
 
-   gdcm::Debug::DebugOn();
-       
+  // gdcm::Debug::DebugOn();
+   char c;   
    int ret=0;
    int i=0;
    while( Images[i].sizeX>0 && Images[i].sizeY>0 )
    {
-      std::cout << "Test n :" << i; 
+      std::cout << "Test n :" << i <<std::endl;
       ret += WriteSimple(Images[i] );
       i++;
+
    }
 
    return ret;