X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tests%2Ftools%2FtoolTestRunner.cxx;h=212321106ec1a32458977c592be1e19a4274a8a6;hb=378ee630dce37a3e15baf3a8027542c2f8cf43de;hp=a4795ee8781fc1e6d4e73fb4b71bf55024a1019e;hpb=e0ebf1a64a59619732afac9476efd97fc9a2dcb6;p=clitk.git diff --git a/tests/tools/toolTestRunner.cxx b/tests/tools/toolTestRunner.cxx index a4795ee..2123211 100644 --- a/tests/tools/toolTestRunner.cxx +++ b/tests/tools/toolTestRunner.cxx @@ -57,6 +57,39 @@ void assertFalse(int fail, const std::string &message=""){ exit(1); } } +bool isLineToIgnore(const std::string line){ + if(std::string::npos == line.find_first_of("ITK_InputFilterName")){ + return true; + } + return false; +} +bool mhdCmp(const std::string &file, const std::string &refFile){ + bool sameFiles = true; + std::ifstream in(file.c_str()); + std::ifstream ref(file.c_str()); + std::string line; + std::string refLine; + while ( in.good() && ref.good()){ + getline (in,line); + //does the line begins by an attribute to ignore + if(isLineToIgnore(line)){ + continue; + } + + getline(ref,refLine); + while(isLineToIgnore(refLine)){ + getline(ref,refLine); + } + if(line!=refLine){ + sameFiles = false; + break; + } + } + in.close(); + ref.close(); + //check files same length + return sameFiles; +} #ifdef _WIN32 void dosToUnixFile(std::string dosFile, std::string unixedFile){ @@ -118,18 +151,18 @@ int main(int argc, char** argv){ //run the command line system(cmd_line.str().c_str()); + assertFalse(!itksys::SystemTools::FileExists(outFile.c_str(), true), "no mhd have been generated"); //compare source files #ifdef _WIN32 std::string unixedOutFile= getTmpFileName(); //replace \r\n dosToUnixFile(outFile, unixedOutFile); - assertFalse((itksys::SystemTools::FilesDiffer(unixedOutFile.c_str(), refFile)), "Generated mhd file != ref File"); + assertFalse(!mhdCmp(unixedOutFile, refFile), "Generated mhd file != ref File"); remove(unixedOutFile.c_str()); #else - assertFalse((itksys::SystemTools::FilesDiffer(outFile.c_str(), refFile)), "Generated mhd file != ref File"); + assertFalse(!mhdCmp(outFile.c_str(), refFile), "Generated mhd file != ref File"); #endif - std::string refRawFile = mhdToRawName(strRefFile); std::string rawFile = mhdToRawName(outFile);