[cig-commits] r13150 - cs/cigma/trunk/tests/libcigma

luis at geodynamics.org luis at geodynamics.org
Wed Oct 29 15:10:55 PDT 2008


Author: luis
Date: 2008-10-29 15:10:55 -0700 (Wed, 29 Oct 2008)
New Revision: 13150

Added:
   cs/cigma/trunk/tests/libcigma/QuadratureTest.cpp
   cs/cigma/trunk/tests/libcigma/QuadratureTest.h
Log:
Basic test for cigma::Quadrature

Added: cs/cigma/trunk/tests/libcigma/QuadratureTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/QuadratureTest.cpp	                        (rev 0)
+++ cs/cigma/trunk/tests/libcigma/QuadratureTest.cpp	2008-10-29 22:10:55 UTC (rev 13150)
@@ -0,0 +1,51 @@
+#include "QuadratureTest.h"
+using namespace libcigma;
+
+#include "Quadrature.h"
+using namespace cigma;
+
+void QuadratureTest::test_constructor()
+{
+    int i,j;
+
+    const int npts = 5;
+    const int ndim = 3;
+
+    double X[npts*ndim] = {
+        0, 1, 2,
+        3, 4, 5,
+        6, 7, 8,
+        9, 10, 11,
+        12, 13, 14
+    };
+
+    double W[npts] = {
+        1, 2, 3, 4, 5
+    };
+
+    Quadrature Q1(npts, ndim);
+    Q1.setData(X, W);
+
+    Quadrature Q2;
+    Q2.reinit(npts, ndim);
+    Q2.setData(X, W);
+
+    CPPUNIT_ASSERT_EQUAL(Q1.n_points(), npts);
+    CPPUNIT_ASSERT_EQUAL(Q1.n_dim(), ndim);
+
+    CPPUNIT_ASSERT_EQUAL(Q2.n_points(), npts);
+    CPPUNIT_ASSERT_EQUAL(Q2.n_dim(), ndim);
+
+    const double delta = 1e-8;
+    for (i = 0; i < npts; i++)
+    {
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(Q1.getWeight(i), W[i], delta);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(Q2.getWeight(i), W[i], delta);
+        for (j = 0; j < ndim; j++)
+        {
+            const int n = ndim*i + j;
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(Q1.getPoint(i,j), X[n], delta);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(Q2.getPoint(i,j), X[n], delta);
+        }
+    }
+}

Added: cs/cigma/trunk/tests/libcigma/QuadratureTest.h
===================================================================
--- cs/cigma/trunk/tests/libcigma/QuadratureTest.h	                        (rev 0)
+++ cs/cigma/trunk/tests/libcigma/QuadratureTest.h	2008-10-29 22:10:55 UTC (rev 13150)
@@ -0,0 +1,23 @@
+#ifndef __QUADRATURE_TEST_H__
+#define __QUADRATURE_TEST_H__
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+
+namespace libcigma
+{
+    class QuadratureTest : public CPPUNIT_NS::TestFixture
+    {
+        CPPUNIT_TEST_SUITE(QuadratureTest);
+        CPPUNIT_TEST(test_constructor);
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+        QuadratureTest() {}
+        ~QuadratureTest() {}
+        void test_constructor();
+    };
+};
+
+#endif



More information about the CIG-COMMITS mailing list