From e2eb1d97f96ec0b799d7a6e44bd7abc72b6a3875 Mon Sep 17 00:00:00 2001
From: Thomas Feuvrier <thomas.feuvrier@c-s.fr>
Date: Wed, 19 Jul 2006 14:51:24 +0000
Subject: [PATCH] =?UTF-8?q?Corrections=20sur=20la=20m=C3=A9thode=20TestFil?=
 =?UTF-8?q?eReadability=20:=20m=C3=A9thode=20surcharg=C3=A9=20dans=20otb::?=
 =?UTF-8?q?ImageFileReader,=20pour=20=C3=A9viter=20de=20faire=20un=20open?=
 =?UTF-8?q?=20sur=20un=20filename=20qui=20d=C3=A9signe=20un=20r=C3=A9perto?=
 =?UTF-8?q?ire.=20Pourquoi=20:=20parceque=20sous=20Windows,=20ca=20sort=20?=
 =?UTF-8?q?en=20ERREUR.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Testing/Code/Common/CMakeLists.txt     |  9 ++++
 Testing/Code/Common/otbCommonTests.cxx |  1 +
 Testing/Code/Common/otbSystemTest.cxx  | 71 ++++++++++++++++++++++++++
 3 files changed, 81 insertions(+)
 create mode 100755 Testing/Code/Common/otbSystemTest.cxx

diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt
index 78ffdffec7..3f66f690f0 100644
--- a/Testing/Code/Common/CMakeLists.txt
+++ b/Testing/Code/Common/CMakeLists.txt
@@ -14,6 +14,14 @@ SET(TOL 0.0)
 
 SET(COMMON_TESTS ${CXX_TEST_PATH}/otbCommonTests)
 
+# -------            otb::System  -------------
+ADD_TEST(coTuSystemTests_IsA_Methods ${COMMON_TESTS}  
+        otbSystemTest
+        ${OTB_DATA_ROOT}/OTBData.readme
+        ${OTB_DATA_ROOT}
+        )
+
+
 # -------            otb::CommandLibneArgumentParser  -------------
 
 ADD_TEST(coTuCmdLineArgParserHelpWithArg ${COMMON_TESTS}  
@@ -208,6 +216,7 @@ ADD_TEST(coTuImageToLineSpatialObjectListNew ${COMMON_TESTS}
          
 # -------       Fichiers sources CXX -----------------------------------
 SET(BasicCommon_SRCS
+otbSystemTest.cxx
 otbTestCommandLineArgumentParser.cxx
 otbTestCommandLineArgumentParserHelp.cxx
 otbTestCommandLineArgumentParserList.cxx
diff --git a/Testing/Code/Common/otbCommonTests.cxx b/Testing/Code/Common/otbCommonTests.cxx
index b51432533e..e24dab82f6 100644
--- a/Testing/Code/Common/otbCommonTests.cxx
+++ b/Testing/Code/Common/otbCommonTests.cxx
@@ -26,6 +26,7 @@
 
 void RegisterTests()
 {
+REGISTER_TEST(otbSystemTest);
 REGISTER_TEST(otbTestCommandLineArgumentParser);
 REGISTER_TEST(otbTestCommandLineArgumentParserHelp);
 REGISTER_TEST(otbTestCommandLineArgumentParserList);
diff --git a/Testing/Code/Common/otbSystemTest.cxx b/Testing/Code/Common/otbSystemTest.cxx
new file mode 100755
index 0000000000..1579f2dd07
--- /dev/null
+++ b/Testing/Code/Common/otbSystemTest.cxx
@@ -0,0 +1,71 @@
+/*=========================================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+
+#if defined(_MSC_VER)
+#pragma warning ( disable : 4786 )
+#endif
+
+#include "itkExceptionObject.h"
+#include <iostream>
+
+#include "itkMacro.h"
+#include "otbSystem.h"
+
+
+int otbSystemTest( int argc, char* argv[] )
+{
+  try 
+    { 
+    	const char * inputFileName  = argv[1];
+        const char * inputDirName   = argv[2];
+        itk::OStringStream msg;
+
+        if( otb::System::IsAFileName( inputFileName ) == false )
+        {
+                itkGenericExceptionMacro( <<"System::IsAFileName() error : the filename "<<inputFileName<<" is not detected.");
+        }
+        if( otb::System::IsADirName( inputFileName ) == true )
+        {
+                itkGenericExceptionMacro( <<"System::IsADirName() error : the filename "<<inputFileName<<" is detected.");
+        }
+        if( otb::System::IsAFileName( inputDirName ) == true )
+        {
+                itkGenericExceptionMacro(<< "System::IsAFileName() error : the dirname "<<inputDirName<<" is detected!!");
+        }
+        if( otb::System::IsADirName( inputDirName ) == false )
+        {
+                itkGenericExceptionMacro(<< "System::IsADirName() error : the dirname "<<inputDirName<<" is not detected!!");
+        }
+        
+    } 
+  catch( itk::ExceptionObject & err ) 
+    { 
+    std::cout << "Exception itk::ExceptionObject levee !" << std::endl; 
+    std::cout << err << std::endl; 
+    return EXIT_FAILURE;
+    } 
+  catch( ... ) 
+    { 
+    std::cout << "Exception levee inconnue !" << std::endl; 
+    return EXIT_FAILURE;
+    } 
+
+  return EXIT_SUCCESS;
+}
+
+
-- 
GitLab