X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestAllVM.cxx;h=3dc460c395514430c33a499e3e796cbefe9c081a;hb=cb593916f564c344b33051ff890ba4a06b77375a;hp=74bab90117f3f5e8d965021bee84e773454c69d2;hpb=0e7b1a139c4071daa78b6a3b2144df02f0b904a9;p=gdcm.git diff --git a/Testing/TestAllVM.cxx b/Testing/TestAllVM.cxx index 74bab901..3dc460c3 100644 --- a/Testing/TestAllVM.cxx +++ b/Testing/TestAllVM.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllVM.cxx,v $ Language: C++ - Date: $Date: 2005/10/21 14:42:12 $ - Version: $Revision: 1.1 $ + 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 @@ -16,54 +16,77 @@ =========================================================================*/ -#include "gdcmDictEntry.h" -#include "gdcmDict.h" -#include "gdcmDictSet.h" #include "gdcmFile.h" -#include "gdcmFileHelper.h" -#include "gdcmUtil.h" -#include "gdcmCommon.h" -#include "gdcmDocEntry.h" -#include "gdcmDocEntrySet.h" -#include "gdcmDocument.h" -#include "gdcmElementSet.h" -#include "gdcmSeqEntry.h" -#include "gdcmSQItem.h" +#include "gdcmDataEntry.h" //Generated file: #include "gdcmDataImages.h" -int TestAllVM(int, char *[]) +int DoTheVMTest(std::string const &filename) { - int i = 0; + 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 ); - while( gdcmDataImages[i] != 0 ) - { - std::string filename = gdcmDataImages[i]; + file->SetFileName( filename ); + if( !file->Load() ) //would be really bad... + return 1; - gdcm::File file; - //file.SetLoadMode( gdcm::LD_NOSEQ ); - file.SetFileName( filename ); - file.Load(); - - gdcm::DocEntry *d = file.GetFirstEntry(); - while(d) + gdcm::DocEntry *d = file->GetFirstEntry(); + std::cerr << "Testing file : " << filename << std::endl; + while(d) + { + if ( gdcm::DataEntry *de = dynamic_cast(d) ) { - if ( gdcm::DataEntry *de = dynamic_cast(d) ) - { - if(! de->IsValueCountValid() ) - std::cerr << "Filename:" << filename << std::endl; + 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() << + " (" << de->GetName() << ") " << + "Contains a wrong VM: " << de->GetValueCount() + << " should be: " << de->GetVM() << std::endl;; + } } - else - { + } + else + { // We skip pb of SQ recursive exploration - } - - d = file->GetNextEntry(); } + d = file->GetNextEntry(); + } + file->Delete(); + return 0; +} + +int TestAllVM(int argc, char *argv[]) +{ + int i = 0; + if( argc >= 2 ) + { + const char *filename = argv[1]; + if( DoTheVMTest( filename ) ) + return 1; + return 0; + } + // else + + while( gdcmDataImages[i] != 0 ) + { + std::string filename = GDCM_DATA_ROOT; + filename += "/"; + filename += gdcmDataImages[i]; + + if( DoTheVMTest( filename ) ) + return 1; i++; + std::cerr << std::endl; // skip a line after each file } + return 0; }