From: mpech Date: Tue, 26 Jul 2011 09:06:47 +0000 (+0200) Subject: remove toolsTest using google framework X-Git-Tag: v1.3.0~253^2~2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a591c076e3b12441800b4de4061a983a8aba14c1;p=clitk.git remove toolsTest using google framework --- diff --git a/tests/tools/CMakeLists.txt b/tests/tools/CMakeLists.txt index f1b9a7b..90cb097 100644 --- a/tests/tools/CMakeLists.txt +++ b/tests/tools/CMakeLists.txt @@ -8,12 +8,6 @@ SET (CUSTOM_TEST_SRC clitkImageInfoTest.cxx vvMainTest.cxx ) -ADD_EXECUTABLE(toolsTest ${CUSTOM_TEST_SRC}) -ADD_DEFINITIONS(-DCLITK_TEST_TOOLS_PATH=\"${PROJECT_BINARY_DIR}/bin/\") -TARGET_LINK_LIBRARIES(toolsTest vvLib ${vvExternalLibs} gtest) - -# Add all tests found in the source code, calling the executable to run them -add_google_tests ( ${EXECUTABLE_OUTPUT_PATH}/toolsTest ${srcs}) SET(BUILDNAME ${BUILDNAME}_tools CACHE INTERNAL DOCSTRING) diff --git a/tests/tools/clitkAffineTransformTest.cxx b/tests/tools/clitkAffineTransformTest.cxx deleted file mode 100644 index 2a7fe92..0000000 --- a/tests/tools/clitkAffineTransformTest.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/*========================================================================= - 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 -static inline void compare(std::string mhd, std::string refMhd, std::string refRaw){ - std::ostringstream cmd_line; - - //Ensure the description file exists - ASSERT_TRUE(itksys::SystemTools::FileExists(mhd.c_str(), true)); - - //Ensure the description reference file exists - ASSERT_TRUE(itksys::SystemTools::FileExists(refMhd.c_str(), true)); - - //Ensure our reference raw exists - ASSERT_TRUE(itksys::SystemTools::FileExists(refRaw.c_str(), true)); -//todo : test this on windows - //Generate the new mhd and the new raw - cmd_line << TOOLS_PATH<<"clitkAffineTransform -i " << mhd << " -o "<<"out.mhd >/dev/null"; - system(cmd_line.str().c_str()); - - //Check the new file has been created - EXPECT_TRUE(itksys::SystemTools::FileExists("out.mhd", true)); - - //Check the mhd and the produced mhd are still equal - EXPECT_FALSE( itksys::SystemTools::FilesDiffer("out.mhd", refMhd.c_str()) ); - - //Check the raw and the produced raw are different - EXPECT_TRUE( itksys::SystemTools::FilesDiffer("out.raw", refRaw.c_str()) ); - - //clean the produced junk - remove("out.mhd"); - remove("out.raw"); -} -TEST(identity, clitkAffineTransformTest){ - std::string mhd1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4D.mhd"; - std::string refMhd1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4DRef.mhd"; - std::string refRaw1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4DRef.raw"; - compare(mhd1, refMhd1, refRaw1); -} \ No newline at end of file diff --git a/tests/tools/clitkImageInfoTest.cxx b/tests/tools/clitkImageInfoTest.cxx deleted file mode 100644 index a2ab2b5..0000000 --- a/tests/tools/clitkImageInfoTest.cxx +++ /dev/null @@ -1,44 +0,0 @@ -/*========================================================================= - 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 -static inline void compare(std::string mhd, std::string ref){ - std::ostringstream cmd_line; - cmd_line << CLITK_TEST_TOOLS_PATH<<"clitkImageInfo " << mhd << " > clitkImageInfoTest.out"; - system(cmd_line.str().c_str()); - - 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 diff --git a/tests/tools/clitkImageInfoTest_oldWay.cpp b/tests/tools/clitkImageInfoTest_oldWay.cpp deleted file mode 100644 index 634a68c..0000000 --- a/tests/tools/clitkImageInfoTest_oldWay.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*========================================================================= - 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 -#include -#include -int main(int argc, char** argv){ - int fail = 1; - std::string mhd = std::string(CLITK_TEST_DATA_PATH); - std::string ref = std::string(CLITK_TEST_DATA_PATH); - - //We select which image we use to test clitkImageInfo - int idImg = atoi(argv[1]); - switch(idImg){ - case '0': - mhd += "Deformation4D.mhd"; - ref += "clitkImageInfoTestRef"; - break; - case '1': - mhd += "Lung3D.mhd"; - ref += "clitkImageInfoTestRef"; - break; - default: - return fail; - } - //end of selection - - //ensure mhd do exist - if(!itksys::SystemTools::FileExists(mhd.c_str(), true)){ - return fail; - } - //ensure ref do exist - if(!itksys::SystemTools::FileExists(ref.c_str(), true)){ - return fail; - } - - std::ostringstream cmd_line; - cmd_line << TOOLS_PATH <<"clitkImageInfo " << mhd << " > clitkImageInfoTest.out"; - system(cmd_line.str().c_str()); - - //files should be equal, so if this is the case return success=0 - fail = (itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", ref.c_str()))?0:1; - remove("clitkImageInfoTest.out"); - return fail; -} diff --git a/tests/tools/clitkWriteDicomSeriesTest.cxx b/tests/tools/clitkWriteDicomSeriesTest.cxx deleted file mode 100644 index 2e0c505..0000000 --- a/tests/tools/clitkWriteDicomSeriesTest.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/*========================================================================= - 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 "gtest/gtest.h" -#include -TEST(clitkWriteDicomSeriesTest, main){ - - std::string fIn=std::string(CLITK_TEST_DATA_PATH)+"/3d/mhd/00.mhd"; - std::string fOut=std::string(CLITK_TEST_DATA_PATH)+"/3d/dcm/1.2.840.113704.1.111.536.1248695032.26"; - ASSERT_TRUE(itksys::SystemTools::FileExists(fIn.c_str(), true)); - std::ostringstream cmd_line; - cmd_line << TOOLS_PATH <<"clitkWriteDicomSeries -i " << fIn << " -d " << fOut << " -o dcm --verbose"; - EXPECT_TRUE(itksys::SystemTools::FileExists(fOut.c_str(), false)); - EXPECT_TRUE(itksys::SystemTools::FileExists("dcm", false)); - EXPECT_EQ(0, system(cmd_line.str().c_str())); - //does directory exists - itksys::SystemTools::RemoveADirectory("dcm"); -} \ No newline at end of file diff --git a/tests/tools/toolTestRunner.cxx b/tests/tools/toolTestRunner.cxx index 768afec..89deab5 100644 --- a/tests/tools/toolTestRunner.cxx +++ b/tests/tools/toolTestRunner.cxx @@ -33,15 +33,25 @@ int getOutputOptionIndex(int argc, char** argv){ } return NO_OUTPUT_OPTION; } + std::string getTmpFileName(){ char fileName[] = "/tmp/vvTempXXXXXX"; - int fd = mkstemp(fileName); - if(fd==-1){ + + #ifdef _WIN32 + errno_t err = tmpfile_s(&fileName, strlen(fileName)); + #else + int err=0; + int fd = mkstemp(fileName); + if(fd==-1) err=1; + #endif + if(err){ std::cout<<"couldnot create file. Exiting"<