Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/med.git] / src / MEDMEM / Test / MEDMEMTest_Coordinate_fault.cxx
1 // Copyright (C) 2006  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
8 //
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20
21 #include "MEDMEM_Array.hxx"
22 #include "MEDMEM_Coordinate.hxx"
23
24 using namespace std;
25 using namespace MEDMEM;
26
27 int main (int argc, char** argv)
28 {
29   COORDINATE anEmptyC (2, 10, MED_EN::MED_FULL_INTERLACE);
30
31   // (BUG) Incoherence between setCoordinateName() and getCoordinateName()
32   //       C++ index notation is used in "set" methods, while in "get" methods indices start from 1.
33   anEmptyC.setCoordinateName("alpha", 1);
34   anEmptyC.setCoordinateName("betta", 2);
35   // (BUG) Incoherence between setCoordinateUnit() and getCoordinateUnit()
36   //       C++ index notation is used in "set" methods, while in "get" methods indices start from 1.
37   anEmptyC.setCoordinateUnit("ttt", 1);
38   anEmptyC.setCoordinateUnit("sss", 2);
39
40   //CPPUNIT_ASSERT(anEmptyC.getCoordinateName(1) == "alpha");
41   //CPPUNIT_ASSERT(anEmptyC.getCoordinateName(2) == "betta");
42   //CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(1) == "ttt");
43   //CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(2) == "sss");
44
45   int len = 10 * 2;
46   double * cc = new double[len];
47   for (int i = 0; i < len; i++) {
48     cc[i] = (double)(i + 1);
49   }
50
51   MEDARRAY<double> mcc (cc, 2, 10, MED_EN::MED_FULL_INTERLACE, false, false);
52   delete [] cc;
53
54   // (BUG) Bug in COORDINATE::setCoordinates() in shallow copy mode:
55   // Segmentation Fault or Hang up after anEmptyC and mcc destruction,
56   // because array will be owned by two pointers (in mcc and in anEmptyC) after this call
57   anEmptyC.setCoordinates(&mcc, true);
58   // In other case (if we dynamically allocate mcc and do not free it) we will have memory leak.
59 }