Salome HOME
dc14ee9ebbaa14de0a7ad7321916049c82258ec0
[modules/geom.git] / src / XAO / tests / GroupTest.cxx
1 // Copyright (C) 2013-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <vector>
21
22 #include "TestUtils.hxx"
23 #include "GroupTest.hxx"
24 #include "../XAO_XaoUtils.hxx"
25 #include "../XAO_Xao.hxx"
26 #include "../XAO_Group.hxx"
27
28 using namespace XAO;
29
30 void GroupTest::setUp()
31 {
32 }
33
34 void GroupTest::tearDown()
35 {
36 }
37
38 void GroupTest::cleanUp()
39 {
40 }
41
42 void GroupTest::testGroup()
43 {
44     Group* group = new Group(XAO::FACE, 20);
45
46     CPPUNIT_ASSERT_EQUAL(XAO::FACE, group->getDimension());
47     CPPUNIT_ASSERT_EQUAL(20, group->getNbElements());
48
49     CPPUNIT_ASSERT_EQUAL(std::string(""), group->getName());
50     group->setName("the Group");
51     CPPUNIT_ASSERT_EQUAL(std::string("the Group"), group->getName());
52
53     CPPUNIT_ASSERT_EQUAL(0, group->count());
54     group->add(10);
55     CPPUNIT_ASSERT_EQUAL(1, group->count());
56     group->add(12);
57     CPPUNIT_ASSERT_EQUAL(2, group->count());
58     group->add(12);
59     CPPUNIT_ASSERT_EQUAL(2, group->count());
60
61     CPPUNIT_ASSERT_EQUAL(10, group->get(0));
62     CPPUNIT_ASSERT_EQUAL(12, group->get(1));
63     CPPUNIT_ASSERT_THROW(group->get(2), XAO_Exception);
64
65     group->remove(15);
66     CPPUNIT_ASSERT_EQUAL(2, group->count());
67     group->remove(10);
68     CPPUNIT_ASSERT_EQUAL(1, group->count());
69     CPPUNIT_ASSERT_EQUAL(12, group->get(0));
70
71     delete group;
72 }
73
74 void GroupTest::testGroupErrors()
75 {
76     CPPUNIT_ASSERT_THROW(new Group(XAO::WHOLE, 20), XAO_Exception);
77 }