]> Creatis software - gdcm.git/blob - Testing/TestAllVM.cxx
ENH: You can now do os << TagKey .... rahhhhh finally
[gdcm.git] / Testing / TestAllVM.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestAllVM.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/10/21 15:01:28 $
7   Version:   $Revision: 1.3 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmFile.h"
20 #include "gdcmDataEntry.h"
21
22 //Generated file:
23 #include "gdcmDataImages.h"
24
25 int TestAllVM(int, char *[])
26 {
27    int i = 0;
28
29    while( gdcmDataImages[i] != 0 )
30    {
31       std::string filename = GDCM_DATA_ROOT;
32       filename += "/";
33       filename += gdcmDataImages[i];
34
35       gdcm::File file;
36       file.SetLoadMode( gdcm::LD_NOSHADOW );
37       file.SetFileName( filename );
38       if( !file.Load() ) //would be really bad...
39         return 1;
40
41       gdcm::DocEntry *d = file.GetFirstEntry();
42       std::cerr << "Testing file : " << filename << std::endl;
43       while(d)
44       {
45          if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
46          {
47            if( !de->IsValueCountValid() )
48              {
49              std::cerr << "Element: " << de->GetKey() <<
50                " (" << de->GetName() << ") " <<
51                "Contains a wrong VM: " << de->GetValueCount() 
52                << " should be: " << de->GetVM() << std::endl;;
53              }
54          }
55          else
56          {
57           // We skip pb of SQ recursive exploration
58          }
59
60          d = file.GetNextEntry();
61          std::cerr << std::endl; // skip a line after each file
62       }
63
64       i++;
65    }
66    return 0;
67 }
68