]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Some code factorization
authorageay <ageay>
Thu, 8 Nov 2012 08:56:09 +0000 (08:56 +0000)
committerageay <ageay>
Thu, 8 Nov 2012 08:56:09 +0000 (08:56 +0000)
src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx

index 1068b74c043bac990c91372811beb82229696391..9e98601c0517d764fb9302a2bf320da2e21a252c 100644 (file)
@@ -1638,3 +1638,37 @@ void MEDCouplingBasicsTest5::testDAIBuildUnique1()
   d->decrRef();
 }
 
+void MEDCouplingBasicsTest5::testDAIPartitionByDifferentValues1()
+{
+  const int data[9]={1,0,1,2,0,2,2,-3,2};
+  const int expected1[4]={-3,0,1,2};
+  const int expected2_0[1]={7};
+  const int expected2_1[2]={1,4};
+  const int expected2_2[2]={0,2};
+  const int expected2_3[4]={3,5,6,8};
+  DataArrayInt *d=DataArrayInt::New();
+  d->useArray(data,false,CPP_DEALLOC,9,1);
+  std::vector<int> f;
+  static const int nbOfOutputsExpected=4;
+  std::vector<DataArrayInt *> e=d->partitionByDifferentValues(f);
+  d->decrRef();
+  CPPUNIT_ASSERT_EQUAL(nbOfOutputsExpected,(int)e.size());
+  CPPUNIT_ASSERT_EQUAL(nbOfOutputsExpected,(int)f.size());
+  for(int i=0;i<nbOfOutputsExpected;i++)
+    {
+      CPPUNIT_ASSERT_EQUAL(expected1[i],f[i]);
+    }
+  CPPUNIT_ASSERT_EQUAL(1,e[0]->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(2,e[1]->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(2,e[2]->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(4,e[3]->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(1,e[0]->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(1,e[1]->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(1,e[2]->getNumberOfComponents());
+  CPPUNIT_ASSERT_EQUAL(1,e[3]->getNumberOfComponents());
+  CPPUNIT_ASSERT(std::equal(expected2_0,expected2_0+1,e[0]->begin()));
+  CPPUNIT_ASSERT(std::equal(expected2_1,expected2_1+2,e[1]->begin()));
+  CPPUNIT_ASSERT(std::equal(expected2_2,expected2_2+2,e[2]->begin()));
+  CPPUNIT_ASSERT(std::equal(expected2_3,expected2_3+4,e[3]->begin()));
+  e[0]->decrRef(); e[1]->decrRef(); e[2]->decrRef(); e[3]->decrRef();
+}
index 8f4607cc9a23eb8f8a816d3213f9e868179e748c..1ee856333a77f0c01e8cade367922aa76ff27f8c 100644 (file)
@@ -68,6 +68,7 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testDuplicateEachTupleNTimes1 );
     CPPUNIT_TEST( testIntersect2DMeshesTmp5 );
     CPPUNIT_TEST( testDAIBuildUnique1 );
+    CPPUNIT_TEST( testDAIPartitionByDifferentValues1 );
     CPPUNIT_TEST_SUITE_END();
   public:
     void testUMeshTessellate2D1();
@@ -102,6 +103,7 @@ namespace ParaMEDMEM
     void testDuplicateEachTupleNTimes1();
     void testIntersect2DMeshesTmp5();
     void testDAIBuildUnique1();
+    void testDAIPartitionByDifferentValues1();
   };
 }