1 // Copyright (C) 2013-2015 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "TestUtils.hxx"
23 #include "XaoTest.hxx"
24 #include "../XAO_XaoUtils.hxx"
25 #include "../XAO_Xao.hxx"
26 #include "../XAO_BrepGeometry.hxx"
27 #include "../XAO_Group.hxx"
28 #include "../XAO_Field.hxx"
36 void XaoTest::tearDown()
40 void XaoTest::cleanUp()
44 void XaoTest::testGroups()
47 CPPUNIT_ASSERT_THROW(obj.addGroup(XAO::FACE), XAO_Exception);
49 BrepGeometry* geom = new BrepGeometry("test");
50 obj.setGeometry(geom);
51 Group* gr = obj.addGroup(XAO::FACE);
52 CPPUNIT_ASSERT_EQUAL(XAO::FACE, gr->getDimension());
53 CPPUNIT_ASSERT_EQUAL(1, obj.countGroups());
54 Group* gr2 = obj.addGroup(XAO::FACE);
57 Group* agr = obj.getGroup(0);
58 CPPUNIT_ASSERT(gr == agr);
59 CPPUNIT_ASSERT_THROW(obj.getGroup(10), XAO_Exception);
61 CPPUNIT_ASSERT_EQUAL(true, obj.removeGroup(gr2));
62 CPPUNIT_ASSERT_EQUAL(1, obj.countGroups());
65 Group* gr3 = new Group(XAO::FACE, 3);
66 CPPUNIT_ASSERT_EQUAL(false, obj.removeGroup(gr3));
70 void XaoTest::testFields()
73 CPPUNIT_ASSERT_THROW(obj.addField(XAO::INTEGER, XAO::FACE, 3), XAO_Exception);
75 BrepGeometry* geom = new BrepGeometry("test");
76 obj.setGeometry(geom);
77 Field* fi = obj.addField(XAO::INTEGER, XAO::FACE, 3);
78 CPPUNIT_ASSERT_EQUAL(1, obj.countFields());
79 CPPUNIT_ASSERT_EQUAL(XAO::INTEGER, fi->getType());
80 CPPUNIT_ASSERT_EQUAL(XAO::FACE, fi->getDimension());
81 CPPUNIT_ASSERT_EQUAL(3, fi->countComponents());
83 Field* fb = obj.addField(XAO::BOOLEAN, XAO::FACE, 3);
84 Field* fd = obj.addField(XAO::DOUBLE, XAO::FACE, 3);
85 Field* fs = obj.addField(XAO::STRING, XAO::FACE, 3);
86 CPPUNIT_ASSERT_EQUAL(4, obj.countFields());
87 CPPUNIT_ASSERT_THROW(obj.getField(10), XAO_Exception);
89 CPPUNIT_ASSERT_EQUAL(true, obj.removeField(fb));
90 CPPUNIT_ASSERT_EQUAL(3, obj.countFields());
93 Field* ff = Field::createField(XAO::INTEGER, XAO::FACE, 3, 3);
94 CPPUNIT_ASSERT_EQUAL(false, obj.removeField(ff));
98 void XaoTest::testFieldsTypes()
101 BrepGeometry* geom = new BrepGeometry("test");
102 obj.setGeometry(geom);
104 IntegerField* fi = obj.addIntegerField(XAO::FACE, 3);
105 BooleanField* fb = obj.addBooleanField(XAO::FACE, 3);
106 DoubleField* fd = obj.addDoubleField(XAO::FACE, 3);
107 StringField* fs = obj.addStringField(XAO::FACE, 3);
109 IntegerField* gfi = obj.getIntegerField(0);
110 CPPUNIT_ASSERT(gfi == fi);
111 BooleanField* gfb = obj.getBooleanField(1);
112 CPPUNIT_ASSERT(gfb == fb);
113 DoubleField* gfd = obj.getDoubleField(2);
114 CPPUNIT_ASSERT(gfd == fd);
115 StringField* gfs = obj.getStringField(3);
116 CPPUNIT_ASSERT(gfs == fs);
118 CPPUNIT_ASSERT_THROW(obj.getIntegerField(1), XAO_Exception);
119 CPPUNIT_ASSERT_THROW(obj.getBooleanField(0), XAO_Exception);
120 CPPUNIT_ASSERT_THROW(obj.getDoubleField(0), XAO_Exception);
121 CPPUNIT_ASSERT_THROW(obj.getStringField(0), XAO_Exception);