From b902cd4e7cede38e98e714c88980ccb7e9d4ed17 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 16 Jun 2016 16:19:04 +0200 Subject: [PATCH] Correction of bug in DataArrayInt::sortEachPairToMakeALinkedList --- src/MEDCoupling/MEDCouplingMemArray.cxx | 4 ++++ src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py | 6 ++++++ 2 files changed, 10 insertions(+) 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): -- 2.39.2