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