]> Creatis software - gdcm.git/blob - Testing/TestValidate.cxx
Avoid warning with icc
[gdcm.git] / Testing / TestValidate.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestValidate.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/11/17 17:44:25 $
7   Version:   $Revision: 1.7 $
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 #include "gdcmFile.h"
19 #include "gdcmValidator.h"
20
21 #include "gdcmGlobal.h"
22 #include "gdcmDictSet.h"
23
24 //Generated file:
25 #include "gdcmDataImages.h"
26
27 int Validate(std::string const &filename);
28
29 int Validate(std::string const &filename)
30 {
31    gdcm::File *input =  gdcm::File::New( );
32    input->SetFileName(filename);
33    input->Load();
34    gdcm::Validator *v = new gdcm::Validator();
35    v->SetInput( input );
36    return 1; // allways true (we don't want to break the test suite)
37
38
39
40 int TestValidate(int argc, char *argv[])
41 {
42    if ( argc == 2 )
43    {
44       // The test is specified a specific filename, use it instead of looping
45       // over all images
46       const std::string input = argv[1];
47       return Validate( input );
48    }
49    else if ( argc > 2 || argc == 2 )
50    {
51       std::cout << "   Usage: " << argv[0]
52                 << " (no arguments needed)." << std::endl;
53       std::cout << "or   Usage: " << argv[0]
54                 << " filename.dcm " << std::endl;
55       return 1;
56    }
57    // Try to track the "FIXME" problem for VM
58    gdcm::Global::GetDicts()->GetDefaultPubDict()->Print();   
59
60    int i =0;
61    int retVal = 0;  //by default : *no* error
62    while( gdcmDataImages[i] != 0 )
63    {
64       std::string filename = GDCM_DATA_ROOT;
65       filename += "/";  //doh!
66       filename += gdcmDataImages[i];
67       std::cout << filename << std::endl;
68       if( Validate( filename ) != 0 )
69       {
70          retVal++;
71       }
72
73       i++;
74    }
75    retVal = 0; // Never break test suite
76    return retVal;
77 }
78