]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Correction of bug in DataArrayInt::sortEachPairToMakeALinkedList
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 16 Jun 2016 14:19:04 +0000 (16:19 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 16 Jun 2016 14:19:04 +0000 (16:19 +0200)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py

index 4df56d006feea6e88871cb1dd325628350ea191e..8f90e1e173f81d343685c9d84edcc9e023611727 100644 (file)
@@ -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]);
+            }
         }
     }
 }
index b8a712ce15caeaaf0d022e6f7ca1253e285a0cae..a9b6541fb1ab7fd5c04534a5e34e6f8a40d541c1 100644 (file)
@@ -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):