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)
+++ /dev/null
-/*=========================================================================
- 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 <iostream>
-#include <sstream>
-#include <string>
-#include <fstream>
-#include "gtest/gtest.h"
-#include "stdio.h"
-#include <itksys/SystemTools.hxx>
-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
+++ /dev/null
-/*=========================================================================
- 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 <iostream>
-#include <sstream>
-#include <string>
-#include <fstream>
-#include "gtest/gtest.h"
-#include "stdio.h"
-#include <itksys/SystemTools.hxx>
-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
+++ /dev/null
-/*=========================================================================
- 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 <iostream>
-#include <sstream>
-#include <string>
-#include <fstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <itksys/SystemTools.hxx>
-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;
-}
+++ /dev/null
-/*=========================================================================
- 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 <iostream>
-#include <sstream>
-#include "gtest/gtest.h"
-#include <itksys/SystemTools.hxx>
-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
}
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"<<std::endl;
exit(TEST_EXITED);
}
return std::string(fileName);
}
+
+
/**
* argv
* [1] executable
+++ /dev/null
-#include "gtest/gtest.h"
-int main(int argc, char** argv){
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}