MOAB: Mesh Oriented datABase  (version 5.5.0)
readutil_test.cpp File Reference
#include <iostream>
#include "moab/Interface.hpp"
#include "Internals.hpp"
#include "moab/ReadUtilIface.hpp"
#include "moab/Core.hpp"
#include "moab/Range.hpp"
+ Include dependency graph for readutil_test.cpp:

Go to the source code of this file.

Macros

#define IS_BUILDING_MB
 
#define CHKERR(A)
 
#define RUN_TEST(A)   _run_test( ( A ), #A )
 

Typedefs

typedef ErrorCode(* TestFunc) ()
 

Functions

ErrorCode gather_related_test ()
 
static void _run_test (TestFunc func, const char *func_str)
 
int main (int, char **)
 

Variables

int number_tests = 0
 
int number_tests_failed = 0
 

Macro Definition Documentation

◆ CHKERR

#define CHKERR (   A)
Value:
do \
{ \
if( MB_SUCCESS != ( A ) ) \
{ \
std::cerr << "Failure (error code " << ( A ) << ") at " __FILE__ ":" << __LINE__ << std::endl; \
return A; \
} \
} while( false )

Definition at line 13 of file readutil_test.cpp.

◆ IS_BUILDING_MB

#define IS_BUILDING_MB

Definition at line 4 of file readutil_test.cpp.

◆ RUN_TEST

#define RUN_TEST (   A)    _run_test( ( A ), #A )

Definition at line 63 of file readutil_test.cpp.

Typedef Documentation

◆ TestFunc

typedef ErrorCode( * TestFunc) ()

Definition at line 65 of file readutil_test.cpp.

Function Documentation

◆ _run_test()

static void _run_test ( TestFunc  func,
const char *  func_str 
)
static

Definition at line 66 of file readutil_test.cpp.

67 {
68  ++number_tests;
69  std::cout << " " << func_str << ": ";
70  std::cout.flush();
71  ErrorCode error = func();
72 
73  if( MB_SUCCESS == error )
74  std::cout << "Success" << std::endl;
75  else if( MB_FAILURE == error )
76  std::cout << "Failure" << std::endl;
77  else
78  {
79  Core moab;
80  std::cout << "Failed: " << moab.get_error_string( error ) << std::endl;
81  }
82 
83  if( MB_SUCCESS != error )
84  {
86  }
87 }

References moab::error(), ErrorCode, MB_SUCCESS, number_tests, and number_tests_failed.

◆ gather_related_test()

ErrorCode gather_related_test ( )

Definition at line 23 of file readutil_test.cpp.

24 {
25  // create an entityset structure and test related entities function
26  // sets: A
27  // |
28  // B C
29  // |/ |
30  // D E
31  // if D is passed in to gather_related_ents, A-D should be returned, and E should not be
32  //
33  EntityHandle A, B, C, D, E;
34  Core mb;
35  ErrorCode rval = mb.create_meshset( MESHSET_SET, A );CHKERR( rval );
36  rval = mb.create_meshset( MESHSET_SET, B );CHKERR( rval );
37  rval = mb.create_meshset( MESHSET_SET, C );CHKERR( rval );
38  rval = mb.create_meshset( MESHSET_SET, D );CHKERR( rval );
39  rval = mb.create_meshset( MESHSET_SET, E );CHKERR( rval );
40 
41  rval = mb.add_parent_child( A, B );CHKERR( rval );
42  rval = mb.add_parent_child( B, D );CHKERR( rval );
43  rval = mb.add_parent_child( C, D );CHKERR( rval );
44  rval = mb.add_parent_child( C, E );CHKERR( rval );
45 
46  // now test it
47  ReadUtilIface* readMeshIface;
48  mb.Interface::query_interface( readMeshIface );
49 
50  Range init_range, set_range, all_sets( A, E );
51  init_range.insert( D );
52  rval = readMeshIface->gather_related_ents( init_range, set_range );CHKERR( rval );
53 
54  if( set_range.size() != 4 ) return MB_FAILURE;
55  all_sets -= set_range;
56  if( 1 != all_sets.size() || *all_sets.begin() != E ) return MB_FAILURE;
57 
58  return MB_SUCCESS;
59 }

References moab::Core::add_parent_child(), moab::Range::begin(), CHKERR, moab::Core::create_meshset(), moab::E, ErrorCode, moab::ReadUtilIface::gather_related_ents(), moab::Range::insert(), mb, MB_SUCCESS, MESHSET_SET, and moab::Range::size().

Referenced by main().

◆ main()

int main ( int  ,
char **   
)

Definition at line 89 of file readutil_test.cpp.

90 {
92 
93  std::cout << "\nMB TEST SUMMARY: \n"
94  << " Number Tests: " << number_tests << "\n"
95  << " Number Successful: " << number_tests - number_tests_failed << "\n"
96  << " Number Failed: " << number_tests_failed << "\n\n";
97 
98  return number_tests_failed;
99 }

References gather_related_test(), number_tests, number_tests_failed, and RUN_TEST.

Variable Documentation

◆ number_tests

int number_tests = 0

Definition at line 61 of file readutil_test.cpp.

Referenced by _run_test(), and main().

◆ number_tests_failed

int number_tests_failed = 0

Definition at line 62 of file readutil_test.cpp.

Referenced by _run_test(), and main().