[cig-commits] r13998 - short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology

brad at geodynamics.org brad at geodynamics.org
Thu Jan 29 20:58:39 PST 2009


Author: brad
Date: 2009-01-29 20:58:39 -0800 (Thu, 29 Jan 2009)
New Revision: 13998

Added:
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldBase.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldBase.hh
Modified:
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/Makefile.am
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc
   short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.hh
Log:
Worked on updating unit tests for changes to Field, FieldBase, etc.

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/Makefile.am	2009-01-28 23:26:08 UTC (rev 13997)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/Makefile.am	2009-01-30 04:58:39 UTC (rev 13998)
@@ -21,8 +21,8 @@
 
 # Primary source files
 testtopology_SOURCES = \
+	TestFieldBase.cc \
 	TestField.cc \
-	TestFieldUniform.cc \
 	TestMesh.cc \
 	TestMeshOps.cc \
 	test_topology.cc
@@ -30,8 +30,8 @@
 #	TestFieldsManager.cc
 
 noinst_HEADERS = \
+	TestFieldBase.hh \
 	TestField.hh \
-	TestFieldUniform.hh \
 	TestFieldsManager.hh \
 	TestMesh.hh \
 	TestMeshOps.hh

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc	2009-01-28 23:26:08 UTC (rev 13997)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.cc	2009-01-30 04:58:39 UTC (rev 13998)
@@ -48,92 +48,54 @@
 pylith::topology::TestField::testConstructor(void)
 { // testConstructor
   Mesh mesh;
-  mesh.createSieveMesh();
-  Field field(mesh.sieveMesh());
-
-  CPPUNIT_ASSERT(!field._mesh.isNull());
+  Field field(mesh);
 } // testConstructor
 
 // ----------------------------------------------------------------------
-// Test section() and newSection().
+// Test newSection().
 void
 pylith::topology::TestField::testSection(void)
 { // testSection
   Mesh mesh;
-  mesh.createSieveMesh();
-  Field field(mesh.sieveMesh());
+  Field field(mesh);
 
+  mesh.createSieveMesh();
   const ALE::Obj<SieveMesh::real_section_type>& section = field.section();
   CPPUNIT_ASSERT(section.isNull());
-
-  field.newSection();
-  CPPUNIT_ASSERT(!section.isNull());
 } // testSection
 
 // ----------------------------------------------------------------------
-// Test section() and newSection(points).
+// Test newSection().
 void
-pylith::topology::TestField::testSectionPoints(void)
-{ // testSectionPoints
+pylith::topology::TestField::testNewSection(void)
+{ // testNewSection
   const int fiberDim = 2;
 
   Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
 
-  Field fieldA(sieveMesh);
+  Field fieldA(mesh);
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
   fieldA.newSection(vertices, fiberDim);
   const ALE::Obj<SieveMesh::real_section_type>& sectionA = fieldA.section();
   CPPUNIT_ASSERT(!sectionA.isNull());
 
-  Field fieldB(sieveMesh);
+  Field fieldB(mesh);
   fieldB.newSection(Field::VERTICES_FIELD, fiberDim);
   const ALE::Obj<SieveMesh::real_section_type>& sectionB = fieldB.section();
   CPPUNIT_ASSERT(!sectionB.isNull());
-} // testSectionPoints
+} // testNewSection
 
 // ----------------------------------------------------------------------
-// Test name().
-void 
-pylith::topology::TestField::testName(void)
-{ // testName
-  Mesh mesh;
-  mesh.createSieveMesh();
-  Field field(mesh.sieveMesh());
-
-  CPPUNIT_ASSERT_EQUAL(std::string("unknown"), std::string(field.name()));
-
-  const std::string name = "field A";
-  field.name(name.c_str());
-  CPPUNIT_ASSERT_EQUAL(name, std::string(field.name()));
-} // testName
-
-// ----------------------------------------------------------------------
-// Test vectorFieldType().
-void
-pylith::topology::TestField::testVectorFieldType(void)
-{ // testVectorFieldType
-  Mesh mesh;
-  mesh.createSieveMesh();
-  Field field(mesh.sieveMesh());
-
-  CPPUNIT_ASSERT_EQUAL(Field::OTHER, field.vectorFieldType());
-
-  const Field::VectorFieldEnum ftype = Field::TENSOR;
-  field.vectorFieldType(ftype);
-  CPPUNIT_ASSERT_EQUAL(ftype, field.vectorFieldType());
-} // testVectorFieldType
-
-// ----------------------------------------------------------------------
 // Test spaceDim().
 void
 pylith::topology::TestField::testSpaceDim(void)
 { // testSpaceDim
   Mesh mesh;
   _buildMesh(&mesh);
-  Field field(mesh.sieveMesh());
+  Field field(mesh);
 
   std::cout << "MESH DIM: " << mesh.sieveMesh()->getDimension() << std::endl;
 
@@ -141,37 +103,6 @@
 } // testSpaceDim
 
 // ----------------------------------------------------------------------
-// Test scale().
-void
-pylith::topology::TestField::testScale(void)
-{ // testScale
-  Mesh mesh;
-  mesh.createSieveMesh();
-  Field field(mesh.sieveMesh());
-
-  CPPUNIT_ASSERT_EQUAL(1.0, field.scale());
-
-  const double scale = 4.0;
-  field.scale(scale);
-  CPPUNIT_ASSERT_EQUAL(scale, field.scale());
-} // testScale
-
-// ----------------------------------------------------------------------
-// Test addDimensionOkay().
-void
-pylith::topology::TestField::testAddDimensionOkay(void)
-{ // testAddDimensionOkay
-  Mesh mesh;
-  mesh.createSieveMesh();
-  Field field(mesh.sieveMesh());
-
-  CPPUNIT_ASSERT_EQUAL(false, field.addDimensionOkay());
-
-  field.addDimensionOkay(true);
-  CPPUNIT_ASSERT_EQUAL(true, field.addDimensionOkay());
-} // testAddDimensionOkay
-
-// ----------------------------------------------------------------------
 // Test copyLayout().
 void
 pylith::topology::TestField::testCopyLayout(void)
@@ -194,10 +125,10 @@
     sieveMesh->depthStratum(0);
 
   // Create field with atlas to use to create new field
-  Field fieldSrc(sieveMesh);
+  Field fieldSrc(mesh);
   { // Setup source field
     fieldSrc.newSection(Field::VERTICES_FIELD, fiberDim);
-    const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
+    const ALE::Obj<MeshRealSection>& section = fieldSrc.section();
     int iV=0;
     for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
 	 v_iter != vertices->end();
@@ -206,10 +137,10 @@
     fieldSrc.allocate();
   } // Setup source field
 
-  Field field(sieveMesh);
+  Field field(mesh);
   field.copyLayout(fieldSrc);
 
-  const ALE::Obj<SieveRealSection>& section = field.section();
+  const ALE::Obj<MeshRealSection>& section = field.section();
   int iV = 0;
   for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
        v_iter != vertices->end();
@@ -226,7 +157,7 @@
 pylith::topology::TestField::testClear(void)
 { // testClear
   Mesh mesh(_TestField::cellDim);
-  Field field(mesh.sieveMesh());
+  Field field(mesh);
 
   field.scale(2.0);
   field.vectorFieldType(Field::TENSOR);
@@ -259,10 +190,10 @@
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
 
-  Field field(sieveMesh);
+  Field field(mesh);
   field.newSection(Field::VERTICES_FIELD, fiberDim);
   field.allocate();
-  const ALE::Obj<SieveRealSection>& section = field.section();
+  const ALE::Obj<MeshRealSection>& section = field.section();
 
   double_array values(fiberDim);
   int i = 0;
@@ -306,10 +237,10 @@
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
 
-  Field field(sieveMesh);
+  Field field(mesh);
   field.newSection(Field::VERTICES_FIELD, fiberDim);
   field.allocate();
-  const ALE::Obj<SieveRealSection>& section = field.section();
+  const ALE::Obj<MeshRealSection>& section = field.section();
 
   double_array values(fiberDim);
   int i = 0;
@@ -354,10 +285,10 @@
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
 
-  Field field(sieveMesh);
+  Field field(mesh);
   field.newSection(Field::VERTICES_FIELD, fiberDim);
   field.allocate();
-  const ALE::Obj<SieveRealSection>& section = field.section();
+  const ALE::Obj<MeshRealSection>& section = field.section();
 
   double_array values(fiberDim);
   int i = 0;
@@ -404,11 +335,11 @@
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
 
-  Field fieldSrc(sieveMesh);
+  Field fieldSrc(mesh);
   { // Setup source field
     fieldSrc.newSection(Field::VERTICES_FIELD, fiberDim);
     fieldSrc.allocate();
-    const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
+    const ALE::Obj<MeshRealSection>& section = fieldSrc.section();
     
     double_array values(fiberDim);
     int i = 0;
@@ -421,10 +352,10 @@
     } // for
   } // Setup source field
 
-  Field field(sieveMesh);
+  Field field(mesh);
   field.newSection(Field::VERTICES_FIELD, fiberDim);
   field.allocate();
-  const ALE::Obj<SieveRealSection>& section = field.section();
+  const ALE::Obj<MeshRealSection>& section = field.section();
 
   field.copy(fieldSrc);
 
@@ -467,11 +398,11 @@
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
 
-  Field fieldSrc(sieveMesh);
+  Field fieldSrc(mesh);
   { // Setup source field
     fieldSrc.newSection(Field::VERTICES_FIELD, fiberDim);
     fieldSrc.allocate();
-    const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
+    const ALE::Obj<MeshRealSection>& section = fieldSrc.section();
     
     double_array values(fiberDim);
     int i = 0;
@@ -484,10 +415,10 @@
     } // for
   } // Setup source field
 
-  Field field(sieveMesh);
+  Field field(mesh);
   field.newSection(Field::VERTICES_FIELD, fiberDim);
   field.allocate();
-  const ALE::Obj<SieveRealSection>& section = field.section();
+  const ALE::Obj<MeshRealSection>& section = field.section();
   { // Setup destination field
 
     double_array values(fiberDim);
@@ -535,10 +466,10 @@
   Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
-  Field field(sieveMesh);
+  Field field(mesh);
   field.newSection(Field::VERTICES_FIELD, fiberDim);
   field.allocate();
-  const ALE::Obj<SieveRealSection>& section = field.section();
+  const ALE::Obj<MeshRealSection>& section = field.section();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
 
@@ -587,10 +518,10 @@
   Mesh mesh;
   _buildMesh(&mesh);
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
-  Field field(sieveMesh);
+  Field field(mesh);
   field.newSection(Field::VERTICES_FIELD, fiberDim);
   field.allocate();
-  const ALE::Obj<SieveRealSection>& section = field.section();
+  const ALE::Obj<MeshRealSection>& section = field.section();
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
     sieveMesh->depthStratum(0);
 

Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.hh	2009-01-28 23:26:08 UTC (rev 13997)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestField.hh	2009-01-30 04:58:39 UTC (rev 13998)
@@ -43,12 +43,8 @@
 
   CPPUNIT_TEST( testConstructor );
   CPPUNIT_TEST( testSection );
-  CPPUNIT_TEST( testSectionPoints );
-  CPPUNIT_TEST( testName );
-  CPPUNIT_TEST( testVectorFieldType );
+  CPPUNIT_TEST( testNewSection );
   CPPUNIT_TEST( testSpaceDim );
-  CPPUNIT_TEST( testScale );
-  CPPUNIT_TEST( testAddDimensionOkay );
   CPPUNIT_TEST( testCopyLayout );
   CPPUNIT_TEST( testClear );
   CPPUNIT_TEST( testAllocate );
@@ -67,27 +63,15 @@
   /// Test constructor.
   void testConstructor(void);
 
-  /// Test newSection() and section().
+  /// Test section().
   void testSection(void);
 
-  /// Test newSection(points) and section().
-  void testSectionPoints(void);
+  /// Test newSection().
+  void testNewSection(void);
 
-  /// Test name().
-  void testName(void);
-
-  /// Test vectorFieldType().
-  void testVectorFieldType(void);
-
   /// Test spaceDim().
   void testSpaceDim(void);
 
-  /// Test scale().
-  void testScale(void);
-
-  /// Test addDimensionOkay().
-  void testAddDimensionOkay(void);
-
   /// Test copyLayout().
   void testCopyLayout(void);
 

Added: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldBase.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldBase.cc	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldBase.cc	2009-01-30 04:58:39 UTC (rev 13998)
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestFieldBase.hh" // Implementation of class methods
+#include "pylith/topology/FieldBase.hh" // USES Field
+
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestFieldBase );
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestFieldBase::testConstructor(void)
+{ // testConstructor
+  FieldBase field;
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test name().
+void 
+pylith::topology::TestFieldBase::testName(void)
+{ // testName
+  FieldBase field;
+
+  CPPUNIT_ASSERT_EQUAL(std::string("unknown"), std::string(field.name()));
+
+  const std::string& name = "field A";
+  field.name(name.c_str());
+  CPPUNIT_ASSERT_EQUAL(name, std::string(field.name()));
+} // testName
+
+// ----------------------------------------------------------------------
+// Test vectorFieldType().
+void
+pylith::topology::TestFieldBase::testVectorFieldType(void)
+{ // testVectorFieldType
+  FieldBase field;
+
+  CPPUNIT_ASSERT_EQUAL(FieldBase::OTHER, field.vectorFieldType());
+
+  const FieldBase::VectorFieldEnum ftype = FieldBase::TENSOR;
+  field.vectorFieldType(ftype);
+  CPPUNIT_ASSERT_EQUAL(ftype, field.vectorFieldType());
+} // testVectorFieldType
+
+// ----------------------------------------------------------------------
+// Test scale().
+void
+pylith::topology::TestFieldBase::testScale(void)
+{ // testScale
+  FieldBase field;
+
+  CPPUNIT_ASSERT_EQUAL(1.0, field.scale());
+
+  const double scale = 4.0;
+  field.scale(scale);
+  CPPUNIT_ASSERT_EQUAL(scale, field.scale());
+} // testScale
+
+// ----------------------------------------------------------------------
+// Test addDimensionOkay().
+void
+pylith::topology::TestFieldBase::testAddDimensionOkay(void)
+{ // testAddDimensionOkay
+  FieldBase field;
+
+  CPPUNIT_ASSERT_EQUAL(false, field.addDimensionOkay());
+
+  field.addDimensionOkay(true);
+  CPPUNIT_ASSERT_EQUAL(true, field.addDimensionOkay());
+} // testAddDimensionOkay
+
+
+// End of file 

Added: short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldBase.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldBase.hh	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldBase.hh	2009-01-30 04:58:39 UTC (rev 13998)
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestFieldBase.hh
+ *
+ * @brief C++ unit testing for FieldBase.
+ */
+
+#if !defined(pylith_topology_testfieldbase_hh)
+#define pylith_topology_testfieldbase_hh
+
+// Include directives ---------------------------------------------------
+#include <cppunit/extensions/HelperMacros.h>
+
+// Forward declarations -------------------------------------------------
+/// Namespace for pylith package
+namespace pylith {
+  namespace topology {
+    class TestFieldBase;
+
+    class FieldBase;
+  } // topology
+} // pylith
+
+// TestFieldBase -------------------------------------------------------------
+/// C++ unit testing for FieldBase.
+class pylith::topology::TestFieldBase : public CppUnit::TestFixture
+{ // class TestFieldBase
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestFieldBase );
+
+  CPPUNIT_TEST( testConstructor );
+  CPPUNIT_TEST( testName );
+  CPPUNIT_TEST( testVectorFieldType );
+  CPPUNIT_TEST( testScale );
+  CPPUNIT_TEST( testAddDimensionOkay );
+
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Test constructor.
+  void testConstructor(void);
+
+  /// Test name().
+  void testName(void);
+
+  /// Test vectorFieldType().
+  void testVectorFieldType(void);
+
+  /// Test scale().
+  void testScale(void);
+
+  /// Test addDimensionOkay().
+  void testAddDimensionOkay(void);
+
+}; // class TestFieldBase
+
+#endif // pylith_topology_testfieldbase_hh
+
+
+// End of file 



More information about the CIG-COMMITS mailing list