Back to index

salome-med  6.5.0
Functions
MEDMEMTest_Coordinate_fault.cxx File Reference
#include "MEDMEM_Array.hxx"
#include "MEDMEM_Coordinate.hxx"

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file MEDMEMTest_Coordinate_fault.cxx.

{
  COORDINATE anEmptyC (2, 10, MED_EN::MED_FULL_INTERLACE);

  // (BUG) Incoherence between setCoordinateName() and getCoordinateName()
  //       C++ index notation is used in "set" methods, while in "get" methods indices start from 1.
  anEmptyC.setCoordinateName("alpha", 1);
  anEmptyC.setCoordinateName("betta", 2);
  // (BUG) Incoherence between setCoordinateUnit() and getCoordinateUnit()
  //       C++ index notation is used in "set" methods, while in "get" methods indices start from 1.
  anEmptyC.setCoordinateUnit("ttt", 1);
  anEmptyC.setCoordinateUnit("sss", 2);

  //CPPUNIT_ASSERT(anEmptyC.getCoordinateName(1) == "alpha");
  //CPPUNIT_ASSERT(anEmptyC.getCoordinateName(2) == "betta");
  //CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(1) == "ttt");
  //CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(2) == "sss");

  int len = 10 * 2;
  double * cc = new double[len];
  for (int i = 0; i < len; i++) {
    cc[i] = (double)(i + 1);
  }

  MEDARRAY<double> mcc (cc, 2, 10, MED_EN::MED_FULL_INTERLACE, false, false);
  delete [] cc;

  // (BUG) Bug in COORDINATE::setCoordinates() in shallow copy mode:
  // Segmentation Fault or Hang up after anEmptyC and mcc destruction,
  // because array will be owned by two pointers (in mcc and in anEmptyC) after this call
  anEmptyC.setCoordinates(&mcc, true);
  // In other case (if we dynamically allocate mcc and do not free it) we will have memory leak.
}