Ejemplo n.º 1
0
REGISTER_UNIT_TEST( RefCountedIntTest, UnitTest )
{
  bool old_use_assert = RefCountedInt::s_UseAssert;
  RefCountedInt::s_UseAssert = false;
  RefCountedInt::s_InfoErrorMessage = NULL;
  
  {
    RefCountedInt a;
    a.~RefCountedInt();
    a = 1;
    EXPECT_NOT_NULL( RefCountedInt::s_InfoErrorMessage );
  }
  RefCountedInt::ClearInfo();
  
  // Test scoping
  {
    RefCountedInt a( 1 );
    RefCountedInt b;
    RefCountedInt c = a;
    EXPECT_STRING( NULL, RefCountedInt::s_InfoErrorMessage );
    EXPECT_INT( 3, RefCountedInt::s_InfoConstructedCount ); // a, b, c
    EXPECT_INT( 2, RefCountedInt::s_InfoAssignedCount );    // a, c
  }
  EXPECT_INT( 0, RefCountedInt::s_InfoConstructedCount );
  EXPECT_INT( 0, RefCountedInt::s_InfoAssignedCount );

  RefCountedInt::s_UseAssert = old_use_assert;
  RefCountedInt::ClearInfo();
}
Ejemplo n.º 2
0
fftw_status fftw_import_wisdom(int (*g) (void *), void *data)
{
     int n;
     int flags;
     fftw_direction dir;
     int dir_int;
     enum fftw_wisdom_category category;
     int category_int;
     enum fftw_node_type type;
     int recurse_kind_int;
     fftw_recurse_kind recurse_kind;
     int type_int;
     int signature;
     int istride, ostride;

     get_input = g;
     input_error = FFTW_SUCCESS;

     read_char(data);

     eat_blanks(data);
     EXPECT('(');
     eat_blanks(data);
     EXPECT_STRING(WISDOM_FORMAT_VERSION);
     eat_blanks(data);

     while (next_char != ')') {
	  EXPECT('(');
	  EXPECT_INT(n);
	  EXPECT_INT(flags);
	  /* paranoid respect for enumerated types */
	  EXPECT_INT(dir_int);
	  dir = (fftw_direction) dir_int;
	  EXPECT_INT(category_int);
	  category = (enum fftw_wisdom_category) category_int;
	  EXPECT_INT(istride);
	  EXPECT_INT(ostride);
	  EXPECT_INT(type_int);
	  type = (enum fftw_node_type) type_int;
	  EXPECT_INT(signature);
	  EXPECT_INT(recurse_kind_int);
	  recurse_kind = (fftw_recurse_kind) recurse_kind_int;
	  eat_blanks(data);
	  EXPECT(')');

	  /* the wisdom has been read properly. Add it */
	  fftw_wisdom_add(n, flags, dir, category,
			  istride, ostride,
			  type, signature, recurse_kind);

	  /* prepare for next morsel of wisdom */
	  eat_blanks(data);
     }

     return FFTW_SUCCESS;
}
Ejemplo n.º 3
0
fftw_status fftw_import_wisdom(int (*g)(void *), void *data)
{
     int n;
     int flags;
     fftw_direction dir;
     enum fftw_node_type type;
     int signature;

     get_input = g;
     input_error = FFTW_SUCCESS;

     read_char(data);

     eat_blanks(data);
     EXPECT('(');
     eat_blanks(data);
     EXPECT_STRING(WISDOM_FORMAT_VERSION);
     eat_blanks(data);

     while (next_char != ')') {
	  EXPECT('(');
	  EXPECT_INT(n);
	  EXPECT_INT(flags);
	  EXPECT_INT(dir);
	  EXPECT_INT(type);
	  EXPECT_INT(signature);
	  eat_blanks(data);
	  EXPECT(')');

	  /* the wisdom has been read properly. Add it */
	  fftw_wisdom_add(n, flags, dir, type, signature);

	  /* prepare for next morsel of wisdom */
	  eat_blanks(data);
     }

     return FFTW_SUCCESS;
}
Ejemplo n.º 4
0
REGISTER_UNIT_TEST( MojoRelationTest, Container )
{
  MojoRelation< MojoId > rel( "test" );

  // For 0..49, insert consecutively
  for( char c = 'a'; c <= 'z'; ++c )
  {
    char group[ 20 ];
    snprintf( group, sizeof group, "%c", c );
    MojoId parent = group;
    for( int i = 0; i < 50; ++i )
    {
      MojoId child = MakeId( group, i );
      rel.InsertChildParent( child, parent );
    }
  }

  // For 50..99, insert jumbled up
  for( int i = 50; i < 100; ++i )
  {
    for( char c = 'z'; c >= 'a'; --c )
    {
      char group[ 20 ];
      snprintf( group, sizeof group, "%c", c );
      MojoId parent = group;
      MojoId child = MakeId( group, i );
      rel.InsertChildParent( child, parent );
    }
  }

  // Now remove all even children, to exercise reordering.
  for( char c = 'a'; c <= 'z'; ++c )
  {
    char group[ 20 ];
    snprintf( group, sizeof group, "%c", c );
    MojoId parent = group;
    for( int i = 0; i < 100; i += 2 )
    {
      MojoId child = MakeId( group, i );
      rel.RemoveChild( child );
    }
  }
  
  // Now remove all parents above and including 'q'.
  for( char c = 'q'; c <= 'z'; ++c )
  {
    char group[ 20 ];
    snprintf( group, sizeof group, "%c", c );
    MojoId parent = group;
    for( int i = 1; i < 100; i += 2 )
    {
      MojoId child = MakeId( group, i );
      rel.RemoveChild( child );
    }
  }
  
  // Now table contains parents 'a'-'p', and only oddly numbered children

  // Find all children's parents
  for( char c = 'a'; c < 'q'; ++c )
  {
    char group[ 20 ];
    snprintf( group, sizeof group, "%c", c );
    MojoId parent = group;
    for( int i = 1; i < 100; i += 2 )
    {
      MojoId child = MakeId( group, i );
      MojoId found_parent = rel.FindParent( child );
      EXPECT_BOOL( false, found_parent.IsNull() );
      EXPECT_STRING( parent.AsCString(), found_parent.AsCString() );
    }
  }
  
  // Verify all even children are missing
  for( char c = 'a'; c < 'q'; ++c )
  {
    char group[ 20 ];
    snprintf( group, sizeof group, "%c", c );
    MojoId parent = group;
    for( int i = 0; i < 100; i += 2 )
    {
      MojoId child = MakeId( group, i );
      MojoId found_parent = rel.FindParent( child );
      EXPECT_BOOL( true, found_parent.IsNull() );
    }
  }
  
  // Verify children of groups 'q'-'z' are gone as well
  for( char c = 'q'; c <= 'z'; ++c )
  {
    char group[ 20 ];
    snprintf( group, sizeof group, "%c", c );
    MojoId parent = group;
    for( int i = 0; i < 100; i += 1 )
    {
      MojoId child = MakeId( group, i );
      MojoId found_parent = rel.FindParent( child );
      EXPECT_BOOL( true, found_parent.IsNull() );
    }
  }

  // Find children of parents
  for( char c = 'a'; c < 'q'; ++c )
  {
    char group[ 20 ];
    snprintf( group, sizeof group, "%c", c );
    MojoId parent = group;
    MojoId child;

    int count = 0;
    MojoForEachMultiValue( rel, parent, child )
    {
      count += 1;
      EXPECT_INT( c, child.AsCString()[ 0 ] );
    }
    EXPECT_INT( 50, count );
  }