X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=inline;f=tests%2Ftools%2FclitkImageInfoTest.cxx;fp=tests%2Ftools%2FclitkImageInfoTest.cxx;h=7642d08aff39ed170e19181e50629b276c25eff1;hb=39e22c039d0de25c4f1e1c60027e4351cb30e445;hp=0000000000000000000000000000000000000000;hpb=451f8e875ec446efa2235abc2085fcf6ec67f523;p=clitk.git diff --git a/tests/tools/clitkImageInfoTest.cxx b/tests/tools/clitkImageInfoTest.cxx new file mode 100755 index 0000000..7642d08 --- /dev/null +++ b/tests/tools/clitkImageInfoTest.cxx @@ -0,0 +1,51 @@ +#include +#include + +#include +#include +#include + +#include + +const size_t NUMTESTS=2; + +// test files +const char mhd_files[NUMTESTS][128] = { + "data/4d/mhd/00.mhd", + "data/4d/mhd/bh.mhd" +}; + +// pre-written validation files. the idea +// is that the output generated from the test +// files match the verification files +const char validation_files[NUMTESTS][128] = { + "data/tools/clitkImageInfoTestValidate3D.out", + "data/tools/clitkImageInfoTestValidate4D.out" +}; + +int main(int argc, char** argv) +{ + bool failed = false; + for (size_t i = 0; i < NUMTESTS; i++) { + std::ostringstream cmd_line; + cmd_line << "clitkImageInfo " << mhd_files[i] << " > clitkImageInfoTest.out"; + + std::cout << "Executing " << cmd_line.str() << std::endl; + system(cmd_line.str().c_str()); + + // compare output with validation file + std::cout << "Validating output against " << validation_files[i] << std::endl; + bool differ = itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", validation_files[i]); + if (differ) + { + failed = true; + std::cout << "FAILED: Program output and reference do not match." << std::endl; + } + else + { + itksys::SystemTools::RemoveFile("clitkImageInfoTest.out"); + std::cout << "PASSED" << std::endl; + } + } + return failed ? -1 : 0; +} \ No newline at end of file