From: Anthony Geay Date: Thu, 16 Jun 2016 14:19:04 +0000 (+0200) Subject: Correction of bug in DataArrayInt::sortEachPairToMakeALinkedList X-Git-Tag: V8_1_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b902cd4e7cede38e98e714c88980ccb7e9d4ed17;p=tools%2Fmedcoupling.git Correction of bug in DataArrayInt::sortEachPairToMakeALinkedList --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 4df56d006..8f90e1e17 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -10755,6 +10755,10 @@ void DataArrayInt::sortEachPairToMakeALinkedList() { tmp[3]=conn[2];} std::copy(tmp,tmp+4,conn); } + else + {//here we are sure to have (std::count(conn,conn+4,conn[1])==2) + std::swap(conn[2],conn[3]); + } } } } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index b8a712ce1..a9b6541fb 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -3724,6 +3724,12 @@ class MEDCouplingBasicsTest5(unittest.TestCase): d=DataArrayInt([(50,49),(50,51),(51,52),(53,52),(53,54),(55,54),(55,56),(56,57),(58,57),(58,59),(60,59),(60,61),(61,62),(63,62),(63,64),(65,64),(65,66),(66,67)]) d.sortEachPairToMakeALinkedList() self.assertTrue(d.isEqual(DataArrayInt([(49,50),(50,51),(51,52),(52,53),(53,54),(54,55),(55,56),(56,57),(57,58),(58,59),(59,60),(60,61),(61,62),(62,63),(63,64),(64,65),(65,66),(66,67)]))) + d=DataArrayInt([(0,2),(1,2),(1,3)]) + d.sortEachPairToMakeALinkedList() + self.assertTrue(d.isEqual(DataArrayInt([(0,2),(2,1),(1,3)]))) + d=DataArrayInt([(0,2),(1,2),(3,1)]) + d.sortEachPairToMakeALinkedList() + self.assertTrue(d.isEqual(DataArrayInt([(0,2),(2,1),(1,3)]))) pass def testSwig2DAIIsRange(self):