]> Creatis software - clitk.git/blob - tests/tools/clitkAffineTransformTest.cxx
2a7fe92e8089977a61fbb9bae44a8d35d4fe6156
[clitk.git] / tests / tools / clitkAffineTransformTest.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================*/
18 #include <iostream>
19 #include <sstream>
20 #include <string>
21 #include <fstream>
22 #include "gtest/gtest.h"
23 #include "stdio.h"
24 #include <itksys/SystemTools.hxx>
25 static inline void compare(std::string mhd, std::string refMhd, std::string refRaw){
26   std::ostringstream cmd_line;
27   
28   //Ensure the description file exists
29   ASSERT_TRUE(itksys::SystemTools::FileExists(mhd.c_str(), true));
30   
31   //Ensure the description reference file exists
32   ASSERT_TRUE(itksys::SystemTools::FileExists(refMhd.c_str(), true));
33   
34   //Ensure our reference raw exists
35   ASSERT_TRUE(itksys::SystemTools::FileExists(refRaw.c_str(), true));
36 //todo : test this on windows  
37   //Generate the new mhd and the new raw
38   cmd_line << TOOLS_PATH<<"clitkAffineTransform -i " << mhd << " -o "<<"out.mhd >/dev/null";
39   system(cmd_line.str().c_str());
40   
41   //Check the new file has been created
42   EXPECT_TRUE(itksys::SystemTools::FileExists("out.mhd", true));
43   
44   //Check the mhd and the produced mhd are still equal
45   EXPECT_FALSE( itksys::SystemTools::FilesDiffer("out.mhd", refMhd.c_str())  );
46   
47   //Check the raw and the produced raw are different
48   EXPECT_TRUE( itksys::SystemTools::FilesDiffer("out.raw", refRaw.c_str())  );
49   
50   //clean the produced junk
51   remove("out.mhd");
52   remove("out.raw");
53 }
54 TEST(identity, clitkAffineTransformTest){
55   std::string mhd1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4D.mhd";
56   std::string refMhd1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4DRef.mhd";
57   std::string refRaw1=std::string(CLITK_TEST_DATA_PATH)+"Deformation4DRef.raw";
58   compare(mhd1, refMhd1, refRaw1);
59 }