X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tests%2Ftools%2FclitkImageInfoTest.cxx;h=0b3f30394a178b6cb08c7dffdfbeacc17091f312;hb=bd1f811abb8c82158d96efa4ab11ee238ee227d9;hp=149e0c7f9c5e0a3980bdb8010ccb82f7275b7730;hpb=e61f20b8e5d4bb528728223194403e6e37808628;p=clitk.git diff --git a/tests/tools/clitkImageInfoTest.cxx b/tests/tools/clitkImageInfoTest.cxx old mode 100755 new mode 100644 index 149e0c7..0b3f303 --- a/tests/tools/clitkImageInfoTest.cxx +++ b/tests/tools/clitkImageInfoTest.cxx @@ -1,54 +1,44 @@ -#include -#include +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================*/ #include #include #include - +#include +#include "gtest/gtest.h" +#include "stdio.h" #include - - -const size_t NUMTESTS=2; - -// test files -const char mhd_files[NUMTESTS][128] = { - CLITK_DATA_PATH"/4d/mhd/00.mhd", - CLITK_DATA_PATH"/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] = { - CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate3D.out", - CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate4D.out" -}; - -int main(int argc, char** argv) -{ - system("pwd"); +static inline void compare(std::string mhd, std::string ref){ + std::ostringstream cmd_line; + cmd_line << TOOLS_PATH<<"clitkImageInfo " << mhd << " > clitkImageInfoTest.out"; + system(cmd_line.str().c_str()); - 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; + EXPECT_FALSE( itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", ref.c_str()) ); + remove("clitkImageInfoTest.out"); +} +TEST(clitkImageInfoTest, main){ + std::string mhd1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4D.mhd"; + ASSERT_TRUE(itksys::SystemTools::FileExists(mhd1.c_str(), true)); + + std::string mhd2=std::string(CLITK_TEST_DATA_PATH)+"Lung3D.mhd"; + ASSERT_TRUE(itksys::SystemTools::FileExists(mhd2.c_str(), true)); + + mhd1+=" "+mhd2; + std::string ref1=std::string(CLITK_TEST_DATA_PATH)+"clitkImageInfoTestRef.out"; + ASSERT_TRUE(itksys::SystemTools::FileExists(ref1.c_str(), true)); + compare(mhd1, ref1); } \ No newline at end of file