]> Creatis software - clitk.git/blob - tests/tools/clitkImageInfoTest.cxx
Romulo:
[clitk.git] / tests / tools / clitkImageInfoTest.cxx
1 #include <cstdlib>
2 #include <cstdio>
3
4 #include <iostream>
5 #include <sstream>
6 #include <string>
7
8 #include <itksys/SystemTools.hxx>
9
10
11 const size_t NUMTESTS=2;
12
13 // test files
14 const char mhd_files[NUMTESTS][128] = {
15   CLITK_DATA_PATH"/4d/mhd/00.mhd",
16   CLITK_DATA_PATH"/4d/mhd/bh.mhd"
17 };
18
19 // pre-written validation files. the idea
20 // is that the output generated from the test
21 // files match the verification files
22 const char validation_files[NUMTESTS][128] = {
23   CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate3D.out",
24   CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate4D.out"
25 };
26
27 int main(int argc, char** argv)
28 {
29   system("pwd");
30   
31   bool failed = false;
32   for (size_t i = 0; i < NUMTESTS; i++) {
33     std::ostringstream cmd_line;
34     cmd_line << "clitkImageInfo " << mhd_files[i] << " > clitkImageInfoTest.out";
35
36     std::cout << "Executing " << cmd_line.str() << std::endl;
37     system(cmd_line.str().c_str());
38     
39     // compare output with validation file
40     std::cout << "Validating output against " << validation_files[i] << std::endl;
41     bool differ = itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", validation_files[i]);
42     if (differ)
43     {
44       failed = true;
45       std::cout << "FAILED: Program output and reference do not match." << std::endl;
46     }
47     else
48     {
49       itksys::SystemTools::RemoveFile("clitkImageInfoTest.out");
50       std::cout << "PASSED" << std::endl;
51     }
52   }
53   return failed ? -1 : 0;
54 }