Skip to content

Commit 1a32bc3

Browse files
committed
[Topology] Add unit tests for adding elements in MeshTopology
Add tests for adding point, edge, triangle, quad, tetrahedron, hexahedron, prism, and pyramid elements to verify correct functionality and point counting.
1 parent 5360377 commit 1a32bc3

File tree

1 file changed

+115
-1
lines changed

1 file changed

+115
-1
lines changed

Sofa/Component/Topology/Container/Constant/tests/MeshTopology_test.cpp

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ class MeshTopology_test : public BaseTest
6464
bool testEdgeTopology();
6565
bool testVertexTopology();
6666

67+
void testAddPoint() const;
68+
void testAddEdge() const;
69+
void testAddTriangle() const;
70+
void testAddQuad() const;
71+
void testAddTetrahedron() const;
72+
void testAddHexahedron() const;
73+
void testAddPrism() const;
74+
void testAddPyramid() const;
75+
6776
protected:
6877

6978
MeshTopology::SPtr m_topo { nullptr };
@@ -585,11 +594,77 @@ bool MeshTopology_test::testVertexTopology()
585594
return true;
586595
}
587596

597+
void MeshTopology_test::testAddPoint() const
598+
{
599+
const auto before = m_topo->getNbPoints();
600+
m_topo->addPoint(0.0, 0.0, 0.0);
601+
EXPECT_EQ(m_topo->getNbPoints(), before + 1);
602+
}
603+
604+
void MeshTopology_test::testAddEdge() const
605+
{
606+
m_topo->addEdge(0, 1);
607+
EXPECT_EQ(m_topo->getNbPoints(), 2u);
608+
609+
m_topo->addEdge(2, 10);
610+
EXPECT_EQ(m_topo->getNbPoints(), 11u);
611+
}
612+
613+
void MeshTopology_test::testAddTriangle() const
614+
{
615+
m_topo->addTriangle(0, 1, 2);
616+
EXPECT_EQ(m_topo->getNbPoints(), 3u);
617+
618+
m_topo->addTriangle(5, 3, 4);
619+
EXPECT_EQ(m_topo->getNbPoints(), 6u);
620+
}
621+
622+
void MeshTopology_test::testAddQuad() const
623+
{
624+
m_topo->addQuad(0, 1, 2, 3);
625+
EXPECT_EQ(m_topo->getNbPoints(), 4u);
626+
627+
m_topo->addQuad(7, 6, 5, 4);
628+
EXPECT_EQ(m_topo->getNbPoints(), 8u);
629+
}
630+
631+
void MeshTopology_test::testAddTetrahedron() const
632+
{
633+
m_topo->addTetra(0, 1, 2, 3);
634+
EXPECT_EQ(m_topo->getNbPoints(), 4u);
588635

636+
m_topo->addTetra(2, 5, 9, 3);
637+
EXPECT_EQ(m_topo->getNbPoints(), 10u);
638+
}
589639

640+
void MeshTopology_test::testAddHexahedron() const
641+
{
642+
m_topo->addHexa(0, 1, 2, 3, 4, 5, 6, 7);
643+
EXPECT_EQ(m_topo->getNbPoints(), 8u);
590644

591-
TEST_F(MeshTopology_test, testEmptyContainer)
645+
m_topo->addHexa(10, 11, 12, 13, 14, 15, 16, 31);
646+
EXPECT_EQ(m_topo->getNbPoints(), 32u);
647+
}
648+
649+
void MeshTopology_test::testAddPrism() const
650+
{
651+
m_topo->addPrism(0, 1, 2, 3, 4, 5);
652+
EXPECT_EQ(m_topo->getNbPoints(), 6u);
653+
654+
m_topo->addPrism(4, 8, 6, 7, 2, 12);
655+
EXPECT_EQ(m_topo->getNbPoints(), 13u);
656+
}
657+
658+
void MeshTopology_test::testAddPyramid() const
592659
{
660+
m_topo->addPyramid(0, 1, 2, 3, 4);
661+
EXPECT_EQ(m_topo->getNbPoints(), 5u);
662+
663+
m_topo->addPyramid(10, 11, 12, 13, 20);
664+
EXPECT_EQ(m_topo->getNbPoints(), 21u);
665+
}
666+
667+
TEST_F(MeshTopology_test, testEmptyContainer) {
593668
ASSERT_TRUE(testEmptyContainer());
594669
}
595670

@@ -624,6 +699,45 @@ TEST_F(MeshTopology_test, testEdgeTopology)
624699
// ASSERT_TRUE(testVertexTopology());
625700
//}
626701

702+
TEST_F(MeshTopology_test, testAddPoint)
703+
{
704+
testAddPoint();
705+
}
706+
707+
TEST_F(MeshTopology_test, testAddEdge)
708+
{
709+
testAddEdge();
710+
}
711+
712+
TEST_F(MeshTopology_test, testAddTriangle)
713+
{
714+
testAddTriangle();
715+
}
716+
717+
TEST_F(MeshTopology_test, testAddQuad)
718+
{
719+
testAddQuad();
720+
}
721+
722+
TEST_F(MeshTopology_test, testAddTetrahedron)
723+
{
724+
testAddTetrahedron();
725+
}
726+
727+
TEST_F(MeshTopology_test, testAddHexahedron)
728+
{
729+
testAddHexahedron();
730+
}
731+
732+
TEST_F(MeshTopology_test, testAddPrism)
733+
{
734+
testAddPrism();
735+
}
736+
737+
TEST_F(MeshTopology_test, testAddPyramid)
738+
{
739+
testAddPyramid();
740+
}
627741

628742

629743
// TODO epernod 2018-07-05: test element on Border

0 commit comments

Comments
 (0)