예제 #1
0
void test_reverse() {
  const char * val1 = "value1";
  const char * val2 = "value2";
  const char * val3 = "value3";
  const char * val4 = "value4";
  
  vector_type * vector1 = vector_alloc_new(  );
  vector_type * vector2 = vector_alloc_new(  );

  vector_append_ref( vector1 , val1 );
  vector_append_ref( vector1 , val2 );
  vector_append_ref( vector1 , val3 );
  vector_append_ref( vector1 , val4 );

  vector_append_ref( vector2 , val1 );
  vector_append_ref( vector2 , val2 );
  vector_append_ref( vector2 , val3 );
  vector_append_ref( vector2 , val4 );

  vector_inplace_reverse( vector1 );

  {
    int i;
    int size = vector_get_size( vector1 );
    for (i=0; i < vector_get_size( vector1 ); i++)
      test_assert_ptr_equal( vector_iget_const( vector2 , i ) , vector_iget_const( vector1 , size - 1 - i ));
  }
  vector_free( vector1 );
  vector_free( vector2 );
}
예제 #2
0
파일: stringlist.c 프로젝트: akva2/ert
void stringlist_reverse( stringlist_type * s ) {
  vector_inplace_reverse( s->strings );
}