From b3078be75652ef0f63e11d7c4addfd082e6c9609 Mon Sep 17 00:00:00 2001
From: Aurelien Bricier <aurelien.bricier@c-s.fr>
Date: Fri, 13 Aug 2010 15:44:56 +0200
Subject: [PATCH] TEST: standardized parser and naryparserimagefilter tests

---
 Testing/Code/BasicFilters/CMakeLists.txt             |  3 +++
 Testing/Code/BasicFilters/otbBasicFiltersTests13.cxx |  1 +
 .../Code/BasicFilters/otbNaryParserImageFilter.cxx   | 12 ++++++++++++
 Testing/Code/Common/CMakeLists.txt                   |  5 ++++-
 Testing/Code/Common/otbCommonTests12.cxx             |  1 +
 Testing/Code/Common/otbParserTest.cxx                | 12 +++++++++++-
 6 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt
index bab294fabc..fde17c1125 100644
--- a/Testing/Code/BasicFilters/CMakeLists.txt
+++ b/Testing/Code/BasicFilters/CMakeLists.txt
@@ -1635,6 +1635,9 @@ ADD_TEST(bfTvImageAndVectorImageOperationFilterTest ${BASICFILTERS_TESTS12}
 IF(OTB_COMPILE_MUPARSER)
 
 ADD_TEST(bfTuNaryParserImageFilter ${BASICFILTERS_TESTS13}
+  otbNaryParserImageFilterNew)
+
+ADD_TEST(bfTvNaryParserImageFilter ${BASICFILTERS_TESTS13}
   otbNaryParserImageFilter)
 
 ENDIF(OTB_COMPILE_MUPARSER)
diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests13.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests13.cxx
index 055f85ea82..52cb1eff1b 100644
--- a/Testing/Code/BasicFilters/otbBasicFiltersTests13.cxx
+++ b/Testing/Code/BasicFilters/otbBasicFiltersTests13.cxx
@@ -26,5 +26,6 @@
 
 void RegisterTests()
 {
+  REGISTER_TEST(otbNaryParserImageFilterNew);
   REGISTER_TEST(otbNaryParserImageFilter);
 }
diff --git a/Testing/Code/BasicFilters/otbNaryParserImageFilter.cxx b/Testing/Code/BasicFilters/otbNaryParserImageFilter.cxx
index 29d45a4de8..826079312b 100644
--- a/Testing/Code/BasicFilters/otbNaryParserImageFilter.cxx
+++ b/Testing/Code/BasicFilters/otbNaryParserImageFilter.cxx
@@ -27,6 +27,18 @@
 #include "otbImage.h"
 #include "otbNaryParserImageFilter.h"
 
+int otbNaryParserImageFilterNew( int argc, char* argv[])
+{
+  typedef double                                            PixelType;
+  //typedef float                                             PixelType;
+  typedef otb::Image<PixelType, 2>                          ImageType;
+  typedef otb::NaryParserImageFilter<ImageType>             FilterType;
+
+   FilterType::Pointer         filter       = FilterType::New();
+
+   return EXIT_SUCCESS;
+}
+
 int otbNaryParserImageFilter( int argc, char* argv[])
 {
   typedef double                                            PixelType;
diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt
index 7e20073d8f..7859d8afec 100644
--- a/Testing/Code/Common/CMakeLists.txt
+++ b/Testing/Code/Common/CMakeLists.txt
@@ -993,8 +993,11 @@ otbVectorDataToLabelMapFilter
 
 # ----------------  otbParser  ---------------------#
 IF(OTB_COMPILE_MUPARSER)
-
   ADD_TEST(coTuParser ${COMMON_TESTS12}
+    otbParserTestNew
+    )
+  
+  ADD_TEST(coTvParser ${COMMON_TESTS12}
     otbParserTest
     )
 ENDIF(OTB_COMPILE_MUPARSER)
diff --git a/Testing/Code/Common/otbCommonTests12.cxx b/Testing/Code/Common/otbCommonTests12.cxx
index d296c9c738..f11a9e0d15 100644
--- a/Testing/Code/Common/otbCommonTests12.cxx
+++ b/Testing/Code/Common/otbCommonTests12.cxx
@@ -26,5 +26,6 @@
 
 void RegisterTests()
 {
+  REGISTER_TEST(otbParserTestNew);
   REGISTER_TEST(otbParserTest);
 }
diff --git a/Testing/Code/Common/otbParserTest.cxx b/Testing/Code/Common/otbParserTest.cxx
index e72b013fab..d70a211e20 100644
--- a/Testing/Code/Common/otbParserTest.cxx
+++ b/Testing/Code/Common/otbParserTest.cxx
@@ -21,6 +21,16 @@
 
 #include "otbParser.h"
 
+int otbParserTestNew(int argc, char * argv[])
+{
+  typedef otb::Parser                                 ParserType;
+  
+  // Instantiating object
+  ParserType::Pointer parser = ParserType::New();
+
+  return EXIT_SUCCESS;
+}
+
 int otbParserTest(int argc, char * argv[])
 {
   double result;
@@ -107,7 +117,7 @@ int otbParserTest(int argc, char * argv[])
 
   if(error > 10E-5)
     { 
-    itkGenericExceptionMacro(  << "Cumulated Error > 10E-3 -> Test Failled" << std::endl );
+    itkGenericExceptionMacro(  << "Cumulated Error > 10E-5 -> Test Failled" << std::endl );
     }
 
   /* Exception Tests */
-- 
GitLab