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