[cig-commits] r5192 - in short/3D/PyLith/trunk: . unittests/libtests unittests/libtests/meshio

brad at geodynamics.org brad at geodynamics.org
Mon Nov 6 20:47:49 PST 2006


Author: brad
Date: 2006-11-06 20:47:48 -0800 (Mon, 06 Nov 2006)
New Revision: 5192

Added:
   short/3D/PyLith/trunk/unittests/libtests/meshio/
   short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh
   short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc
Modified:
   short/3D/PyLith/trunk/configure.ac
   short/3D/PyLith/trunk/unittests/libtests/Makefile.am
Log:
Started implementing unit tests for MeshIOAscii stuff.

Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac	2006-11-07 04:24:26 UTC (rev 5191)
+++ short/3D/PyLith/trunk/configure.ac	2006-11-07 04:47:48 UTC (rev 5192)
@@ -155,6 +155,7 @@
 		unittests/Makefile
 		unittests/libtests/Makefile
 		unittests/libtests/feassemble/Makefile
+		unittests/libtests/meshio/Makefile
 		unittests/pytests/Makefile
 		unittests/pytests/feassemble/Makefile
                 doc/Makefile])

Modified: short/3D/PyLith/trunk/unittests/libtests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/Makefile.am	2006-11-07 04:24:26 UTC (rev 5191)
+++ short/3D/PyLith/trunk/unittests/libtests/Makefile.am	2006-11-07 04:47:48 UTC (rev 5192)
@@ -11,6 +11,7 @@
 #
 
 SUBDIRS = \
-	feassemble
+	feassemble \
+	meshio
 
 # End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am	2006-11-07 04:24:26 UTC (rev 5191)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am	2006-11-07 04:47:48 UTC (rev 5192)
@@ -0,0 +1,43 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+subpackage = meshio
+include $(top_srcdir)/subpackage.am
+
+TESTS = testmeshio
+
+check_PROGRAMS = testmeshio
+
+# Primary source files
+testmeshio_SOURCES = \
+	TestMeshIOAscii.cc \
+	test_meshio.cc
+
+noinst_HEADERS = \
+	TestMeshIOAscii.hh
+
+# Source files associated with testing data
+testmeshio_SOURCES += 
+
+noinst_HEADERS += 
+
+testmeshio_LDFLAGS = $(PETSC_LIB) \
+	-ljournal
+
+INCLUDES += $(PETSC_INCLUDE)
+AM_CPPFLAGS = $(PETSC_SIEVE_FLAGS)
+
+testmeshio_LDADD = \
+	-lcppunit -ldl \
+	$(top_builddir)/libsrc/meshio/libpylithmeshio.la
+
+# End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc	2006-11-07 04:24:26 UTC (rev 5191)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc	2006-11-07 04:47:48 UTC (rev 5192)
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestMeshIOAscii.hh" // Implementation of class methods
+
+#include "pylith/meshio/MeshIOAscii.hh"
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestMeshIOAscii );
+
+// ----------------------------------------------------------------------
+// Test constructor
+void
+pylith::meshio::TestMeshIOAscii::testConstructor(void)
+{ // testConstructor
+  MeshIOAscii iohandler;
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test filename()
+void
+pylith::meshio::TestMeshIOAscii::testFilename(void)
+{ // testFilename
+  MeshIOAscii iohandler;
+
+  const char* filename = "hi.txt";
+  iohandler.filename(filename);
+  CPPUNIT_ASSERT(0 == strcasecmp(filename, iohandler.filename()));
+} // testFilename
+
+// ----------------------------------------------------------------------
+// Test write() and read() for 1D mesh.
+void
+pylith::meshio::TestMeshIOAscii::testWriteRead1D(void)
+{ // testWriteRead1D
+  CPPUNIT_ASSERT(false);
+} // testWriteRead1D
+
+// ----------------------------------------------------------------------
+// Test write() and read() for 1D mesh in 2D space.
+void
+pylith::meshio::TestMeshIOAscii::testWriteRead1Din2D(void)
+{ // testWriteRead1D
+  CPPUNIT_ASSERT(false);
+} // testWriteRead1D
+
+// ----------------------------------------------------------------------
+// Test write() and read() for 1D mesh in 3D space.
+void
+pylith::meshio::TestMeshIOAscii::testWriteRead1Din3D(void)
+{ // testWriteRead1D
+  CPPUNIT_ASSERT(false);
+} // testWriteRead1D
+
+// ----------------------------------------------------------------------
+// Test write() and read() for 2D mesh in 2D space.
+void
+pylith::meshio::TestMeshIOAscii::testWriteRead2D(void)
+{ // testWriteRead2D
+  CPPUNIT_ASSERT(false);
+} // testWriteRead2D
+
+// ----------------------------------------------------------------------
+// Test write() and read() for 2D mesh in 3D space.
+void
+pylith::meshio::TestMeshIOAscii::testWriteRead2Din3D(void)
+{ // testWriteRead2Din3D
+  CPPUNIT_ASSERT(false);
+} // testWriteRead2Din3D
+
+// ----------------------------------------------------------------------
+// Test write() and read() for 3D mesh.
+void
+pylith::meshio::TestMeshIOAscii::testWriteRead3D(void)
+{ // testWriteRead3D
+  CPPUNIT_ASSERT(false);
+} // testWriteRead3D
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh	2006-11-07 04:24:26 UTC (rev 5191)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh	2006-11-07 04:47:48 UTC (rev 5192)
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestMeshIOAscii.hh
+ *
+ * @brief C++ TestMeshIOAscii object
+ *
+ * C++ unit testing for MeshIOAscii.
+ */
+
+#if !defined(pylith_meshio_testmeshioascii_hh)
+#define pylith_meshio_testmeshioascii_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/// Namespace for spatialdata package
+namespace pylith {
+  namespace meshio {
+    class TestMeshIOAscii;
+  } // meshio
+} // pylith
+
+/// C++ unit testing for Quadrature1D
+class pylith::meshio::TestMeshIOAscii : public CppUnit::TestFixture
+{ // class TestMeshIOAscii
+
+  // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+  CPPUNIT_TEST_SUITE( TestMeshIOAscii );
+  CPPUNIT_TEST( testConstructor );
+  CPPUNIT_TEST( testFilename );
+  CPPUNIT_TEST( testWriteRead1D );
+  CPPUNIT_TEST( testWriteRead1Din2D );
+  CPPUNIT_TEST( testWriteRead1Din3D );
+  CPPUNIT_TEST( testWriteRead2D );
+  CPPUNIT_TEST( testWriteRead2Din3D );
+  CPPUNIT_TEST( testWriteRead3D );
+  CPPUNIT_TEST_SUITE_END();
+
+  // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+  /// Test constructor
+  void testConstructor(void);
+
+  /// Test filename()
+  void testFilename(void);
+
+  /// Test write() and read() for 1D mesh in 1D space.
+  void testWriteRead1D(void);
+
+  /// Test write() and read() for 1D mesh in 2D space.
+  void testWriteRead1Din2D(void);
+
+  /// Test write() and read() for 1D mesh in 3D space.
+  void testWriteRead1Din3D(void);
+
+  /// Test write() and read() for 2D mesh in 2D space.
+  void testWriteRead2D(void);
+
+  /// Test write() and read() for 2D mesh in 3D space.
+  void testWriteRead2Din3D(void);
+
+  /// Test write() and read() for 3D mesh in 3D space.
+  void testWriteRead3D(void);
+
+}; // class TestMeshIOAscii
+
+#endif // pylith_meshio_testmeshioascii_hh
+
+// End of file 

Added: short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc	2006-11-07 04:24:26 UTC (rev 5191)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/test_meshio.cc	2006-11-07 04:47:48 UTC (rev 5192)
@@ -0,0 +1,71 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include "petsc.h"
+
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TestRunner.h>
+#include <cppunit/TextOutputter.h>
+
+#include <stdlib.h> // USES abort()
+
+#include "journal/debug.h"
+
+int
+main(int argc,
+     char* argv[])
+{ // main
+  journal::debug_t debug("TestMeshIOAscii");
+  debug.deactivate();
+
+  CppUnit::TestResultCollector result;
+
+  try {
+    // Initialize PETSc
+    PetscErrorCode err = PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
+    CHKERRQ(err);
+
+    // Create event manager and test controller
+    CppUnit::TestResult controller;
+
+    // Add listener to collect test results
+    controller.addListener(&result);
+
+    // Add listener to show progress as tests run
+    CppUnit::BriefTestProgressListener progress;
+    controller.addListener(&progress);
+
+    // Add top suite to test runner
+    CppUnit::TestRunner runner;
+    runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+    runner.run(controller);
+
+    // Print tests
+    CppUnit::TextOutputter outputter(&result, std::cerr);
+    outputter.write();
+
+    // Finalize PETSc
+    err = PetscFinalize();
+    CHKERRQ(err);
+  } catch (...) {
+    abort();
+  } // catch
+
+  return (result.wasSuccessful() ? 0 : 1);
+} // main
+
+// End of file



More information about the cig-commits mailing list