]> Creatis software - clitk.git/blob - tests/tools/clitkImageInfoTest.cxx
changes in license header
[clitk.git] / tests / tools / clitkImageInfoTest.cxx
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 <cstdlib>
19 #include <cstdio>
20
21 #include <iostream>
22 #include <sstream>
23 #include <string>
24
25 #include <itksys/SystemTools.hxx>
26
27
28 const size_t NUMTESTS=2;
29
30 // test files
31 const char mhd_files[NUMTESTS][128] = {
32   CLITK_DATA_PATH"/4d/mhd/00.mhd",
33   CLITK_DATA_PATH"/4d/mhd/bh.mhd"
34 };
35
36 // pre-written validation files. the idea
37 // is that the output generated from the test
38 // files match the verification files
39 const char validation_files[NUMTESTS][128] = {
40   CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate3D.out",
41   CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate4D.out"
42 };
43
44 int main(int argc, char** argv)
45 {
46   system("pwd");
47   
48   bool failed = false;
49   for (size_t i = 0; i < NUMTESTS; i++) {
50     std::ostringstream cmd_line;
51     cmd_line << "clitkImageInfo " << mhd_files[i] << " > clitkImageInfoTest.out";
52
53     std::cout << "Executing " << cmd_line.str() << std::endl;
54     system(cmd_line.str().c_str());
55     
56     // compare output with validation file
57     std::cout << "Validating output against " << validation_files[i] << std::endl;
58     bool differ = itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", validation_files[i]);
59     if (differ)
60     {
61       failed = true;
62       std::cout << "FAILED: Program output and reference do not match." << std::endl;
63     }
64     else
65     {
66       itksys::SystemTools::RemoveFile("clitkImageInfoTest.out");
67       std::cout << "PASSED" << std::endl;
68     }
69   }
70   return failed ? -1 : 0;
71 }