]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
More additionnal tests
authorageay <ageay>
Fri, 4 Jan 2013 07:35:56 +0000 (07:35 +0000)
committerageay <ageay>
Fri, 4 Jan 2013 07:35:56 +0000 (07:35 +0000)
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index c467ed71e6b352202d12fe4e531ef065532dfca1..3a418e0a637bb06c62793cc70f15c46b78b4c3d6 100644 (file)
@@ -10579,6 +10579,58 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         d.pushBackSilent(555)
         d.pushBackSilent(666)
         self.assertTrue(d.isEqual(DataArrayInt([444,555,666])))
+        #
+        d=DataArrayInt()
+        d.alloc(10,1)
+        d.setInfoOnComponent(0,"ABC")
+        d.setName("dEf")
+        d.iota(7)
+        e=DataArrayInt([7,8,9,10,11,12,13,14,15,16]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e))
+        self.assertEqual(10,d.getNbOfElemAllocated())
+        d.pushBackSilent(55)
+        e=DataArrayInt([7,8,9,10,11,12,13,14,15,16,55]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e))
+        self.assertEqual(20,d.getNbOfElemAllocated())
+        d.reserve(4)
+        e=DataArrayInt([7,8,9,10]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e))
+        self.assertEqual(4,d.getNbOfElemAllocated())
+        d.pushBackSilent(5)
+        e=DataArrayInt([7,8,9,10,5]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e))
+        self.assertEqual(8,d.getNbOfElemAllocated())
+        self.assertEqual(5,d.popBackSilent())
+        e=DataArrayInt([7,8,9,10]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e))
+        self.assertEqual(8,d.getNbOfElemAllocated())
+        self.assertRaises(InterpKernelException,d.reserve,-1)
+        e=DataArrayInt([7,8,9,10]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e))
+        self.assertEqual(8,d.getNbOfElemAllocated())
+        d.reserve(0)
+        e=DataArrayInt([]) ; e.setInfoOnComponent(0,"ABC") ; e.setName("dEf") ; self.assertTrue(d.isEqual(e))
+        self.assertEqual(0,d.getNbOfElemAllocated())
+        #
+        d=DataArrayDouble()
+        d.alloc(10,1)
+        d.setInfoOnComponent(0,"ABC")
+        d.setName("dEf")
+        d.iota(7)
+        e=DataArrayDouble([7,8,9,10,11,12,13,14,15,16]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e,1e-14))
+        self.assertEqual(10,d.getNbOfElemAllocated())
+        d.pushBackSilent(55)
+        e=DataArrayDouble([7,8,9,10,11,12,13,14,15,16,55]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e,1e-14))
+        self.assertEqual(20,d.getNbOfElemAllocated())
+        d.reserve(4)
+        e=DataArrayDouble([7,8,9,10]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e,1e-14))
+        self.assertEqual(4,d.getNbOfElemAllocated())
+        d.pushBackSilent(5)
+        e=DataArrayDouble([7,8,9,10,5]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e,1e-14))
+        self.assertEqual(8,d.getNbOfElemAllocated())
+        self.assertEqual(5.,d.popBackSilent())
+        e=DataArrayDouble([7,8,9,10]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e,1e-14))
+        self.assertEqual(8,d.getNbOfElemAllocated())
+        self.assertRaises(InterpKernelException,d.reserve,-1)
+        e=DataArrayDouble([7,8,9,10]) ; e.copyStringInfoFrom(d) ; self.assertTrue(d.isEqual(e,1e-14))
+        self.assertEqual(8,d.getNbOfElemAllocated())
+        d.reserve(0)
+        e=DataArrayDouble([]) ; e.setInfoOnComponent(0,"ABC") ; e.setName("dEf") ; self.assertTrue(d.isEqual(e,1e-14))
+        self.assertEqual(0,d.getNbOfElemAllocated())
         pass
 
     def setUp(self):