X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tests%2Ftools%2FtoolTestRunner.cxx;h=212321106ec1a32458977c592be1e19a4274a8a6;hb=378ee630dce37a3e15baf3a8027542c2f8cf43de;hp=8a49c43e1cedb0561fe41068877fa7b7d23ecd6f;hpb=4d95e8a4680c1f0e635da4a36b336d316f16b8ba;p=clitk.git diff --git a/tests/tools/toolTestRunner.cxx b/tests/tools/toolTestRunner.cxx index 8a49c43..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){ @@ -78,6 +111,11 @@ void dosToUnixFile(std::string dosFile, std::string unixedFile){ } #endif + +std::string mhdToRawName(const std::string &mhdName){ + int found = mhdName.find_last_of("."); + return mhdName.substr(0, found)+".raw"; +} /** * argv * [1] executable @@ -90,7 +128,8 @@ void dosToUnixFile(std::string dosFile, std::string unixedFile){ int main(int argc, char** argv){ //reference file must exist or we fail char* refFile = argv[argc-1]; - assertFalse(!(itksys::SystemTools::FileExists(refFile, true)), "refFile "+std::string(refFile)+" doesn't exist"); + std::string strRefFile = std::string(refFile); + assertFalse(!(itksys::SystemTools::FileExists(refFile, true)), "refFile "+strRefFile+" doesn't exist"); std::ostringstream cmd_line; cmd_line<