From: fps Date: Mon, 9 Sep 2013 15:08:17 +0000 (+0000) Subject: add XaoTest X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=23adb0a6eb74007558b3aef617dfbba2a2696346;p=modules%2Fgeom.git add XaoTest --- diff --git a/src/XAO/tests/XaoTest.cxx b/src/XAO/tests/XaoTest.cxx new file mode 100644 index 000000000..23a0fa621 --- /dev/null +++ b/src/XAO/tests/XaoTest.cxx @@ -0,0 +1,70 @@ +#include +#include + +#include "TestUtils.hxx" +#include "XaoTest.hxx" +#include "../XAO_Xao.hxx" +#include "../XAO_BrepGeometry.hxx" +#include "../XAO_Group.hxx" +#include "../XAO_Field.hxx" + +using namespace XAO; + +void XaoTest::setUp() +{ +} + +void XaoTest::tearDown() +{ +} + +void XaoTest::cleanUp() +{ +} + +void XaoTest::testGroups() +{ + Xao obj; + CPPUNIT_ASSERT_THROW(obj.addGroup(XAO::FACE), SALOME_Exception); + + BrepGeometry* geom = new BrepGeometry("test"); + obj.setGeometry(geom); + Group* gr = obj.addGroup(XAO::FACE); + CPPUNIT_ASSERT_EQUAL(XAO::FACE, gr->getDimension()); + CPPUNIT_ASSERT_EQUAL(1, obj.countGroups()); + Group* gr2 = obj.addGroup(XAO::FACE); + + Group* agr = obj.getGroup(0); + CPPUNIT_ASSERT(gr == agr); + CPPUNIT_ASSERT_THROW(obj.getGroup(10), SALOME_Exception); + + CPPUNIT_ASSERT_EQUAL(true, obj.removeGroup(gr2)); + CPPUNIT_ASSERT(gr2 != NULL); + CPPUNIT_ASSERT_EQUAL(1, obj.countGroups()); + CPPUNIT_ASSERT_EQUAL(false, obj.removeGroup(gr2)); // remove again +} + +void XaoTest::testFields() +{ + Xao obj; + CPPUNIT_ASSERT_THROW(obj.addField(XAO::INTEGER, XAO::FACE, 3), SALOME_Exception); + + BrepGeometry* geom = new BrepGeometry("test"); + obj.setGeometry(geom); + Field* fi = obj.addField(XAO::INTEGER, XAO::FACE, 3); + CPPUNIT_ASSERT_EQUAL(1, obj.countFields()); + CPPUNIT_ASSERT_EQUAL(XAO::INTEGER, fi->getType()); + CPPUNIT_ASSERT_EQUAL(XAO::FACE, fi->getDimension()); + CPPUNIT_ASSERT_EQUAL(3, fi->countComponents()); + + Field* fb = obj.addField(XAO::BOOLEAN, XAO::FACE, 3); + Field* fd = obj.addField(XAO::DOUBLE, XAO::FACE, 3); + Field* fs = obj.addField(XAO::STRING, XAO::FACE, 3); + CPPUNIT_ASSERT_EQUAL(4, obj.countFields()); + CPPUNIT_ASSERT_THROW(obj.getField(10), SALOME_Exception); + + CPPUNIT_ASSERT_EQUAL(true, obj.removeField(fb)); + CPPUNIT_ASSERT(fb != NULL); + CPPUNIT_ASSERT_EQUAL(3, obj.countFields()); + CPPUNIT_ASSERT_EQUAL(false, obj.removeField(fb)); // remove again +} diff --git a/src/XAO/tests/XaoTest.hxx b/src/XAO/tests/XaoTest.hxx new file mode 100644 index 000000000..777afb399 --- /dev/null +++ b/src/XAO/tests/XaoTest.hxx @@ -0,0 +1,25 @@ +#ifndef __XAO_XAO_TEST_HXX__ +#define __XAO_XAO_TEST_HXX__ + +#include + +namespace XAO +{ + class XaoTest: public CppUnit::TestFixture + { + CPPUNIT_TEST_SUITE(XaoTest); + CPPUNIT_TEST(testGroups); + CPPUNIT_TEST(testFields); + CPPUNIT_TEST_SUITE_END(); + + public: + void setUp(); + void tearDown(); + void cleanUp(); + + void testGroups(); + void testFields(); + }; +} + +#endif // __XAO_GROUP_TEST_HXX__