]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
add XaoTest
authorfps <fps@opencascade.com>
Mon, 9 Sep 2013 15:08:17 +0000 (15:08 +0000)
committerfps <fps@opencascade.com>
Mon, 9 Sep 2013 15:08:17 +0000 (15:08 +0000)
src/XAO/tests/XaoTest.cxx [new file with mode: 0644]
src/XAO/tests/XaoTest.hxx [new file with mode: 0644]

diff --git a/src/XAO/tests/XaoTest.cxx b/src/XAO/tests/XaoTest.cxx
new file mode 100644 (file)
index 0000000..23a0fa6
--- /dev/null
@@ -0,0 +1,70 @@
+#include <vector>
+#include <Utils_SALOME_Exception.hxx>
+
+#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 (file)
index 0000000..777afb3
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef __XAO_XAO_TEST_HXX__
+#define __XAO_XAO_TEST_HXX__
+
+#include <cppunit/extensions/HelperMacros.h>
+
+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__