Пример #1
0
void simple_test() {
  time_map_type * time_map = time_map_alloc( );
  test_work_area_type * work_area = test_work_area_alloc("enkf_time_map" , true);
  const char * mapfile = "map";
  
  test_assert_true( time_map_update( time_map , 0 , 100 )   );
  test_assert_true( time_map_update( time_map , 1 , 200 )   );
  test_assert_true( time_map_update( time_map , 1 , 200 )   );
  test_assert_false( time_map_update( time_map , 1 , 250 )  );

  test_assert_true( time_map_equal( time_map , time_map ) );
  time_map_fwrite( time_map , mapfile);
  {
    time_map_type * time_map2 = time_map_alloc( );

    test_assert_false( time_map_equal( time_map , time_map2 ) );
    time_map_fread( time_map2 , mapfile );
    test_assert_true( time_map_equal( time_map , time_map2 )  );
    time_map_free( time_map2 );
  }
  {
    time_t mtime1 = util_file_mtime( mapfile );
    sleep(2);
    time_map_fwrite( time_map , mapfile);
    
    test_assert_time_t_equal( mtime1 , util_file_mtime( mapfile ) );
    time_map_update( time_map , 2 , 300 );
    time_map_fwrite( time_map , mapfile);
    test_assert_time_t_not_equal( mtime1 , util_file_mtime( mapfile ) );
  }
  test_work_area_free( work_area );
}
Пример #2
0
void * update_time_map( void * arg ) {
  time_map_type * time_map = time_map_safe_cast( arg );
  int i;
  for (i=0; i < MAP_SIZE; i++)
    time_map_update( time_map , i , i );
  return NULL;
}
Пример #3
0
void * update_time_map( void * arg ) {
  time_map_type * time_map = time_map_safe_cast( arg );
  int i;
  for (i=0; i < MAP_SIZE; i++)
    time_map_update( time_map , i , i );

  test_assert_int_equal( MAP_SIZE , time_map_get_size( time_map ));
  return NULL;
}
Пример #4
0
void ecl_test( const char * ecl_case ) {
  ecl_sum_type * ecl_sum  = ecl_sum_fread_alloc_case( ecl_case , ":");
  time_t start_time = ecl_sum_get_start_time( ecl_sum );
  time_t end_time   = ecl_sum_get_end_time( ecl_sum );
  time_map_type * ecl_map = time_map_alloc( );
  
  test_assert_true( time_map_summary_update( ecl_map , ecl_sum ) );
  test_assert_true( time_map_summary_update( ecl_map , ecl_sum ) );
  
  test_assert_time_t_equal( time_map_get_start_time( ecl_map ) , start_time );
  test_assert_time_t_equal( time_map_get_end_time( ecl_map ) , end_time );
  test_assert_double_equal( time_map_get_end_days( ecl_map ) , ecl_sum_get_sim_length( ecl_sum ));

  time_map_clear( ecl_map );
  time_map_update( ecl_map , 1 , 256 );
  test_assert_false( time_map_summary_update( ecl_map , ecl_sum ));
  
  time_map_free( ecl_map );
  ecl_sum_free( ecl_sum );
}