]> Creatis software - clitk.git/blob - tests/tools/clitkImageInfoTest_oldWay.cpp
fa60e44ec1e9379a19af79d28442d22d9427b3e7
[clitk.git] / tests / tools / clitkImageInfoTest_oldWay.cpp
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================*/
18 #include <iostream>
19 #include <sstream>
20 #include <string>
21 #include <fstream>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <itksys/SystemTools.hxx>
25 int main(int argc, char** argv){
26   int fail = 1;
27   std::string mhd = std::string(CLITK_DATA_PATH);
28   std::string ref = std::string(CLITK_DATA_PATH);
29   
30   //We select which image we use to test clitkImageInfo
31   int idImg = atoi(argv[1]);
32   switch(idImg){
33      case '0':
34         mhd += "Deformation4D.mhd";
35         ref += "clitkImageInfoTestRef";
36       break;
37      case '1':
38         mhd += "Lung3D.mhd";
39         ref += "clitkImageInfoTestRef";
40       break;
41     default:
42       return fail;
43   }  
44   //end of selection
45   
46   //ensure mhd do exist
47   if(!itksys::SystemTools::FileExists(mhd.c_str(), true)){
48       return fail;
49   }
50   //ensure ref do exist
51   if(!itksys::SystemTools::FileExists(ref.c_str(), true)){
52       return fail;
53   }
54   
55   std::ostringstream cmd_line;
56   cmd_line << TOOLS_PATH <<"clitkImageInfo " << mhd << " > clitkImageInfoTest.out";
57   system(cmd_line.str().c_str());
58   
59   //files should be equal, so if this is the case return success=0
60   fail = (itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", ref.c_str()))?0:1;
61   remove("clitkImageInfoTest.out");
62   return fail;
63 }