Пример #1
0
void test_io( ) {
  test_work_area_type * work_area = test_work_area_alloc( "enkf-state-map" );
  {
    state_map_type * state_map = state_map_alloc();
    state_map_type * copy1 , *copy2;
    state_map_iset( state_map , 0 , STATE_INITIALIZED );
    state_map_iset( state_map , 100 , STATE_INITIALIZED );
    state_map_fwrite( state_map , "map");
    
    copy1 = state_map_fread_alloc( "map" );
    test_assert_true( state_map_equal( state_map , copy1 ));
    
    copy2 = state_map_alloc();
    state_map_fread( copy2 , "map" );
    test_assert_true( state_map_equal( state_map , copy2 ));

    state_map_iset( copy2 , 67 , STATE_INITIALIZED );
    test_assert_false(state_map_equal( state_map , copy2 ));
    
    state_map_fread( copy2 , "map");
    test_assert_true( state_map_equal( state_map , copy2 ));

    state_map_fread( copy2 , "DoesNotExis");
    test_assert_int_equal( 0 , state_map_get_size( copy2 ));
  }
  test_work_area_free( work_area );
}
Пример #2
0
void load_empty_test() {
  state_map_type * state_map = state_map_fread_alloc( "File/does/not/exists" );
  test_assert_true( state_map_is_instance( state_map ));
  test_assert_int_equal( 0 , state_map_get_size( state_map ));
  state_map_free( state_map );
}
Пример #3
0
state_map_type * state_map_fread_alloc_readonly( const char * filename ) {
  state_map_type * map = state_map_fread_alloc(filename);
  map->read_only = true;
  return map;
}