[MOAB-dev] r1709 - MOAB/trunk/test/h5file

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Thu Mar 27 12:39:57 CDT 2008


Author: kraftche
Date: 2008-03-27 12:39:57 -0500 (Thu, 27 Mar 2008)
New Revision: 1709

Modified:
   MOAB/trunk/test/h5file/h5legacy.cpp
Log:
use TestUtil.hpp

Modified: MOAB/trunk/test/h5file/h5legacy.cpp
===================================================================
--- MOAB/trunk/test/h5file/h5legacy.cpp	2008-03-27 17:39:22 UTC (rev 1708)
+++ MOAB/trunk/test/h5file/h5legacy.cpp	2008-03-27 17:39:57 UTC (rev 1709)
@@ -1,28 +1,23 @@
 #include "MBCore.hpp"
 #include "testdir.h"
+#include "TestUtil.hpp"
 
 #include <iostream>
 #include <stdlib.h>
 #include <math.h>
 
-// define our own assert so it doesn't get compiled out during release builds
-#define assert( A ) if (!(A)) { \
-  std::cerr << "Assertion failed at line " << __LINE__ << " : " << #A << std::endl; \
-  abort(); \
-}
-
-
 void calc_centroid( MBInterface* iface, MBEntityHandle pent, double result[3] )
 {
   int len;
   const MBEntityHandle* conn;
   MBErrorCode rval;
   rval = iface->get_connectivity( pent, conn, len );
-  assert(MB_SUCCESS == rval && 5 == len);
+  CHECK_ERR(rval);
+  CHECK_EQUAL( 5, len );
   
   double coords[15];
   rval = iface->get_coords( conn, len, coords );
-  assert(MB_SUCCESS == rval);
+  CHECK_ERR(rval);
   
   for (int d = 0; d < 3; ++d) {
     result[d] = 0;
@@ -40,30 +35,30 @@
   
     // load file containing a dodecahedron
   rval = mb.load_mesh( "../../" TEST_DIR "/v3_dodec.h5m" );
-  assert( MB_SUCCESS == rval );
+  CHECK_ERR(rval);
   
     // get entities from file
   MBRange verts, faces, polyhedrons;
   rval = mb.get_entities_by_type( 0, MBVERTEX, verts );
-  assert( MB_SUCCESS == rval );
+  CHECK_ERR(rval);
   rval = mb.get_entities_by_type( 0, MBPOLYGON, faces );
-  assert( MB_SUCCESS == rval );
+  CHECK_ERR(rval);
   rval = mb.get_entities_by_type( 0, MBPOLYHEDRON, polyhedrons );
-  assert( MB_SUCCESS == rval );
+  CHECK_ERR(rval);
   
     // check expected number of entities
-  assert( 20 == verts.size() );
-  assert( 12 == faces.size() );
-  assert( 1 == polyhedrons.size() );
+  CHECK_EQUAL( (MBEntityHandle)20, verts.size() );
+  CHECK_EQUAL( (MBEntityHandle)12, faces.size() );
+  CHECK_EQUAL( (MBEntityHandle)1,  polyhedrons.size() );
   const MBEntityHandle polyhedron = polyhedrons.front();
   
     // check the polyhedron connectivity list
   std::vector<MBEntityHandle> faces1, faces2;
   std::copy( faces.begin(), faces.end(), std::back_inserter(faces1) );
   rval = mb.get_connectivity( &polyhedron, 1, faces2 );
-  assert( MB_SUCCESS == rval );
+  CHECK_ERR(rval);
   std::sort( faces2.begin(), faces2.end() );
-  assert( faces1 == faces2 );
+  CHECK( faces1 == faces2 );
   
     // each polygonshould have a tag value storing its centroid.
     // compare this value against the centroid calculated from
@@ -72,17 +67,17 @@
     // get tag for saved values
   MBTag centroid;
   rval = mb.tag_get_handle( "CENTROID", centroid );
-  assert( MB_SUCCESS == rval );
+  CHECK_ERR(rval);
   
     // for each face...
   for (MBRange::iterator i = faces.begin(); i != faces.end(); ++i) {
     double saved[3], calc[3];
     rval = mb.tag_get_data( centroid, &*i, 1, saved );
-    assert( MB_SUCCESS == rval );
+    CHECK_ERR(rval);
     calc_centroid( &mb, *i, calc );
-    assert( fabs(saved[0] - calc[0]) < 1e-6 );
-    assert( fabs(saved[1] - calc[1]) < 1e-6 );
-    assert( fabs(saved[2] - calc[2]) < 1e-6 );
+    CHECK_REAL_EQUAL( saved[0], calc[0], 1e-6 );
+    CHECK_REAL_EQUAL( saved[1], calc[1], 1e-6 );
+    CHECK_REAL_EQUAL( saved[2], calc[2], 1e-6 );
   }
 }
 
@@ -93,8 +88,7 @@
 {
   // only one test so far... should probably add second test
   // for really-old-format  entityset parent/child links
-  test_moab_v3_poly_format();
-  return 0;
+  return RUN_TEST( test_moab_v3_poly_format );
 }
 
   




More information about the moab-dev mailing list