void test_file( const char * filename , int occurence , bool exists , const ecl_rsthead_type * true_header) { int report_step = ecl_util_filename_report_nr( filename ); ecl_file_type * rst_file = ecl_file_open( filename , 0); ecl_file_enum file_type = ecl_util_get_file_type( filename , NULL , NULL ); ecl_file_view_type * rst_view; ecl_rsthead_type * rst_head; if (file_type == ECL_RESTART_FILE) rst_view = ecl_file_get_global_view( rst_file ); else rst_view = ecl_file_get_restart_view( rst_file , occurence , -1 , -1 , -1 ); if (exists) { test_assert_not_NULL( rst_view ); rst_head = ecl_rsthead_alloc( rst_view , report_step); test_assert_not_NULL( rst_head ); if (occurence == 0) { ecl_rsthead_type * rst_head0 = ecl_rsthead_alloc( rst_view , report_step ); test_assert_true( ecl_rsthead_equal( rst_head , rst_head0 )); ecl_rsthead_free( rst_head0 ); } test_assert_true( ecl_rsthead_equal( rst_head , true_header )); ecl_rsthead_free( rst_head ); } else test_assert_NULL( rst_view ); }
void test_fortio_safe_cast(const char * filename ) { void * i_am_a_fortio = fortio_open_reader( filename , false , ECL_ENDIAN_FLIP); test_assert_not_NULL( i_am_a_fortio ); fortio_type * fortio = fortio_safe_cast(i_am_a_fortio); test_assert_true(fortio_is_instance(fortio)); fortio_fclose( fortio ); }
void test_write_gen_kw_export_file(enkf_main_type * enkf_main) { test_assert_not_NULL(enkf_main); enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); test_assert_not_NULL(state); enkf_node_type * enkf_node = enkf_state_get_node( state , "MULTFLT" ); test_assert_not_NULL(enkf_node); const enkf_config_node_type * config_node = enkf_node_get_config(enkf_node); test_assert_not_NULL(config_node); if (GEN_KW == enkf_config_node_get_impl_type(config_node)) { enkf_fs_type * fs = enkf_main_get_fs(enkf_main); enkf_state_ecl_write(state, fs); test_assert_true(util_file_exists("parameters.txt")); } }
void test_min_realizations_percent(const char * num_realizations_str, const char * min_realizations_str, int min_realizations){ test_work_area_type * work_area = test_work_area_alloc("test_min_realizations"); { FILE * config_file_stream = util_mkdir_fopen("config_file", "w"); test_assert_not_NULL(config_file_stream); fprintf(config_file_stream, num_realizations_str); fprintf(config_file_stream, min_realizations_str); fclose(config_file_stream); config_type * c = config_alloc(); config_schema_item_type * item = config_add_schema_item(c , NUM_REALIZATIONS_KEY , true ); config_schema_item_set_default_type(item, CONFIG_INT); config_schema_item_set_argc_minmax( item , 1 , 1); item = config_add_schema_item(c , MIN_REALIZATIONS_KEY , false ); config_schema_item_set_argc_minmax( item , 1 , 2); test_assert_true(config_parse(c , "config_file" , "--" , NULL , NULL , false , true )); analysis_config_type * ac = create_analysis_config( ); analysis_config_init(ac, c); test_assert_int_equal( min_realizations , analysis_config_get_min_realisations( ac ) ); analysis_config_free( ac ); config_free( c ); } test_work_area_free(work_area); }
int main(int argc , char ** argv) { int i; ecl_kw_type * ecl_kw = ecl_kw_alloc("HEAD" , 10 , ECL_INT_TYPE); for (i=0; i < 10; i++) ecl_kw_iset_int(ecl_kw , i , i ); { test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl" , true); FILE * stream = util_fopen( "FILE.grdecl" , "w"); ecl_kw_fprintf_grdecl(ecl_kw , stream ); fclose(stream); stream = util_fopen( "FILE.grdecl" , "r"); { ecl_kw_type * ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD" , 10 , ECL_INT_TYPE); test_assert_not_NULL( ecl_kw2 ); test_assert_true( ecl_kw_equal( ecl_kw , ecl_kw2)); ecl_kw_free( ecl_kw2 ); } fclose( stream ); stream = util_fopen( "FILE.grdecl" , "w"); ecl_kw_fprintf_grdecl__(ecl_kw , "HEAD1234" , stream ); fclose( stream ); stream = util_fopen( "FILE.grdecl" , "r"); { ecl_kw_type * ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD" , 10 , ECL_INT_TYPE); test_assert_NULL( ecl_kw2 ); ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD1234" , 10 , ECL_INT_TYPE); test_assert_not_NULL( ecl_kw2 ); test_assert_string_equal( ecl_kw_get_header( ecl_kw2 ) , "HEAD1234" ); test_assert_true( ecl_kw_content_equal( ecl_kw , ecl_kw2 )); ecl_kw_free( ecl_kw2 ); } fclose( stream ); test_work_area_free( work_area ); } ecl_kw_free( ecl_kw ); exit(0); }
void test_write( const char * filename , bool path_exists) { fortio_type * fortio = fortio_open_writer( filename , false , ECL_ENDIAN_FLIP); if (path_exists) { test_assert_not_NULL( fortio ); fortio_fclose( fortio ); } else test_assert_NULL( fortio ); }
void test_send_fortio_to_gen_kw_ecl_write(void * arg) { enkf_main_type * enkf_main = arg; test_assert_not_NULL(enkf_main); fortio_type * fortio = fortio_open_writer("my_new_file", false, ECL_ENDIAN_FLIP); test_assert_not_NULL(fortio); enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); test_assert_not_NULL(state); enkf_node_type * enkf_node = enkf_state_get_node( state , "MULTFLT" ); test_assert_not_NULL(enkf_node); const enkf_config_node_type * config_node = enkf_node_get_config(enkf_node); test_assert_not_NULL(config_node); if (GEN_KW == enkf_config_node_get_impl_type(config_node)) { const char * dummy_path = "dummy_path"; enkf_node_ecl_write(enkf_node, dummy_path, fortio, 0); } }
int main(int argc , char ** argv) { test_install_SIGNALS(); double * rseg_data = util_calloc( 100 , sizeof * rseg_data ); well_segment_collection_type * sc = well_segment_collection_alloc(); test_assert_not_NULL( sc ); test_assert_int_equal( well_segment_collection_get_size( sc ) , 0 ); { int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE; int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE; well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data); well_segment_collection_add( sc , ws ); test_assert_int_equal( well_segment_collection_get_size( sc ) , 1); test_assert_ptr_equal( well_segment_collection_iget( sc , 0 ) , ws ); test_assert_false( well_segment_collection_has_segment( sc , 451 )); test_assert_true( well_segment_collection_has_segment( sc , 89 )); test_assert_ptr_equal( well_segment_collection_get( sc , 89 ) , ws ); } { int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE; int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE; well_segment_type * ws = well_segment_alloc(90 , outlet_segment_id , branch_nr , rseg_data); well_segment_collection_add( sc , ws ); test_assert_int_equal( well_segment_collection_get_size( sc ) , 2); test_assert_ptr_equal( well_segment_collection_iget( sc , 1 ) , ws ); test_assert_false( well_segment_collection_has_segment( sc , 451 )); test_assert_true( well_segment_collection_has_segment( sc , 89 )); test_assert_true( well_segment_collection_has_segment( sc , 90 )); test_assert_ptr_equal( well_segment_collection_get( sc , 90 ) , ws ); test_assert_NULL( well_segment_collection_get( sc , 76 )); } { int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE; int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE; well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data); well_segment_collection_add( sc , ws ); test_assert_int_equal( well_segment_collection_get_size( sc ) , 2); test_assert_ptr_equal( well_segment_collection_iget( sc , 0 ) , ws ); test_assert_false( well_segment_collection_has_segment( sc , 451 )); test_assert_true( well_segment_collection_has_segment( sc , 89 )); test_assert_ptr_equal( well_segment_collection_get( sc , 89 ) , ws ); } free( rseg_data ); well_segment_collection_free( sc ); exit(0); }
void test_wrapper( const char * filename ) { FILE * stream = util_fopen( filename , "r"); fortio_type * fortio = fortio_alloc_FILE_wrapper( filename , false , false , stream ); test_assert_not_NULL( fortio ); test_assert_false( fortio_fclose_stream( fortio )); test_assert_false( fortio_fopen_stream( fortio )); test_assert_true( fortio_stream_is_open( fortio )); fortio_free_FILE_wrapper( fortio ); fclose( stream ); }
void test_write_gen_kw_export_file(enkf_main_type * enkf_main) { test_assert_not_NULL(enkf_main); enkf_fs_type * init_fs = enkf_main_get_fs( enkf_main ); enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); run_arg_type * run_arg = run_arg_alloc_INIT_ONLY( init_fs , 0 ,0 , "simulations/run0"); test_assert_not_NULL(state); enkf_node_type * enkf_node = enkf_state_get_node( state , "MULTFLT" ); test_assert_not_NULL(enkf_node); const enkf_config_node_type * config_node = enkf_node_get_config(enkf_node); test_assert_not_NULL(config_node); if (GEN_KW == enkf_config_node_get_impl_type(config_node)) { enkf_state_ecl_write(state, run_arg , init_fs); test_assert_true(util_file_exists("simulations/run0/parameters.txt")); } run_arg_free( run_arg ); }
void test_close_stream2(const char * src_file , const char * target_file ) { util_copy_file( src_file , target_file ); ecl_file_type * ecl_file = ecl_file_open( target_file , ECL_FILE_CLOSE_STREAM ); ecl_file_load_all( ecl_file ); unlink( target_file ); ecl_kw_type * kw2 = ecl_file_iget_kw( ecl_file , 2 ); test_assert_not_NULL( kw2 ); ecl_file_close( ecl_file ); }
void test_close_stream1(const char * src_file , const char * target_file ) { util_copy_file( src_file , target_file ); ecl_file_type * ecl_file = ecl_file_open( target_file , ECL_FILE_CLOSE_STREAM ); ecl_kw_type * kw0 = ecl_file_iget_kw( ecl_file , 0 ); ecl_kw_type * kw1 = ecl_file_iget_kw( ecl_file , 1 ); unlink( target_file ); ecl_kw_type * kw1b = ecl_file_iget_kw( ecl_file , 1 ); test_assert_not_NULL( kw0 ); test_assert_not_NULL( kw1 ); test_assert_ptr_equal( kw1 , kw1b ); ecl_kw_type * kw2 = ecl_file_iget_kw( ecl_file , 2 ); test_assert_NULL( kw2 ); test_assert_false( ecl_file_writable( ecl_file )); ecl_file_close( ecl_file ); }
int main(int argc , char ** argv) { const char * config_file = argv[1]; ert_test_context_type * test_context = ert_test_context_alloc("gen_kw_test" , config_file , NULL); enkf_main_type * enkf_main = ert_test_context_get_main(test_context); test_assert_not_NULL(enkf_main); test_write_gen_kw_export_file(enkf_main); test_assert_util_abort("gen_kw_ecl_write", test_send_fortio_to_gen_kw_ecl_write, enkf_main); ert_test_context_free( test_context ); exit(0); }
void test_fortio_is_instance(const char * filename ) { { fortio_type * fortio = fortio_open_reader( filename , false , ECL_ENDIAN_FLIP); test_assert_not_NULL( fortio ); test_assert_true(fortio_is_instance(fortio)); fortio_fclose( fortio ); } { vector_type * dummy_vector = vector_alloc_new(); test_assert_false(fortio_is_instance(dummy_vector)); vector_free(dummy_vector); } }
void test_init_case_job(ert_test_context_type * test_context, const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); enkf_main_type * enkf_main = ert_test_context_get_main(test_context); test_assert_true( ert_test_context_install_workflow_job( test_context , "JOB" , job_file ) ); //Test init current case from existing { enkf_fs_type * cur_fs = enkf_main_mount_alt_fs( enkf_main , "new_current_case" , true ); enkf_main_select_fs(enkf_main, "new_current_case"); test_assert_ptr_not_equal(cur_fs , enkf_main_get_fs( enkf_main )); stringlist_append_copy( args, "default"); //case to init from test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) ); enkf_fs_decref(cur_fs); } { const char * current_case = enkf_main_get_current_fs( enkf_main ); test_assert_string_equal(current_case, "new_current_case"); test_assert_true(enkf_fs_has_node(enkf_main_get_fs(enkf_main), "PERMZ", PARAMETER, 0, 0, ANALYZED)); enkf_fs_type * default_fs = enkf_main_mount_alt_fs( enkf_main , "default" , true ); state_map_type * default_state_map = enkf_fs_get_state_map(default_fs); state_map_type * current_state_map = enkf_fs_get_state_map(enkf_main_get_fs(enkf_main)); test_assert_int_equal(state_map_get_size(default_state_map), state_map_get_size(current_state_map)); enkf_fs_decref(default_fs); } //Test init case from existing case: stringlist_clear(args); stringlist_append_copy(args, "default"); //case to init from stringlist_append_copy(args, "new_not_current_case"); test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) ); { enkf_fs_type * fs = enkf_main_mount_alt_fs(enkf_main, "new_not_current_case", true); test_assert_not_NULL( fs ); test_assert_true( enkf_fs_has_node(fs, "PERMZ", PARAMETER, 0, 0, ANALYZED )); enkf_fs_type * default_fs = enkf_main_mount_alt_fs( enkf_main , "default" , true ); state_map_type * default_state_map = enkf_fs_get_state_map(default_fs); state_map_type * new_state_map = enkf_fs_get_state_map(fs); test_assert_int_equal(state_map_get_size(default_state_map), state_map_get_size(new_state_map)); enkf_fs_decref(fs); } stringlist_free( args ); }
void test_tranLL( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1 , int lgr_nr2, int size, double first , double last) { ecl_kw_type * ecl_kw = ecl_nnc_export_get_tranll_kw(grid , init_file , lgr_nr1 , lgr_nr2 ); printf("lgr: %d -> %d \n",lgr_nr1 , lgr_nr2); test_assert_not_NULL(ecl_kw); test_assert_true(ecl_kw_is_instance( ecl_kw )); test_assert_int_equal( size , ecl_kw_get_size( ecl_kw )); test_assert_double_equal( first , ecl_kw_iget_as_double( ecl_kw , 0 )); test_assert_double_equal( last , ecl_kw_iget_as_double( ecl_kw , size - 1 )); }
void test_open_close_read( const char * filename ) { fortio_type * fortio = fortio_open_reader( filename , false , ECL_ENDIAN_FLIP); test_assert_not_NULL( fortio ); test_assert_true( fortio_stream_is_open( fortio )); test_assert_true( fortio_fclose_stream( fortio )); test_assert_false( fortio_stream_is_open( fortio )); test_assert_false( fortio_fclose_stream( fortio )); test_assert_true( fortio_fopen_stream( fortio )); test_assert_true( fortio_stream_is_open( fortio )); test_assert_false( fortio_fopen_stream( fortio )); fortio_fclose( fortio ); }
int main(int argc , char ** argv) { config_type * config = config_alloc(); ert_report_list_type * report_list = ert_report_list_alloc( NULL , NULL ); test_assert_not_NULL( report_list ); ert_report_list_add_config_items( config ); test_assert_true( config_parse( config , argv[1] , "--" , NULL, NULL , CONFIG_UNRECOGNIZED_IGNORE , true )); ert_report_list_init( report_list , config , NULL); test_assert_int_equal( 167 , ert_report_list_get_latex_timeout( report_list )); test_assert_true( ert_report_list_get_init_large_report( report_list )); ert_report_list_free( report_list ); exit(0); }
void test_join() { const char * elt0 = "AAA"; const char * elt1 = "BBB"; const char * elt2 = "CCC"; const char * elt3 = "DDD"; const char * elt4 = "EEE"; const char * elt5 = "FFF"; stringlist_type * s = stringlist_alloc_new(); { // empty join const char* empty_join = stringlist_alloc_joined_string(s, "!!!"); test_assert_not_NULL(empty_join); test_assert_string_equal("", empty_join); } stringlist_append_copy( s , elt0 ); stringlist_append_copy( s , elt1 ); stringlist_append_copy( s , elt2 ); const char * sep0 = ""; const char * sep1 = "!!!"; const char * sep2 = " abc "; const char * j0 = stringlist_alloc_joined_string( s, sep0); const char * j1 = stringlist_alloc_joined_string( s, sep1); const char * j2 = stringlist_alloc_joined_string( s, sep2); test_assert_string_equal( j0, "AAABBBCCC"); test_assert_string_equal( j1, "AAA!!!BBB!!!CCC"); test_assert_string_equal( j2, "AAA abc BBB abc CCC"); stringlist_type * s1 = stringlist_alloc_new(); stringlist_append_copy( s1 , elt0 ); test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep0)); test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep1)); test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep2)); stringlist_type * sub = stringlist_alloc_new(); stringlist_append_copy( sub , elt0 ); stringlist_append_copy( sub , elt1 ); stringlist_append_copy( sub , elt2 ); stringlist_append_copy( sub , elt3 ); stringlist_append_copy( sub , elt4 ); stringlist_append_copy( sub , elt5 ); test_assert_string_equal( "CCC:DDD:EEE", stringlist_alloc_joined_substring( sub, 2, 5, ":")); }
int main(int argc , char ** argv) { int lgr_nr = 77; nnc_info_type * nnc_info = nnc_info_alloc(lgr_nr); test_assert_int_equal( 0 , nnc_info_get_total_size( nnc_info )); test_assert_int_equal( lgr_nr , nnc_info_get_lgr_nr( nnc_info )); test_assert_true(nnc_info_is_instance(nnc_info)); test_assert_not_NULL(nnc_info); nnc_info_add_nnc(nnc_info, lgr_nr, 110 , 0); test_assert_int_equal( 1, nnc_info_get_total_size( nnc_info )); nnc_info_add_nnc(nnc_info, 1, 110 , 1); nnc_info_add_nnc(nnc_info, 1, 111 , 2); test_assert_int_equal( 3, nnc_info_get_total_size( nnc_info )); nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1); const int_vector_type * nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1); test_assert_int_equal(int_vector_size(nnc_cells), 2); test_assert_ptr_equal( nnc_cells , nnc_vector_get_grid_index_list( nnc_vector )); nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2); const int_vector_type * nnc_cells_null = nnc_info_get_grid_index_list(nnc_info, 2); test_assert_NULL(nnc_cells_null); test_assert_NULL(nnc_vector_null); nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info ); const nnc_vector_type * nnc_vector_77 = nnc_info_get_vector( nnc_info , lgr_nr ); test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self ); const int_vector_type * nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr); const int_vector_type * nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info); test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self ); test_assert_int_equal( 2 , nnc_info_get_size( nnc_info )); test_assert_ptr_equal( nnc_info_get_vector( nnc_info , 1 ) , nnc_info_iget_vector( nnc_info , 1 )); nnc_info_free(nnc_info); exit(0); }
int main(int argc , char ** argv) { int i = 10; int j = 5; int k = 16; double CF = 0; bool open = true; test_install_SIGNALS(); { well_conn_dir_enum dir = well_conn_dirX; well_conn_type * conn = well_conn_alloc(i,j,k,CF,dir,open); well_conn_type * conn2 = well_conn_alloc(i,j,k,CF,dir,open); well_conn_type * conn3 = well_conn_alloc(i,j,k+1,CF,dir,open); test_assert_not_NULL( conn ); test_assert_true( well_conn_is_instance( conn )); test_assert_int_equal( i , well_conn_get_i( conn )); test_assert_int_equal( j , well_conn_get_j( conn )); test_assert_int_equal( k , well_conn_get_k( conn )); test_assert_int_equal( dir , well_conn_get_dir( conn )); test_assert_bool_equal( open , well_conn_open( conn )); test_assert_false( well_conn_MSW( conn )); test_assert_true( well_conn_matrix_connection( conn )); test_assert_true( well_conn_equal( conn , conn2 )); test_assert_false( well_conn_equal( conn , conn3 )); test_assert_double_equal( CF , well_conn_get_connection_factor( conn )); well_conn_free( conn3 ); well_conn_free( conn2 ); well_conn_free( conn ); } { well_conn_dir_enum dir = well_conn_fracX; well_conn_type * conn = well_conn_alloc(i,j,k,CF,dir,open); test_assert_NULL( conn ); } { well_conn_dir_enum dir = well_conn_fracX; well_conn_type * conn = well_conn_alloc_fracture(i,j,k,CF,dir,open); test_assert_not_NULL( conn ); test_assert_int_equal( i , well_conn_get_i( conn )); test_assert_int_equal( j , well_conn_get_j( conn )); test_assert_int_equal( k , well_conn_get_k( conn )); test_assert_bool_equal( open , well_conn_open( conn )); test_assert_int_equal( dir , well_conn_get_dir( conn )); test_assert_false( well_conn_MSW( conn )); test_assert_false( well_conn_matrix_connection( conn )); test_assert_true( well_conn_fracture_connection( conn )); well_conn_free( conn ); } { well_conn_dir_enum dir = well_conn_dirX; well_conn_type * conn = well_conn_alloc_fracture(i,j,k,CF,dir,open); test_assert_not_NULL( conn ); well_conn_free( conn ); } { int segment = 16; well_conn_dir_enum dir = well_conn_dirX; well_conn_type * conn = well_conn_alloc_MSW(i,j,k,CF,dir,open,segment); test_assert_not_NULL( conn ); test_assert_int_equal( i , well_conn_get_i( conn )); test_assert_int_equal( j , well_conn_get_j( conn )); test_assert_int_equal( k , well_conn_get_k( conn )); test_assert_int_equal( segment , well_conn_get_segment_id( conn )); test_assert_bool_equal( open , well_conn_open( conn )); test_assert_int_equal( dir , well_conn_get_dir( conn )); test_assert_true( well_conn_MSW( conn )); test_assert_true( well_conn_matrix_connection( conn )); well_conn_free( conn ); } { int segment = 16; well_conn_dir_enum dir = well_conn_fracX; well_conn_type * conn = well_conn_alloc_fracture_MSW(i,j,k,CF,dir,open,segment); test_assert_not_NULL( conn ); test_assert_int_equal( i , well_conn_get_i( conn )); test_assert_int_equal( j , well_conn_get_j( conn )); test_assert_int_equal( k , well_conn_get_k( conn )); test_assert_int_equal( segment , well_conn_get_segment_id( conn )); test_assert_bool_equal( open , well_conn_open( conn )); test_assert_int_equal( dir , well_conn_get_dir( conn )); test_assert_true( well_conn_MSW( conn )); test_assert_false( well_conn_matrix_connection( conn )); well_conn_free( conn ); } test_conn_rate(); }
int main( int argc , char ** argv) { const char * exjob_file = "job"; const char * bin_path = argv[1]; const char * internal_workflow = argv[2]; test_work_area_type * work_area = test_work_area_alloc( "job_workflow_test" ); signal(SIGSEGV , util_abort_signal); create_exjob( exjob_file , bin_path ); { int int_value = rand(); int read_value = 100; workflow_joblist_type * joblist = workflow_joblist_alloc(); if (!workflow_joblist_add_job_from_file( joblist , "CREATE_FILE" , exjob_file)) { remove( exjob_file ); { config_type * job_config = workflow_joblist_get_job_config( joblist ); config_fprintf_errors( job_config , true , stdout ); } test_error_exit("Loading job CREATE_FILE failed\n"); } else remove( exjob_file ); if (!workflow_joblist_add_job_from_file( joblist , "READ_FILE" , internal_workflow)) test_error_exit("Loading job READ_FILE failed\n"); { config_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); if (config_get_schema_size( workflow_compiler ) != 2) test_error_exit("Config compiler - wrong size \n"); } { const char * workflow_file = "workflow"; const char * tmp_file = "fileX"; workflow_type * workflow; create_workflow( workflow_file , tmp_file , int_value ); workflow = workflow_alloc(workflow_file , joblist ); unlink( workflow_file ); { bool runOK; runOK = workflow_run( workflow , &read_value , false , NULL); if (runOK) { if (int_value != read_value) test_error_exit("Wrong numeric value read back \n"); test_assert_int_equal( workflow_get_stack_size( workflow ) , 2 ); test_assert_not_NULL( workflow_iget_stack_ptr( workflow , 0 ) ); test_assert_NULL( workflow_iget_stack_ptr( workflow , 1 ) ); { void * return_value = workflow_iget_stack_ptr( workflow , 0 ); int return_int = *((int *) return_value); if (int_value != return_int) test_error_exit("Wrong numeric value read back \n"); test_assert_not_NULL( workflow_pop_stack( workflow )); test_assert_NULL( workflow_pop_stack( workflow )); test_assert_int_equal( workflow_get_stack_size( workflow ) , 0 ); free( return_value ); } } else { config_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); config_fprintf_errors( workflow_compiler , true ,stdout); unlink( tmp_file ); test_error_exit("Workflow did not run\n"); } unlink( tmp_file ); } } workflow_joblist_free( joblist ); } { workflow_joblist_type * joblist = workflow_joblist_alloc(); const char * workflow_file = "workflow"; const char * tmp_file = "fileX"; int read_value; int int_value = 100; workflow_type * workflow; create_workflow( workflow_file , tmp_file , int_value ); workflow = workflow_alloc(workflow_file , joblist ); unlink( workflow_file ); test_assert_false( workflow_run( workflow , &read_value , false , NULL) ); test_assert_int_equal( workflow_get_stack_size( workflow ) , 0 ); } test_work_area_free( work_area ); exit(0); }
void test_create_range() { plot_range_type * range = plot_range_alloc(); test_assert_not_NULL( range ); plot_range_free( range ); }
int main(int argc , char ** argv) { const char * Xfile = argv[1]; ecl_file_type * rst_file = ecl_file_open( Xfile , 0 ); ecl_file_view_type * rst_view = ecl_file_get_active_view( rst_file ); ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_view , ecl_util_filename_report_nr(Xfile)); const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 ); const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 ); well_rseg_loader_type * rseg_loader = well_rseg_loader_alloc(rst_view); const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 ); const ecl_kw_type * scon_kw = NULL; const ecl_kw_type * xcon_kw = NULL; test_install_SIGNALS(); test_assert_not_NULL( rst_file ); test_assert_not_NULL( rst_head ); { int well_nr; for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) { well_conn_collection_type * connections = well_conn_collection_alloc(); well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , scon_kw, xcon_kw, well_nr , rst_head); { well_segment_collection_type * segments = well_segment_collection_alloc(); bool load_segment_information = true; bool is_MSW_well = false; if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head , load_segment_information , &is_MSW_well)) { well_branch_collection_type * branches = well_branch_collection_alloc(); test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head)); well_segment_collection_link( segments ); { int is; for (is=0; is < well_segment_collection_get_size( segments ); is++) { well_segment_type * segment = well_segment_collection_iget( segments , is ); if (well_segment_nearest_wellhead( segment )) test_assert_NULL( well_segment_get_outlet( segment )); else test_assert_not_NULL( well_segment_get_outlet( segment )); test_assert_int_not_equal( well_segment_get_id( segment ) , well_segment_get_outlet_id( segment )); test_assert_ptr_not_equal( segment , well_segment_get_outlet( segment )); } } well_segment_collection_add_branches( segments , branches ); { int ib; for (ib = 0; ib < well_branch_collection_get_size( branches ); ib++) { const well_segment_type * start_segment = well_branch_collection_iget_start_segment( branches , ib ); const well_segment_type * segment = start_segment; printf("Branch %d " , ib ); while (segment) { printf("%d -> ",well_segment_get_id( segment )); segment = well_segment_get_outlet( segment ); } printf(" X \n"); } } well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections ); well_branch_collection_free( branches ); } else test_assert_false( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head )); well_segment_collection_free( segments ); } well_conn_collection_free( connections ); } } ecl_file_close( rst_file ); ecl_rsthead_free( rst_head ); exit(0); }
void test_fortio_unsafe_cast(void * arg) { void * i_am_not_a_fortio = vector_alloc_new(); test_assert_not_NULL( i_am_not_a_fortio ); fortio_safe_cast(i_am_not_a_fortio); }
ert_test_context_type * create_context( const char * config_file, const char * name ) { ert_test_context_type * test_context = ert_test_context_alloc(name , config_file); test_assert_not_NULL(test_context); return test_context; }
void test_existing_read(const char * filename) { fortio_type * fortio = fortio_open_reader( filename , false , ECL_ENDIAN_FLIP); test_assert_not_NULL( fortio ); fortio_fclose( fortio ); }
int main(int argc , char ** argv) { const char * Xfile = argv[1]; ecl_file_type * rst_file = ecl_file_open( Xfile , 0 ); ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file ); const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 ); const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 ); const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 ); const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 ); test_install_SIGNALS(); test_assert_not_NULL( rst_file ); test_assert_not_NULL( rst_head ); { int well_nr; for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) { well_conn_collection_type * connections = well_conn_collection_alloc(); well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , well_nr , rst_head); { well_segment_collection_type * segments = well_segment_collection_alloc(); if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_kw , rst_head )) { well_branch_collection_type * branches = well_branch_collection_alloc(); test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head)); well_segment_collection_link( segments ); { int is; for (is=0; is < well_segment_collection_get_size( segments ); is++) { well_segment_type * segment = well_segment_collection_iget( segments , is ); if (well_segment_nearest_wellhead( segment )) test_assert_NULL( well_segment_get_outlet( segment )); else test_assert_not_NULL( well_segment_get_outlet( segment )); test_assert_ptr_not_equal( segment , well_segment_get_outlet( segment )); } } well_segment_collection_add_branches( segments , branches ); { int ib; for (ib = 0; ib < well_branch_collection_get_size( branches ); ib++) { const well_segment_type * start_segment = well_branch_collection_iget_start_segment( branches , ib ); const well_segment_type * segment = start_segment; printf("Branch %d/%d " , ib , well_branch_collection_get_size( branches ) ); while (segment) { printf("[%p]%d -> \n",segment , well_segment_get_id( segment )); segment = well_segment_get_outlet( segment ); } printf("\n"); sleep(1); } } well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections ); well_branch_collection_free( branches ); } else test_assert_false( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head )); well_segment_collection_free( segments ); } well_conn_collection_free( connections ); } } ecl_file_close( rst_file ); ecl_rsthead_free( rst_head ); exit(0); }
int main(int argc , char ** argv) { const char * Xfile = argv[1]; bool MSW; ecl_file_type * rst_file = ecl_file_open( Xfile , 0 ); ecl_rsthead_type * rst_head = ecl_rsthead_alloc( ecl_file_get_global_view(rst_file) , ecl_util_filename_report_nr( Xfile )); test_install_SIGNALS(); test_assert_true( util_sscanf_bool( argv[2] , &MSW )); test_assert_not_NULL( rst_file ); test_assert_not_NULL( rst_head ); { int iwell; const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 ); const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 ); ecl_kw_type * scon_kw = NULL; bool caseMSW = false; for (iwell = 0; iwell < rst_head->nwells; iwell++) { const int iwel_offset = rst_head->niwelz * iwell; int num_connections = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_CONNECTIONS_INDEX ); int iconn; well_conn_collection_type * wellcc = well_conn_collection_alloc( ); well_conn_collection_type * wellcc_ref = well_conn_collection_alloc(); for (iconn = 0; iconn < num_connections; iconn++) { well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , scon_kw , rst_head , iwell , iconn ); test_assert_true( well_conn_is_instance( conn )); test_assert_not_NULL( conn ); if (!MSW) test_assert_bool_equal( well_conn_MSW( conn ) , MSW); else caseMSW |= well_conn_MSW( conn ); well_conn_collection_add( wellcc , conn ); well_conn_collection_add_ref( wellcc_ref , conn ); test_assert_int_equal( iconn + 1 , well_conn_collection_get_size( wellcc )); test_assert_ptr_equal( well_conn_collection_iget_const( wellcc , iconn) , conn); test_assert_ptr_equal( well_conn_collection_iget_const( wellcc_ref , iconn) , conn); } well_conn_collection_free( wellcc_ref ); { int i; for (i=0; i < well_conn_collection_get_size( wellcc ); i++) test_assert_true( well_conn_is_instance( well_conn_collection_iget_const( wellcc , i ))); } { well_conn_collection_type * wellcc2 = well_conn_collection_alloc(); int i; test_assert_int_equal( well_conn_collection_get_size( wellcc ) , well_conn_collection_load_from_kw( wellcc2 , iwel_kw , icon_kw , scon_kw , iwell , rst_head)); for (i=0; i < well_conn_collection_get_size( wellcc2 ); i++) { test_assert_true( well_conn_is_instance( well_conn_collection_iget_const( wellcc2 , i ))); test_assert_true( well_conn_equal( well_conn_collection_iget_const( wellcc2 , i ) , well_conn_collection_iget_const( wellcc , i ))); } well_conn_collection_free( wellcc2 ); } well_conn_collection_free( wellcc ); } test_assert_bool_equal( caseMSW , MSW); } exit( 0 ); }