Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDMEMCppTest / MEDMEMTest_VtkMeshDriver.cxx
index 10c6bb0d7d0b48a5c1e88eaa7c88cd4a6e9e6ccc..7145d1489260365bb4fd42d2737995a92ff24793 100644 (file)
@@ -1,29 +1,27 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "MEDMEMTest.hxx"
 #include <cppunit/TestAssert.h>
 
 #include <MEDMEM_VtkMeshDriver.hxx>
-#include <MEDMEM_MedMeshDriver22.hxx>
+#include <MEDMEM_MedMeshDriver.hxx>
 #include <MEDMEM_Mesh.hxx>
 
 // use this define to enable lines, execution of which leads to Segmentation Fault
@@ -54,16 +52,14 @@ using namespace MEDMEM;
  */
 void MEDMEMTest::testVtkMeshDriver()
 {
-  MESH * aMesh = new MESH();
+  MESH * aMesh = new MESH;
 
-  string data_dir                  = getenv("MED_ROOT_DIR");
-  string tmp_dir                   = getenv("TMP") ? getenv("TMP") : "/tmp";
-  string filename_rd               = data_dir + "/share/salome/resources/med/pointe_import22.med";
+  string filename_rd               = getResourceFile("pointe.med");
   string emptyfilename             = "";
   string meshname_rd               = "maa1";
   string meshname                  = "MyMesh";
   string fileNotExistsName         = "/path_not_exists/file_not_exists.vtk";
-  string filename                  =  tmp_dir  + "/my_pointe.vtk";
+  string filename                  = makeTmpFile("my_pointe.vtk");
 
   MEDMEMTest_TmpFilesRemover aRemover;
   aRemover.Register(filename);
@@ -76,10 +72,7 @@ void MEDMEMTest::testVtkMeshDriver()
     CPPUNIT_ASSERT_THROW(aInvalidVtkDriver->open(), MEDEXCEPTION);
     CPPUNIT_ASSERT_THROW(aInvalidVtkDriver->openConst(), MEDEXCEPTION);
 
-    //#ifdef ENABLE_FORCED_FAILURES
-    // (BUG) In destructor of VTK_MESH_DRIVER: Exception after trying close not existing file
-    //CPPUNIT_ASSERT_NO_THROW(delete aInvalidVtkDriver);
-    //#endif
+    CPPUNIT_ASSERT_NO_THROW(delete aInvalidVtkDriver);
   }
 
   {
@@ -98,7 +91,7 @@ void MEDMEMTest::testVtkMeshDriver()
   CPPUNIT_ASSERT(aVtkDriver);
 
   //Create a Mesh
-  MED_MESH_RDONLY_DRIVER22 *aMedMeshRdDriver22 = new MED_MESH_RDONLY_DRIVER22(filename_rd, aMesh);
+  MED_MESH_RDONLY_DRIVER *aMedMeshRdDriver22 = new MED_MESH_RDONLY_DRIVER(filename_rd, aMesh);
   aMedMeshRdDriver22->open();
   aMedMeshRdDriver22->setMeshName(meshname_rd);
 
@@ -110,19 +103,14 @@ void MEDMEMTest::testVtkMeshDriver()
   CPPUNIT_ASSERT_NO_THROW(aVtkDriver->open());
 
   //Trying open file secondary
-  //#ifdef ENABLE_FORCED_FAILURES
-  // (BUG) No exception on attempt to open a file for the second time
-  //CPPUNIT_ASSERT_THROW(aVtkDriver->open(), MEDEXCEPTION);
-  //#endif
+  // (NOT!!! BUG) No exception on attempt to open a file for the second time
+  //CPPUNIT_ASSERT_NO_THROW(aVtkDriver->open());
 
   //Test read method
   CPPUNIT_ASSERT_THROW(aVtkDriver->read(), MEDEXCEPTION);
 
   //Trying write empty mesh
-  //#ifdef ENABLE_FAULTS
-  // ? (BUG) ? In VTK_MESH_DRIVER::write() => Segmentation fault on attempt to write an empty mesh
-  //CPPUNIT_ASSERT_THROW(aVtkDriver->write(), MEDEXCEPTION);
-  //#endif
+  CPPUNIT_ASSERT_THROW(aVtkDriver->write(), MEDEXCEPTION);
 
   //Read mesh from Med file
   aMedMeshRdDriver22->read();
@@ -144,10 +132,7 @@ void MEDMEMTest::testVtkMeshDriver()
   VTK_MESH_DRIVER aVtkDriverCpy_1;
 
   //Test copy constructor
-  //#ifdef ENABLE_FAULTS
-  // (BUG) In copy constructor of VTK_MESH_DRIVER: Segmentation fault
   VTK_MESH_DRIVER aVtkDriverCpy_2 (*aVtkDriver);
-  //#endif
 
   //Test (bool operator ==) defined in GENDRIVER class
   //CPPUNIT_ASSERT(aVtkDriverCpy_2.GENDRIVER::operator==(aVtkDriver));
@@ -162,5 +147,5 @@ void MEDMEMTest::testVtkMeshDriver()
   //Delete objects
   delete aVtkDriver;
   delete aMedMeshRdDriver22;
-  delete aMesh;
+  aMesh->removeReference();
 }