From: ageay Date: Thu, 8 Nov 2012 08:56:09 +0000 (+0000) Subject: Some code factorization X-Git-Tag: V6_6_0b1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=097ec3ddd047bc5028ee9162abc84ccfa8efb4bb;p=tools%2Fmedcoupling.git Some code factorization --- diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 1068b74c0..9e98601c0 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -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 f; + static const int nbOfOutputsExpected=4; + std::vector e=d->partitionByDifferentValues(f); + d->decrRef(); + CPPUNIT_ASSERT_EQUAL(nbOfOutputsExpected,(int)e.size()); + CPPUNIT_ASSERT_EQUAL(nbOfOutputsExpected,(int)f.size()); + for(int i=0;igetNbOfElems()); + 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(); +} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx index 8f4607cc9..1ee856333 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx @@ -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(); }; }