[cig-commits] r13040 - in cs/cigma/trunk/tests: . libcigma

luis at geodynamics.org luis at geodynamics.org
Wed Oct 15 02:07:29 PDT 2008


Author: luis
Date: 2008-10-15 02:07:28 -0700 (Wed, 15 Oct 2008)
New Revision: 13040

Added:
   cs/cigma/trunk/tests/README
   cs/cigma/trunk/tests/libcigma/NodeCoordinatesTest.cpp
   cs/cigma/trunk/tests/libcigma/NodeCoordinatesTest.h
Modified:
   cs/cigma/trunk/tests/test_registry.cpp
Log:
CppUnit test for NodeCoordinates

Added: cs/cigma/trunk/tests/README
===================================================================
--- cs/cigma/trunk/tests/README	                        (rev 0)
+++ cs/cigma/trunk/tests/README	2008-10-15 09:07:28 UTC (rev 13040)
@@ -0,0 +1,3 @@
+This directory contains the unit tests for the libcigma static library.
+To see the results of these tests on various systems, refer to the
+cigma buildbots located at http://www.geodynamics.org:8009/?project=cigma

Added: cs/cigma/trunk/tests/libcigma/NodeCoordinatesTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/NodeCoordinatesTest.cpp	                        (rev 0)
+++ cs/cigma/trunk/tests/libcigma/NodeCoordinatesTest.cpp	2008-10-15 09:07:28 UTC (rev 13040)
@@ -0,0 +1,67 @@
+#include "NodeCoordinatesTest.h"
+
+#include "NodeCoordinates.h"
+#include "Exception.h"
+
+#include <boost/smart_ptr.hpp>
+
+using namespace libcigma;
+
+using namespace cigma;
+using boost::shared_ptr;
+
+
+NodeCoordinatesTest::NodeCoordinatesTest() {}
+NodeCoordinatesTest::~NodeCoordinatesTest() {}
+
+void NodeCoordinatesTest::test_constructor()
+{
+    int i,j;
+
+    const int nno = 8;
+    const int nsd = 3;
+
+    int node_number_map[nno] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+
+    double _coords[nno*nsd] = {
+        -1.0, -1.0, -1.0,
+        +1.0, -1.0, -1.0,
+        +1.0, +1.0, -1.0,
+        -1.0, +1.0, -1.0,
+        -1.0, -1.0, +1.0,
+        +1.0, -1.0, +1.0,
+        +1.0, +1.0, +1.0,
+        -1.0, +1.0, +1.0
+    };
+
+    double *m_coords = new double[nno * nsd];
+    for (i = 0; i < nno; i++)
+    {
+        for (j = 0; j < nsd; j++)
+        {
+            int k = i*nsd + j;
+            m_coords[k] = _coords[k];
+        }
+    }
+
+    const double delta = 1e-6;
+    shared_ptr<NodeCoordinates> coords(new NodeCoordinates());
+    coords->setCoordinates(m_coords, nno, nsd);
+    for (i = 0; i < nno; i++)
+    {
+        for (j = 0; j < nsd; j++)
+        {
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(coords->getPoint(i,j), _coords[i*nsd+j], delta);
+        }
+    }
+    for (i =0; i < nno; i++)
+    {
+        double *pt = coords->getPointOffset(i);
+        for (j = 0; j < nsd; j++)
+        {
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(pt[j], _coords[i*nsd + j], delta);
+        }
+    }
+
+    return;
+}

Added: cs/cigma/trunk/tests/libcigma/NodeCoordinatesTest.h
===================================================================
--- cs/cigma/trunk/tests/libcigma/NodeCoordinatesTest.h	                        (rev 0)
+++ cs/cigma/trunk/tests/libcigma/NodeCoordinatesTest.h	2008-10-15 09:07:28 UTC (rev 13040)
@@ -0,0 +1,22 @@
+#ifndef __NODE_COORDINATES_TEST_H__
+#define __NODE_COORDINATES_TEST_H__
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace libcigma
+{
+    class NodeCoordinatesTest : public CPPUNIT_NS::TestFixture
+    {
+        CPPUNIT_TEST_SUITE(NodeCoordinatesTest);
+        CPPUNIT_TEST(test_constructor);
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+        NodeCoordinatesTest();
+        ~NodeCoordinatesTest();
+        void test_constructor();
+    };
+}
+
+#endif

Modified: cs/cigma/trunk/tests/test_registry.cpp
===================================================================
--- cs/cigma/trunk/tests/test_registry.cpp	2008-10-15 09:07:26 UTC (rev 13039)
+++ cs/cigma/trunk/tests/test_registry.cpp	2008-10-15 09:07:28 UTC (rev 13040)
@@ -8,3 +8,7 @@
 
 #include <libcigma/DataPathTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION(libcigma::DataPathTest);
+
+#include <libcigma/NodeCoordinatesTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION(libcigma::NodeCoordinatesTest);
+



More information about the cig-commits mailing list