]> Creatis software - clitk.git/commitdiff
correction of data test path
authormpech <maxime.pech@insa-lyon.fr>
Thu, 19 May 2011 15:36:26 +0000 (17:36 +0200)
committermpech <maxime.pech@insa-lyon.fr>
Thu, 19 May 2011 15:36:26 +0000 (17:36 +0200)
adding some trivial test

tests/CMakeLists.txt
tests/tools/clitkAffineTransformTest.cxx [new file with mode: 0644]
tests/tools/clitkImageInfoTest.cxx

index 0b0ad3eac8c729c40cd519761c52cbbf092d7397..bc9beae3f91d5f5ccad2def356d1c46e675d87e7 100644 (file)
@@ -13,9 +13,8 @@ macro(ADD_GOOGLE_TESTS executable)
 endmacro()
 SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests/bin)
 SET(BUILDNAME ${CMAKE_SYSTEM_NAME}${CMAKE_OSX_ARCHITECTURES} CACHE INTERNAL DOCSTRING)
-SET(CLITK_DATA_PATH ${PROJECT_BINARY_DIR}/tests/data/ CACHE STRING "dataTest path")
+SET(CLITK_DATA_PATH ${PROJECT_SOURCE_DIR}/tests/data/ CACHE STRING "dataTest path")
 #todo  test if data test path exists
-
 ADD_DEFINITIONS(-DCLITK_DATA_PATH=\"${CLITK_DATA_PATH}\")
 
 add_library(gtest UNKNOWN IMPORTED)
diff --git a/tests/tools/clitkAffineTransformTest.cxx b/tests/tools/clitkAffineTransformTest.cxx
new file mode 100644 (file)
index 0000000..1af7cc2
--- /dev/null
@@ -0,0 +1,43 @@
+/*=========================================================================
+  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;
+  ASSERT_TRUE(itksys::SystemTools::FileExists(mhd.c_str(), true));
+  ASSERT_TRUE(itksys::SystemTools::FileExists(refMhd.c_str(), true));
+  ASSERT_TRUE(itksys::SystemTools::FileExists(refRaw.c_str(), true));
+  cmd_line << TOOLS_PATH<<"clitkAffineTransform -i " << mhd << " -o "<<"out.mhd >/dev/null";
+  system(cmd_line.str().c_str());
+  EXPECT_TRUE(itksys::SystemTools::FileExists("out.mhd", true));
+  EXPECT_FALSE( itksys::SystemTools::FilesDiffer("out.mhd", refMhd.c_str())  );
+  EXPECT_FALSE( itksys::SystemTools::FilesDiffer("out.raw", refRaw.c_str())  );
+  remove("out.mhd");
+  remove("out.raw");
+}
+TEST(clitkAffineTransformTest, main){
+  std::string mhd1=std::string(CLITK_DATA_PATH)+"Deformation4D.mhd";
+  std::string refMhd1=std::string(CLITK_DATA_PATH)+"Deformation4DRef.mhd";
+  std::string refRaw1=std::string(CLITK_DATA_PATH)+"Deformation4DRef.raw";
+  compare(mhd1, refMhd1, refRaw1);
+}
\ No newline at end of file
index 5e7476bc9add5f989fd1efd62fd42b2a1454c05c..4f8413c798fba30ae8878e9a216cc22eded500b8 100644 (file)
 #include <itksys/SystemTools.hxx>
 static inline void compare(std::string mhd, std::string ref){
   std::ostringstream cmd_line;
-  ASSERT_TRUE(itksys::SystemTools::FileExists(mhd.c_str(), true));
   cmd_line << TOOLS_PATH<<"clitkImageInfo " << mhd << " > clitkImageInfoTest.out";
-  std::cout << "Executing " << cmd_line.str() << std::endl;
   system(cmd_line.str().c_str());
   
-  bool differ = itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", ref.c_str());
+  EXPECT_FALSE( itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", ref.c_str()) );
   remove("clitkImageInfoTest.out");
-  EXPECT_FALSE(differ);
 }
 TEST(clitkImageInfoTest, main){
-  std::string mhd1=std::string(CLITK_DATA_PATH)+"4d/mhd/00.mhd";
-  std::string ref1=std::string(CLITK_DATA_PATH)+"tools/clitkImageInfoTestValidate3D.out";
-  compare(mhd1, ref1);
+  std::string mhd1=std::string(CLITK_DATA_PATH)+"Deformation4D.mhd";
+  ASSERT_TRUE(itksys::SystemTools::FileExists(mhd1.c_str(), true));
+  
+  std::string mhd2=std::string(CLITK_DATA_PATH)+"Lung3D.mhd";
+  ASSERT_TRUE(itksys::SystemTools::FileExists(mhd2.c_str(), true));
   
-  std::string mhd2=std::string(CLITK_DATA_PATH)+"4d/mhd/bh.mhd";
-  std::string ref2=std::string(CLITK_DATA_PATH)+"tools/clitkImageInfoTestValidate4D.out";
-  compare(mhd2, ref2);
+  mhd1+=" "+mhd2;
+  std::string ref1=std::string(CLITK_DATA_PATH)+"clitkImageInfoTestRef.out";
+  ASSERT_TRUE(itksys::SystemTools::FileExists(ref1.c_str(), true));
+  compare(mhd1, ref1);
 }
\ No newline at end of file