From 0a04d1a2c6e99ad31ab6189d00437390e3bc0884 Mon Sep 17 00:00:00 2001
From: Jonathan Guinet <jonathan.guinet@c-s.fr>
Date: Thu, 13 Oct 2011 15:57:05 +0200
Subject: [PATCH] TEST:  IsAttribute method tests.

---
 .../Code/Wrappers/CommandLine/CMakeLists.txt  | 25 +++++++++++++++++++
 .../otbWrapperCommandLineParserTests.cxx      | 21 ++++++++++++++++
 .../otbWrapperCommandLineTests.cxx            |  2 ++
 3 files changed, 48 insertions(+)

diff --git a/Testing/Code/Wrappers/CommandLine/CMakeLists.txt b/Testing/Code/Wrappers/CommandLine/CMakeLists.txt
index 67315564d2..89d288f8d2 100644
--- a/Testing/Code/Wrappers/CommandLine/CMakeLists.txt
+++ b/Testing/Code/Wrappers/CommandLine/CMakeLists.txt
@@ -23,6 +23,31 @@ add_test(clTvWrapperCommandLineParserTest_GetAtt ${OTB_WRAPPER_COMMAND_LINE_TEST
         "this is a line test to extract --key name1 name2"
   )
 
+add_test(clTvWrapperCommandLineParserTest_IsAttExists_Wrong ${OTB_WRAPPER_COMMAND_LINE_TESTS}
+	otbWrapperCommandLineParserTest3
+        "--m"
+        " TrainImagesClassifier --il QB_1_ortho.tif --vd vd .shape --modulePath test"
+  )
+  
+  
+add_test(clTvWrapperCommandLineParserTest_IsAttExists ${OTB_WRAPPER_COMMAND_LINE_TESTS}
+	otbWrapperCommandLineParserTest4
+        "--m"
+         " TrainImagesClassifier --il QB_1_ortho.tif --vd vd .shape --m name --modulePath test"
+  )
+   
+add_test(clTvWrapperCommandLineParserTest_IsAttExistsEnd ${OTB_WRAPPER_COMMAND_LINE_TESTS}
+	otbWrapperCommandLineParserTest4
+        "--m"
+         " TrainImagesClassifier --il QB_1_ortho.tif --vd vd .shape --modulePath test --m name"
+  )
+    
+add_test(clTvWrapperCommandLineParserTest_IsAttExistsEndNoParam ${OTB_WRAPPER_COMMAND_LINE_TESTS}
+	otbWrapperCommandLineParserTest4
+        "--m"
+        " TrainImagesClassifier --il QB_1_ortho.tif --vd vd .shape --modulePath test --m"
+  )
+   
 add_test(clTvWrapperCommandLineParserTest_GetAttWithoutValue ${OTB_WRAPPER_COMMAND_LINE_TESTS}
 	otbWrapperCommandLineParserTest1
         "--key"
diff --git a/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineParserTests.cxx b/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineParserTests.cxx
index 441c9d1365..4b5a15850a 100644
--- a/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineParserTests.cxx
+++ b/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineParserTests.cxx
@@ -114,5 +114,26 @@ int otbWrapperCommandLineParserTest2(int argc, char* argv[])
   return CheckReturn(res);
 }
 
+int otbWrapperCommandLineParserTest3(int argc, char* argv[])
+{
+  ParserType::Pointer parser = ParserType::New();
+
+  if (parser->IsAttributExists(argv[1], argv[2]))
+    {
+    return EXIT_FAILURE;
+    }
+  return EXIT_SUCCESS;
+}
 
 
+int otbWrapperCommandLineParserTest4(int argc, char* argv[])
+{
+  ParserType::Pointer parser = ParserType::New();
+
+  if (parser->IsAttributExists(argv[1], argv[2]))
+    {
+    return EXIT_SUCCESS;
+    }
+  return EXIT_FAILURE;
+}
+
diff --git a/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineTests.cxx b/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineTests.cxx
index c00478d5da..f107b149d4 100644
--- a/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineTests.cxx
+++ b/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineTests.cxx
@@ -27,6 +27,8 @@ void RegisterTests()
   REGISTER_TEST(otbWrapperCommandLineParserNew);
   REGISTER_TEST(otbWrapperCommandLineParserTest1);
   REGISTER_TEST(otbWrapperCommandLineParserTest2);
+  REGISTER_TEST(otbWrapperCommandLineParserTest3);
+  REGISTER_TEST(otbWrapperCommandLineParserTest4);
   REGISTER_TEST(otbWrapperCommandLineLauncherNew);
   REGISTER_TEST(otbWrapperCommandLineLauncherTest);
 }
-- 
GitLab